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() causes Persistent Containers to be recreated every execution #6889

Open
afscrome opened this issue Dec 6, 2024 · 2 comments
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication
Milestone

Comments

@afscrome
Copy link
Contributor

afscrome commented Dec 6, 2024

If you have a persistent container and try to enable open telemetry on it, the container persistence stops workign, with the container being recreated every time.

builder.AddRedis("redis")
       .WithLifetime(ContainerLifetime.Persistent)
       .WithOtlpExporter()
       ;

I believe this is because the instance id in the OTEL_RESOURCE_ATTRIBUTES environment variable and the api key in OTEL_EXPORTER_OTLP_HEADERS change on each app host restart, and so DCP believes it needs to re-create the container

@joperezr joperezr added the untriaged New issue has not been triaged label Dec 9, 2024
@DamianEdwards DamianEdwards added area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication area-orchestrator labels Dec 9, 2024
@DamianEdwards
Copy link
Member

FYI @karolz-ms @danegsta @eerhardt

This seems like a pretty fundamental issue with persistent containers in that anything with launch-time randomization will result in the definition changing, e.g. random password on start (like we used to do by default) would cause this too.

A possible tactical fix could be to preserve the OTLP API key in user secrets, like we do resource passwords for container-based integrations.

@karolz-ms
Copy link
Member

The default logic that decides if a container instance can be reused takes environment variables into account. So yes, changing one of them per execution will effectively disable the persistence.

That is why LifecycleKey property exists for Containers. We should probably have a design discussion about the default "policy" for container reuse in Aspire and how it could be exposed via app model to allow developers to customize it.

@afscrome @mitchdenny any thoughts on this?

@joperezr joperezr added this to the Backlog milestone Dec 10, 2024
@joperezr joperezr removed area-orchestrator untriaged New issue has not been triaged labels Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication
Projects
None yet
Development

No branches or pull requests

4 participants