Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing TraceEnricher instance scope information in OpenTelemetry.Extensions.Enrichment documentation #2551

Open
julealgon opened this issue Feb 10, 2025 · 2 comments
Assignees
Labels
comp:extensions.enrichment Things related to OpenTelemetry.Extensions.Enrichment

Comments

@julealgon
Copy link

I just saw the release information for this new OpenTelemetry.Extensions.Enrichment package today and it seems super useful for some use cases that we have.

I went to check the main README.md on the project to learn more about how it works, and one thing that immediately jumped to me as lacking was information about when/how the TraceEnricher class is created. Is a single instance of the enricher created per application (singleton), is it scoped, or is it created for each individual Activity?

This is important to be able to know the types of dependencies we can inject in the implementations. I would like to be able to inject things that are naturally scoped, for instance.

Can the docs be updated to add detail about the lifetime of the TraceEnricher instances when DI is used?

@evgenyfedorov2

@Kielek Kielek added the comp:extensions.enrichment Things related to OpenTelemetry.Extensions.Enrichment label Feb 10, 2025
@evgenyfedorov2
Copy link
Contributor

TraceEnricher is an abstract class, so user code is expected to have one or more concrete implementations. Each implementation type will be registered with singleton lifetime. So basically you can create your implementation whose instance will be created only once (singleton) and expect its Enrich() method will be called on every Activity.

If we speak about things like IHttpContextAccessor, it can be injected and will work, but I know that it is not very convenient because there is no access to HttpRequestMessage /HttpResponseMessage from it. Please also consider this functionality.

@julealgon
Copy link
Author

Each implementation type will be registered with singleton lifetime.

Can you add this to the documentation? I believe this is a very important point that should be exposed there.

So basically you can create your implementation whose instance will be created only once (singleton) and expect its Enrich() method will be called on every Activity.

This makes it less usable for us in particular. I wonder if you could reconsider this design? Would it be possible to change it to be a scoped registration instead?

If we speak about things like IHttpContextAccessor, it can be injected and will work, but I know that it is not very convenient because there is no access to HttpRequestMessage /HttpResponseMessage from it. Please also consider this functionality.

Yeah, I'm already familiar with this and we are currently leveraging it, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:extensions.enrichment Things related to OpenTelemetry.Extensions.Enrichment
Projects
None yet
Development

No branches or pull requests

3 participants