Skip to content

propagation: extract of multiple header values #5973

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

Merged

Conversation

jamesmoessis
Copy link
Contributor

@jamesmoessis jamesmoessis commented Nov 14, 2024

  • Add ValuesGetter interface, an optional TextMapCarrier feature that adds Values(string) []string.
  • HeaderCarrier implements ValuesGetter.
  • Change Baggage to use the Values() method if it's implemented.

Notable comment: #5973 (comment)

Adds tests extracting requests with multiple 'baggage' headers set.
Does not introduce any breaking changes or alter any existing tests.

Spec issue: open-telemetry/opentelemetry-specification#433
Corresponding Java prototype: open-telemetry/opentelemetry-java#6852

@jamesmoessis jamesmoessis changed the title Prototypes proposed spec changes to allow multiple header values Prototypes proposed spec changes to allow extraction of multiple header values Nov 14, 2024
Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.0%. Comparing base (0385f83) to head (1307ad4).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@     Coverage Diff      @@
##   main   #5973   +/-   ##
============================
============================
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
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.

I think your prototype is good. For an actual PR we would need to improve the docs and call out the MultiTextMapCarrier in more places.

PS. Not feeling well today so treat my review with low confidence (like an pre-approval). I will do my best to look at it again once I recover and have a clearer mind.

@pellared
Copy link
Member

@open-telemetry/go-maintainers, PTAL at this prototype

