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

OpenTelemetry: Have guidance that use hosting extensions builder for configuration #6662

Open
ramonsmits opened this issue May 27, 2024 · 0 comments

Comments

@ramonsmits
Copy link
Member

Greenfield projects likely use .NET builder from hosting extensions for configuration. The current guidance and samples use the OpenTelemetry SDK

For example, at https://docs.particular.net/nservicebus/operations/opentelemetry#traces:

var tracingProviderBuilder = Sdk.CreateTracerProviderBuilder()
    .AddSource("NServiceBus.Core")
    // ... Add other trace sources
    // ... Add exporters
    .Build();

while it likely is better to use:

services.AddOpenTelemetry()
    .ConfigureResource(rb => rb.AddService(Global.ActivitySource.Name, serviceInstanceId: Global.InstanceId).AddAttributes(attributes))
    .WithTracing(tracerProviderBuilder =>
    {
        tracerProviderBuilder
            .AddSource("NServiceBus.*")
            .AddSource(Global.ActivitySource.Name)
            .AddAzureMonitorTraceExporter(o => o.ConnectionString = applicationInsightsConnectionString)
            ;
    })
    .WithMetrics(cfg =>
    {
        cfg
            .AddMeter("NServiceBus.Core")
            .AddAzureMonitorMetricExporter(o => o.ConnectionString = applicationInsightsConnectionString)
            ;
    });```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant