Skip to content

Latest commit

 

History

History
132 lines (97 loc) · 5.45 KB

File metadata and controls

132 lines (97 loc) · 5.45 KB

Jaeger Exporter for OpenTelemetry .NET

NuGet NuGet

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 (default localhost). Used for UdpCompactThrift protocol.

  • AgentPort: The Jaeger Agent port (default 6831). Used for UdpCompactThrift protocol.

  • BatchExportProcessorOptions: Configuration options for the batch exporter. Only used if ExportProcessorType is set to Batch.

  • Endpoint: The Jaeger Collector HTTP endpoint (default http://localhost:14268). Used for HttpBinaryThrift protocol.

  • ExportProcessorType: Whether the exporter should use Batch or Simple exporting processor (default ExportProcessorType.Batch).

  • HttpClientFactory: A factory function called to create the HttpClient instance that will be used at runtime to transmit spans over HTTP when the HttpBinaryThrift protocol is configured. See Configure HttpClient for more details.

  • MaxPayloadSizeInBytes: The maximum size of each batch that gets sent to the agent or collector (default 4096).

  • Protocol: The protocol to use. The default value is UdpCompactThrift.

    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.

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.

References