The OpenTelemetry Protocol (OTLP) exporters for .NET currently support gRPC and HTTP 1.1 with binary Protocol Buffers (Protobuf) payload transports. Supported corresponding protocol values are grpc
and http/protobuf
. Configuration options can be set either via environment variables or explicitly in code.
The following prerequisites and limitations apply:
Dynatrace uses OpenTelemetry Trace Ingest to provide end-to-end visibility to your Azure Functions.
To instrument your Azure Functions
To ingest gRPC via the Dynatrace Trace API, you need to use an OpenTelemetry collector between Dynatrace and the exporter.
If you use environment variables for setup, you need to set the following value:
OTEL_EXPORTER_OTLP_PROTOCOL
: grpc
To ingest gRPC via the Dynatrace Trace API, you need to use an OpenTelemetry collector between Dynatrace and the exporter.
The OpenTelemetry Collector is available as a Docker image. To use this collector to export trace data to Dynatrace, you need to customize the configuration using the OpenTelemetry OTLP exporter.
Here is a sample configuration file:
receivers:otlp:protocols:grpc:exporters:otlphttp:endpoint: "https://<YOUR-TENANT-ID>.live.dynatrace.com/api/v2/otlp"headers: {"Authorization": "Api-Token <YOUR-DYNATRACE-API-TOKEN>"}service:pipelines:traces:receivers: [otlp]exporters: [otlphttp]
For further details on configuration, see Best practices for OpenTelemetry traces.
Add the following dependencies via NuGet to your project:
OpenTelemetry.Exporter.OpenTelemetryProtocol
OpenTelemetry also provides other auto-instrumentation libraries available as NuGet packages.
If you don't set the Protocol
property of the OtlpExporterOptions
class via environment variables or in code, it will be initialized as OtlpExportProtocol.Grpc
by default.
public class Startup : FunctionsStartup{public override void Configure(IFunctionsHostBuilder builder){string activitySource = "[activitySource]";string serviceName = "[serviceName]";string collectorUrl = "[collectorUrl]" // Points to the running collector, configured before.builder.Services.AddSingleton((builder) =>{return Sdk.CreateTracerProviderBuilder().SetSampler(new AlwaysOnSampler()).AddSource(activitySource).SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(serviceName)).AddHttpClientInstrumentation(op =>{// Exclude frequent calls generated by Azure Application Insightsop.FilterHttpRequestMessage = (req) => !req.RequestUri.AbsoluteUri.Contains("visualstudio");}).AddOtlpExporter(otlpOptions =>{otlpOptions.Endpoint = new Uri(collectorUrl);}).Build();});}}