Commit Graph

35 Commits

Author SHA1 Message Date
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
Daniel Jaglowski fa3471825e
Add ingoing and outgoing counts to processorhelper (#10910)
#### Description

Implements ingoing and outgoing counts as described in
https://github.com/open-telemetry/opentelemetry-collector/issues/10708.
2024-09-09 08:19:22 -07:00
Tyler Helmuth 4e44e32280
[service] Remove getBallastSize from service (#10696)
#### Description

This PR removes all ballast logic from service. This effectively
deprecates the ballastextension as including the extension with this
service would do nothing.

Related to
https://github.com/open-telemetry/opentelemetry-collector/pull/10671

#### Link to tracking issue
Closes
https://github.com/open-telemetry/opentelemetry-collector/issues/8342

#### Testing
Unit tests.
2024-07-23 14:59:53 -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
Ankit Patel c8f9563f1b
MemoryLimiterProcessor - switch to MustNewID instead of zero value ID (#10128)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
In an upcoming PR, I change Type to be an interface. This means the zero
value of Type will be nil - which will cause this test to fail.
Initializing ID instead of relying on the zero value fixes this

<!-- Issue number if applicable -->
#### Link to tracking issue
related to
https://github.com/open-telemetry/opentelemetry-collector/issues/9429


<!--Please delete paragraphs that you did not use before submitting.-->
In preparation for
https://github.com/open-telemetry/opentelemetry-collector/pull/10069
2024-05-09 22:38:16 +02:00
Antoine Toulme 2a6a3f9eab
[chore] rework memorylimiter test to avoid flaky tests (#9733)
Peeling this set of changes from #9584 as a separate PR.

These changes allow a reduction of issues when working with ARM64, which
seems to fail on some of the resource locking used in those tests.
2024-03-19 10:14:15 -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
splunkertimn a85b37df73
[extension/memorylimiter] add memory limiter extension, a copy of memorylimiter processor (#8964)
**Description:**

Following
https://github.com/open-telemetry/opentelemetry-collector/issues/8632,
this change introduces memory limiter as an extension. This allows
us to place the component to reject incoming connections due to limited
memory, providing better protection from running out of memory.

missing feature: receiver fairness. issue where a receiver hogs all the
resource can happen.

**Link to tracking Issue:** <Issue number if applicable>
 https://github.com/open-telemetry/opentelemetry-collector/issues/8632

---------

Co-authored-by: Dmitry Anoshin <anoshindx@gmail.com>
2024-01-23 10:44:46 -08:00
Alex Boten dbaec76447
[chore] use mdatagen for memorylimiter processor (#9182)
Signed-off-by: Alex Boten <aboten@lightstep.com>
2023-12-22 09:24:37 -08:00
Dmitrii Anoshin b81d4efd05
[processor/memory_limiter] Update config validation (#9059)
- Fix names of the config fields that are validated in the error
messages
  - Move the validation from start to the initialization phrase
2023-12-12 10:13:56 -08:00
Alex Boten 9549a14a31
deprecate processor API in obsreport (#8496)
These deprecated methods/structs have been moved to processorhelper:
- `obsreport.BuildProcessorCustomMetricName` ->
`processorhelper.BuildCustomMetricName`
  - `obsreport.Processor` -> `processorhelper.ObsReport`
  - `obsreport.ProcessorSettings` -> `processorhelper.ObsReportSettings`
  - `obsreport.NewProcessor` -> `processorhelper.NewObsReport`

Same as the change for the exporter, no functional changes just moving
code over to the
new location.

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

---------

Signed-off-by: Alex Boten <aboten@lightstep.com>
2023-09-20 16:51:35 -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
Tigran Najaryan b1426afc1b
Clarify that memory limiter refuses data, doesn't drop it (#7459)
Contributes to https://github.com/open-telemetry/opentelemetry-collector/issues/1084

- Clarify what the memory limiter does.
- Set expectations from receivers, how they are supposed to react
  when the memory limiter refuses the data.
- Add a test that demonstrates that memory limiter does not lose data
  if the receiver and exporter behave according to the contract.

All receivers must adhere to this contract. See for example
an issue opened against filelog receiver:
https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/20511

Note that there are no functional changes to the memory limiter.

Future work: one additional thing we can do is implement a backoff
logic in the memory limiter. When in memory limited mode the processor
can introduce pauses before it returns from the ConsumeLogs/Traces/Metrics
call. This will allow to slow down the inflow of data into the Collector
and give time for the pipeline to clear and memory usage to return to the
normal. This needs to be explored further.
2023-04-03 08:45:25 -07:00
Kshitij Patil 5c58fb38e4
replacing go.uber.org/atomic by sync/atomic (#7220)
replacing go.uber.org/atomic by sync/atomic
wrt issue #7160
2023-03-05 12:24:52 -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
Bogdan Drutu aaaa356a38
Minimum changes to component.Host, to allow split of the component package (#6553)
* Draft minimum changes to component.Host

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

* Update .chloggen/draftminhost.yaml

Co-authored-by: Dmitrii Anoshin <anoshindx@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Co-authored-by: Dmitrii Anoshin <anoshindx@gmail.com>
2022-11-18 09:44:06 -08:00
Gustavo Paiva 20e3aac004
deprecate obsreport.Must functions in favor of obsreport.New (#6510)
* deprecate obsreport.Must functions in favor of obsreport.New

* add changelog

* fix lint

* split changelog in two

* Update .chloggen/return_error_for_obsreport_new_functions.yaml

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

Co-authored-by: Bogdan Drutu <lazy@splunk.com>
2022-11-10 14:26:31 -08:00
Bogdan 74e53c9475 Fix deprecated calls
Signed-off-by: Bogdan <bogdandrutu@gmail.com>
2022-11-05 10:25:02 -07: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 a167b006e8
[chore] remove dependency on ballastextension from main core module (#6466)
Signed-off-by: Bogdan <bogdandrutu@gmail.com>
2022-11-03 09:19:31 -07:00
gustavo.paiva 5a548e8c75 deprecate obsreport New* methods in favor of MustNew* 2022-11-02 12:26:35 -03:00
Bogdan Drutu 9e90e25435
Deprecate New*ProcessorWithCreateSettings, update New*Processor to the new API (#5915)
Signed-off-by: Bogdan <bogdandrutu@gmail.com>

Signed-off-by: Bogdan <bogdandrutu@gmail.com>
2022-08-15 15:25:21 -07:00
Bogdan Drutu 7a41e2f47e
Deprecate processorhelper.New*Processor in favor of New*ProcessorWithCreateSettings (#5833)
Main motivation is to ensure that Settings are passed (to enable obsreport usage which requires settings to be passed) as well as the context.

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

Signed-off-by: Bogdan <bogdandrutu@gmail.com>
2022-08-10 10:54:59 -07:00
Bogdan Drutu fe226f3d86
Deprecate obsreport.[Processor|Exporter]Settings.Level and use MetricsLevel from CreateSettings (#5824)
Signed-off-by: Bogdan <bogdandrutu@gmail.com>
2022-08-05 07:12:23 -07:00
Bogdan Drutu e8dd9536f5
Enable errorlint and fix all warnings (#5364)
On top of the errorlint errors, also changes `fmt.Errorf("string literal")` with `errors.New("string literal")`.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-05-16 10:36:41 -07:00
Bogdan Drutu 39b719f28d
Use atomic.Bool when int was used as a bool variable (#5218)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-04-14 10:17:09 -07:00
Pablo Baeyens 698fbae76b
Use `go.uber.org/atomic` everywhere (#5215)
* Add depguard to enforce usage of `go.uber.org/atomic`

* Use `go.uber.org/atomic` everywhere
2022-04-14 08:42:48 -07:00
Dmitrii Anoshin 734e25e8de
Split `model` by signal type and move it to the new `pdata` module (#5168)
Split all `pdata` related code by type and move it from `model` to the new module `pdata`.

- `model/pdata` and `model/otlp` are moved to `pdata/plog`, `pdata/pmetric` and `pdata/ptrace`.
- `model/otlpgrpc` is moved to `pdata/plogotlp`, `pdata/pmetricotlp` and `pdata/ptraceotlp`.

Now all the API in `model` except for `model/semconv` is deprecated.
2022-04-11 16:00:26 -07:00
Dani Louca 52d651861c
[processor/memorylimiter] Only drops traces, not logs or metrics
Signed-off-by: Dani Louca <dlouca@splunk.com>

**Description:** 

This change 062e64f1d7 caused the memory limiter to "only" start the `checkMemLimits` routine for the ml instance used by the traces processor . 
In other words, metrics and logs processor will NOT [drop/refuse](https://github.com/open-telemetry/opentelemetry-collector/blob/main/processor/memorylimiterprocessor/memorylimiter.go#L206) data and will pass them down to the next consumer regardless of the current memory pressure as their instance of ml->forcingDrop will not be set.

The simplest solution, is to call start for each processor (metrics, logs, traces) , but this will not be efficient as we'll be running 3 instances of `checkMemLimits`, ie: multiple GC .
But at the same we need to allow multiple instances, with different configs, example: `memory_limiter/another` and `memory_limiter`

````
extensions:
  memory_ballast:
    size_mib: 4

receivers:
  otlp:
    protocols:
      grpc:
      http:
processors:
  memory_limiter:
    check_interval: 2s
    limit_mib: 10

  memory_limiter/another:
    check_interval: 1s
    limit_mib: 100
exporters:
  logging:
    logLevel: info

service:
  telemetry:
    logs:
      level: "info"
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [memory_limiter]
      exporters: [logging]
    metrics/default:
      receivers: [otlp]
      processors: [memory_limiter]
      exporters: [logging]
    traces:
      receivers: [otlp]
      processors: [memory_limiter/another]
      exporters: [logging]
  extensions: [memory_ballast]
````

The fix adds a global map to keep track of the different instance and add ~~sync once~~ mutex for the start and shutdown call, so only the first processor can launch the `checkMemLimits` routine and the last one to call `shutdown` to take it down.
If shutdown was called and no `checkMemLimits` has started, then we'll return an error message; unit tests were updated to handle this.


**Testing:** 
Tested with above config and using splunk otel instance with valid data.
Made sure only a single `checkMemLimits` is running when there is a single config for memory-limiter and more than one when we have multiple.
I also verified that under memory pressure, when we pass the soft limit, all data types, traces, logs and metrics are getting dropped.

One we agree on this solution, I will look into adding more unit test to validate the change
2022-02-24 13:13:32 -05:00
Pablo Baeyens a8ff2dd98c
Enable `errcheck` linter (#4462)
* Check or explicitly ignore all errors

* Enable errcheck

* Use `t.Cleanup` instead of `defer`

* Point to issue on `Set` ignored error
2021-11-23 12:27:32 -08:00
Anthony Mirabella ee7fa0eeed
obsreport: wire up ProcessorCreateSettings for processors using obsreport (#4148)
* obsreport: wire up ProcessorCreateSettings for processors using obsreport

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>

* Add ToProcessorCreateSettings() to obsreporttest settings

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>

* Fix lint issue

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
2021-09-30 09:15:50 -07:00
James 85b8094e26
Rename `config.NewID` to `config.NewComponentID` and `config.NewIDFromString` to `config.NewComponentIDFromString` (#4137)
This PR is to rename `config.NewID` to `config.NewComponentID` and `config.NewIDFromString` to `config.NewComponentIDFromString` for naming consistency.  

**Link to tracking Issue:** 
Fixes #4105
2021-09-29 10:28:07 -04:00
alrex 3577bd05d4
rename memorylimiter -> memorylimiterprocessor (#4064) 2021-09-17 03:01:07 -07:00