Skip to content

OpenTelemetryCollector endpoint not allocated during run mode when using Azure resources #957

@theiam79

Description

@theiam79

Describe the bug

I'm trying to test the OpenTelemetryCollector integration during local dev and I get the following error:

One or more errors occurred. (The endpoint grpc is not allocated for the resource opentelemetry-collector.)

I believe this is due to a logging call within WithOpenTelemetryCollectorRouting, if I include an Azure resource in my apphost this endpoint is not yet allocated when this call happens

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

If I use my own implementation that uses a reference expression, the application launches as expected

var url = endpoint.Property(EndpointProperty.Url);
callback.Logger.LogDebug("Forwarding Telemetry for {name} to the collector on {endpoint}", builder.Resource.Name, ReferenceExpression.Create($"{url}"));

Regression

No response

Steps to reproduce

- net9.0
- Aspire AppHost v9.5.2

- Create an AppHost with at least one project resource
- Configure the Open Telemetry Collection with either `WithOpenTelemetryCollection` or `WithAppForwarding`
- Run AppHost
- Exception throws during startup

Expected behavior

The AppHost starts up completely and the project resources send telemetry data to the collector resource

Screenshots

No response

IDE and version

VS 2022

IDE version

17.14.19

Nuget packages

Aspire.Hosting.Azure.AppConfiguration (9.5.2)
CommunityToolkit.Aspire.Hosting.OpenTelemetryCollector (9.9.0)

Additional context

No response

Help us help you

No, just wanted to report this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions