What is the difference between AddHttpClientInstrumentation and AddAspNetCoreInstrumentation

andrew choi 1 Reputation point
2022-09-16T22:57:23.02+00:00

In Asp.net core, to provide auto trace instrumentation, we can do the followings.

services.AddOpenTelemetryTracing(providerBuilder =>
{
providerBuilder
.AddSource("TemenosInsightDataService")
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("InsightDataService"))
.AddHttpClientInstrumentation()
.AddAspNetCoreInstrumentation()
.AddSqlClientInstrumentation()
.AddConsoleExporter()

        });  

After reading the limited documentation on github, I still quite understand the purpose and difference between them. It seems to me their main purpose is to allow Enrich function to be called to add additional information to activity. I can do that on both AddHttpClientInstrumentation() and AddAspNetCoreInstrumentation() which will both add to trace context. How to choose which one to use?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,189 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Liam Bao 0 Reputation points
    2024-05-01T14:34:25.1066667+00:00

    We can always use both of them.

    • AddAspNetCoreInstrumentation is instrumenting inbound HTTP connections.
    • AddHttpClientInstrumentation is instrumenting outbound HTTP connections.
    0 comments No comments