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

Specifying an endpoint in appsettings.json breaks appending suffix to endpoint path #5668

Open
Volkmire opened this issue Jun 3, 2024 · 1 comment
Labels
bug Something isn't working pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package

Comments

@Volkmire
Copy link

Volkmire commented Jun 3, 2024

Package

OpenTelemetry.Exporter.OpenTelemetryProtocol

Package Version

Package Name Version
OpenTelemetry.Exporter.OpenTelemetryProtocol 1.8.1
OpenTelemetry.Extensions.Hosting 1.8.1

Runtime Version

net8.0

Description

I tried to configure an app similar to this README, but when I specify the endpoint and do Configure, the exporter uses the same URI as in options and does not append signal specific suffix to any of the calls.
I assume this is because of AppendSignalPathToEndpoint being set to false in Endpoint setter of OtlpExporterOptions.

Steps to Reproduce

// simplified example
static void ConfigureTelemetry(WebApplicationBuilder appBuilder)
{
    var logging = appBuilder.Logging;
    var services = appBuilder.Services;
    var configuration = appBuilder.Configuration;

    logging.ClearProviders();
    logging.AddConsole();

    // if I try to do this, signal exporters no longer append signal suffixes to base path
    services.Configure<OtlpExporterOptions>(configuration.GetSection("OpenTelemetry:Otlp"));

    var resourceBuilder = ResourceBuilder.CreateEmpty()
        .AddAttributes(new KeyValuePair<string, object>[]
        {
            new("service.name", $"unknown:{Process.GetCurrentProcess().ProcessName}"),
            new("service.instance.id", MachineName)
        })
        .AddEnvironmentVariableDetector();

    logging.Configure(opts => opts.ActivityTrackingOptions = ActivityTrackingOptions.Tags)
        .AddOpenTelemetry(cfg =>
        {
            cfg.SetResourceBuilder(resourceBuilder);
            cfg.AddOtlpExporter();
        });

    services.AddOpenTelemetry()
        .WithTracing(cfg =>
        {
            cfg.SetResourceBuilder(resourceBuilder);
    
            cfg.AddSource("Azure.*")
                .AddAspNetCoreInstrumentation()
                .AddHttpClientInstrumentation();
                    
            cfg.AddOtlpExporter();
        })
        .WithMetrics(cfg =>
        {
            cfg.SetResourceBuilder(resourceBuilder);
            cfg.AddOtlpExporter();
        });

Expected Result

Options behavior should be the same for environment variables (OTEL_EXPORTER_OTLP_ENDPOINT, etc) and options registration.

Actual Result

Specifying an endpoint as environment variable allows exporter to append signal suffix.
Specifying an endpoint via options registration prevents exporter from appending signal suffix.

Additional Context

No response

@Volkmire Volkmire added the bug Something isn't working label Jun 3, 2024
@github-actions github-actions bot added the pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package label Jun 3, 2024
@vishweshbankwar
Copy link
Member

Related: #5054

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package
2 participants