MySQL :: MySQL Connector/NET Developer Guide :: 5.12.1 Enabling OpenTelemetry Tracing (original) (raw)

5.12.1 Enabling OpenTelemetry Tracing

OpenTelementry (OTel) standardizes instrumentation, generation, collecting and exporting telemetry data to be consumed by an Observability backend. For more details on OpenTelemetry, visit its official site.

Starting in Connector/NET 8.1.0, support for OTel is encapsulated in the MySQL.Data.OpenTelemetry NuGet package. This package implements the functionality to add the connector to the tracer provider usingOpenTelementry.Api. Connector/NET neither creates nor provides the means to create an OTel exporter. Instead, it relies on the default exporter supplied by your application.

Note

OTel context forwarding works only with MySQL Enterprise Edition, a commercial product. To learn more about commercial products, seehttps://www.mysql.com/products/.

Requirements for Enabling Tracing

Enabling OpenTelemetry

To enable OTel tracing using the Connector/NET implementation, add the connector to the trace provider builder as follows:

var tracerProvider = sdk.TraceProviderBuilder().AddConnectorNet().Build();

When you build code that links to Connector/NET and uses OTel instrumentation, the additional spans generated by the connector appear in the traces generated by your code. Spans generated by the connector are sent to the same destination (trace exporter) where other spans generated by the user code are sent as configured by user code. It is not possible to send spans generated by the connector to any other destination.