feat: Propagate process context to profiles#66
Open
nsavoire wants to merge 5 commits into
Open
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5d31f5fdb1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
5d31f5f to
777db74
Compare
777db74 to
4075fdb
Compare
4075fdb to
e13e762
Compare
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
e13e762 to
e11c1cf
Compare
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
Propagate OTel ProcessContext resource attributes (per OTEP #4719) to the OTLP profile output so profiles can be correlated with the rest of the telemetry from the same service instance.
Changes
processcontext:
Info.Resourceis now a*pcommon.Resource(was*resourcepb.Resource), so resource attributes flow directly into the OTLP reporter without re-conversion.convertAnyValuehandles allAnyValuevariants includingnested arrays/maps.
WithMergedEnvVars(info, envVars)enriches anInfowithOTEL_SERVICE_NAMEandOTEL_RESOURCE_ATTRIBUTES. Per the OTel resource SDK spec: keys and values are percent-encoded; on any decoding error the entireOTEL_RESOURCE_ATTRIBUTESvalue is discarded; duplicate keys within it resolve last-writer-wins;OTEL_SERVICE_NAMEoverridesservice.nameif both are set; values from the proto resource win over env-var-derived ones on collision.ResourceToContextKey(resource)returns a stable key from the(service.namespace, service.name, service.instance.id)triplet — described as globally unique by the semantic conventions. Used inResourceKeyfor trace deduplication grouping.Infois documented as immutable after publication; the embedded*pcommon.Resourceis shared by pointer across the process-manager writer, the tracer event loop, and the reporter, and must be treated as read-only by all holders.processmanager:
SynchronizeProcessdefers theprocesscontext.Readuntil afterGetProcessMeta, so env vars are available to merge in the same sync.readProcessContextreturns(Info, publish bool):falsepreserves the previously-published context on transientErrNoUpdate/ErrConcurrentUpdate,truepublishes a new context.Behaviour notes
OTEL_CTXmapping are unchanged:Info.Resourcestays nil,ContextKey == NullString, and bucketing falls back to the existing PID/container/executable keys.OTEL_SERVICE_NAME/OTEL_RESOURCE_ATTRIBUTESbut doesn't publish aProcessContextmapping still gets a Resource derived from those env vars.setResourceAttributescopies the process context attributes onto the emitted ResourceProfiles. eBPF-derived process.pid, container.id, and process.executable.* are added on top. APMServiceName, when set, takes precedence over the process context supplied service.name. This override is transitional and APMServiceName should be removed once ProcessContext is the canonical source of service identity.