opentelemetry-dotnet icon indicating copy to clipboard operation
opentelemetry-dotnet copied to clipboard

How can i trace activity in ASP.NET core Filters

Open sonnguyenit opened this issue 3 years ago • 1 comments

Question

How can i trace activity in ASP.NET core Filters In Startup.cs i added following AddSource .AddSource(nameof(MyControllerFilter))

...
services.AddOpenTelemetryTracing(builder =>
{
	builder.AddAspNetCoreInstrumentation()
		.AddHttpClientInstrumentation()
		.AddEntityFrameworkCoreInstrumentation()
		.AddSource(nameof(MyControllerFilter))
		.AddSource(nameof(MyController))
		.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(Configuration["ServiceName"]))
		.AddJaegerExporter(opts =>
		{
			opts.AgentHost = Configuration["Jaeger:AgentHost"];
			opts.AgentPort = System.Convert.ToInt32(Configuration["Jaeger:AgentPort"]);
			opts.ExportProcessorType = ExportProcessorType.Batch;
		});
});
...

MyController.cs

public class MyController : ControllerBase
{
	.....
	
	[ServiceFilter(typeof(MyControllerFilter))]
	public IActionResult HandleAction([FromQuery] string action)
	{
	
		....
		
	}
	
	....
}

but seems it's not working.

Thank you for read my question.

sonnguyenit avatar Jul 19 '22 04:07 sonnguyenit

AddSource is meant to add ActivitySources. I dont think this usage is correct.

Take a look at the example asp.net core app, and see if that is what you are looking for. If not, please modify it/create new repro app, explaining which part is not working.

cijothomas avatar Jul 26 '22 15:07 cijothomas

Closing old issues that are not active.

cijothomas avatar Feb 28 '23 17:02 cijothomas