Commit Graph

41 Commits

Author SHA1 Message Date
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
Pablo Baeyens 3b7d066b2b
[configoptional] Add a confmap.Marshaler implementation (#13196)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Adds a `confmap.Marshaler` implementation for `configoptional.Optional`

---------

Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
2025-06-17 16:57:58 +00:00
Bogdan Drutu 249e5d55ad
[pipeline] Dreprecate MustNewID and MustNewIDWithName (#12835)
Updates
https://github.com/open-telemetry/opentelemetry-collector/issues/12831

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-05-26 14:11:50 +00:00
Pablo Baeyens bac08e21f5
[confmap] Correctly distinguish between empty and nil slices (#12872)
<!--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 -->

A second attempt at #11882.

Note that I added some tests in #12871 to prevent something like #12661
from happening again.

#### Link to tracking issue
Fixes #11749

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

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

See tests from #12871 as well as the new tests added here.
2025-04-21 09:07:57 +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
Evan Bradley 8afa426d18
[confmap] Fix handling for slices with default values (#12662)
#### Description

https://github.com/open-telemetry/opentelemetry-collector/pull/11882
introduced issues with handling slices which have default values. It's
likely that the removal of `zeroSliceHookFunc` is causing problems with
overriding default lists.
2025-03-18 13:01:52 -07:00
Evan Bradley b8830dd7c6
[confmap] Maintain nil slice values when marshaling and unmarshaling (#11882)
Expands on
https://github.com/open-telemetry/opentelemetry-collector/pull/11755 to
show how we could test for a 1:1 mapping between map[string]any <->
`confmap.Conf` <-> Config structs for `[]any(nil)` and `[]any{}` slices.
2025-03-11 14:51:43 +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
Evan Bradley 0faea294d6
[service] Add `omitempty` tag to config fields (#12501)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Update config structs in the service module to include `omitempty` tags.

<!-- Issue number if applicable -->
#### Link to tracking issue
Works toward
https://github.com/open-telemetry/opentelemetry-collector/issues/12191
2025-02-27 19:23:06 +00:00
Evan Bradley 0ac887e6b7
[xconfmap] Create module and add validation facilities (#12226)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Builds on
https://github.com/open-telemetry/opentelemetry-collector/pull/12224 and
starts the move of config validation from component to confmap. We can
keep this in `xconfmap` while we determine whether to add the ability to
validate using struct field tags.

I think this has the following advantages:
1. Everything configuration-related is now in confmap instead of split
between confmap and component.
2. We can share things like the mapstructure tag and config key
separator as constants between unmarshaling and validation without
creating dependencies between confmap and component.

~The one uncertainty this creates is what to do with `component.Config`,
which would now be used as a thin alias for `any` without any meaningful
usage in component.~

<!-- Issue number if applicable -->
#### Link to tracking issue
Fixes
https://github.com/open-telemetry/opentelemetry-collector/issues/11524
2025-02-04 22:25:59 +00:00
Evan Bradley 13470870db
[chore] Remove manual calls to `Validate` (#12224)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Follow-up to
https://github.com/open-telemetry/opentelemetry-collector/pull/12108.

This calls `component.ValidateConfig` on `otelcol.Config`, which causes
`Validate` to be recursively called on all eligible structs in the
config.

This has the following benefits:
1. `Validate` will now automatically be called instead of config structs
needing to call it on member structs.
2. Paths to the exact key that caused a validation error in the config
are now consistently printed.
3. If there are multiple errors in the config, they are now all returned
to the user instead of just the first error encountered.
2025-01-31 17:31:16 +00:00
Evan Bradley 50b76b95bf
[service] Return `telemetry.Config` validation errors (#12100)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Currently these are just printed, which hides validation issues with
`telemetry.Config`. If we don't want to return these errors, we should
document that and print them at a warning log level.
2025-01-30 22:47:51 +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
Matthieu MOREL 96e860b9cb
[chore]: enable gofumpt linter in receiver, scraper, semconv and service (#11856)
#### Description

[gofumpt](https://golangci-lint.run/usage/linters/#gofumpt) is a
stricter format than gofmt, while being backwards compatible.

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2024-12-12 17:59:26 +00:00
Bogdan Drutu c8005ec855
[chore] Pass the signal constant instead of the string (#11420)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-10-13 13:21:03 -07:00
Tyler Helmuth 8ced6eb6e1
[service] Remove deprecations and continue renames around DataType (#11303)
#### Description

Continues deprecation/rename processor for
`Config.PipelinesWithPipelineID`, `pipelines.ConfigWithPipelineID` and
`GetExportersWithSignal`.


#### Link to tracking issue
Related to
https://github.com/open-telemetry/opentelemetry-collector/issues/9429
2024-09-30 11:31:26 -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
Tyler Helmuth 77bb849aa0
[component] Refactor to use pipeline.ID and pipeline.Signal (#11204)
#### Description
Depends on
https://github.com/open-telemetry/opentelemetry-collector/pull/11209

This PR is a non-breaking implementation of
https://github.com/open-telemetry/opentelemetry-collector/pull/10947. It
adds a new module, `pipeline`, which houses a `pipeline.ID` and
`pipeline.Signal`. `pipeline.ID` is used to identify a pipeline within
the service. `pipeline.Signal` is uses to identify the signal associated
to a pipeline.

I do this work begrudgingly. As the PR shows, this is a huge refactor
when done in a non-breaking way, will require 3 full releases, and
doesn't benefit our [End Users or, in my opinion, our Component
Developers or Collector Library
Users](https://github.com/open-telemetry/opentelemetry-collector/blob/main/CONTRIBUTING.md#target-audiences).
I view this refactor as a Nice-To-Have, not a requirement for Component
1.0.

<!-- Issue number if applicable -->
#### Link to tracking issue
Works towards
https://github.com/open-telemetry/opentelemetry-collector/issues/9429
2024-09-23 07:38:59 -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
Pablo Baeyens 26c157e3bf
[component] Add MustNewType constructor for component.Type (#9414)
**Description:** 

- Adds `component.MustNewType` to create a type. This function panics if
the type has invalid characters. Add similar functions
`component.MustNewID` and `component.MustNewIDWithName`.
- Adds `component.Type.String` to recover the string
- Use `component.MustNewType`, `component.MustNewID`,
`component.MustNewIDWithName` and `component.Type.String` everywhere in
this codebase. To do this I changed `component.Type` into an opaque
struct and checked for compile-time errors.

Some notes:

1. All components currently on core and contrib follow this rule. This
is still breaking for other components.
2. A future PR will change this into a struct, to actually validate this
(right now you can just do `component.Type("anything")` to bypass
validation). I want to do this in two steps to avoid breaking contrib
tests: we first introduce this function, and after that we change into a
struct.

**Link to tracking Issue:** Updates #9208
2024-02-02 17:33:03 +01:00
Bogdan Drutu 9c7193555b
Add pipelines.Config to remove duplicate of the pipelines configuration (#7854)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2023-06-09 12:29:22 -07:00
Bogdan Drutu 2a7c92e6c2
[chore] use extensions.Config when refer to the serivce::extensions (#7853)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2023-06-07 16:57:09 -07:00
Alex Boten 80d704deb4
[chore] use license shortform (#7694)
* [chore] use license shortform

To remain consistent w/ contrib repo, see https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/22052

Signed-off-by: Alex Boten <aboten@lightstep.com>

* make goporto

Signed-off-by: Alex Boten <aboten@lightstep.com>

---------

Signed-off-by: Alex Boten <aboten@lightstep.com>
2023-05-18 13:11:17 -07:00
Bogdan Drutu a2f0153679
[chore] replace the usage of interface{} with any (#7053)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2023-01-30 15:01:25 -08:00
Bogdan Drutu cfa49fca08 Improve service Config types name (#6787)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-12-15 10:38:44 -08:00
Bogdan Drutu 7ee940d53d
Remove deprecated service.Config (#6774)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-12-13 09:54:45 -08:00
Bogdan Drutu 7cb2d7622d
Remove deprecated comonent.Config.[ID|SetIDName]; Deprecate config.*Settings (#6718)
* Remove deprecated comonent.Config.[ID|SetIDName]; Deprecate config.*Settings

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

* Update .chloggen/rmcfgid-1.yaml

Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com>
2022-12-12 14:35:45 -08:00
Bogdan Drutu fb0842a5a2
Improve config error messages, split Validate functionality (#6665)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-12-02 07:51:41 -08:00
Bogdan Drutu 1028e3d2a2
Deprecate special Configs for each component type, use a standard opaque Config (#6617)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-11-23 15:02:54 -08:00
Daniel Jaglowski c2055955c4
[pipelines] Change test to not reuse same processor twice in one pipeline (#6540)
* [pipelines] Change test to not reuse same processor twice in one pipeline

* Add note to documentation about reuse of processors within a pipeline

* can -> MUST
2022-11-17 07:59:58 -08:00
Bogdan Drutu 3899d3e73c
add validation for empty telemetry metric address when level not none (#5661) 2022-11-07 08:40:40 -08:00
Bogdan fbf1e2a09c Revert changes to config.[Receiver|Processor|Exporter|Extension]Settings
Signed-off-by: Bogdan <bogdandrutu@gmail.com>
2022-11-05 10:04:50 -07:00
Bogdan d6ed8246b6 Deprecate all types and funcs in config package
The main reason is to remove the circular dependency between the config (including sub-packages) and component. Here is the current state:
* component depends on config
* config/sub-package[grpc, http, etc.] depends on config & component

Because of this "circular" dependency, we cannot split for example "config" into its own module, only if all the other config sub-packages are also split.

Signed-off-by: Bogdan <bogdandrutu@gmail.com>
2022-11-05 10:04:49 -07:00
Ziqi Zhao 445927208d add validation for empty telemetry metric address when metric level is not none
Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
2022-10-28 14:49:23 +08:00
Bogdan Drutu 3262fd8f8b
Remove already deprecates config.Config (#6394)
* Remove already deprecates config.Config

Signed-off-by: Bogdan <bogdandrutu@gmail.com>

* Update service/internal/configunmarshaler/defaultunmarshaler.go

Co-authored-by: Alex Boten <alex@boten.ca>

Signed-off-by: Bogdan <bogdandrutu@gmail.com>
Co-authored-by: Alex Boten <alex@boten.ca>
2022-10-26 15:01:35 -07:00
Bogdan Drutu 2118622701
[chore] move service pipeline id validation to main config Validate (#6281)
Signed-off-by: Bogdan <bogdandrutu@gmail.com>

Signed-off-by: Bogdan <bogdandrutu@gmail.com>
2022-10-12 15:56:53 -07:00
Bogdan Drutu 62d41a8ac4
[chore] use proper velidate error instead of a hacky way (#5916)
Signed-off-by: Bogdan <bogdandrutu@gmail.com>

Signed-off-by: Bogdan <bogdandrutu@gmail.com>
2022-08-23 10:40:33 -07:00
Bogdan Drutu de51f9e800
Remove deprecated funcs/types from service related to Config (#5755)
Signed-off-by: Bogdan <bogdandrutu@gmail.com>
2022-07-26 17:26:02 -07:00
Bogdan Drutu d63aea3c5b
Fix initialization of the MetricProvider (#5571)
The problem was that the MetricProvider is initialized into the "service.telemetry.MetricProvider" after components were created. This change was not a trivial change because the process telemetry initialization requires the ballast size, which is available after the extensions are initialized, because of that I split the initialization of the MetricProvider/oc.Registry from the initialization of the process telemetry.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-06-29 05:54:47 -07:00
Bogdan Drutu f1ba384452
Move config tests to service to avoid using deprecated config types (#5466)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-06-08 12:39:03 -07:00