OpenTelemetry, AspNetCore and Jaeger - Getting started questions

Viewed 287

I've been doing some reading and watching some videos on aspnetcore and otel.

Its been a bit challenging b/c the api surface appears to have evolved quite a bit since 2020.

I've got my aspnetcore solution wired up with otel via OpenTelemetry.Extensions.Hosting, OpenTelemetry.Instrumentation.HTTP, OpenTelemetry.Instrumentation.AspNetCore and using a Jaeger exporter.

I have a couple of questions;

  1. In the sample's I've seen I can set the top level service name via service registration on the exporters, but this property appears to have been dropped in the most recent packages. How do I set the top level service name (its showing up a unknown service in jaeger)?

  2. I'm trying to propagate my tenant identifier to all span related calls. I'm using activity.Current.AddBaggage("TenantId",MyTenantId) but the value isn't getting exported to jaeger (the baggage items aren't present in the raw json received by jaeger).

  3. I'd like to include the activity id in the response headers for all outgoing responses. Do I need to write this myself, or is it baked into the aspnet core otel code somewhere?

Thanks!

1 Answers

How do I set the top level service name (its showing up a unknown service in jaeger)?

You achieve this using Resource. There are couple of ways to do this. You could set the env variables OTEL_RESOURCE_ATTRIBUTES=service.name=my-service-name or the OTEL_SERVICE_NAME=my-service-name

If you want to do this programatically you would register a Resource object to The TracerProvider.

I'm trying to propagate my tenant identifier to all span related calls. I'm using activity.Current.AddBaggage("TenantId",MyTenantId) but the value isn't getting exported to jaeger (the baggage items aren't present in the raw json received by jaeger).

I don't think baggage items are automatically added to trace. For this use you probably should be looking at TraceState.

I'd like to include the activity id in the response headers for all outgoing responses. Do I need to write this myself, or is it baked into the aspnet core otel code somewhere?

I am not super familiar with aspnet instrumentation components but there should be some sort of hooks to do this. JS, Python and other Client libraries has this feature.

Related