Note: This is an experimental package under active development. Minor releases may include breaking changes.
The Jaeger Remote Sampler package is designed for OpenTelemetry to dynamically fetch and update sampling strategies from a Jaeger agent or collector. This enables applications to adjust their sampling strategies based on the current configuration provided by Jaeger, optimizing for both performance and observability.
npm install --save @opentelemetry/sampler-jaeger-remote
To integrate the Jaeger Remote Sampler with your application, configure it with the endpoint of your Jaeger agent or collector. The sampler can be set up as follows:
const { JaegerRemoteSampler } = require('@opentelemetry/sampler-jaeger-remote');
const { Resource } = require('@opentelemetry/resources');
const { NodeTracerProvider } = require('@opentelemetry/node');
// Jaeger agent endpoint
const sampler = new JaegerRemoteSampler({
endpoint: 'http://your-jaeger-agent:14268/api/sampling',
serviceName: 'your-service-name',
initialSampler: new AlwaysOnSampler(),
poolingInterval: 60000 // 60 seconds
});
const provider = new NodeTracerProvider({
resource: Resource.default().merge(new Resource({
'service.name': 'your-service-name'
})),
sampler
});
provider.register();
The Jaeger Remote Sampler supports the following sampling strategies based on the configuration received from the remote endpoint:
-
Per-Operation Sampling: If the remote configuration includes
operationSampling
withperOperationStrategies
, it creates aPerOperationSampler
. This allows for different sampling rates for different operations. -
Probabilistic Sampling: If the remote configuration specifies
StrategyType.PROBABILISTIC
, it creates aTraceIdRatioBasedSampler
. This samples a percentage of traces based on the trace ID. -
Default Sampling: If none of the above apply, it falls back to the initial sampler provided in the constructor.
- For more information on OpenTelemetry, visit: https://opentelemetry.io/
- For more about OpenTelemetry JavaScript: https://github.com/open-telemetry/opentelemetry-js
- For help or feedback on this project, join us in GitHub Discussions
Apache 2.0 - See LICENSE for more information.