asp.net core 5.0 opentelemetry is not generating traces for http request coming in
See original GitHub issueBug Report
Packages used in project
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.13" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.1.0-beta3" />
<PackageReference Include="OpenTelemetry.Exporter.Jaeger" Version="1.1.0-beta3" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc4" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc4" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.4" />
</ItemGroup>
Runtime
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<UserSecretsId>30a3fffe-4ad1-4e93-8ab2-66e18ca23da5</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
Symptom
when i am sending request from either swagger or putting url in browser then no traces are generated neither on console nor in jeager
i should traces in jeager and console.
but i don’t see any trace generated
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "OTel.POC.Web", Version = "v1" });
});
services.AddOpenTelemetryTracing((builder) =>
builder
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("OTel.POC.Web"))
.AddHttpClientInstrumentation()
.AddAspNetCoreInstrumentation(option=> { option.RecordException = true; })
.AddConsoleExporter()
.AddJaegerExporter(options =>
{
options.AgentHost = "localhost";
options.AgentPort = 6831;
})
);
}
program.cs
public class Program
{
public static void Main(string[] args)
{
Activity.DefaultIdFormat = ActivityIdFormat.W3C;
var listener = new ActivityListener
{
ShouldListenTo = _ => true,
ActivityStopped = activity =>
{
foreach (var (key, value) in activity.Baggage)
{
activity.AddTag(key, value);
}
}
};
ActivitySource.AddActivityListener(listener);
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.ConfigureLogging((context, builder) =>
{
builder.AddConsole();
builder.AddOpenTelemetry(options =>
{
options.IncludeScopes = true;
options.ParseStateValues = true;
options.IncludeFormattedMessage = true;
options.AddConsoleExporter();
});
});
}
}
Repo link https://github.com/Dheerajcode2016/OpenTelemetry-dotnet
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Tracing .NET Applications Easily With OpenTelemetry
In this article, we take a look at tracing in .NET applications, starting with the auto-instrumentation libraries and then custom traces.
Read more >NET Observability with OpenTelemetry
Distributed tracing, which tracks requests and activities across ... NET Core instrumentation to get metrics and activities from ASP.
Read more >asp.net core - Dotnet: OpenTelemetry, connect two scopes
I have three services running on .Net with OpenTelemetry tracing enabled. Communication begins from the first service to the second one via ...
Read more >Getting Started
Get telemetry for your app in less than 5 minutes! This page will show you how to get started with OpenTelemetry in .NET....
Read more >Add distributed tracing instrumentation - .NET
Create initial app. First you will create a sample app that collects telemetry using OpenTelemetry, but doesn't yet have any instrumentation. .
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
@Dheerajcode2016 There is a breaking change with the 1.1.0-beta3 version of the SDK. There is an issue created to track this #2051.
As a temporary fix, could you please downgrade the Console and Jaeger exporter packages to version 1.1.0-beta2 to unblock yourself?
Thank you Piotr (@Kielek) for mentioning
.StartWithHost()
method (yeah, I’ve been in that trap already), but no, this time it wasn’t the reason for the issue I had.If I’ll come up with new info (let me double check everything) - I’ll come back to leave feedback.