dotnet add package OpenTelemetry.Exporter.Zipkin
You can enable the ZipkinExporter
with the AddZipkinExporter()
extension
method on TracerProviderBuilder
.
You can configure the ZipkinExporter
through ZipkinExporterOptions
and environment variables. The ZipkinExporterOptions
setters
take precedence over the environment variables.
-
BatchExportProcessorOptions
: Configuration options for the batch exporter. Only used if ExportProcessorType is set to Batch. -
Endpoint
: URI address to receive telemetry (defaulthttp://localhost:9411/api/v2/spans
). -
ExportProcessorType
: Whether the exporter should use Batch or Simple exporting processor. -
HttpClientFactory
: A factory function called to create theHttpClient
instance that will be used at runtime to transmit spans over HTTP. See Configure HttpClient for more details. -
MaxPayloadSizeInBytes
: Maximum payload size of UTF8 JSON chunks sent to Zipkin (default 4096). -
ServiceName
: Name of the service reporting telemetry. If theResource
associated with the telemetry has "service.name" defined, then it'll be preferred over this option. -
UseShortTraceIds
: Whether the trace's ID should be shortened before sending to Zipkin (default false).
See
TestZipkinExporter.cs
for example use.
This exporter allows easy configuration of ZipkinExporterOptions
from
dependency injection container, when used in conjunction with
OpenTelemetry.Extensions.Hosting
.
See the Startup class of the ASP.NET Core application for example use.
The following environment variables can be used to override the default
values of the ZipkinExporterOptions
.
Environment variable | ZipkinExporterOptions property |
---|---|
OTEL_EXPORTER_ZIPKIN_ENDPOINT |
Endpoint |
The HttpClientFactory
option is provided on ZipkinExporterOptions
for users
who want to configure the HttpClient
used by the ZipkinExporter
. Simply
replace the function with your own implementation if you want to customize the
generated HttpClient
:
services.AddOpenTelemetry()
.WithTracing(builder => builder
.AddZipkinExporter(o => o.HttpClientFactory = () =>
{
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("X-MyCustomHeader", "value");
return client;
}));
For users using
IHttpClientFactory
you may also customize the named "ZipkinExporter" HttpClient
using the
built-in AddHttpClient
extension:
services.AddHttpClient(
"ZipkinExporter",
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-Zipkin" for its internal logging. Please refer to SDK troubleshooting for instructions on seeing these internal logs.