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

Mapping enrichers with Resource attributes #119

Open
cecilphillip opened this issue Dec 8, 2023 · 1 comment
Open

Mapping enrichers with Resource attributes #119

cecilphillip opened this issue Dec 8, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@cecilphillip
Copy link

Given a configuration similar to the following, would it possible to flow enriched properties to OTEL Resource attributes. For instances, I'd want to be able to set the host.name attribute with the value from WithMachineName.

Log.Logger = new LoggerConfiguration()
    .MinimumLevel.Information()
    .Enrich.FromLogContext()
    .Enrich.WithThreadId()
    .Enrich.WithEnvironmentName()
    .Enrich.WithMachineName()
    .WriteTo.Console(outputTemplate: outputTemplate)
    .WriteTo.OpenTelemetry(opts =>
    {
        opts.ResourceAttributes = new Dictionary<string, object>
        {
            ["service.name"] = "BackendApiService"
        };
    })
    .CreateLogger();
@nblumhardt
Copy link
Member

I think this is ultimately where we're heading, but I'm not sure what the mechanics should be.

Since resource attributes are expected to be static for the life of the application it's a bit of a waste to use an enricher in this case, but on the other hand, it leaves nice friendly-named properties for other sinks to consume 🤔

Resource attributes are also shared across the entire batched OTLP payload, so we'd need to think about what happens when multiple values show up for a RA.

@nblumhardt nblumhardt added the enhancement New feature or request label Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants