Registry / observability / jaeger-client-utility

jaeger-client-utility

JSON →
library1.0.1jsnpmunverified

A lightweight wrapper around the Jaeger client (opentracing) that simplifies tracing setup and span management for Node.js services. Current stable version is 1.0.1 (last updated 2020). It provides a simple API to initialize the tracer, start spans, and inject/extract context for distributed tracing. This package is a thin layer over the official jaeger-client library, intended for quick integration but may lack flexibility for advanced use cases. No breaking changes documented; the package relies on opentracing as a peer dependency. Compared to the official jaeger-client, it reduces boilerplate but hides configuration options like sampling and reporter settings.

npm install jaeger-client-utility
INSTALL
IMPORT
SIG · JAEGER-CLIENT-UTIL
J
jaeger-client-utility
observabilityjavascriptv1.0.1
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.

default
import jaegerClient from 'jaeger-client-utility'
const jaegerClient = require('jaeger-client-utility')
Package uses default export; CommonJS require works but TypeScript users prefer ESM. In CJS, use `const jaegerClient = require('jaeger-client-utility').default` or import syntax.
jaegerClient.init
jaegerClient.init({ serviceName: 'my-service' })
jaegerClient.init('my-service')
init expects an object with serviceName, not a string.
jaegerClient.startSpan
jaegerClient.startSpan('operationName', { isChild: { format: FORMAT_HTTP_HEADERS, injectData: headers } })
jaegerClient.startSpan('op', FORMAT_HTTP_HEADERS, headers)
Child span context is passed as an object via the second argument, not separate parameters.

Initializes Jaeger tracer, starts a span, and demonstrates distributed tracing with injection and extraction.

import jaegerClient from 'jaeger-client-utility'; import { FORMAT_HTTP_HEADERS } from 'opentracing'; jaegerClient.init({ serviceName: 'my-service' }); const span = jaegerClient.startSpan('my-operation'); try { // Simulate work } finally { span.finish(); } // For distributed tracing: const parentSpan = jaegerClient.startSpan('parent'); const headers = {}; jaegerClient.inject(FORMAT_HTTP_HEADERS, headers); parentSpan.finish(); // In downstream service: const childSpan = jaegerClient.startSpan('child', { isChild: { format: FORMAT_HTTP_HEADERS, injectData: headers } }); childSpan.finish();
Debug
Known issues
gotchaPackage does not expose configuration for Jaeger agent host/port or sampler; defaults to localhost:6831 and const sampler.
fix
Use the official jaeger-client directly if you need custom sampler or agent location.
affects: >=1.0.0
deprecatedThe opentracing API is deprecated in favor of OpenTelemetry. This package still uses opentracing.
fix
Consider migrating to OpenTelemetry-based instrumentation.
affects: >=1.0.0
gotchaPackage has no TypeScript type definitions; users must declare module or use @types/opentracing.
fix
Install @types/opentracing and create a declaration file: declare module 'jaeger-client-utility';
affects: >=1.0.0
breakingIn version 1.0.0, the default export was changed from a class to an object with methods. Previous 0.x versions used `new JaegerClient()`.
fix
Replace `const client = new JaegerClient()` with `import jaegerClient from 'jaeger-client-utility'` and use `jaegerClient.init()`.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: jaegerClient.init is not a function
In CJS, require returns the module object; the default export is not automatically assigned.
fix
Use ES import or `const jaegerClient = require('jaeger-client-utility').default;`
Error: No serviceName provided. Must pass serviceName to init.
Called init() without arguments or with a string instead of an object.
fix
Call `jaegerClient.init({ serviceName: 'your-service' })`
ReferenceError: FORMAT_HTTP_HEADERS is not defined
Missing import from opentracing package.
fix
Add `import { FORMAT_HTTP_HEADERS } from 'opentracing';`
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
opentracingoptionalPeer dependency required for FORMAT_HTTP_HEADERS and span types.
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
2
Resources
jaeger-client-utility — npm install jaeger-client-utility · libregistry