jack-berg added a commit to open-telemetry/opentelemetry-specification that referenced this pull request Nov 28, 2024
…ey (#4295)

Fixes #433

Discussed in 11/5/24 Spec SIG, and prototyped in Java and Go.

## Changes

Adds `GetAll` method to Getter, allowing for the retrieval of multiple
keys for the same value. For example, an HTTP request may have multiple
`baggage` headers.

As written in the changes, the implementation of `GetAll` is strictly
optional. This is for two reasons:
1. Backwards compatibility with existing types/interfaces
2. Carriers do not necessarily support returning multiple values for a
single key

## Links to Prototypes

This includes implementations of `GetAll()` in Java and Go, as well as
using the method in the W3C Baggage Propagators (multiple baggage
headers are allowed, [spec
reference](https://www.w3.org/TR/baggage/#baggage-http-header-format)).

- Java: open-telemetry/opentelemetry-java#6852
- Go: open-telemetry/opentelemetry-go#5973

* [x] Links to the prototypes (when adding or changing features)
* [x]
[`CHANGELOG.md`](https://github.com/open-telemetry/opentelemetry-specification/blob/main/CHANGELOG.md)
file updated for non-trivial changes

---------

Co-authored-by: Trask Stalnaker <[email protected]>
Co-authored-by: jack-berg <[email protected]>
Co-authored-by: Robert Pająk <[email protected]>
@jamesmoessis jamesmoessis force-pushed the multi-baggage-propagation-prototype branch from 530b431 to 9e4e348 Compare April 28, 2025 05:15
@jamesmoessis jamesmoessis marked this pull request as ready for review April 28, 2025 05:15
@jamesmoessis jamesmoessis changed the title Prototypes proposed spec changes to allow extraction of multiple header values Implement spec changes to allow extraction of multiple header values Apr 28, 2025
@jamesmoessis
Copy link
Contributor Author

hello @pellared @MrAlias I have addressed all outstanding issues and marked this as ready for review. Please take a look when you can!

@jamesmoessis jamesmoessis force-pushed the multi-baggage-propagation-prototype branch from be8a45a to 9de8b16 Compare April 28, 2025 05:36
Copy link
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.

👍

@jamesmoessis
Copy link
Contributor Author

Seems there's a build failure relating to links checking, don't think it's got anything to do with this PR

@jamesmoessis
Copy link
Contributor Author

@MrAlias @pellared - all conversations are resolved, should be ready

@pellared pellared changed the title Implement spec changes to allow extraction of multiple header values propagation: extract of multiple header values May 8, 2025
Copy link
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.

Nice 👍

Mostly nit comments.

My biggest concern is the lack of unit test covering extractSingleBaggage.

jamesmoessis and others added 4 commits May 9, 2025 09:36
Co-authored-by: Robert Pająk <[email protected]>
Co-authored-by: Robert Pająk <[email protected]>
…rier does not implement ValuesGetter so increases test coverage on single-valued path
@jamesmoessis
Copy link
Contributor Author

Thankyou again @pellared 👍 everything is addressed

@pellared pellared requested review from MrAlias and dmathieu May 9, 2025 07:56
@pellared
Copy link
Member

pellared commented May 9, 2025

@open-telemetry/go-approvers, PTAL

@MrAlias
Copy link
Contributor

MrAlias commented May 13, 2025

@XSAM @dmathieu PTAL.

@dmathieu
Copy link
Member

Could you fix the CI?

@jamesmoessis
Copy link
Contributor Author

jamesmoessis commented May 15, 2025

Thanks @dmathieu I've fixed the linting issue. Last failure seems to be 429 from the link checking - unrelated to this pr

@dmathieu dmathieu merged commit f410084 into open-telemetry:main May 15, 2025
30 checks passed
@pellared
Copy link
Member

pellared commented May 15, 2025

@jamesmoessis, thanks a lot for your contribution 🏅

@jamesmoessis jamesmoessis deleted the multi-baggage-propagation-prototype branch May 15, 2025 23:38
dmathieu added a commit that referenced this pull request May 21, 2025
# Overview

Closes #6786

### Added

- Add exponential histogram support in
`go.opentelemetry.io/otel/exporters/prometheus`. (#6421)
- The `go.opentelemetry.io/otel/semconv/v1.31.0` package.
The package contains semantic conventions from the `v1.31.0` version of
the OpenTelemetry Semantic Conventions.
See the [migration documentation](./semconv/v1.31.0/MIGRATION.md) for
information on how to upgrade from
`go.opentelemetry.io/otel/semconv/v1.30.0`. (#6479)
- Add `Recording`, `Scope`, and `Record` types in
`go.opentelemetry.io/otel/log/logtest`. (#6507)
- Add `WithHTTPClient` option to configure the `http.Client` used by
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`.
(#6751)
- Add `WithHTTPClient` option to configure the `http.Client` used by
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`.
(#6752)
- Add `WithHTTPClient` option to configure the `http.Client` used by
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#6688)
- Add `ValuesGetter` in `go.opentelemetry.io/otel/propagation`, a
`TextMapCarrier` that supports retrieving multiple values for a single
key. (#5973)
- Add `Values` method to `HeaderCarrier` to implement the new
`ValuesGetter` interface in `go.opentelemetry.io/otel/propagation`.
(#5973)
- Update `Baggage` in `go.opentelemetry.io/otel/propagation` to retrieve
multiple values for a key when the carrier implements `ValuesGetter`.
(#5973)
- Add `AssertEqual` function in `go.opentelemetry.io/otel/log/logtest`.
(#6662)
- The `go.opentelemetry.io/otel/semconv/v1.32.0` package.
The package contains semantic conventions from the `v1.32.0` version of
the OpenTelemetry Semantic Conventions.
See the [migration documentation](./semconv/v1.32.0/MIGRATION.md) for
information on how to upgrade from
`go.opentelemetry.io/otel/semconv/v1.31.0`(#6782)
- Add `Transform` option in `go.opentelemetry.io/otel/log/logtest`.
(#6794)
- Add `Desc` option in `go.opentelemetry.io/otel/log/logtest`. (#6796)

### Removed

- Drop support for [Go 1.22]. (#6381, #6418)
- Remove `Resource` field from `EnabledParameters` in
`go.opentelemetry.io/otel/sdk/log`. (#6494)
- Remove `RecordFactory` type from
`go.opentelemetry.io/otel/log/logtest`. (#6492)
- Remove `ScopeRecords`, `EmittedRecord`, and `RecordFactory` types from
`go.opentelemetry.io/otel/log/logtest`. (#6507)
- Remove `AssertRecordEqual` function in
`go.opentelemetry.io/otel/log/logtest`, use `AssertEqual` instead.
(#6662)

### Changed

- ⚠️ Update `github.com/prometheus/client_golang` to `v1.21.1`, which
changes the `NameValidationScheme` to `UTF8Validation`.
This allows metrics names to keep original delimiters (e.g. `.`), rather
than replacing with underscores.
This can be reverted by setting
`github.com/prometheus/common/model.NameValidationScheme` to
`LegacyValidation` in `github.com/prometheus/common/model`. (#6433)
- Initialize map with `len(keys)` in `NewAllowKeysFilter` and
`NewDenyKeysFilter` to avoid unnecessary allocations in
`go.opentelemetry.io/otel/attribute`. (#6455)
- `go.opentelemetry.io/otel/log/logtest` is now a separate Go module.
(#6465)
- `go.opentelemetry.io/otel/sdk/log/logtest` is now a separate Go
module. (#6466)
- `Recorder` in `go.opentelemetry.io/otel/log/logtest` no longer
separately stores records emitted by loggers with the same
instrumentation scope. (#6507)
- Improve performance of `BatchProcessor` in
`go.opentelemetry.io/otel/sdk/log` by not exporting when exporter cannot
accept more. (#6569, #6641)

### Deprecated

- Deprecate support for `model.LegacyValidation` for
`go.opentelemetry.io/otel/exporters/prometheus`. (#6449)

### Fixes

- Stop percent encoding header environment variables in
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc` and
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#6392)
- Ensure the `noopSpan.tracerProvider` method is not inlined in
`go.opentelemetry.io/otel/trace` so the `go.opentelemetry.io/auto`
instrumentation can instrument non-recording spans. (#6456)
- Use a `sync.Pool` instead of allocating `metricdata.ResourceMetrics`
in `go.opentelemetry.io/otel/exporters/prometheus`. (#6472)

---------

Co-authored-by: Tyler Yahn <[email protected]>
Co-authored-by: Robert Pająk <[email protected]>
@pellared pellared added this to the v1.36.0 milestone May 21, 2025
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.

5 participants