Skip to content

Conversation

dmitryax
Copy link
Member

@dmitryax dmitryax commented Jun 17, 2025

Preserve client metadata key values in persistent queue.

It allows request client metadata to propagate through the persistent queue used by the exporters. The same way as it's done for the in-memory queue. Currently, it is behind the exporter.PersistRequestContext feature gate, which can be enabled by adding --feature-gates=exporter.PersistRequestContext to the collector command line. An exporter buffer stored by a previous version of the collector (or by a collector with the feature gate disabled) can be read by a newer collector with the feature enabled. However, the reverse is not supported: a buffer stored by a newer collector with the feature enabled cannot be read by an older collector (or by a collector with the feature gate disabled).

Resolves #10110, #11780 and open-telemetry/opentelemetry-collector-contrib#38666

Follow-up work:

To fully propagate the client context, we also add support for serializing remaining client.Client fields:

	Addr net.Addr
	Auth AuthData

Then, we probably want to make this configurable or rely on the transform processor to be able to manipulate the context

@dmitryax dmitryax force-pushed the persist-context-client-metadata branch from a863ea5 to 48aada5 Compare June 17, 2025 05:27
@dmitryax dmitryax added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Jun 17, 2025
Copy link

codecov bot commented Jun 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.52%. Comparing base (8d71881) to head (8c641d3).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13220      +/-   ##
==========================================
+ Coverage   91.51%   91.52%   +0.01%     
==========================================
  Files         522      522              
  Lines       28988    29028      +40     
==========================================
+ Hits        26529    26569      +40     
  Misses       1939     1939              
  Partials      520      520              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dmitryax dmitryax force-pushed the persist-context-client-metadata branch 2 times, most recently from 29e9879 to b353546 Compare June 17, 2025 16:44
github-merge-queue bot pushed a commit that referenced this pull request Jun 18, 2025
…#13230)

Resolves
#13220 (comment)

Benchmarks:
```
goos: darwin
goarch: arm64
pkg: go.opentelemetry.io/collector/pdata/xpdata/request
cpu: Apple M1 Max

before:
BenchmarkEncodeDecodeContext-10    	  528876	      2331 ns/op	    1200 B/op	      28 allocs/op

after:
BenchmarkEncodeDecodeContext-10    	  559353	      1832 ns/op	     864 B/op	      16 allocs/op
```
@dmitryax dmitryax reopened this Jun 18, 2025
@github-actions github-actions bot requested a review from bogdandrutu June 18, 2025 17:56
@dmitryax dmitryax enabled auto-merge June 18, 2025 17:57
@dmitryax dmitryax added this pull request to the merge queue Jun 18, 2025
Merged via the queue into open-telemetry:main with commit 8cc2954 Jun 18, 2025
56 checks passed
@dmitryax dmitryax deleted the persist-context-client-metadata branch June 18, 2025 18:40
github-merge-queue bot pushed a commit that referenced this pull request Jun 19, 2025
Preserve client address in persistent queue as part of the request
context

