Commit Graph

20 Commits

Author SHA1 Message Date
Andrew Wilkins 4c24b49532
[chore] service/telemetry: improve test coverage (#13558)
#### Description

Improve coverage of config validation, TracerProvider creation, and
trace context propagator configuration.
Simplify some other tests.

#### Link to tracking issue

N/A

#### Testing

N/A

#### Documentation

N/A
2025-08-07 15:33:00 +00:00
Andrew Wilkins 777be10a9e
[service] Deprecate telemetry.disableHighCardinalityMetrics (#13538)
#### Description

Deprecate the feature gate now that metric views can be configured.

#### Link to tracking issue

Fixes #13537

#### Testing

Verified that the flag is deprecated with `otelcorecol featuregate` and
`otelcorecol --feature-gates telemetry.disableHighCardinalityMetrics`
(the latter leads to an error, as expected for deprecated feature
gates.)

#### Documentation

Added changelog

---------

Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com>
Co-authored-by: Jade Guiton <jade.guiton@datadoghq.com>
2025-08-05 12:54:58 +00:00
Andrew Wilkins f1aa3dba91
[chore] service: move SDK creation to service/telemetry (#13536)
#### Description

Move SDK construction into service/telemetry. This is a step towards
fully encapsulating the otelconf SDK in the service/telemetry package,
so we can have different telemetry provider implementations that can be
injected.

#### Link to tracking issue

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

#### Testing

N/A, non-functional change.

#### Documentation

N/A
2025-08-04 16:07:24 +00:00
Matthieu MOREL 84e29958f1
[chore]: enable-all rules from go-critic (#13433)
#### Description

Enables all rules from
[go-critic](https://golangci-lint.run/usage/linters/#gocritic) by
default and disable the one that needs to be fixed

* https://go-critic.com/overview.html#appendcombine
* https://go-critic.com/overview.html#emptystringtest
* https://go-critic.com/overview.html#evalorder
* https://go-critic.com/overview.html#httpnobody
* https://go-critic.com/overview.html#nestingreduce
* https://go-critic.com/overview.html#regexpsimplify
* https://go-critic.com/overview.html#sloppyreassign
* https://go-critic.com/overview.html#sprintfquotedstring
* https://go-critic.com/overview.html#typeassertchain
* https://go-critic.com/overview.html#typeunparen

---------

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-07-24 10:34:03 +00:00
Yang Song 59b5328782
Downgrade otel-go (#13429) (#13466)
cherry-pick of
d82267dd69

`go.opentelemetry.io/otel/exporters/prometheus v0.59.1` does not fully
fix the metric name issue so we have to revert to v0.58.0

Downgrades opentelemetry-go dependencies effectively reverting #13289
and others

- Due to a
[bug](https://github.com/open-telemetry/opentelemetry-go/issues/7039) in
the prometheus exporter, if you are configuring a prometheus exporter,
the collector's internal metrics will be emitted with an unexpected
suffix in its name. For example, the metric
`otelcol_exporter_sent_spans__spans__total` instead of
`otelcol_exporter_sent_spans_total`. The workaround is to manually
configure `without_units: true` in your prometheus exporter config

 ```yaml
  service:
    telemetry:
      metrics:
        readers:
          - pull: 
              exporter: 
                prometheus: 
                  host: 0.0.0.0 
                  port: 8888 
                  without_units: true 
 ``` 
     
If you are using the collector's default Prometheus exporter for
exporting internal metrics you are unaffected.

Signed-off-by: alex boten <223565+codeboten@users.noreply.github.com>
Co-authored-by: Pablo Baeyens <pablo.baeyens@datadoghq.com>
Co-authored-by: alex boten <223565+codeboten@users.noreply.github.com>
2025-07-23 16:16:50 +00:00
Jade Guiton f847043147
[service] Enable scope information in default Prometheus exporter (#13344)
#### Description

This changes the config for the default Prometheus exporter to remove
`disable_scope_info: true`. This prevent errors in the exporter caused
by metrics only differentiated by their scope being considered aliasing,
which will become more common when the `telemetry.newPipelineTelemetry`
feature gate graduates (see tracking issue for details).

I marked this as a "breaking change", but I'm not sure if we make
guarantees about the format of the Prometheus metrics we emit?

#### Link to tracking issue

Fixes #12939

#### Testing

I updated some tests to reflect the additional labels added to
Prometheus metrics.

I performed manual testing and confirmed that the reproduction case in
the tracking issue no longer emits an error when the feature gate is
enabled.
2025-07-08 12:05:51 +00:00
Alex Boten 4ca0f1829e
update semconv dependency to otelgo's semconv package (#12991)
This updates the calls to the collector's internal semconv package with
otelgo's instead. The main difference is how the keys can be used, they
will need to be cast as strings where they key name is needed, otherwise
it's not a huge change. This would allow us to stop producing our own
semconv package once contrib is moved as well.

Related to
https://github.com/open-telemetry/opentelemetry-collector/issues/10346,
https://github.com/open-telemetry/opentelemetry-collector/issues/11828,
https://github.com/open-telemetry/opentelemetry-collector/issues/11807

---------

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2025-05-09 19:04:08 +00:00
Jade Guiton 8a79193d28
[service] Add `service::telemetry::metrics::views` config key (#12433)
#### Description

This PR adds a `service::telemetry::metrics::views` config key, which
explicitly sets the list of metric views used for internal telemetry,
mirroring `meter_provider::views` in the SDK config. This can be used to
disable specific internal metrics, among other uses.

This key will cause an error if used alongside other features which
would normally implicitly create views, such as:
- not setting `service::telemetry::metrics::level` to `detailed`;
- enabling the `telemetry.disableHighCardinalityMetrics` feature gate.

#### Further discussion needed

- A comment notes that the `telemetry.disableHighCardinalityMetrics`
alpha gate *"will be removed when the collector allows for view
configuration"*. I think setting the gate as deprecated first would be
the correct thing to do, but it means that users relying on it will see
their Collectors crash on update. Is that okay?

- In the context of being able to enable/disable specific metrics, this
key is only useful to disable metrics from an "all enabled" baseline. It
cannot easily be used to customize the set of metrics emitted at `level:
normal`, `level: basic`. Discussion is ongoing in #10769 on how to
handle that, but the solution will probably involve a new key, which
should hopefully be backward-compatible with the user-visible changes in
this PR.

#### Link to tracking issue
Updates #10769

#### Testing
None yet

#### Documentation
None yet, except the changelog

---------

Co-authored-by: Pablo Baeyens <pablo.baeyens@datadoghq.com>
2025-03-28 11:10:11 +00:00
Matthew Sainsbury ab63cdff96
[chore] bump otel-go deps (#12575)
#### Description
Upgrading the collector to use opentelemetry-go-contrib
v1.35.0/v0.60.0/v0.29.0/v0.15.0/v0.10.0/v0.8.0/v0.7.0

See changelog here:
https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v1.35.0

<!-- Issue number if applicable -->
#### Link to tracking issue
none available

<!--Describe what testing was performed and which tests were added.-->
#### Testing
I ran `make all` but happy to run other targets if needed
2025-03-06 20:20:20 +00:00
Alex Boten 4edaacddf9
update config dependency (#11611)
This PR does a couple of things that I couldn't quite split up so I put
together a PR w/ individual commits to help reviewers get through it.
This PR does the following:

1. update `go.opentelemetry.io/contrib/config` package to latest. this
brings in breaking changes. in order to prevent those breaking changes
from impacting end users, i've also added a layer of config unmarshaling
2. updates the collector to instantiate the meter provider (and
exporters) via the config package. this allows us to remove all the code
in `otelinit`. the reason for including this change was that
unmarshaling the config was causing circular dependencies i didn't want
to address by moving code that could be deleted around.


Replacement for
https://github.com/open-telemetry/opentelemetry-collector/pull/11458.

Fixes
https://github.com/open-telemetry/opentelemetry-collector/issues/12021

---------

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2025-01-24 17:47:00 +00:00
Pablo Baeyens 70f9fe94fe
[chore][service] Drop component metrics depending on level (#12143)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

<!-- Issue number if applicable -->

Drops metrics that depend on the metrics level:
- Batch processor metric
- otelarrow metrics (see open-telemetry/otel-arrow/issues/280 for
limitation).
- internal/otelarrow/netstats metrics. I did not implement
a25f058256/internal/otelarrow/netstats/netstats.go (L133-L136)
since `LevelNone` drops all metrics.

This attemps to unblock #11601 by hardcoding the metrics here since
there is a small number of them. Once we do #11754 we can move this back
to the individual components

#### Link to tracking issue

Updates #11061
2025-01-22 09:51:27 +00:00
John L. Peterson (Jack) 75a77b7369
[chore] add retry logic to flaky http test (#11655)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
attempts to fix flaky `service/telemetry/metrics` test

<!-- Issue number if applicable -->
#### Link to tracking issue
Fixes #11654 

<!--Describe what testing was performed and which tests were added.-->
#### Testing
update to test helper function

<!--Describe the documentation added.-->
#### Documentation
n/a
<!--Please delete paragraphs that you did not use before submitting.-->
2024-11-13 12:19:24 -08:00
Matthieu MOREL 0204d957e5
[chore]: enable whitespace linter (#11579)
#### Description

[whitespace](https://golangci-lint.run/usage/linters/#whitespace) is a
linter that checks for unnecessary newlines at the start and end of
functions.

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-31 12:15:54 -07:00
Alex Boten 1a5cb6450f
[chore] clean up duplicated test (#11530)
This test wasn't testing any new behaviour since similar config was used
in both test cases. Removed the duplicate and updated
`getMetricsFromPrometheus` to not require a handler anymore. This will
be useful when updating the code with the new upstream config package.

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2024-10-23 14:12:20 -07:00
Alex Boten 4dbbb90c46
[chore] gprc -> grpc typos (#11473)
Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2024-10-16 14:29:50 -07:00
Bogdan Drutu 6a8c88d68f
[chore] Improve otel metrics performance, pre-calculate attribute Set (#11288)
Depends on
https://github.com/open-telemetry/opentelemetry-collector/pull/11293

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-10-04 11:04:25 -07:00
Bogdan Drutu 3eec76c4a3
Deprecate service::telemetry::metrics::address (#11205)
Existing configs like:

```yaml
service:
  telemetry:
    metrics:
      level: "basic"
      address: "localhost:8888"
```

Should change to:

```yaml
service:
  telemetry:
    metrics:
      level: "basic"
      readers:
        - pull:
            exporter:
              prometheus:
                host: "localhost"
                port: 8888
```

---------

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2024-09-25 13:34:53 -07:00
Alex Boten fbffbb0820
[chore] small test improvements (#11211)
Clean up some inconsistencies in the test code across the components.

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2024-09-18 13:47:25 -07:00
Matthieu MOREL 012cf86228
[chore]: enable float-compare rule from testifylint (#11149)
#### Description

Testifylint is a linter that provides best practices with the use of
testify.

This PR enables
[float-compare](https://github.com/Antonboom/testifylint?tab=readme-ov-file#float-compare)
rule from [testifylint](https://github.com/Antonboom/testifylint)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-09-18 11:34:34 +02:00
Bogdan Drutu 6cbe5d6424
[chore] Move metrics initialization in service/telemetry (#11185)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-09-17 14:00:06 -07:00