Giter VIP home page Giter VIP logo

Comments (6)

RehanSaeed avatar RehanSaeed commented on June 6, 2024

My understanding was that the OTEL API was just a wrapper around Activity but with the correct names. Is that incorrect?

from serilog.enrichers.span.

bmcclory avatar bmcclory commented on June 6, 2024

Looks like that's not not the case. There's not much documentation around it but:

open-telemetry/opentelemetry-dotnet#1842

and

https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Api/README.md#baggage-api

The recommended way to add Baggage is to use the Baggage.SetBaggage() API. OpenTelemetry users should not use the Activity.AddBaggage method.

I think the idea here is that in OTEL API Baggage isn't tied to an Activity (Span) context; it's a separate/standalone thing with its own propagator and whatnot.

It's all pretty confusing, because OTEL Baggage is propagated using standard W3C headers (as long you're using the OTEL propagators). And a receiving app using ASP.NET Core's built in diagnostics (without OTEL) will see those headers and set them on Activity.Baggage, where this Serilog Enricher will find them.

But the limitation there is that OTEL Baggage isn't copied into Activity.Baggage until that propagation has occurred. So for an app that does Baggage.SetBaggage(), this Serilog Enricher won't see that data and include it in the logs.

Maybe this is an issue for OTEL .NET to address -- maybe Baggage.SetBaggage() should be copying values into Activity.Baggage() But it's really hard to know what's most correct here...

from serilog.enrichers.span.

RehanSaeed avatar RehanSaeed commented on June 6, 2024

The key lines in the second link:

It is important to note that Baggage is not automatically attached to any telemetry. User can explicitly read Baggage and use it to enrich metrics, logs and traces. An example of doing this for traces is shown here.

It sounds like you have to copy baggage manually?

from serilog.enrichers.span.

bmcclory avatar bmcclory commented on June 6, 2024

I think the idea there is that OTEL telemetry data (Traces, Metrics, Logs) is not automatically enriched with Baggage. If you want it, you have to be explicit.

This also underscores how, in the OTEL specification, Baggage is a standalone thing and not tied to Traces/Activities, which is probably why OTEL .NET is trying to move away from Activity.Baggage.

Since this project is a Serilog Enricher, that's why I raised the issue here. But I realize Serilog != OTEL Logging, and I don't know what it'd look like to bring those things together. For now, I can certainly add a tiny OtelBaggageEnricher to Serilog to solve this problem.

from serilog.enrichers.span.

RehanSaeed avatar RehanSaeed commented on June 6, 2024

This is certainly confusing. I'm not sure this project should do anything about this though. We'd also need to add a reference to the OTEL package if we decide to. Should we close for now?

from serilog.enrichers.span.

bmcclory avatar bmcclory commented on June 6, 2024

Confusing indeed. Especially when OTEL acts as if Baggage is a separate thing from Trace, but recommends using "W3C format for distributed trace" to propagate it. But these things are in various levels of draft/experimental/beta, so probably premature to decide how Serilog (and this Enricher) should participate in that world, and maybe another package someday to avoid the extra dependency.

I'll go ahead and close. Hope this issue / bread crumb helps someone else!

from serilog.enrichers.span.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.