Open kolanos opened 3 years ago
For debugging, there's an exporter that will write the data OpenTelemetry collects to the console. Add the OpenTelemetry.Exporter.Console
package to your project and then add .AddConsoleExporter()
before the line with .AddNewRelicExporter(...)
. This will allow you to see traces when running locally. You'll likely want to remove this when deploying, though.
Additionally, OpenTelemetry does sampling by default. If you want OpenTelemetry to collect data on every invocation you can add .SetSampler(new AlwaysOnSampler())
. This will require you to import OpenTelemetry
and OpenTelemetry.Trace
.
public void Configure(IWebJobsBuilder builder)
{
builder.Services.AddOpenTelemetryTracing(tracingBuilder =>
@nintexvictor This service builder is based on the following Azure documentation.
@nintexvictor The above docs say Microsoft.Extensions.DependencyInjection
(3.x) is required, but appears to be missing here. Can we add this dependency and try a redeploy? Please report back your results. Thanks.
Hey @kolanos I have added Microsoft.Extensions.DependencyInjection -v 3.1.10
and published the app, I'm still not able to find data for my functions in New Relic.
@nintexvictor It looks like Azure is still blocking the hosting extensions for OpenTelemetry. Can you try this approach and see if it works? https://github.com/open-telemetry/opentelemetry-dotnet/issues/1602#issuecomment-731498274
This approach should run locally as well.
@nintexvictor There's been some changes to how OpenTelemetry .NET works in Azure that haven't been addressed in the New Relic Azure Binding Extension yet. But you should still be able to wire up OpenTelemetry to your Azure Functions and export your telemetry data to New Relic.
First, you'll want to create a
Startup.cs
in your project. The Azure runtime will use this to bootstrap your FunctionApp. It should have something like this:You can change the configuration keys to whatever you prefer. This is similar to how you would configure a ASP.NET Core application, since FunctionApps are built upon ASP .NET Core.
For dependencies you'll want to remove
NewRelic.Azure.BindingExtension
for now and add the following:You'll then want to remove the New Relic Azure Binding Extension code, including the binding itself. You can add tags, spans and such using
System.Diagnostics
directly. This is now what OpenTelemetry .NET recommends.Let me know if you have any questions.