Using OpenTelemetry Sdk with Azure Functions
See original GitHub issueFor using OpenTelemetry Sdk with Azure Functions, AddOpenTelemetryTracing extension method cannot be used. This is because Azure Functions has restrictions on running background hosted services. The right way to configure it for Functions is below:
var openTelemetry = Sdk.CreateTracerProviderBuilder().
AddSource("MyActivitySourceName")
.SetSampler(new AlwaysOnSampler())
.AddConsoleExporter()
.Build();
builder.Services.AddSingleton(openTelemetry);
There is also the issue (https://github.com/Azure/azure-functions-host/issues/7135) of Azure Functions not supporting DiagnosticListener callbacks when using System.Diagnostics.DiagnosticSource (> 4.7.0)
. Therefore, OpenTelemetry instrumentations (like HttpClient, SqlClient etc.) will not work in Azure Functions as the instrumentations use System.Diagnostics.DiagnosticSource (= 5.0.1)
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Enable Azure Monitor OpenTelemetry for .NET, Java, Node ...
This article provides guidance on how to enable Azure Monitor on applications by using OpenTelemetry.
Read more >OpenTelemetry & correlation support for Azure Functions
I have a project written in .net 6. I use Azure Function to send data to Service bus and MediatR. How can I...
Read more >Boost your Serverless Observability with OpenTelemetry ...
OpenTelemetry provides a powerful and flexible way to collect telemetry data from your applications, and Azure Monitor provides a comprehensive ...
Read more >Set up OpenTelemetry monitoring for Azure Functions on ...
Dynatrace uses OpenTelemetry to monitor Azure Functions invocations. For that purpose, Dynatrace provides language-specific packages, such as Dynatrace.
Read more >OpenTelemetry Support for Azure Functions (Isolated ...
Currently, OpenTelemetry is supported on the following SDKs: NodeJS · NextJS · Python · Ruby · Java .NET · Go. You can configure...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Seems to be working. I’m using the following setup in functions (v4 runtime + in-process):
Just a note that using
OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddHttpClientInstrumentation
with a .NET 5 isolated runtime Azure Function does seem to work, at least somewhat. If I set the trace ID in anActivityContext
and start my ownActivity
, then callHttpClient.GetAsync
within the activity scope, that outgoing request contains thetraceparent
header that contains the trace ID.