Commit Graph

49 Commits

Author SHA1 Message Date
Chao Weng 6de29ce169 Add `component.Type` parameter to `NewNopSettings` And deprecate `NewNopSettingsWithType` (#12452)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Add `component.Type` parameter to `NewNopSettings` And deprecate
`NewNopSettingsWithType` cc @mx-psi

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

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

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

<!--Please delete paragraphs that you did not use before submitting.-->
2025-02-21 11:17:45 +00:00
Pablo Baeyens a4ae175111
[*test] Add NewNopSettingsWithType everywhere (#12357)
<!--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 -->

Creates `NewNopSettingsWithType` function on test modules and deprecates
the `NewNopSettings` functions on those modules. Replace all usages of
`NewNopSettings` with `NewNopSettingsWithType`.

Part of #12305 but applied to all component kinds.

#### Link to tracking issue
Updates #12221
2025-02-13 16:56:20 +00:00
Daniel Jaglowski 7425fe859c
[chore] Clean up naming in testcomponent package (#12072)
This PR just cleans up some naming in the `testcomponents` package, so
that no component kind has a monopoly on the generic version of a
variable or function name.

Subset of #12057
2025-01-10 21:05:23 +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 0d94e09e70
Deprecate exporterprofiles module in favor of xexporter (#11885)
to allow adding more experimental data types.

Updates
https://github.com/open-telemetry/opentelemetry-collector/issues/11778
2024-12-13 21:56:43 +00:00
Dmitrii Anoshin 324f5a22d6
Deprecate processorprofiles module in favor of xprocessor (#11883)
to allow adding more experimental data types

Updates
https://github.com/open-telemetry/opentelemetry-collector/issues/11778
2024-12-13 21:36:25 +00:00
Dmitrii Anoshin 4593ba7de2
Deprecate receiverprofiles module in favor of xreceiver (#11876)
to allow adding more experimental data types

Updates
https://github.com/open-telemetry/opentelemetry-collector/issues/11778
2024-12-13 18:50:00 +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 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
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
Bogdan Drutu bce1040a63
Deprecate funcs that repeate receiver in name (#11287)
This change makes the names to be more "Go" friendly. Also it will not
become an issue that types will try to implement different Factory types
(receiver,processor) because that is forbidden because of our design.
This also makes the names consistent with connector.Factory.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-09-30 09:19:33 -07:00
Bogdan Drutu 99cf16ef4c
[chore] Move back exporter definitions, make profile embed exporter (#11290)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-09-27 14:09:13 -07:00
Bogdan Drutu 632461fb91
[chore] Move back processor definitions, make profile embed processor (#11286)
Same as
https://github.com/open-telemetry/opentelemetry-collector/pull/11254 but
for processor

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-09-27 11:07:54 -07:00
Bogdan Drutu 5cc717d747
[chore] Move back receiver definitions, make profile embed receiver (#11254)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-09-26 12:46:40 -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
Matthieu MOREL 37f783308e
[chore]: enable require-error rule from testifylint (#11199)
#### Description

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

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

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-09-18 15:02:22 -07:00
Matthieu MOREL 6925a306fa
[chore]: enable len and empty rules from testifylint (#11021)
#### Description

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

This PR enables
[len](https://github.com/Antonboom/testifylint?tab=readme-ov-file#len)
and
[empty](https://github.com/Antonboom/testifylint?tab=readme-ov-file#empty)
rules from [testifylint](https://github.com/Antonboom/testifylint)

It also adds testifylint as tool to use with a make command

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-09-09 09:57:58 -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
Alex Boten 3b3deb8dbe
[connector] deprecate CreateSettings -> Settings (#10338)
This deprecates CreateSettings in favour of Settings.
NewNopCreateSettings is also being deprecated in favour of
NewNopSettings

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2024-06-06 10:04:47 -07:00
Alex Boten 9907ba50df
[processor] deprecate CreateSettings -> Settings (#10336)
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 09:34:53 -07:00
Alex Boten f0c8787d2b
[exporter] deprecate CreateSettings -> Settings (#10335)
This deprecates CreateSettings in favour of Settings.
NewNopCreateSettings is also being deprecated in favour of
NewNopSettings
    
Part of #9428

~Follows
https://github.com/open-telemetry/opentelemetry-collector/pull/10333~

---------

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2024-06-06 08:03:40 -07:00
Alex Boten 1e44a9c473
[receiver] deprecate CreateSettings -> Settings (#10333)
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-05 13:57:23 -07:00
Alex Boten fc28929061
move internal/testdata to pdata/testdata (#9885)
This reduces dependencies from the consumer package while making
testdata available across repos. It will allow us to remove duplicated
code and its a fairly small surface area.

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

---------

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2024-04-08 08:36:57 -07:00
Alex Boten 062d0a7ffc
[chore] remove unnecessary underscores (#9580)
As per feedback from my previous PR

Signed-off-by: Alex Boten <aboten@lightstep.com>
2024-02-13 13:34:53 -08: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
Alex Boten 9c7177496f
[chore] remove unused opencensus code (#9108)
Follows
https://github.com/open-telemetry/opentelemetry-collector/pull/9102

---------

Signed-off-by: Alex Boten <aboten@lightstep.com>
2024-01-30 10:19:42 -08:00
Alex Boten 83d463ceba
[obsreport] deprecate test funcs/structs (#8538)
This deprecates the remaining code under the obsreport package.

Follows
bf141227c5

---------

Signed-off-by: Alex Boten <aboten@lightstep.com>
2024-01-12 09:28:57 -08:00
Curtis Robert 8ee1f13743
[chore] Enable goleak for all (passing) tests (#9173)
**Description:**
It was suggested that we add the [goleak
package](https://pkg.go.dev/go.uber.org/goleak) to every test in core.
This change adds `goleak` to every package that is succeeds with goleak.
There a number that are not successful, the full list of which I've
posted in the bug.

I generated these files using a shell script to copy a template
`main_test.go` file into each package, then modified the package name.
I'm sure there was a better way to automate this, but it worked well
enough at this point. Here's the script:
 ```
cp ./main_test.go $1

PACKAGE_NAME=$(basename $1)

sed -i '' -e "s|package component|package $PACKAGE_NAME|g"
$1/main_test.go

pushd . && cd $1 && go mod tidy 
go test -v .
```
Usage example:
```
$ ./add_leak_test reciever/scrapererror
```


**Link to tracking Issue:**
#9165

**Testing:**
All added tests are passing, but there are a number failing. Note that there's no sign of `goleak` running until it fails.
2024-01-03 08:35:58 -08:00
Bogdan Drutu edf7aca852
Remove circular dependency between default otel and connector (#9095)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2023-12-13 23:50:35 -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
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
Daniel Jaglowski 6ababc9c71
Incorporate next consumer's capabilities into connector capabilities (#7779)
Resolves #7776

The collector copies data whenever handing it to components that may mutate it. The point at which a copy must be made is within a fanout consumer. There are two points at which a fanout consumer may be placed:
1. Immediately after a receiver shared by multiple pipelines
2. Immediately before multiple exporters of a single pipeline

When data is fanned out _to_ a connector (acting as an exporter), we must ensure that the fanout consumer before exporters (point 2 above) is able to take into account whether or not the connector will be handing the data off to a pipeline that will mutate the data.
2023-06-05 08:03:01 -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
Daniel Jaglowski 0674cb5aa0
Allow connectors to request consumers to specific routes (#7179)
* Allow connectors to route data to specific consumers

* Allow connectors to request consumers for specific routes
2023-03-04 11:11:29 -08:00
Daniel Jaglowski 490fd6ae5b
Add full component graph build (#7045)
* Add full component graph build

* PR feedback

* Split adding nodes to graph from adding to pipelines

* Rename fanInNode to capabilitiesNode

* Add consumerNode interface

* Clarify comments about start/stop order of graph

* Simplify nextProcessors

* Move virtual node creation to createNodes, simplify createEdges

* Remove node build methods. Pull CreateSettings into buildComponent functions.

* Fix capabilities node MutatesData
2023-02-03 08:29:28 -08:00
Daniel Jaglowski 424bde88ef
Add testcomponents.StatefulComponent (#6893) 2023-01-17 12:56:28 -08:00
Daniel Jaglowski 052f761598
Add example connector to service/internal/testcomponents (#6762) 2022-12-12 16:26:49 -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
Daniel Jaglowski fdef8b181a
Deprecate `Processor` related structs and functions in favor of `processor` package (#6709) 2022-12-09 08:09:27 -08:00
Daniel Jaglowski a470d8a8f3
Deprecate component.Receiver* in favor of new receiver.* (#6687)
* Deprecate component.Receiver* in favor of new receiver.*

* Update component/receiver.go

Co-authored-by: Bogdan Drutu <lazy@splunk.com>

* Update component/receiver.go

Co-authored-by: Bogdan Drutu <lazy@splunk.com>

* Update component/receiver.go

Co-authored-by: Bogdan Drutu <lazy@splunk.com>

Co-authored-by: Bogdan Drutu <lazy@splunk.com>
2022-12-08 14:26:14 -08:00
Bogdan Drutu 6a2dc302a9
Move exporter Factory and types to exporter package (#6672)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-12-07 10:20:34 -08:00
Bogdan Drutu 9133b9b0b4
[chore] remove dependency on Factories, and LoadFiles in internal/pipelines (#6661)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-12-01 12:26:33 -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
Dmitrii Anoshin 4bb55bc1fa
[component] Rename "In development" stability level to "Development" (#6561) 2022-11-16 09:48:18 -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
Bogdan Drutu 8efcb44cc9
Move internal/testcomponents to service/internal/testcomponents, reduce scope (#6133)
Signed-off-by: Bogdan <bogdandrutu@gmail.com>

Signed-off-by: Bogdan <bogdandrutu@gmail.com>
2022-10-04 13:04:46 -07:00