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

WithOtlpExporter should not set environment variables when dashboard is disabled #7031

Open
1 task done
afscrome opened this issue Jan 6, 2025 · 0 comments
Open
1 task done
Labels
untriaged New issue has not been triaged

Comments

@afscrome
Copy link
Contributor

afscrome commented Jan 6, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When the dashboard is disabled (such as when running with DistributedApplicationTestingBuilder), then the WithOtlpEndpoint method will configure apps to use a non existant OTLP exporter. This can lead to misleading errors in apps that fail to send open telemetry to the non existant endpoint.

Expected Behavior

When the dashboard is not running, there's nothing to receive OTLP, so the OTLP environment variables should be omitted.

Steps To Reproduce

var builder = DistributedApplication.CreateBuilder(new DistributedApplicationOptions { DisableDashboard = true }); 

var app = builder.AddExecutable("app", "pwsh", ".")
    .WithOtlpExporter();

builder.Eventing.Subscribe<BeforeStartEvent>(async (beforeStartEvent, ct) =>
{
    _ = Task.Run(async () =>
    {
        var notificationService = beforeStartEvent.Services.GetRequiredService<ResourceNotificationService>();
        var evt = await notificationService.WaitForResourceAsync("app", e => e.Snapshot.State == KnownResourceStates.Running);
        var endpoint = evt.Snapshot.EnvironmentVariables.Single(x => x.Name == "OTEL_EXPORTER_OTLP_ENDPOINT");
        if (endpoint != null)
        {
            Console.Beep();
            Console.WriteLine($"OTLP Exporter value was set even though there's no dashboard: {endpoint.Value}");
        }
    });
});

Expected result: OTEL_EXPORTER_OTLP_ENDPOINT is not set
Actual Results: OTEL_EXPORTER_OTLP_ENDPOINT is set.

Exceptions (if any)

No response

.NET Version info

.NET SDK:
 Version:           8.0.404
 Commit:            7b190310f2
 Workload version:  8.0.400-manifests.7db8327f
 MSBuild version:   17.11.9+a69bbaaf5

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22621
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.404\

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
 [aspire]
   Installation Source: SDK 8.0.400, VS 17.12.35514.174
   Manifest Version:    8.2.2/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
   Install Type:        FileBased


Host:
  Version:      9.0.0
  Architecture: x64
  Commit:       9d5a6a9aa4

.NET SDKs installed:
  6.0.428 [C:\Program Files\dotnet\sdk]
  8.0.404 [C:\Program Files\dotnet\sdk]
  9.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  S:\Trayport.Aspire\global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Anything else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged New issue has not been triaged
Projects
None yet
Development

No branches or pull requests

2 participants