The Jaeger exporter converts OpenTelemetry traces into the Jaeger model following the OpenTelemetry specification.
The exporter communicates to a Jaeger Agent through the Thrift protocol on the Compact Thrift API port, and as such only supports Thrift over UDP.
Refer to the Getting Started with Jaeger tutorial.
dotnet add package OpenTelemetry.Exporter.Jaeger
You can configure the JaegerExporter
through JaegerExporterOptions
and environment variables. The JaegerExporterOptions
setters
take precedence over the environment variables.
The JaegerExporter
can be configured using the JaegerExporterOptions
properties:
-
AgentHost
: The Jaeger Agent host (defaultlocalhost
). Used forUdpCompactThrift
protocol. -
AgentPort
: The Jaeger Agent port (default6831
). Used forUdpCompactThrift
protocol. -
BatchExportProcessorOptions
: Configuration options for the batch exporter. Only used ifExportProcessorType
is set toBatch
. -
Endpoint
: The Jaeger Collector HTTP endpoint (defaulthttp://localhost:14268
). Used forHttpBinaryThrift
protocol. -
ExportProcessorType
: Whether the exporter should use Batch or Simple exporting processor (defaultExportProcessorType.Batch
). -
HttpClientFactory
: A factory function called to create theHttpClient
instance that will be used at runtime to transmit spans over HTTP when theHttpBinaryThrift
protocol is configured. See Configure HttpClient for more details. -
MaxPayloadSizeInBytes
: The maximum size of each batch that gets sent to the agent or collector (default4096
). -
Protocol
: The protocol to use. The default value isUdpCompactThrift
.Protocol Description UdpCompactThrift
Apache Thrift compact over UDP to a Jaeger Agent. HttpBinaryThrift
Apache Thrift binary over HTTP to a Jaeger Collector.
See the TestJaegerExporter.cs
for an example of how to use the exporter.
The following environment variables can be used to override the default
values of the JaegerExporterOptions
(following the OpenTelemetry specification).
Environment variable | JaegerExporterOptions property |
---|---|
OTEL_EXPORTER_JAEGER_AGENT_HOST |
AgentHost |
OTEL_EXPORTER_JAEGER_AGENT_PORT |
AgentPort |
OTEL_EXPORTER_JAEGER_ENDPOINT |
Endpoint |
OTEL_EXPORTER_JAEGER_PROTOCOL |
Protocol (udp/thrift.compact or http/thrift.binary ) |
FormatException
is thrown in case of an invalid value for any of the
supported environment variables.
The HttpClientFactory
option is provided on JaegerExporterOptions
for users
who want to configure the HttpClient
used by the JaegerExporter
when
HttpBinaryThrift
protocol is used. Simply replace the function with your own
implementation if you want to customize the generated HttpClient
:
services.AddOpenTelemetryTracing((builder) => builder
.AddJaegerExporter(o =>
{
o.Protocol = JaegerExportProtocol.HttpBinaryThrift;
o.HttpClientFactory = () =>
{
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("X-MyCustomHeader", "value");
return client;
};
}));
For users using
IHttpClientFactory
you may also customize the named "JaegerExporter" HttpClient
using the
built-in AddHttpClient
extension:
services.AddHttpClient(
"JaegerExporter",
configureClient: (client) =>
client.DefaultRequestHeaders.Add("X-MyCustomHeader", "value"));
Note: The single instance returned by HttpClientFactory
is reused by all
export requests.
This component uses an EventSource with the name "OpenTelemetry-Exporter-Jaeger" for its internal logging. Please refer to SDK troubleshooting for instructions on seeing these internal logs.