Commit Graph

32 Commits

Author SHA1 Message Date
Antoine Toulme b3e68c3756
[chore] prevent unkeyed literal initialization (#12762)
This relates to
https://github.com/open-telemetry/opentelemetry-collector/issues/12360

Co-authored-by: Andrzej Stencel <andrzej.stencel@elastic.co>
2025-04-15 08:18:07 +00:00
Pablo Baeyens 9ea6963fca
Remove a lot of deprecated symbols (#12421)
<!--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 -->

Remove deprecated symbols

#### Link to tracking issue
Updates #12222, #12305, #11524
2025-02-18 16:57:10 +00:00
Jade Guiton 77f824660e
Make MakeFactoryMap generic and move to otelcol (#12220)
#### Description

At the moment, `receiver`, `scraper`, `processor`, `exporter`, and
`extension` each have their own version of the `MakeFactoryMap`
function, which takes a list of Factories and returns it as a map, with
the component name as the key (and an error if there is overlap).
Because all versions are near-identical except for the Factory type
used, and this function is only used in tests and in the code generated
by OCB (`components.go`), it was suggested to make it generic and move
it to the `otelcol` package.

This PR does exactly that. The old `MakeFactoryMap` functions are
deprecated (and may be removed alongside their tests in a future
release). I also had to make a few other odd changes to fit the new
dependency graph.

#### Link to tracking issue
Resolves #12222

---------

Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2025-02-13 11:47:22 +00:00
Pablo Baeyens 183d7edf9f
[extension] Error out if passed extension.Settings has incorrect type (#12305)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Explicitly error out if the passed `component.ID` does not have a
matching `component.Type`

<!-- Issue number if applicable -->
#### Link to tracking issue
Updates #12221
2025-02-07 20:15:42 +00:00
Pablo Baeyens 1f0365cbdd
[extension] Remove Settings.ModuleInfo and move to service.Host hidden method (#12296)
<!--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 -->

Moves `extension.Settings.ModuleInfo` to a `service.Host.GetModuleInfo`
method.

This field probably fits better on `extension.Settings` or even in
`component.BuildInfo`, but since its contents are a bit in flux per
discussions like #12283, I would like to move it here to not stabilize
it alongside the rest of `extension`.

The field is not used in any public code on Github, so I think it won't
have a huge impact to remove it in one go, happy to do this in two steps
if preferred.

One relevant difference is that this information is no longer available
at extension build time, but rather after the `Start` method is called.
Another relevant difference is that this is now available for all
component kinds, not just extensions. This could be worked around (we
could pass a different host depending on the component kind) but I don't
see the use right now.

#### Link to tracking issue
Updates #12283
2025-02-05 19:13:45 +00:00
Pablo Baeyens 74bff40691
[extension] Change from interface alias to embedding alias (#12208)
<!--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 -->

Changes `extension.Extension` to a proper interface that embeds
`component.Component` instead of being an alias.

#### Link to tracking issue
Fixes the second point mentioned in
https://github.com/open-telemetry/opentelemetry-collector/issues/11443#issuecomment-2616396687
2025-01-29 16:20:24 +00:00
Matthieu MOREL 0b978307c2
[chore]: enable gofumpt linter in connector, consumer, exporter, extension and featuregate (#11854)
#### 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>
2024-12-12 19:25:06 +00:00
Bogdan Drutu f4546bf56f
Remove deprecated funcs CreateExtension and ExtensionStability (#11663)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-11-13 08:06:47 -08:00
Bogdan Drutu 9701538c89
Deprecate funcs that repeate extension in name (#11413)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-10-10 16:10:02 -07:00
Pablo Baeyens 3ed205e03a
[extension] Remove deprecated interfaces (#11043)
<!--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 -->

Follows #11000. Removes deprecated symbols.

#### Link to tracking issue

Updates #11005
2024-09-10 13:42:55 +02:00
Pablo Baeyens 46d0f7361e
[extension] Move optional interfaces to extensioncapabilities (#11000)
<!--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 -->

Moves extension optional interfaces to a new module,
`extensioncapabilities`.

The intent is to be able to evolve these interfaces independently from
the core interfaces on core.

These are used by at most one component/project, so I think they are not
mature yet for 1.0

---------

Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
2024-09-04 12:37:27 +02:00
Damien Mathieu c4e527e7e8
Remove builders that were deprecated in 0.108.0 (#11019)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

There builders were deprecated in 0.108.0, so they can be removed now.

PRs that deprecated the builders:
* https://github.com/open-telemetry/opentelemetry-collector/pull/10781
* https://github.com/open-telemetry/opentelemetry-collector/pull/10782
* https://github.com/open-telemetry/opentelemetry-collector/pull/10783
* https://github.com/open-telemetry/opentelemetry-collector/pull/10784
* https://github.com/open-telemetry/opentelemetry-collector/pull/10785

cc @mx-psi
2024-08-30 12:38:59 +02:00
Damien Mathieu 549ee7220f
Move extension builder into internal service (#10785)
<!--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

While this is not technically required for the profiles work (there is
no notion of signals in extensions), this PR is here to keep things
consistent.
2024-08-22 11:04:43 +02:00
Dakota Paasman 6764622672
[extension] Add ModuleInfo to extension.Settings (#10888)
#### Description
Paired with @djaglowski on adding a new struct, `ModuleInfo`, to
`extension.Settings`. The goal is to make the collector's component go
modules available to extensions that may want to use that information
(in particular the OpAMP extension).

We didn't want to modify the `extension` package but adding this
information to the Settings struct seems to be the most painless way to
make this information available. No function signatures need to be
updated and existing extensions can just ignore the new field on the
Settings struct unless they want the information.

#### Link to tracking issue
Fixes #10876 

#### Testing
Updated existing tests.

---------

Co-authored-by: Dan Jaglowski <jaglows3@gmail.com>
2024-08-21 14:09:36 +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
Alex Boten e590ed1dd4
[connector,exporter,receiver,extension,processor] remove deprecated funcs/structs (#10423)
Finishing CreateSettings rename.

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2024-07-19 08:13:50 -07:00
Alex Boten cf0b959a79
[extension] deprecate CreateSettings -> Settings (#10339)
This deprecates CreateSettings in favour of Settings.
NewNopCreateSettings is also being deprecated in favour of
NewNopSettings
    
Part of #9428

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2024-06-06 10:33:25 -07:00
xu0o0 7d2cb74e29
[chore][extension] update NotifyConfig contract (#9005)
**Description:**
The collector implementation makes a copy of effective configuration
before calling `NotifyConfig` so it's safe for the config watcher to
save the pointer and use it later. It is resonable to promise this in
the API contract.

**Link to tracking Issue:**
https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/29277#discussion_r1406522281

---------

Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
2023-11-28 08:42:56 -08:00
Yuri Shkuro 2e44da36e2
[service/extensions] extension lifecycle order (#8768)
**Description**:
Enforce order of start and shutdown of extensions according to their
internally declared dependencies

**Link to tracking Issue**:
Resolves #8732

**Motivation**:
This is an alternative approach to #8733 which uses declaration order in
the config to start extensions. That approach (a) enforces order when
it's not always necessary to enforce, and (b) exposes unnecessary
complexity to the user by making them responsible for the order.

This PR instead derives the desired order of extensions based on the
dependencies they declare by implementing a `DependentExtension`
interface. That means that extensions that must depend on others can
expose this interface and be guaranteed to start after their
dependencies, while other extensions can be started in arbitrary order
(same as happens today because of iterating over a map).

The extensions that have dependencies have two options to expose them:
1. if the dependency is always static (e.g. `jaeger_query` extension
depending on `jaeger_storage` as in the OP), the extension can express
this statically as well, by returning a predefined ID of the dependent
extension
2. in cases where dependencies are dynamic, the extension can read the
names of the dependencies from its configuration.

The 2nd scenario is illustrated by the following configuration. Here
each complex extension knows that it needs dependencies that implement
`storage` and `encoding` interfaces (both existing APIs in collector &
contrib), but does not know statically which instances of those, the
actual names are supplied by the user in the configuration.

```yaml
extensions:
  complex_extension_1:
    storage: filestorage
    encoding: otlpencoding
  complex_extension_2:
    storage: dbstorage
    encoding: jsonencoding
  filestorage:
    ...
  dbstorage:
    ...
  otlpencoding:
  jsonencoding:
```

**Changes**:
* Introduce `DependentExtension` optional interface 
* Change `Extensions` constructor to derive the required order using a
directed graph (similar to pipelines)
* Inherited from #8733 - use new ordered list of IDs to
start/stop/notify extensions in the desired order (previously a map was
used to iterate over, which resulted in random order).
* Tests

**Testing**:
Unit tests

---------

Signed-off-by: Yuri Shkuro <github@ysh.us>
Co-authored-by: Antoine Toulme <antoine@lunar-ocean.com>
2023-11-01 21:08:25 -07: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
Evan Bradley 49a090ba92
Notify extensions of the Collector's effective configuration (#6833)
**Description:**

This adds an optional `ConfigWatcher` interface that extensions can
implement if they want to be notified of the effective configuration
that is used by the Collector.

I don't feel very strongly about any of the decisions I made in this PR,
so I am open to input if we would like to take a different approach
anywhere. I will leave some comments to explain the decisions I made.

**Link to tracking Issue:**
Closes
https://github.com/open-telemetry/opentelemetry-collector/issues/6596

**Testing:**

I've made minimal unit test changes, but I expect to write more tests
once there is consensus on the direction for implementing this
functionality. I have done some manual testing to show that an extension
can get a YAML representation of the effective config using two YAML
input files.

---------

Co-authored-by: Evan Bradley <evan-bradley@users.noreply.github.com>
2023-08-08 09:40: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
Bogdan Drutu 1bfb1804fb
Continue to disallow directly implementing Factories, but allow it for component.Factory (#6962)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2023-01-24 09:50:47 -08:00
Bogdan Drutu 39ccb07aa7
[chore]: fix godoc comments for connector/extension Factories (#6963)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2023-01-17 12:50:46 -08:00
Daniel Jaglowski cd369d6075
Remove deprecated component.Extension types 2023-01-03 14:18:19 -08:00
Bogdan Drutu e63aed8fef
Improve service Config types name (#6787) (#6803)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

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

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-12-15 12:43:00 -08:00
Bogdan Drutu ace2bc6829
Remove deprecated funcs/types from component package (#6769)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-12-12 18:12:32 -08:00
Bogdan Drutu 03370c7ff5
Move Extension/ExtensionFactory to extension package (#6642)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-12-01 10:39:09 -08:00
Tigran Najaryan c931b9875f
Refactor component and factory interface definitions (#683)
As we are preparing for Beta release we want to cleanup publicly exported
types and interfaces and do all necessary refactoring and breaking changes
now, before the Beta release. We will have a lot less leeway for breaking
changes after the Beta release.

Component related type declarations are now all in the `component` package.
This makes it possible for the interfaces to reference each other. This
was were very restricted earlier because component interfaces were in 5
different packages and many proposals were impossible to implement because
they would result in circular dependencies between packages.

(An example upcoming new capability that is enabled by this refactoring
is for components to query the Host for other components and for factories).

List of changes in this commit:

- Move all factory interfaces and component interfaces to component package.
- Rename old factories and components interfaces to use "Old" suffix for clarity.
- Eliminate forced checks that components implement factories. This is already
  enforced by the compiler when the factory is added to the Defaults() and
  was unnecessary code.
- Eliminated some unnecessary codes (removed overall over 200 lines).
- Run `go mod tidy` on testbed.

Warning: this is a breaking change to publicly exported types and function
signatures. We announced that a breaking change is comming. Once we agree
to merge this commit we will need to announce the exact list of changes
and guide component authors to modify their components accordingly.

Future changes:
- Once all components are migrated to the new internal representation,
  delete all "Old"-suffixed definitions. This will likely be done while
  we are still in Beta phase, before the Stable release.
2020-03-25 13:43:35 -04:00
Tigran Najaryan 91728bc8ce
Make component interfaces uniform (#488)
This change fixes inconsistencies in component interfaces. Motivation:

- Uniformness results in reduction of code that currently has to
  deal with differences.
- Processor.Start is missing and is important for allowing processors
  to communicate with the Host.

What's changed:

- Introduced Component interface.
- Unified Host interface.
- Added a Start function to processors (via Component interface).
- Start/Shutdown is now called for Processors from service start/shutdown.
- Receivers, Exporters, Processors, Extensions now embed Component interface.
- Replaced StartTraceReception/StartMetricsReception by single Start function for receivers.
- Replaced StopTraceReception/StopMetricsReception by single Shutdown function for receivers.

Note: before merging this we need to announce the change in Gitter since it
breaks existing implementations in contrib (although the fix is easy).

Resolves #477
Resolves #262
2020-01-10 08:49:34 -05:00
Tigran Najaryan 7609eaa71b
Rename OpenTelemetry Service to Collector in docs and comments (#354)
This begins implementation of https://github.com/open-telemetry/opentelemetry-service/issues/352
2019-09-19 11:46:11 -04:00
Paulo Janotti 3c3718be3f
Add extensions and service to configuration (#299)
* Add extensions and service to configuration

Adds the extensions and service to the configuration model so "extension components" can be configured in the standard way of data pipelines.

* Rename extension.Component to extension.ServiceExtension
2019-08-27 17:41:27 -07:00