-
Notifications
You must be signed in to change notification settings - Fork 773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using OpenTelemetry Sdk with Azure Functions #1803
Comments
Now that we have out of process net5 support, will this start working (since s.d.ds is part of net5?) -- @cijothomas |
I am not sure if I understood your question. Could you elaborate? |
I guess it's more about this: Azure/azure-functions-host#7135 -- but since you're here :) The functions v2 runtime is in-process, and as such, we're stuck with using system.diagnostics.diagnosticsource 4.7, ergo OTEL instrumentation libraries for HttpClient, SqlClient etc do not work. Now that net 5.0 is out of process, and we provide the runtime ourselves (right?) does this mean that we can use system.diagnostics.diagnosticsource 5.x and OTEL will work correctly in a functions v3 context? |
I cannot comment on whether Functions V3 (or V2) addresses this. The owners of Azure Functions has to make that clarification. I'll still check with Functions team and post back in this thread if I hear anything. |
Just a note that using |
Seems to be working. I'm using the following setup in functions (v4 runtime + in-process): [assembly: FunctionsStartup(typeof(Startup))]
namespace FunctionApp1;
internal class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services.AddOpenTelemetryTracing(b =>
{
b.AddHttpClientInstrumentation();
b.AddSource("AzureFunctionsOpenTelemetry");
b.AddOtlpExporter(options => options.Endpoint = new Uri("http://localhost:4317"));
});
builder.AddOpenTelemetry(b =>
{
b.IncludeFormattedMessage = true;
b.IncludeScopes = true;
b.ParseStateValues = true;
b.AddOtlpExporter(options => options.Endpoint = new Uri("http://localhost:4317"));
});
}
}
public static class OpenTelemetryLoggingExtensions
{
public static IFunctionsHostBuilder AddOpenTelemetry(
this IFunctionsHostBuilder builder,
Action<OpenTelemetryLoggerOptions> configure = null)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, OpenTelemetryLoggerProvider>());
if (configure != null)
{
builder.Services.Configure(configure);
}
return builder;
}
} |
can someone please provide a full working example of an azure function ? |
This is repo with my experiments so far. Tried to model some "distributed" system in field of mine: e-commerce. https://github.com/valdisiljuconoks/otel-experiment/tree/master/application/Commerce.Batch |
Can't access the repo, is it public? |
https://github.com/cijothomas/FunctionsOpenTelemetry/blob/master/FunctionsOpenTelemetry/Startup.cs - Note that this is not approved or reviewed by Functions experts, so not sure if any Functions specific things are required. It does work in my testing. |
|
For 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:
There is also the issue (Azure/azure-functions-host#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 useSystem.Diagnostics.DiagnosticSource (= 5.0.1)
The text was updated successfully, but these errors were encountered: