feat(python/cerebrium): OTel auto-instrumentation example → Last9#198
Open
prathamesh-sonpatki wants to merge 1 commit into
Open
feat(python/cerebrium): OTel auto-instrumentation example → Last9#198prathamesh-sonpatki wants to merge 1 commit into
prathamesh-sonpatki wants to merge 1 commit into
Conversation
Deploy a FastAPI app on Cerebrium with zero OTel code — opentelemetry-instrument runs in the entrypoint and auto-patches FastAPI, requests, and httpx at startup. Spans ship to Last9 over OTLP/HTTP. Key bits: - [cerebrium.runtime.custom].entrypoint prepends opentelemetry-instrument before uvicorn — Cerebrium honors the array so the auto-instrumentation launcher gets first-class control of process startup. - opentelemetry-bootstrap runs in shell_commands at build to pull every matching instrumentor for the libraries in the pip deps. - Pinned opentelemetry-distro/semantic-conventions >=0.51b0 to avoid a version skew where the newer exporter-otlp-proto-common imports semconv._incubating against an older semconv wheel and fails at sitecustomize import time. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A FastAPI app running on Cerebrium with zero OpenTelemetry code in source. All instrumentation comes from
opentelemetry-instrumentrunning in the Cerebrium entrypoint. Spans ship to Last9 over OTLP/HTTP.Originated from a customer thread where Cerebrium → Last9 integration kept failing. We documented the metrics path (Cerebrium dashboard → Custom OTLP) in last9/last9.io#581; this PR adds the traces side.
Key bits
[cerebrium.runtime.custom].entrypoint = ["opentelemetry-instrument", "uvicorn", "main:app", ...]— Cerebrium honors the array verbatim, so OTel's auto-instrumentation launcher gets first-class control of process startup.shell_commands = ["opentelemetry-bootstrap --action=install"]runs at build to pull every matching instrumentor for the libs in the pip deps.opentelemetry-distro >=0.51b0+opentelemetry-semantic-conventions >=0.51b0pinned together. Without this, pip resolves a newer exporter-otlp-proto-common that importssemconv._incubatingagainst an older semconv wheel, and sitecustomize crashes at startup withModuleNotFoundError. Hit this trap during verification.Verification
Deployed end-to-end to Cerebrium project
last9and confirmed trace ingestion in Last9 (otlp-aps1cluster):service.name = otel-autoinstrument-last9telemetry.auto.version = 0.63b1← confirms auto-instrumentation, not SDK codeScopeName = opentelemetry.instrumentation.fastapi← FastAPI instrumentor firingPOST /predictSERVER span + childhttp receive/http sendINTERNAL spans, all under one TraceIdGET /readyspans every second from Cerebrium's kube-probeSample TraceId:
0000000000000000804b1b6f2fae3993.Test plan
ModuleNotFoundErrorat startupPOST /predictspans land in Last9 with FastAPI scope🤖 Generated with Claude Code