I've been struggling with this issue for a few hours now and I can't find a good explanation or example in the documentation or any blog post. They all seem to say you can do it, but reference an example of how easy it is to configure the Zipkin server which pretty much works out of the box and is not a very useful example.
So far I've tried one approach referencing "Azure Application Insights exporter" installed in the Dapr runtime as a component and another using the Open Telemetry protocol. I'm not even sure what the endpoint for App Insights should be in either case. The microservices are simple .NET web apis.
Azure Application Insights exporter
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
spec:
tracing:
enabled: true
exporter:
type: azure-appinsights
config:
instrumentationKey:
endpoint: https://westeurope-5.in.applicationinsights.azure.com/
components:
exporters:
azure-appinsights:
type: exporters.azure.appinsights
version: v1
Open Telemetry
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
namespace: default
spec:
tracing:
samplingRate: "1"
otel:
endpointAddress: https://westeurope-5.in.applicationinsights.azure.com/
Has anyone managed to configure and send telemetry to App Insights from a local dev machine running dapr?
instrumentationKey
is properly set to the key associated with your Application Insights resource.I have installed Dapr, Open Telemetry .NET SDK and the Open Telemetry Exporter for Application Insights. Connected the Application Insights to the app by adding the below step.
Manual using config.yaml
file we can connect the app Insight but tried by adding through connected services check below.
Configure Dapr to use OpenTelemetry by creating dapr.yaml
:
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
spec:
tracing:
samplingRate: "1"
otel:
endpointAddress: https://dc.services.visualstudio.com/v2/track
Here is the sample code:
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using OpenTelemetry.Exporter.AzureMonitor;
using OpenTelemetry.Trace;
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureServices((hostContext, services) =>
{
services.AddOpenTelemetryTracing(builder =>
{
builder
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(hostContext.HostingEnvironment.ApplicationName))
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddAzureMonitorExporter(o =>
{
o.ConnectionString = "InstrumentationKey=<Your-Instrumentation-Key>";
});
});
services.AddHostedService<Worker>();
});
AddOpenTelemetryTracing
method configures an Azure Monitor exporter to send telemetry data to Azure Monitor. Finally, it adds a hosted service to run.
Reference: