{"id":49835,"library":"zipkin-instrumentation-fetch","title":"zipkin-instrumentation-fetch","description":"Interceptor for wrapping the browser's Fetch API with Zipkin distributed tracing. Version 0.22.0 is the last release of the legacy 0.x line; the package is deprecated in favor of `@zipkin.js/instrumentation-fetch` in the 0.23+ rewrite. It wraps `window.fetch` or a fetch polyfill to automatically propagate trace context via headers and record spans. Key differentiator: designed specifically for Zipkin's JS tracer ecosystem, lightweight, and works in browser environments where fetch is available. Ideal for microservices frontends needing end-to-end tracing with Zipkin.","status":"deprecated","version":"0.22.0","language":"javascript","source_language":"en","source_url":"https://github.com/openzipkin/zipkin-js","tags":["javascript"],"install":[{"cmd":"npm install zipkin-instrumentation-fetch","lang":"bash","label":"npm"},{"cmd":"yarn add zipkin-instrumentation-fetch","lang":"bash","label":"yarn"},{"cmd":"pnpm add zipkin-instrumentation-fetch","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-first. CommonJS require works but is not recommended.","wrong":"const ZipkinFetchInterceptor = require('zipkin-instrumentation-fetch').ZipkinFetchInterceptor","symbol":"ZipkinFetchInterceptor","correct":"import { ZipkinFetchInterceptor } from 'zipkin-instrumentation-fetch'"}],"quickstart":{"code":"import { Tracer, BatchRecorder, jsonEncoder } from 'zipkin';\nimport ZipkinFetchInterceptor from 'zipkin-instrumentation-fetch';\n\nconst tracer = new Tracer({\n  recorder: new BatchRecorder({ logger: new HttpLogger({ endpoint: 'http://localhost:9411/api/v2/spans', jsonEncoder: jsonEncoder.JSON_V2 }) }),\n  localServiceName: 'frontend'\n});\n\nconst fetchInterceptor = new ZipkinFetchInterceptor({ tracer });\n\n// Use the interceptor to wrap fetch\nconst tracedFetch = fetchInterceptor.wrap(fetch);\n\n// Now use tracedFetch instead of fetch\nconst response = await tracedFetch('http://backend/api/data');","lang":"typescript","description":"Initializes a Zipkin tracer and wraps the global fetch function to automatically propagate trace context."},"warnings":[{"fix":"Replace import with 'import { ZipkinFetchInterceptor } from '@zipkin.js/instrumentation-fetch' and ensure compatible tracer version.","message":"Package is deprecated. Use @zipkin.js/instrumentation-fetch instead.","severity":"deprecated","affected_versions":">=0.22.0"},{"fix":"Ensure fetched function conforms to the standard Request/Response API.","message":"Wrapper expects a native fetch function; polyfills with different signatures may cause issues.","severity":"gotcha","affected_versions":">=0.19.0"},{"fix":"Use a fetch polyfill that supports clone or avoid streaming bodies.","message":"Interceptor will read request body; if body is a ReadableStream, it may be consumed and cause errors.","severity":"gotcha","affected_versions":">=0.20.0"}],"env_vars":null,"search_vec":"'/instrumentation-fetch':38 '0':26 '0.22.0':18 '0.23':41 'api':12 'automat':51 'avail':79 'browser':9,74 'context':54 'deprec':32 'design':62 'differenti':61 'distribut':15 'ecosystem':69 'end':86,88 'end-to-end':85 'environ':75 'favor':34 'fetch':4,11,48,77 'frontend':83 'header':56 'ideal':80 'instrument':3 'interceptor':5 'javascript':92 'js':67 'key':60 'last':21 'legaci':25 'lightweight':70 'line':28 'microservic':82 'need':84 'packag':30 'polyfil':49 'propag':52 'record':58 'releas':22 'rewrit':42 'span':59 'specif':63 'trace':16,53,89 'tracer':68 'version':17 'via':55 'window.fetch':45 'work':72 'wrap':7,44 'x':27 'zipkin':2,14,65,91 'zipkin-instrumentation-fetch':1 'zipkin.js':37 'zipkin.js/instrumentation-fetch':36","created_at":"2026-06-07T17:03:50.776668+00:00","updated_at":"2026-06-07T17:03:50.776668+00:00","problems":[{"fix":"Use default import: import ZipkinFetchInterceptor from 'zipkin-instrumentation-fetch'","cause":"Incorrect default import vs named import.","error":"TypeError: fetchInterceptor.wrap is not a function"},{"fix":"Ensure new ZipkinFetchInterceptor({ tracer }) receives a valid tracer instance.","cause":"Missing or incorrectly passed tracer configuration.","error":"Error: No tracer provided"},{"fix":"Pass a bound fetch: fetchInterceptor.wrap(window.fetch.bind(window))","cause":"Using interceptor.wrap with a fetch that is not bound to window.","error":"Uncaught TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/openzipkin/zipkin-js#readme","github":"https://github.com/openzipkin/zipkin-js","docs":null,"changelog":null,"pypi":null,"npm":"zipkin-instrumentation-fetch","openapi_spec":null,"status_page":null,"smithery":null,"categories":["observability"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}