Commit Graph

6 Commits

Author SHA1 Message Date
Andrew Wilkins 5b18870ccc
[chore] service: refactor logger wrapping (#13329)
#### Description

There are two main changes here:
- We move the componentattribute logger core wrapping and Logger to
LoggerProvider tee'ing to the service package. This will enable the
wrapping to be performed independently of the implementation of
telemetry providers.
- We move away from using zapcore.NewTeeCore, and introduce a new
zapcore.Core implementation that only copies log entries accepted by the
native Zap core to the OTel LoggerProvider.

The second change is necessary due to the first: because the
LoggerProvider will in the future be injectable, and because the
telemetry configuration will be opaque to the service package, we must
always tee the logs from the zap logger to the LoggerProvider. When
using zapcore.NewTeeCore, the resulting core will duplicate all entries
to all cores - which is not what we want.

There's also some light refactoring of tests, and the service package
tests are now ~30s faster by replacing a sleep with assert.Eventually.

#### Link to tracking issue

Preparation work for
https://github.com/open-telemetry/opentelemetry-collector/issues/4970

#### Testing

Unit tests pass

#### Documentation

N/A

---------

Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2025-07-18 10:13:33 +00:00
Jade Guiton 4ddf2cc7c8
[service] Share log sampler core allocations with reflect magic (#13107)
#### Context

PR #12617, which implemented the injection of component-identifying
attributes into the `zap.Logger` provided to components, introduced
significant additional memory use when the Collector's pipelines contain
many components (#13014). This was because we would call
`zapcore.NewSamplerWithOptions` to wrap the specialized logger core of
each Collector component, which allocates half a megabyte's worth of
sampling counters.

This problem was mitigated in #13015 by moving the sampling layer to a
different location in the logger core hierarchy. This meant that
Collector users that do not export their logs through OTLP and only use
stdout-based logs no longer saw the memory increase.

#### Description

This PR aims to provide a better solution to this issue, by using the
`reflect` library to clone zap's sampler core and set a new inner core,
while reusing the counter allocation.

(This may also be "more correct" from a sampling point of view, ie. we
only have one global instance of the counters instead of one for console
logs and one for each component's OTLP-exported logs, but I'm not sure
if anyone noticed the difference anyway).

#### Link to tracking issue
Fixes #13014

#### Testing
A new test was added which checks that the log counters are shared
between two sampler cores with different attributes.
2025-06-11 10:06:08 +00:00
renovate[bot] 392b705719
Update opentelemetry-go monorepo (#13099)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[go.opentelemetry.io/otel](https://redirect.github.com/open-telemetry/opentelemetry-go)
| `v1.35.0` -> `v1.36.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/go.opentelemetry.io%2fotel/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/go.opentelemetry.io%2fotel/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/go.opentelemetry.io%2fotel/v1.35.0/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/go.opentelemetry.io%2fotel/v1.35.0/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
|
[go.opentelemetry.io/otel/log](https://redirect.github.com/open-telemetry/opentelemetry-go)
| `v0.11.0` -> `v0.12.2` |
[![age](https://developer.mend.io/api/mc/badges/age/go/go.opentelemetry.io%2fotel%2flog/v0.12.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/go.opentelemetry.io%2fotel%2flog/v0.12.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/go.opentelemetry.io%2fotel%2flog/v0.11.0/v0.12.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/go.opentelemetry.io%2fotel%2flog/v0.11.0/v0.12.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
|
[go.opentelemetry.io/otel/metric](https://redirect.github.com/open-telemetry/opentelemetry-go)
| `v1.35.0` -> `v1.36.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/go.opentelemetry.io%2fotel%2fmetric/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/go.opentelemetry.io%2fotel%2fmetric/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/go.opentelemetry.io%2fotel%2fmetric/v1.35.0/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/go.opentelemetry.io%2fotel%2fmetric/v1.35.0/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
|
[go.opentelemetry.io/otel/sdk](https://redirect.github.com/open-telemetry/opentelemetry-go)
| `v1.35.0` -> `v1.36.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/go.opentelemetry.io%2fotel%2fsdk/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/go.opentelemetry.io%2fotel%2fsdk/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/go.opentelemetry.io%2fotel%2fsdk/v1.35.0/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/go.opentelemetry.io%2fotel%2fsdk/v1.35.0/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
|
[go.opentelemetry.io/otel/sdk/metric](https://redirect.github.com/open-telemetry/opentelemetry-go)
| `v1.35.0` -> `v1.36.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/go.opentelemetry.io%2fotel%2fsdk%2fmetric/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/go.opentelemetry.io%2fotel%2fsdk%2fmetric/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/go.opentelemetry.io%2fotel%2fsdk%2fmetric/v1.35.0/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/go.opentelemetry.io%2fotel%2fsdk%2fmetric/v1.35.0/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
|
[go.opentelemetry.io/otel/trace](https://redirect.github.com/open-telemetry/opentelemetry-go)
| `v1.35.0` -> `v1.36.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/go.opentelemetry.io%2fotel%2ftrace/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/go.opentelemetry.io%2fotel%2ftrace/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/go.opentelemetry.io%2fotel%2ftrace/v1.35.0/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/go.opentelemetry.io%2fotel%2ftrace/v1.35.0/v1.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

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

###
[`v1.36.0`](https://redirect.github.com/open-telemetry/opentelemetry-go/releases/tag/v1.36.0):
/v0.58.0/v0.12.0

[Compare
Source](https://redirect.github.com/open-telemetry/opentelemetry-go/compare/v1.35.0...v1.36.0)

##### Added

- Add exponential histogram support in
`go.opentelemetry.io/otel/exporters/prometheus`.
([#&#8203;6421](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/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`.
([#&#8203;6479](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6479))
- Add `Recording`, `Scope`, and `Record` types in
`go.opentelemetry.io/otel/log/logtest`.
([#&#8203;6507](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6507))
- Add `WithHTTPClient` option to configure the `http.Client` used by
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`.
([#&#8203;6751](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6751))
- Add `WithHTTPClient` option to configure the `http.Client` used by
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`.
([#&#8203;6752](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6752))
- Add `WithHTTPClient` option to configure the `http.Client` used by
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`.
([#&#8203;6688](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6688))
- Add `ValuesGetter` in `go.opentelemetry.io/otel/propagation`, a
`TextMapCarrier` that supports retrieving multiple values for a single
key.
([#&#8203;5973](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/5973))
- Add `Values` method to `HeaderCarrier` to implement the new
`ValuesGetter` interface in `go.opentelemetry.io/otel/propagation`.
([#&#8203;5973](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/5973))
- Update `Baggage` in `go.opentelemetry.io/otel/propagation` to retrieve
multiple values for a key when the carrier implements `ValuesGetter`.
([#&#8203;5973](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/5973))
- Add `AssertEqual` function in `go.opentelemetry.io/otel/log/logtest`.
([#&#8203;6662](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/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`([#&#8203;6782](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6782))
- Add `Transform` option in `go.opentelemetry.io/otel/log/logtest`.
([#&#8203;6794](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6794))
- Add `Desc` option in `go.opentelemetry.io/otel/log/logtest`.
([#&#8203;6796](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6796))

##### Removed

- Drop support for \[Go 1.22].
([#&#8203;6381](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6381),
[#&#8203;6418](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6418))
- Remove `Resource` field from `EnabledParameters` in
`go.opentelemetry.io/otel/sdk/log`.
([#&#8203;6494](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6494))
- Remove `RecordFactory` type from
`go.opentelemetry.io/otel/log/logtest`.
([#&#8203;6492](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6492))
- Remove `ScopeRecords`, `EmittedRecord`, and `RecordFactory` types from
`go.opentelemetry.io/otel/log/logtest`.
([#&#8203;6507](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6507))
- Remove `AssertRecordEqual` function in
`go.opentelemetry.io/otel/log/logtest`, use `AssertEqual` instead.
([#&#8203;6662](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/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`.
([#&#8203;6433](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6433))
- Initialize map with `len(keys)` in `NewAllowKeysFilter` and
`NewDenyKeysFilter` to avoid unnecessary allocations in
`go.opentelemetry.io/otel/attribute`.
([#&#8203;6455](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6455))
- `go.opentelemetry.io/otel/log/logtest` is now a separate Go module.
([#&#8203;6465](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6465))
- `go.opentelemetry.io/otel/sdk/log/logtest` is now a separate Go
module.
([#&#8203;6466](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6466))
- `Recorder` in `go.opentelemetry.io/otel/log/logtest` no longer
separately stores records emitted by loggers with the same
instrumentation scope.
([#&#8203;6507](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6507))
- Improve performance of `BatchProcessor` in
`go.opentelemetry.io/otel/sdk/log` by not exporting when exporter cannot
accept more.
([#&#8203;6569](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6569),
[#&#8203;6641](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6641))

##### Deprecated

- Deprecate support for `model.LegacyValidation` for
`go.opentelemetry.io/otel/exporters/prometheus`.
([#&#8203;6449](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/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`.
([#&#8203;6392](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/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.
([#&#8203;6456](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6456))
- Use a `sync.Pool` instead of allocating `metricdata.ResourceMetrics`
in `go.opentelemetry.io/otel/exporters/prometheus`.
([#&#8203;6472](https://redirect.github.com/open-telemetry/opentelemetry-go/issues/6472))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "on tuesday" (UTC), 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://redirect.github.com/renovatebot/renovate/discussions) if
that's undesired.

---

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

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/open-telemetry/opentelemetry-collector).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC4xNi4wIiwidXBkYXRlZEluVmVyIjoiNDAuMTYuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIiwicmVub3ZhdGVib3QiXX0=-->

---------

Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: opentelemetrybot <107717825+opentelemetrybot@users.noreply.github.com>
Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-05-27 09:15:23 +00:00
Bogdan Drutu 8991b48796
Avoid allocating too much memory, sampling logic is not re-applied (#13015)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Avoid re-creating sampler counters every time we wrap with attributes.

<!-- Issue number if applicable -->
#### Link to tracking issue
Updates #13014 

<!--Describe what testing was performed and which tests were added.-->
#### Testing

<!--Describe the documentation added.-->
#### Documentation

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Co-authored-by: Jade Guiton <jade.guiton@datadoghq.com>
2025-05-12 16:31:17 +00:00
Jade Guiton 54c13a9217
Inject component-identifying scope attributes (#12617)
#### Description

Fork of #12384 to showcase how component attributes can be injected into
scope attributes instead of log/metric/span attributes. See that PR for
more context.

To see the diff from the previous PR, filter changes starting from the
"Prototype using scope attributes" commit.

#### Link to tracking issue
Resolves #12217 
Also incidentally resolves #12213 and resolves #12117

#### Testing
I updated the existing tests to check for scope attributes, and did some
manual testing with a debug exporter to check that the scope attributes
are added/removed properly.

---------

Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com>
2025-03-28 12:15:25 +00:00
Pablo Baeyens f87b93a8f9
[chore] Move LoggerWithout temporarily to internal package (#12334)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Moves `LoggerWithout` to an internal package so that we can keep on
experimenting on it while mark component 1.0 on v0.121.0.

This does not need a changelog since the change has not been released

<!-- Issue number if applicable -->
#### Link to tracking issue
Updates #12217
2025-02-12 10:35:58 +00:00