Skip to content

Commit

Permalink
Add Zipkin exporter for OpenTelemetry tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
0GiS0 committed Nov 26, 2023
1 parent 6828d4b commit d70c535
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

// Open Telemetry configuration
var tracingOtlpEndpoint = builder.Configuration["OTLP_ENDPOINT_URL"];
var zipKinEndpoint = builder.Configuration["ZIPKIN_ENDPOINT_URL"];
var otel = builder.Services.AddOpenTelemetry();

// Configure OpenTelemetry Resources with the application name
Expand Down Expand Up @@ -53,6 +54,18 @@
{
tracing.AddConsoleExporter();
}

if(zipKinEndpoint != null)
{
tracing.AddZipkinExporter(zipkinOptions =>
{
zipkinOptions.Endpoint = new Uri($"{zipKinEndpoint}/api/v2/spans");
});
}
else
{
tracing.AddConsoleExporter();
}
});

// Add CORS policy
Expand Down
1 change: 1 addition & 0 deletions tour-of-heroes-api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<PackageReference Include="OpenTelemetry" Version="1.6.0" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.6.0" />
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="1.6.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.6.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.6.0-beta.3" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.6.0-beta.3" />
Expand Down

0 comments on commit d70c535

Please sign in to comment.