5.4 KiB
Jaeger Exporter for OpenTelemetry .NET
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.
Getting Started
Refer to the Getting Started with Jaeger tutorial.
Installation
dotnet add package OpenTelemetry.Exporter.Jaeger
Configuration
You can configure the JaegerExporter through JaegerExporterOptions
and environment variables. The JaegerExporterOptions setters
take precedence over the environment variables.
Options Properties
The JaegerExporter can be configured using the JaegerExporterOptions
properties:
-
AgentHost: The Jaeger Agent host (defaultlocalhost). Used forUdpCompactThriftprotocol. -
AgentPort: The Jaeger Agent port (default6831). Used forUdpCompactThriftprotocol. -
BatchExportProcessorOptions: Configuration options for the batch exporter. Only used ifExportProcessorTypeis set toBatch. -
Endpoint: The Jaeger Collector HTTP endpoint (defaulthttp://localhost:14268). Used forHttpBinaryThriftprotocol. -
ExportProcessorType: Whether the exporter should use Batch or Simple exporting processor (defaultExportProcessorType.Batch). -
HttpClientFactory: A factory function called to create theHttpClientinstance that will be used at runtime to transmit spans over HTTP when theHttpBinaryThriftprotocol 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 UdpCompactThriftApache Thrift compact over UDP to a Jaeger Agent. HttpBinaryThriftApache Thrift binary over HTTP to a Jaeger Collector.
See the TestJaegerExporter.cs
for an example of how to use the exporter.
Environment Variables
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.
Configure HttpClient
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.
Troubleshooting
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.