OpenTelemetryCollector: WithAppForwarding breaks manifest publish ("The endpoint `grpc` is not allocated for the resource")

Abierto Apto para principiantes
#2,593 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
62/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
csharp, docker
Área
devops

Línea de trabajo

El callback que falla está en src/CommunityToolkit.Aspire.Hosting.OpenTelemetryCollector/OpenTelemetryCollectorRoutingExtensions.cs, dentro de WithOpenTelemetryCollectorRouting; la línea problemática es endpoint.Url en una llamada a LogDebug. Para reproducirlo, ejecuta dotnet run sobre el AppHost con --publisher manifest y confirma la excepción. Está terminado cuando el manifiesto se escribe completo y el valor de OTEL_EXPORTER_OTLP_ENDPOINT sigue resolviéndose en el modo de ejecución.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Describe the bug

Publishing an AppHost that uses AddOpenTelemetryCollector(...).WithAppForwarding() as a manifest fails with

Step 'publish-manifest' failed: The endpoint `grpc` is not allocated for the resource `otel-collector`.

The manifest file that is written is cut off in the middle (not valid JSON), and the process still exits with code 0.

Running the AppHost works; only publishing fails.

Cause

The environment callback registered by WithOpenTelemetryCollectorRouting reads endpoint.Url as an argument of a debug log call:

src/CommunityToolkit.Aspire.Hosting.OpenTelemetryCollector/OpenTelemetryCollectorRoutingExtensions.cs

var endpoint = collectorBuilder.Resource.GetEndpoint(endpointName);
callback.Logger.LogDebug("Forwarding Telemetry for {name} to the collector on {endpoint}", builder.Resource.Name, endpoint.Url);

The argument is evaluated whatever the log level is. In publish mode no endpoint is allocated, so EndpointReference.Url throws. The line after it, which sets OTEL_EXPORTER_OTLP_ENDPOINT to the endpoint reference itself, is fine in both modes.

Stack trace (top):

System.InvalidOperationException: The endpoint `grpc` is not allocated for the resource `otel-collector`.
   at Aspire.Hosting.ApplicationModel.EndpointReference.get_AllocatedEndpoint()
   at Aspire.Hosting.ApplicationModel.EndpointReference.get_Url()
   at Aspire.Hosting.OpenTelemetryCollectorRoutingExtensions.<>c__DisplayClass0_0`1.<WithOpenTelemetryCollectorRouting>b__0(EnvironmentCallbackContext callback)
   at Aspire.Hosting.ApplicationModel.EnvironmentCallbackAnnotation.ExecuteCallbackAsync(EnvironmentCallbackContext context)
   ...
   at Aspire.Hosting.Publishing.ManifestPublishingContext.WriteEnvironmentVariablesAsync(IResource resource)
   at Aspire.Hosting.Publishing.ManifestPublishingContext.WriteContainerAsync(ContainerResource container)
Steps to reproduce
  1. An AppHost with at least one container or project resource and

    builder.AddOpenTelemetryCollector("otel-collector")
        .WithConfig("./otel/config.yaml")
        .WithAppForwarding();
    
  2. dotnet run --project <AppHost> -- --publisher manifest --output-path ./manifest.json

I have not reduced this to a minimal project; the stack trace and the source line above are from a larger AppHost.

Expected behavior

The manifest is written completely; OTEL_EXPORTER_OTLP_ENDPOINT of the routed resources is an expression that refers to the collector's endpoint.

Suggested fix

Do not read Url in the callback, for example log the endpoint's name instead of its address, or log only in run mode (callback.ExecutionContext.IsRunMode). I can send a pull request for that if it helps.

Versions
  • CommunityToolkit.Aspire.Hosting.OpenTelemetryCollector 13.6.1 (the line is also on main as of 2026-11-23)
  • Aspire.Hosting / Aspire.AppHost.Sdk 13.6.5
  • .NET 10
Lenguaje dominante
C#
Estrellas
637
Forks
209
Merge medio
1 d 10 h
PR fusionados (30 d)
131

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de CommunityToolkit/Aspire

Todos los issues de CommunityToolkit/Aspire

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.