A follow-up to
#13220
TimoBehrendt pushed a commit to TimoBehrendt/tracebasedlogsampler that referenced this pull request Aug 13, 2025
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [go.opentelemetry.io/collector/component](https://github.com/open-telemetry/opentelemetry-collector) | require | minor | `v1.31.0` -> `v1.35.0` |
| [go.opentelemetry.io/collector/component/componenttest](https://github.com/open-telemetry/opentelemetry-collector) | require | minor | `v0.125.0` -> `v0.129.0` |
| [go.opentelemetry.io/collector/confmap](https://github.com/open-telemetry/opentelemetry-collector) | require | minor | `v1.31.0` -> `v1.35.0` |
| [go.opentelemetry.io/collector/consumer](https://github.com/open-telemetry/opentelemetry-collector) | require | minor | `v1.31.0` -> `v1.35.0` |
| [go.opentelemetry.io/collector/consumer/consumertest](https://github.com/open-telemetry/opentelemetry-collector) | require | minor | `v0.125.0` -> `v0.129.0` |
| [go.opentelemetry.io/collector/pdata](https://github.com/open-telemetry/opentelemetry-collector) | require | minor | `v1.31.0` -> `v1.35.0` |
| [go.opentelemetry.io/collector/processor](https://github.com/open-telemetry/opentelemetry-collector) | require | minor | `v1.31.0` -> `v1.35.0` |
| [go.opentelemetry.io/collector/processor/processortest](https://github.com/open-telemetry/opentelemetry-collector) | require | minor | `v0.125.0` -> `v0.129.0` |

---

### Release Notes

<details>
<summary>open-telemetry/opentelemetry-collector (go.opentelemetry.io/collector/component)</summary>

### [`v1.35.0`](https://github.com/open-telemetry/opentelemetry-collector/blob/HEAD/CHANGELOG.md#v1350v01290)

##### 🛑 Breaking changes 🛑

-   `exporterhelper`: Remove deprecated sending_queue::blocking options, use sending_queue::block_on_overflow. ([#&#8203;13211](open-telemetry/opentelemetry-collector#13211))

##### 💡 Enhancements 💡

-   `mdatagen`: Taught mdatagen to print the `go list` stderr output on failures, and to run `go list` where the metadata file is. ([#&#8203;13205](open-telemetry/opentelemetry-collector#13205))

-   `service`: Support setting `sampler` and `limits` under `service::telemetry::traces` ([#&#8203;13201](open-telemetry/opentelemetry-collector#13201))
    This allows users to enable sampling and set span limits on internal Collector traces using the
    OpenTelemetry SDK declarative configuration.

-   `pdata/pprofile`: Add new helper methods `FromLocationIndices` and `PutLocation` to read and modify the content of locations. ([#&#8203;13150](open-telemetry/opentelemetry-collector#13150))

-   `exporterhelper`: Preserve request span context and client information in the persistent queue. ([#&#8203;11740](open-telemetry/opentelemetry-collector#11740), [#&#8203;13220](open-telemetry/opentelemetry-collector#13220), [#&#8203;13232](open-telemetry/opentelemetry-collector#13232))
    It allows internal collector spans and client information to propagate through the persistent queue used by
    the exporters. The same way as it's done for the in-memory queue.
    Currently, it is behind the exporter.PersistRequestContext feature gate, which can be enabled by adding
    `--feature-gates=exporter.PersistRequestContext` to the collector command line. An exporter buffer stored by
    a previous version of the collector (or by a collector with the feature gate disabled) can be read by a newer
    collector with the feature enabled. However, the reverse is not supported: a buffer stored by a newer collector with
    the feature enabled cannot be read by an older collector (or by a collector with the feature gate disabled).

##### 🧰 Bug fixes 🧰

-   `pdata`: Fix copying of optional fields when the source is unset. ([#&#8203;13268](open-telemetry/opentelemetry-collector#13268))
-   `service`: Only allocate one set of internal log sampling counters ([#&#8203;13014](open-telemetry/opentelemetry-collector#13014))
    The case where logs are only exported to stdout was fixed in v0.126.0;
    this new fix also covers the case where logs are exported through OTLP.

<!-- previous-version -->

### [`v1.34.0`](https://github.com/open-telemetry/opentelemetry-collector/blob/HEAD/CHANGELOG.md#v1340v01280)

##### 🛑 Breaking changes 🛑

-   `service/telemetry`: Mark "telemetry.disableAddressFieldForInternalTelemetry" as stable ([#&#8203;13152](open-telemetry/opentelemetry-collector#13152))

##### 💡 Enhancements 💡

-   `confighttp`: Update the HTTP server span naming to use the HTTP method and route pattern instead of the path. ([#&#8203;12468](open-telemetry/opentelemetry-collector#12468))
    The HTTP server span name will now be formatted as `<http.request.method> <http.route>`.
    If a route pattern is not available, it will fall back to `<http.request.method>`.

-   `service`: Use configured loggers to log errors as soon as it is available ([#&#8203;13081](open-telemetry/opentelemetry-collector#13081))

-   `service`: Remove stabilized featuregate useOtelWithSDKConfigurationForInternalTelemetry ([#&#8203;13152](open-telemetry/opentelemetry-collector#13152))

##### 🧰 Bug fixes 🧰

-   `telemetry`: Add generated resource attributes to the printed log messages. ([#&#8203;13110](open-telemetry/opentelemetry-collector#13110))
    If service.name, service.version, or service.instance.id are not specified in the config, they will be generated automatically.
    This change ensures that these attributes are also included in the printed log messages.

-   `mdatagen`: Fix generation when there are no events in the metadata. ([#&#8203;13123](open-telemetry/opentelemetry-collector#13123))

-   `confmap`: Do not panic on assigning nil maps to non-nil maps ([#&#8203;13117](open-telemetry/opentelemetry-collector#13117))

-   `pdata`: Fix event_name skipped when unmarshalling LogRecord from JSON ([#&#8203;13127](open-telemetry/opentelemetry-collector#13127))

<!-- previous-version -->

### [`v1.33.0`](https://github.com/open-telemetry/opentelemetry-collector/blob/HEAD/CHANGELOG.md#v1330v01270)

##### 🚩 Deprecations 🚩

-   `semconv`: Deprecating the semconv package in favour of go.opentelemetry.io/otel/semconv ([#&#8203;13012](open-telemetry/opentelemetry-collector#13012))

##### 💡 Enhancements 💡

-   `exporter/debug`: Display resource and scope in `normal` verbosity ([#&#8203;10515](open-telemetry/opentelemetry-collector#10515))
-   `service`: Add size metrics defined in Pipeline Component Telemetry RFC ([#&#8203;13032](open-telemetry/opentelemetry-collector#13032))
    See [Pipeline Component Telemetry RFC](https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/rfcs/component-universal-telemetry.md) for more details:
    -   `otelcol.receiver.produced.size`
    -   `otelcol.processor.consumed.size`
    -   `otelcol.processor.produced.size`
    -   `otelcol.connector.consumed.size`
    -   `otelcol.connector.produced.size`
    -   `otelcol.exporter.consumed.size`

<!-- previous-version -->

### [`v1.32.0`](https://github.com/open-telemetry/opentelemetry-collector/blob/HEAD/CHANGELOG.md#v1320v01260)

##### 🛑 Breaking changes 🛑

-   `configauth`: Removes deprecated `configauth.Authentication` and `extensionauthtest.NewErrorClient` ([#&#8203;12992](open-telemetry/opentelemetry-collector#12992))
    The following have been removed:
    -   `configauth.Authentication` use `configauth.Config` instead
    -   `extensionauthtest.NewErrorClient` use `extensionauthtest.NewErr` instead

##### 💡 Enhancements 💡

-   `service`: Replace `go.opentelemetry.io/collector/semconv` usage with `go.opentelemetry.io/otel/semconv` ([#&#8203;12991](open-telemetry/opentelemetry-collector#12991))
-   `confmap`: Update the behavior of the confmap.enableMergeAppendOption feature gate to merge only component lists. ([#&#8203;12926](open-telemetry/opentelemetry-collector#12926))
-   `service`: Add item count metrics defined in Pipeline Component Telemetry RFC ([#&#8203;12812](open-telemetry/opentelemetry-collector#12812))
    See [Pipeline Component Telemetry RFC](https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/rfcs/component-universal-telemetry.md) for more details:
    -   `otelcol.receiver.produced.items`
    -   `otelcol.processor.consumed.items`
    -   `otelcol.processor.produced.items`
    -   `otelcol.connector.consumed.items`
    -   `otelcol.connector.produced.items`
    -   `otelcol.exporter.consumed.items`
-   `tls`: Add trusted platform module (TPM) support to TLS authentication. ([#&#8203;12801](open-telemetry/opentelemetry-collector#12801))
    Now the TLS allows the use of TPM for loading private keys (e.g. in TSS2 format).

##### 🧰 Bug fixes 🧰

-   `exporterhelper`: Add validation error for batch config if min_size is greater than queue_size. ([#&#8203;12948](open-telemetry/opentelemetry-collector#12948))

-   `telemetry`: Allocate less memory per component when OTLP exporting of logs is disabled ([#&#8203;13014](open-telemetry/opentelemetry-collector#13014))

-   `confmap`: Use reflect.DeepEqual to avoid panic when confmap.enableMergeAppendOption feature gate is enabled. ([#&#8203;12932](open-telemetry/opentelemetry-collector#12932))

-   `internal telemetry`: Add resource attributes from telemetry.resource to the logger ([#&#8203;12582](open-telemetry/opentelemetry-collector#12582))
    Resource attributes from telemetry.resource were not added to the internal
    console logs.

    Now, they are added to the logger as part of the "resource" field.

-   `confighttp and configcompression`: Fix handling of `snappy` content-encoding in a backwards-compatible way ([#&#8203;10584](open-telemetry/opentelemetry-collector#10584), [#&#8203;12825](open-telemetry/opentelemetry-collector#12825))
    The collector used the Snappy compression type of "framed" to handle the HTTP
    content-encoding "snappy".  However, this encoding is typically used to indicate
    the "block" compression variant of "snappy".  This change allows the collector to:
    -   When receiving a request with encoding 'snappy', the server endpoints will peek
        at the first bytes of the payload to determine if it is "framed" or "block" snappy,
        and will decompress accordingly.  This is a backwards-compatible change.
    If the feature-gate "confighttp.framedSnappy" is enabled, you'll see new behavior for both client and server:
    -   Client compression type "snappy" will now compress to the "block" variant of snappy
        instead of "framed". Client compression type "x-snappy-framed" will now compress to the "framed" variant of snappy.
    -   Servers will accept both "snappy" and "x-snappy-framed" as valid content-encodings.

-   `tlsconfig`: Disable TPM tests on MacOS/Darwin ([#&#8203;12964](open-telemetry/opentelemetry-collector#12964))

<!-- previous-version -->

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yNjMuMSIsInVwZGF0ZWRJblZlciI6IjM5LjI2My4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://gitea.t000-n.de/t.behrendt/tracebasedlogsampler/pulls/20
Reviewed-by: t.behrendt <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
Co-committed-by: Renovate Bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Skip Changelog PRs that do not require a CHANGELOG.md entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Persistent Queue breaks Headers Setter extension

3 participants