Skip to content

envcar: add environment carrier#8442

Merged
dmathieu merged 31 commits intoopen-telemetry:mainfrom
Joibel:envcar
Mar 5, 2026
Merged

envcar: add environment carrier#8442
dmathieu merged 31 commits intoopen-telemetry:mainfrom
Joibel:envcar

Conversation

@Joibel
Copy link
Copy Markdown
Member

@Joibel Joibel commented Jan 21, 2026

Fixes #8300

Add a carrier implementing environment carrier based on top of TextMapCarrier.

Allows the callers selection of mechanism for setting environment variables, compatible with os.Setenv - for users who'd like to set environment variables in spawned processes.

This is mostly a migration of @pellared's work in open-telemetry/opentelemetry-go#6778 to go-contrib. I've added further test coverage to appease the coverage bot.

There are three example tests for how to use it.

This is incomplete due to ownership: I'd be happy to be CODEOWNER, or add @pellared as the owner.
I've set myself as CODEOWNER

@Joibel Joibel requested a review from a team as a code owner January 21, 2026 15:21
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.1%. Comparing base (69addb4) to head (517f352).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #8442   +/-   ##
=====================================
  Coverage   82.1%   82.1%           
=====================================
  Files        180     182    +2     
  Lines      13722   13756   +34     
=====================================
+ Hits       11270   11304   +34     
  Misses      2049    2049           
  Partials     403     403           
Files with missing lines Coverage Δ
propagators/envcar/carrier.go 100.0% <100.0%> (ø)
propagators/envcar/version.go 100.0% <100.0%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Alan Clucas <alan@clucas.org>
@Joibel Joibel marked this pull request as ready for review January 21, 2026 17:16
@kamphaus
Copy link
Copy Markdown
Contributor

I see that other propagators have example_test.go files.
Would it be interesting to add such for envcar?

I think two scenarios might be interesting:

  • once with os.Setenv
  • once to show how to launch a child process with different context than the current process

@pellared

This comment was marked as resolved.

Comment thread propagators/envcar/carrier.go Outdated
Signed-off-by: Alan Clucas <alan@clucas.org>
@Joibel

This comment was marked as resolved.

Comment thread propagators/envcar/carrier_example_test.go Outdated
Copy link
Copy Markdown
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's please add a test that ensures that it works correctly in a scenario when the application (code) spawns processes from a few concurrent goroutines and each process is created inside a new span (so that each of the new process receives unique trace context).

Reference: https://opentelemetry.io/docs/specs/otel/context/env-carriers/#process-spawning

Comment thread CODEOWNERS Outdated
Co-authored-by: Robert Pająk <pellared@hotmail.com>
Comment thread CHANGELOG.md Outdated
Joibel and others added 2 commits January 30, 2026 15:16
Co-authored-by: Robert Pająk <pellared@hotmail.com>
Signed-off-by: Alan Clucas <alan@clucas.org>
Comment thread propagators/envcar/carrier.go Outdated
Comment thread propagators/envcar/carrier_example_test.go Outdated
Comment thread propagators/envcar/carrier.go Outdated
Joibel and others added 2 commits February 2, 2026 10:27
Co-authored-by: Christophe Kamphaus <christophe.kamphaus@gmail.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
Comment thread propagators/envcar/carrier.go Outdated
Joibel and others added 5 commits February 26, 2026 11:39
Co-authored-by: Robert Pająk <pellared@hotmail.com>
Signed-off-by: Alan Clucas <alan@clucas.org>
Signed-off-by: Alan Clucas <alan@clucas.org>
Signed-off-by: Alan Clucas <alan@clucas.org>
Signed-off-by: Alan Clucas <alan@clucas.org>
Copy link
Copy Markdown
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few nit comments.

Comment thread propagators/envcar/carrier.go Outdated
Comment thread propagators/envcar/carrier.go
Comment thread propagators/envcar/carrier.go Outdated
Comment thread propagators/envcar/carrier.go Outdated
@pellared pellared dismissed their stale review March 4, 2026 09:41

I am no longer blocking this PR. Only a few cleanups are needed.

@pellared
Copy link
Copy Markdown
Member

pellared commented Mar 4, 2026

@kamphaus, @adrielp, can you please take another look?

Signed-off-by: Alan Clucas <alan@clucas.org>
Copy link
Copy Markdown
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor feedback regarding docs. Besides, LGTM. Great work!

Comment thread propagators/envcar/carrier.go Outdated
Comment thread propagators/envcar/carrier.go
Comment thread propagators/envcar/carrier.go Outdated
@pellared pellared added this to the v1.42.0 milestone Mar 4, 2026
@pellared pellared changed the title feat: add environment carrier envcar: add environment carrier Mar 4, 2026
Signed-off-by: Alan Clucas <alan@clucas.org>
Comment thread propagators/envcar/carrier.go
Joibel added 2 commits March 5, 2026 09:14
Signed-off-by: Alan Clucas <alan@clucas.org>
@dmathieu
Copy link
Copy Markdown
Member

dmathieu commented Mar 5, 2026

I've invited you to the @open-telemetry/go-contributors team. This is required to let GH actions auto-request reviews from PRs opened against this module.

Comment thread propagators/envcar/carrier_test.go Outdated
Co-authored-by: Damien Mathieu <42@dmathieu.com>
@dmathieu dmathieu merged commit 324662a into open-telemetry:main Mar 5, 2026
27 checks passed
@Joibel Joibel deleted the envcar branch March 5, 2026 10:52
pellared added a commit that referenced this pull request Mar 6, 2026
#8649)

### Added

- Add environment variables propagation carrier in `go.opentelemetry.io/contrib/propagators/envcar`. (#8442)

### Changed

- Upgrade `go.opentelemetry.io/otel/semconv` to `v1.40.0`, including updates across instrumentation and detector modules. (#8631)
  - The semantic conventions v1.40.0 release introduces RPC breaking changes applied in this repository:
    - RPC spans and metrics no longer include `network.protocol.name`, `network.protocol.version`, or `network.transport` attributes.
    - `rpc.client.request.size`, `rpc.client.response.size`, `rpc.server.request.size`, and `rpc.server.response.size` are no longer emitted in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc`.
    - `rpc.message` span events and their message attributes are no longer emitted in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc` (including when `WithMessageEvents` is configured).

  See [semantic-conventions v1.40.0 release](https://github.com/open-telemetry/semantic-conventions/releases/tag/v1.40.0) for complete details.

### Fixed

- Ignore informational response status codes (`100-199`) except `101 Switching Protocols` when storing the HTTP status code in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` and `go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux`. (#6913)
- Make `Body` handling in `Transport` consistent with stdlib in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp`. (#8618)
- Fix bucket boundaries for `rpc.server.call.duration` and `rpc.client.call.duration` in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc`. (#8642)
- Host resource detector in `go.opentelemetry.io/contrib/otelconf` now includes `os.` attributes. (#8578)

### Removed

- Drop support for [Go 1.24]. (#8628)

[Go 1.24]: https://go.dev/doc/go1.24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support the environment variable propagation

6 participants