This package is deprecated and no longer maintained.
The underlying libraries (
jaeger-clientandopentracing) are end-of-life. The Jaeger project has fully migrated to OpenTelemetry.Please use
@fastify/otelinstead — the official Fastify OpenTelemetry instrumentation plugin, maintained by the Fastify team.npm remove fastify-jaeger npm install @fastify/otel @opentelemetry/api @opentelemetry/sdk-trace-node @opentelemetry/exporter-trace-otlp-http// Setup OpenTelemetry SDK (run before importing fastify) const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node') const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http') const { BatchSpanProcessor } = require('@opentelemetry/sdk-trace-base') const provider = new NodeTracerProvider() provider.addSpanProcessor(new BatchSpanProcessor(new OTLPTraceExporter({ url: 'http://localhost:4318/v1/traces' // Jaeger OTLP endpoint }))) provider.register() // Register the Fastify plugin const fastify = require('fastify')() fastify.register(require('@fastify/otel'), { serviceName: 'my-service' })Jaeger natively supports OTLP ingestion (port 4317 for gRPC, 4318 for HTTP) since Jaeger v1.35+. No Jaeger-specific client library is needed.
Fastify plugin for Jaeger distributed tracing system.
npm install fastify-jaegerRequire the plugin and register it within Fastify, the pass the following options: { serviceName [, exposeAPI] }
exposeAPI: (true by default) Exposes the Span API, binded to the current request, which allows the user to setTags, and log the current span.
This plugins supports all options and configurations of jaeger-client-node's initTracer method.
- The options param can be configured via
opts.initTracerOpts - All other top-level
optswill be passed in as the config param.
It uses the logger set to the fastify instance as the tracer logger.
const fastify = require('fastify')()
fastify.register(require('fastify-jaeger'), {
serviceName: 'my-service-name'
})
fastify.get('/', (req, reply) => {
reply.send({ hello: 'world' })
})
fastify.listen(3000, err => {
if (err) throw err
console.log('Server listening on localhost:', fastify.server.address().port)
})Licensed under MIT.