Commit Graph

37 Commits

Author SHA1 Message Date
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
Roger Coll af659fa1de
[service] Include component id/type in start error (#11837)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Wraps the component ID and type into the component's start retuned
error. If `telemetry::logs::level` is < error (e.g fatal), the service
error message does not give information about which pipeline component
failed:

Current error message:
```
 $ otelcontribcol --config config.yaml
Error: cannot start pipelines: start function error
2024/12/10 10:07:25 collector server run finished with error: cannot start pipelines: start function error
```
 
 With these changes:
 
 ```
 $ otelcontribcol --config config.yaml
Error: cannot start pipelines: failed to start geoip processor: start
function error
2024/12/10 09:58:29 collector server run finished with error: cannot
start pipelines: failed to start geoip processor: start function error
```
 

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

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

<!--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.-->

---------

Co-authored-by: Bogdan Drutu <bogdandrutu@gmail.com>
Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
2025-03-07 14:58:09 +00:00
John L. Peterson (Jack) 4d927b97e1
[service] create service/hostcapabilities package (#12375)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
create `service/hostcapabilities` package to expose `GetModuleInfos()`
from service/host. Also moves getExporters interface for
`GetExporters()` to this package.
<!-- Issue number if applicable -->
#### Link to tracking issue
Addresses planned work from #12296

<!--Describe what testing was performed and which tests were added.-->
#### Testing
none, creates interface for existing function

<!--Describe the documentation added.-->
#### Documentation
changelog yaml
<!--Please delete paragraphs that you did not use before submitting.-->
2025-02-24 11:36:45 +00:00
Sudipto Baral 18e18b21da
Add pipeline ID to the error message for unused connectors. (#12410)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
As mentioned in this
https://github.com/open-telemetry/opentelemetry-collector/issues/8721#issuecomment-1813468623,
the error message for unused connectors currently lacks specific
pipeline names, making debugging more difficult.

This PR enhances the error message by including pipeline names in the
`[signal/name]` format, consistent with how they appear in
`config.yaml`. This provides a better context for identifying
misconfigurations.

<!-- Issue number if applicable -->
#### Link to tracking issue
Related to #8721 

<!--Describe what testing was performed and which tests were added.-->
#### Testing
A few scenarios and example output are given below. I will do additional
testing and add unit tests if necessary.

**1. Used as a receiver but not used as an exporter with 1 signal**
<details>
  <summary><strong>config.yaml</strong></summary>

```yaml
receivers:
  otlp:
    protocols:
      grpc:
exporters:
  debug:
connectors:
  forward:
service:
  pipelines:
    logs/in:
      receivers: [otlp]
      processors: []
      exporters: [debug]
    logs/out:
      receivers: [forward]
      processors: []
      exporters: [debug]
```
</details>

Main Branch Output:
```
Error: failed to build pipelines: connector "forward" used as receiver in logs pipeline but not used in any supported exporter pipeline
```
Proposed Output:
```
Error: failed to build pipelines: connector "forward" used as receiver in [logs/out] pipeline but not used in any supported exporter pipeline
```

**2. Plain**
<details>
  <summary><strong>config.yaml</strong></summary>

```yaml
receivers:
  otlp:
    protocols:
      grpc:
exporters:
  debug:
connectors:
  forward:
service:
  pipelines:
    traces:
      receivers: [ otlp ]
      processors: [ ]
      exporters: [ forward ]
    metrics:
      receivers: [ forward ]
      processors: [ ]
      exporters: [ debug ]
```
</details>

Main Branch Output:
```
Error: failed to build pipelines: connector "forward" used as exporter in traces pipeline but not used in any supported receiver pipeline
```
Proposed Output:
```
Error: failed to build pipelines: connector "forward" used as exporter in [traces] pipeline but not used in any supported receiver pipeline
```
**3. Multiple pipeline**
<details>
  <summary><strong>config.yaml</strong></summary>

```yaml
receivers:
  otlp:
    protocols:
      grpc:
exporters:
  debug:
connectors:
  forward:
service:
  pipelines:
    logs/in:
      receivers: [otlp]
      processors: []
      exporters: [forward]
    logs/in2:
      receivers: [ otlp ]
      processors: [ ]
      exporters: [ forward ]
    logs/out:
      receivers: [otlp]
      processors: []
      exporters: [debug]
    traces:
      receivers: [ otlp ]
      processors: [ ]
      exporters: [ forward ]
    metrics:
      receivers: [ forward ]
      processors: [ ]
      exporters: [ debug ]
```
</details>

Main Branch Output:
```
Error: failed to build pipelines: connector "forward" used as exporter in logs pipeline but not used in any supported receiver pipeline
```
Proposed Output:
```
Error: failed to build pipelines: connector "forward" used as exporter in [logs/in2 logs/in] pipeline but not used in any supported receiver pipeline

```

---------

Co-authored-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-02-24 01:06:54 +00:00
Daniel Jaglowski 81f1fad0ee
[chore] Add test to validate expected component instances (#12071)
Subset of #12057

This PR adds a test to validate the expected number of instances of each
component. This framework becomes more useful once singleton components
are explicitly supported.
2025-01-20 13:45:55 +00:00
Dmitrii Anoshin e9bc4bde92
Deprecate connectorprofiles module in favor of xconnector (#11887)
to allow adding more experimental data types.

Updates
https://github.com/open-telemetry/opentelemetry-collector/issues/11778
2024-12-14 15:04:34 +00:00
Dmitrii Anoshin 9206c68ec2
Deprecate pipelineprofiles module in favor of xpipeline (#11888)
to allow adding more experimental data types.

Updates
https://github.com/open-telemetry/opentelemetry-collector/issues/11778
2024-12-13 23:23:06 +00:00
Dmitrii Anoshin 63d83d5e79
Deprecate consumerprofiles module in favor of xconsumer (#11779)
To allow adding more experimental data types. First step towards
https://github.com/open-telemetry/opentelemetry-collector/issues/11778
2024-12-12 22:09:02 +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 98a326a3c5
Move componentprofiles to pipelineprofiles (#11421)
Move componentprofiles to pipelineprofiles since only the signal
constant is defined in that package.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-10-13 13:47:00 -07:00
Tyler Helmuth e69f2f38ff
[componentstatus] Continue DataType rename (#11313)
#### Description
Continues the DataType rename process for
`NewInstanceIDWithPipelineIDs`, `AllPipelineIDsWithPipelineIDs`, and
`WithPipelineIDs`.

#### Link to tracking issue
Related to
https://github.com/open-telemetry/opentelemetry-collector/issues/9429
2024-10-01 17:27:59 +02:00
Bogdan Drutu 6412988f19
[chore] Move back connector definitions, make profile embed connector (#11306)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-09-30 13:53: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
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
Damien Mathieu 720f3a86a3
Add profiles support in service (#11024)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

This is the last PR to add profiles support, adding it to the service
package.

This is based after #11023.
2024-09-05 17:56:11 +02:00
Damien Mathieu 18d5c02ade
Move processor builders into internal service (#10782)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

This moves the processor builder out of the `processor` package, and
into `service/internal/builders`.
There's no real reason for this struct to be public (folks shouldn't
call it), and making it private will allow us to add profiling support
to it.

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

https://github.com/open-telemetry/opentelemetry-collector/pull/10375#pullrequestreview-2144929463
2024-08-22 12:22:23 +02:00
Damien Mathieu 7cd1579d1f
Move exporter builder into internal service (#10783)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

This moves the exporter builder out of the `exporter` package, and into
`service/internal/builders`.
There's no real reason for this struct to be public (folks shouldn't
call it), and making it private will allow us to add profiling support
to it.

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

https://github.com/open-telemetry/opentelemetry-collector/pull/10375#pullrequestreview-2144929463
2024-08-22 11:43:35 +02:00
Damien Mathieu cde1055559
Move connector builder into internal service (#10784)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

This moves the connector builder out of the `connector` package, and
into `service/internal/builders`.
There's no real reason for this struct to be public (folks shouldn't
call it), and making it private will allow us to add profiling support
to it.

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

https://github.com/open-telemetry/opentelemetry-collector/pull/10375#pullrequestreview-2144929463
2024-08-22 10:35:19 +02:00
Damien Mathieu 454432e06f
Move receiver builder into internal service (#10781)
#### Description

This moves the receiver builder out of the `receiver` package, and into
`service/internal/builders`.
There's no real reason for this struct to be public (folks shouldn't
call it), and making it private will allow us to add profiling support
to it.

#### Link to tracking issue

https://github.com/open-telemetry/opentelemetry-collector/pull/10375#pullrequestreview-2144929463
2024-08-21 07:59:38 -07:00
Matthew Wear 98fb888dfe
[component] Make InstanceID immutable (#10495)
#### Description
This PR makes component.InstanceID immutable. Previously it was a struct
with all fields exported. Technically this is a breaking change, but the
only thing using the InstanceID is the in-progress
healthcheckv2extension.

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

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

<!--Describe the documentation added.-->
#### Documentation
code comments
<!--Please delete paragraphs that you did not use before submitting.-->

---------

Co-authored-by: Antoine Toulme <antoine@toulme.name>
Co-authored-by: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com>
Co-authored-by: Pablo Baeyens <pablo.baeyens@datadoghq.com>
2024-08-21 10:41:55 +02:00
Tyler Helmuth cb24d0c7d7
[component] Remove ReportStatus from component.TelemetrySettings (#10777)
#### Description

This PR removes `ReportStatus` from `component.TelemetrySettings` and
instead expects components to check if their `component.Host` implements
a new `componentstatus.Reporter` interface.

<!-- Issue number if applicable -->
#### Link to tracking issue
Related to
https://github.com/open-telemetry/opentelemetry-collector/pull/10725
Related to
https://github.com/open-telemetry/opentelemetry-collector/pull/10413

<!--Describe what testing was performed and which tests were added.-->
#### Testing
unit tests and a sharedinstance e2e test.

The contrib tests will fail because this is a breaking change. If we
merge this I and @mwear can commit to updating contrib before the next
release.

---------

Co-authored-by: Pablo Baeyens <pablo.baeyens@datadoghq.com>
2024-08-16 09:27:01 +02:00
Tyler Helmuth fb5b1e6aa5
[service] Remove servicetelemetry.TelemetrySettings (#10728)
#### Description
Reorganizes service to not require `servicetelemetry.TelemetrySettings`
and instead depend directly on `component.TelemetrySettings`

Whether or not we move forward with
https://github.com/open-telemetry/opentelemetry-collector/pull/10725 I
think this is a useful change for service.

#### Testing
Unit tests
2024-07-29 10:29:05 +02:00
Mikołaj Świątek fbadc23b71
Improve logging of component start errors (#10440)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Improved logging of component start errors, so the log lines appear
where they chronologically happen, rather than at the end. They also use
the component logger, which makes them look nicer.

Output before change:
```text
2024-06-19T14:15:30.822+0200    info    service@v0.103.0/service.go:115 Setting up own telemetry...
2024-06-19T14:15:30.822+0200    info    service@v0.103.0/telemetry.go:96        Serving metrics {"address": ":8888", "level": "Normal"}
2024-06-19T14:15:30.823+0200    info    service@v0.103.0/service.go:182 Starting otelcorecol... {"Version": "0.103.0-dev", "NumCPU": 32}
2024-06-19T14:15:30.823+0200    info    extensions/extensions.go:35     Starting extensions...
2024-06-19T14:15:30.823+0200    info    service@v0.103.0/service.go:245 Starting shutdown...
2024-06-19T14:15:30.823+0200    info    extensions/extensions.go:61     Stopping extensions...
2024-06-19T14:15:30.823+0200    info    service@v0.103.0/service.go:259 Shutdown complete.
Error: cannot start pipelines: failed to resolve authenticator "oauth2client": authenticator not found
2024/06/19 14:15:30 collector server run finished with error: cannot start pipelines: failed to resolve authenticator "oauth2client": authenticator not found
```

Output after change:
```
2024-06-19T14:25:18.324+0200    info    service@v0.103.0/service.go:115 Setting up own telemetry...
2024-06-19T14:25:18.325+0200    info    service@v0.103.0/telemetry.go:96        Serving metrics {"address": ":8888", "level": "Normal"}
2024-06-19T14:25:18.326+0200    info    service@v0.103.0/service.go:182 Starting otelcorecol... {"Version": "0.103.0-dev", "NumCPU": 32}
2024-06-19T14:25:18.326+0200    info    extensions/extensions.go:35     Starting extensions...
2024-06-19T14:25:18.326+0200    error   graph/graph.go:428      Failed to start component       {"error": "failed to resolve authenticator \"oauth2client\": authenticator not found", "type": "Exporter", "id": "otlphttp"}
2024-06-19T14:25:18.326+0200    info    service@v0.103.0/service.go:245 Starting shutdown...
2024-06-19T14:25:18.326+0200    info    extensions/extensions.go:61     Stopping extensions...
2024-06-19T14:25:18.326+0200    info    service@v0.103.0/service.go:259 Shutdown complete.
Error: cannot start pipelines: failed to resolve authenticator "oauth2client": authenticator not found
2024/06/19 14:25:18 collector server run finished with error: cannot start pipelines: failed to resolve authenticator "oauth2client": authenticator not found

```

We've added the following line:
```
2024-06-19T14:25:18.326+0200    error   graph/graph.go:428      Failed to start component       {"error": "failed to resolve authenticator \"oauth2client\": authenticator not found", "type": "Exporter", "id": "otlphttp"}
```

For extensions, the new line looks like so:
```
2024-06-25T16:59:18.513+0200    error    extensions/extensions.go:54     Failed to start extension      {"kind": "extension", "name": "memory_limiter", "error": "failed to get memory limit"}
```

<!-- Issue number if applicable -->
#### Link to tracking issue
Fixes #7078
2024-07-18 16:15:26 +02:00
Daniel Jaglowski b3c781b90e
[chore] Remove telemetry from graph initialization (#10446)
This PR refactors the service graph initialization so that the graph can
be assembled without the intention to start it.
1. Do not save telemetry on the graph. The only use of this was for
reporting component status. Instead, pass in a reporter when starting or
stopping. Correspondingly, add an internal `statustest` package to make
it easy to pass in a status reporter in tests.
2. Decouple graph building from extension building. There isn't any
direct relationship so these things should be separated.
2024-06-21 12:32:21 +02:00
Ankit Patel ecdbb535c7
Documentation improvements - Internal Architecture Doc + Package level comments (#10068)
<!--Describe the documentation added.-->
#### Documentation
Creates an internal architecture file. In it is a diagram of the startup
flow of the collector as well as links to key files / packages. I also
added package level comments to some key packages.

I wrote some other documentation in
https://github.com/open-telemetry/opentelemetry-collector/pull/10029 but
split the PRs up.

---------

Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com>
2024-05-20 22:33:02 +02:00
Ankit Patel 2875844e3c
Documentation improvements - Comments in key functions (#10029)
#### Documentation
I wrote comments on a bunch of important functions that helped me
understand how the collector works.
I also created some other documentation in
https://github.com/open-telemetry/opentelemetry-collector/pull/10068 -
but split it up from this PR.
2024-05-02 13:28:54 -07:00
Antoine Toulme c5a2c78d61
Move error out of `ReportComponentStatus` function signature, use `ReportStatus` instead (#9175)
Fixes #9148
2024-01-09 09:36:41 -08:00
Daniel Jaglowski 7c58e71515
Fix bug where MutatesData would not correctly propogate through connectors (#9053)
This fixes two closely related problems. 
1. While fanoutconsumers do not themselves mutate data, they should
expose whether or not they are handing data off to consumers which may
do so. Otherwise, the service cannot correctly determine how to fan out
after a receiver. e.g. a receiver shared between two pipelines, one of
which contains an exporter or connector which mutates data.
2. Connectors can themselves mutate data but we were not taking this
into account when building the graph.
2023-12-09 09:44:55 -08:00
Matthew Wear 433f7aef92
Automate status reporting on start (#8836)
This is part of the continued component status reporting effort.
Currently we have automated status reporting for the following component
lifecycle events: `Starting`, `Stopping`, `Stopped` as well as
definitive errors that occur in the starting or stopping process (e.g.
as determined by an error return value). This leaves the responsibility
to the component to report runtime status after start and before stop.
We'd like to be able to extend the automatic status reporting to report
`StatusOK` if `Start` completes without an error. One complication with
this approach is that some components spawn async work (via goroutines)
that, depending on the Go scheduler, can report status before `Start`
returns. As such, we cannot assume a nil return value from `Start` means
the component has started properly. The solution is to detect if the
component has already reported status when start returns, if it has, we
will use the component-reported status and will not automatically report
status. If it hasn't, and `Start` returns without an error, we can
report `StatusOK`. Any subsequent reports from the component (async or
otherwise) will transition the component status accordingly.

The tl;dr is that we cannot control the execution of async code, that's
up to the Go scheduler, but we can handle the race, report the status
based on the execution, and not clobber status reported from within the
component during the startup process. That said, for components with
async starts, you may see a `StatusOK` before the component-reported
status, or just the component-reported status depending on the actual
execution of the code. In both cases, the end status will be same.

The work in this PR will allow us to simplify #8684 and #8788 and
ultimately choose which direction we want to go for runtime status
reporting.

**Link to tracking Issue:** #7682

**Testing:** units / manual

---------

Co-authored-by: Alex Boten <aboten@lightstep.com>
2023-11-28 12:43:32 -08:00
Matthew Wear 53615832e6
Component Status Reporting (#8169)
This PR introduces component status reporting. There have been several
attempts to introduce this functionality previously, with the most
recent being: #6560.

This PR was orignally based off of #6560, but has evolved based on the
feedback received and some additional enhancements to improve the ease
of use of the `ReportComponentStatus` API.

In earlier discussions (see
https://github.com/open-telemetry/opentelemetry-collector/pull/8169#issuecomment-1668367246)
we decided to model status as a finite state machine with the following
statuses: `Starting`, `OK`, `RecoverableError`, `PermanentError`,
`FatalError`. `Stopping`, and `Stopped`. A benefit of this design is
that `StatusWatcher`s will be notified on changes in status rather than
on potentially repetitive reports of the same status.

With the additional statuses and modeling them using a finite state
machine, there are more statuses to report. Rather than having each
component be responsible for reporting all of the statuses, I automated
status reporting where possible. A component's status will automatically
be set to `Starting` at startup. If the components `Start` returns an
error, the status will automatically be set to `PermanentError`. A
component is expected to report `StatusOK` when it has successfully
started (if it has successfully started) and from there can report
changes in status as it runs. It will likely be a common scenario for
components to transition between `StatusOK` and `StatusRecoverableError`
during their lifetime. In extenuating circumstances they can transition
into terminal states of `PermanentError` and `FatalError` (where a fatal
error initiates collector shutdown). Additionally, during component
Shutdown statuses are automatically reported where possible. A
component's status is set to `Stopping` when Shutdown is initially
called, if Shutdown returns an error, the status will be set to
`PermanentError` if it does not return an error, the status is set to
`Stopped`.

In #6560 ReportComponentStatus was implemented on the `Host` interface.
I found that few components use the Host interface, and none of them
save a handle to it (to be used outside of the `start` method). I found
that many components keep a handle to the `TelemetrySettings` that they
are initialized with, and this seemed like a more natural, convenient
place for the `ReportComponentStatus` API. I'm ultimately flexible on
where this method resides, but feel that `TelemetrySettings` a more user
friendly place for it.

Regardless of where the `ReportComponentStatus` method resides (Host or
TelemetrySettings), there is a difference in the method signature for
the API based on whether it is used from the service or from a
component. As the service is not bound to a specific component, it needs
to take the `instanceID` of a component as a parameter, whereas the
component version of the method already knows the `instanceID`. In #6560
this led to having both `component.Host` and `servicehost.Host` versions
of the Host interface to be used at the component or service levels. In
this version, we have the same for TelemetrySettings. There is a
`component.TelemetrySettings` and a `servicetelemetry.Settings` with the
only difference being the method signature of `ReportComponentStatus`.

Lastly, this PR sets up the machinery for report component status, and
allows extensions to be `StatusWatcher`s, but it does not introduce any
`StatusWatcher`s. We expect the OpAMP extension to be a `StatusWatcher`
and use data from this system as part of its AgentHealth message (the
message is currently being extended to accommodate more component level
details). We also expect there to be a non-OpAMP `StatusWatcher`
implementation, likely via the HealthCheck extension (or something
similiar).

**Link to tracking Issue:** #7682

cc: @tigrannajaryan @djaglowski @evan-bradley

---------

Co-authored-by: Tigran Najaryan <tnajaryan@splunk.com>
Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com>
Co-authored-by: Daniel Jaglowski <jaglows3@gmail.com>
Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
Co-authored-by: Tigran Najaryan <4194920+tigrannajaryan@users.noreply.github.com>
Co-authored-by: Alex Boten <aboten@lightstep.com>
2023-10-06 11:35:38 -07:00
Daniel Jaglowski e1d0f26559
Fix connector validation based on usage in pipelines (#8004)
Alternate to
https://github.com/open-telemetry/opentelemetry-collector/pull/8003

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

Validation of connectors was too aggressive such that a connector that
was used in any combination of unsupported roles would fail. Instead,
validation should pass as long as each use of the connector has a
supported corresponding use.

For example, the forward connector may forward traces and metrics at the
same time. Previously, validation would fail because it detected that
traces->metrics and metrics->traces were possible connections. Now it
will pass as long as there is a supported connection type for each
pipeline in which the connector is used.
2023-07-10 10:31:08 -07:00
Matthew Wear fd72651e14
Add helpers to construct `connector.*Router`s for tests (#7673)
This PR adds helpers to `connectortest` to aid the construction of
`connector.*Router`s for testing connectors. This was implemented based
on @djaglowski's [comment
here](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/21498#issuecomment-1542682841),
with some slight modifications. I found it more ergonomic to pass the
sink into the `WithTracesSink` (and similar) options. You usually want a
handle on the sink after creating the router. While it's possible to get
the sink out of the router after the fact, it's a little cumbersome.

These helpers will be useful for
https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/21498
and future connectors that need use of routers.

For example, here is a test with the consumer passed in:

```go
func TestFanoutTracesWithSink(t *testing.T) {
    var sink0, sink1 consumertest.TracesSink

    tr, err := NewTracesRouterSink(
        WithTracesSink(component.NewIDWithName(component.DataTypeTraces, "0"), &sink0),
        WithTracesSink(component.NewIDWithName(component.DataTypeTraces, "1"), &sink1),
    )

    require.NoError(t, err)
    require.Equal(t, 0, sink0.SpanCount())
    require.Equal(t, 0, sink1.SpanCount())

    td := testdata.GenerateTraces(1)
    err = tr.(consumer.Traces).ConsumeTraces(context.Background(), td)

    require.NoError(t, err)
    require.Equal(t, 1, sink0.SpanCount())
    require.Equal(t, 1, sink1.SpanCount())
}

```

The same test having to extract the consumer out after the fact:

```go
func TestFanoutTracesWithSink(t *testing.T) {
    traces0 := component.NewIDWithName(component.DataTypeTraces, "0")
    traces1 := component.NewIDWithName(component.DataTypeTraces, "1")

    tr, err := NewTracesRouterSink(
        WithTracesSink(traces0),
        WithTracesSink(traces1),
    )
   
    require.NoError(t, err)
   
    cons0, _ := tr.Consumer(traces0)
    sink0 := cons0.(*consumertest.TracesSink)
    cons1, _ := tr.Consumer(traces1)
    sink1 := cons1.(*consumertest.TracesSink)

    require.Equal(t, 0, sink0.SpanCount())
    require.Equal(t, 0, sink1.SpanCount())

    td := testdata.GenerateTraces(1)
    err = tr.(consumer.Traces).ConsumeTraces(context.Background(), td)

    require.NoError(t, err)
    require.Equal(t, 1, sink0.SpanCount())
    require.Equal(t, 1, sink1.SpanCount())}
}
```


**Link to tracking Issue:** 
#7672

**Testing:**
Unit tests

**Documentation:**
Source code comments

---------

Co-authored-by: Daniel Jaglowski <jaglows3@gmail.com>
2023-06-22 14:35:40 -07: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
Daniel Jaglowski fe2ae8defc
Deprecate component.Host.GetExporters (#7390)
Co-authored-by: Dmitrii Anoshin <anoshindx@gmail.com>
2023-05-26 15:34:08 -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
Alex Boten e479b7e664
[chore] rename cap variable (#7417)
To address lint issue in https://github.com/open-telemetry/opentelemetry-collector/pull/7413

```
redefines-builtin-id: redefinition of the built-in function cap
```

Signed-off-by: Alex Boten <aboten@lightstep.com>
2023-03-22 10:09:13 -07:00
Daniel Jaglowski 3b238936e6
Move service graph and nodes into internal package (#7365) 2023-03-21 07:48:11 -07:00