Skip to content

opentelemetry-process-context: implement process context publishing (OTEP-4719)#5337

Draft
herin049 wants to merge 5 commits into
open-telemetry:mainfrom
herin049:feat/profiles-context
Draft

opentelemetry-process-context: implement process context publishing (OTEP-4719)#5337
herin049 wants to merge 5 commits into
open-telemetry:mainfrom
herin049:feat/profiles-context

Conversation

@herin049

Copy link
Copy Markdown
Contributor

Description

External profilers and observability tools (such as the OpenTelemetry eBPF Profiler) operate outside the instrumented process and have no access to resource attributes configured inside OpenTelemetry SDKs. OTEP-4719 (Process Context Sharing) introduces a standard mechanism for OpenTelemetry SDKs to publish resource attributes for access by out-of-process readers

This PR introduces the opentelemetry-process-context package as a Rust backed Python extension (built with maturin/pyo3) that implements the process outlined in OTEP-4719. It publishes the SDK's resource attributes to
a memory region that any external reader with access to /proc/<pid>/maps and /proc/<pid>/mem can discover.

Python API

The introduced Python API has a very light surface area, consisting of three methods to publish, update and unpublish the process context.

def publish_context(resource: Resource) -> None: ...
def update_context(resource: Resource) -> None: ...
def unpublish_context() -> None: ...

Compatability

The original OTEP explicitly mentions that this functionality is Linux only. However, I have tried to implement this package in such a way that limited testing/development can be performed natively on any Posix compatible system (e.g. MacOS). However, the full functionality of OTEP-4719 is only available on Linux and Windows is explicitly not supported.

Feature Linux macOS
Backing region memfd_create("OTEL_CTX") -> mmap(MAP_PRIVATE) Anonymous mmap
Reader discoverability /proc/<pid>/maps shows memfd:OTEL_CTX Not discoverable (no /proc)
Fork protection madvise(MADV_DONTFORK) Skipped
Mapping name prctl(PR_SET_VMA_ANON_NAME, "OTEL_CTX") Skipped
Publish timestamp clock CLOCK_BOOTTIME CLOCK_MONOTONIC
Production use Fully supported Development/testing only

Fixes #5291

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

uv run tox -e py314-test-opentelemetry-process-context

TODO: Add more elaborate testing.

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@herin049 herin049 requested a review from a team as a code owner June 19, 2026 21:37
@herin049 herin049 marked this pull request as draft June 19, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Support Otlp Profiling

1 participant