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

[Auto-instrumentation] Add unique instance.id to all post-fork processes #4390

Open
noobHappylife opened this issue Jan 21, 2025 · 1 comment

Comments

@noobHappylife
Copy link

Is your feature request related to a problem?

When working with process with multiple workers, like a FastAPI server using uvicorn workers. Metrics provider doesn't have unique instance.id for each workers, thus the metrics doesn't work properly. Ex: All workers are using the same timeseries without unique identifier, causing the statistics unstable.

Describe the solution you'd like

Would it be possible to allow adding unique instance.id while using auto-instrumentation? For now using Opentelemetry python SDK you can do it manually, like the following during the post-fork hook https://opentelemetry-python.readthedocs.io/en/latest/examples/fork-process-model/README.html.

But with auto-instrumentation, I'm not sure how to add the unique instance id, as MeterProvider can't be override.

resource = Resource.create({
    "service.instance.id": uuid7_str(),
})
reader = PeriodicExportingMetricReader(
    OTLPMetricExporter(endpoint=endpoint), export_interval_millis=math.inf
)
self.provider = MeterProvider(resource=resource, metric_readers=[reader])
metrics.set_meter_provider(self.provider)

Describe alternatives you've considered

No response

Additional Context

No response

Would you like to implement a fix?

None

@xrmx
Copy link
Contributor

xrmx commented Jan 22, 2025

Dup of #2113?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants