Registry / observability / zipkin-instrumentation-fetch

zipkin-instrumentation-fetch

JSON →
library0.22.0jsnpmunverified

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.

npm install zipkin-instrumentation-fetch
INSTALL
IMPORT
SIG · ZIPKIN-INSTRUMENTA
Z
zipkin-instrumentation-fetch
observabilityjavascriptv0.22.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ZipkinFetchInterceptor
import { ZipkinFetchInterceptor } from 'zipkin-instrumentation-fetch'
const ZipkinFetchInterceptor = require('zipkin-instrumentation-fetch').ZipkinFetchInterceptor
Package is ESM-first. CommonJS require works but is not recommended.

Initializes a Zipkin tracer and wraps the global fetch function to automatically propagate trace context.

import { Tracer, BatchRecorder, jsonEncoder } from 'zipkin'; import ZipkinFetchInterceptor from 'zipkin-instrumentation-fetch'; const tracer = new Tracer({ recorder: new BatchRecorder({ logger: new HttpLogger({ endpoint: 'http://localhost:9411/api/v2/spans', jsonEncoder: jsonEncoder.JSON_V2 }) }), localServiceName: 'frontend' }); const fetchInterceptor = new ZipkinFetchInterceptor({ tracer }); // Use the interceptor to wrap fetch const tracedFetch = fetchInterceptor.wrap(fetch); // Now use tracedFetch instead of fetch const response = await tracedFetch('http://backend/api/data');
Debug
Known issues
deprecatedPackage is deprecated. Use @zipkin.js/instrumentation-fetch instead.
fix
Replace import with 'import { ZipkinFetchInterceptor } from '@zipkin.js/instrumentation-fetch' and ensure compatible tracer version.
affects: >=0.22.0
gotchaWrapper expects a native fetch function; polyfills with different signatures may cause issues.
fix
Ensure fetched function conforms to the standard Request/Response API.
affects: >=0.19.0
gotchaInterceptor will read request body; if body is a ReadableStream, it may be consumed and cause errors.
fix
Use a fetch polyfill that supports clone or avoid streaming bodies.
affects: >=0.20.0
Errors
Common errors & fixes
TypeError: fetchInterceptor.wrap is not a function
Incorrect default import vs named import.
fix
Use default import: import ZipkinFetchInterceptor from 'zipkin-instrumentation-fetch'
Error: No tracer provided
Missing or incorrectly passed tracer configuration.
fix
Ensure new ZipkinFetchInterceptor({ tracer }) receives a valid tracer instance.
Uncaught TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
Using interceptor.wrap with a fetch that is not bound to window.
fix
Pass a bound fetch: fetchInterceptor.wrap(window.fetch.bind(window))
Upgrade
Version history
0.22.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
54 hits · last 30 days
node
46
OpenAI (training)
1
Resources
zipkin-instrumentation-fetch — npm install zipkin-instrumentation-fetch · libregistry