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

オープン 初心者向け
#2,593 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
62/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
csharp, docker
領域
devops

調査の方向性

失敗しているコールバックは src/CommunityToolkit.Aspire.Hosting.OpenTelemetryCollector/OpenTelemetryCollectorRoutingExtensions.cs の WithOpenTelemetryCollectorRouting 内にあります。問題の行は LogDebug 呼び出し内の endpoint.Url です。再現するには、AppHost に対して --publisher manifest を指定して dotnet run を実行し、例外が発生することを確認してください。マニフェストが完全に書き出され、実行モードで OTEL_EXPORTER_OTLP_ENDPOINT の値が引き続き解決されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
C#
スター
637
フォーク
209
平均マージ
1日 10時間
マージ済み PR(30日)
131

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

CommunityToolkit/Aspire のほかの issue

CommunityToolkit/Aspire の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。