Commit Graph

70 Commits

Author SHA1 Message Date
Bogdan Drutu 3203167e9a
Make registration of callback for async metric always optional (#12204)
This PR also solves one more issues with the new interface, which is the
ability to record multiple observations for a single async metric using
one callback.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-01-29 23:58:43 +00:00
Pablo Baeyens 70f9fe94fe
[chore][service] Drop component metrics depending on level (#12143)
<!--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 -->

Drops metrics that depend on the metrics level:
- Batch processor metric
- otelarrow metrics (see open-telemetry/otel-arrow/issues/280 for
limitation).
- internal/otelarrow/netstats metrics. I did not implement
a25f058256/internal/otelarrow/netstats/netstats.go (L133-L136)
since `LevelNone` drops all metrics.

This attemps to unblock #11601 by hardcoding the metrics here since
there is a small number of them. Once we do #11754 we can move this back
to the individual components

#### Link to tracking issue

Updates #11061
2025-01-22 09:51:27 +00:00
William Dumont 69e7a409e3
(batchprocessor): Move single shard batcher creation to the constructor (#11594)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

The single-shard batcher is currently created and started in the start
function. If the consume function is called before the start function,
sb.single will be nil and it will panic. I'm not sure if that can happen
in the Otel collector but it might happen in distributions that have a
different runtime (such as Alloy - Grafana's distribution).

I think that conceptually, it's better to create the shard in the
constructor and start it in the start function.

PS: I did not create an entry in the changelog because the initial
[PR](https://github.com/open-telemetry/opentelemetry-collector/pull/11314)
for this change didn't but let me know if I should add one.

Credits also to @thampiotr for this fix
2024-11-04 09:55:11 -08:00
Bogdan Drutu 403c782d50
[chore] Remove unnecessary context from Batch.split (#11504)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-10-21 16:58:09 -07:00
Bogdan Drutu 8f20a07847
[chore] Small nits in batch processor, use generics to avoid type conversions (#11501)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-10-21 16:21:33 -07:00
Bogdan Drutu 5cd035b1b5
[chore] BatchProcessor: Move fields from top level struct to child that uses it (#11502)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-10-21 12:49:39 -07:00
Nathan Baulch 42e6304f65
Fix typos (#11348)
Just thought I'd contribute some typo fixes I stumbled upon. Nothing
controversial (hopefully), just 72 simple fixes.

Use the following command to get a quick and dirty summary of the
specific corrections made:
```shell
git diff HEAD^! --word-diff-regex='\w+' -U0 \
  | grep -E '\[\-.*\-\]\{\+.*\+\}' \
  | sed -r 's/.*\[\-(.*)\-\]\{\+(.*)\+\}.*/\1 \2/' \
  | sort | uniq -c | sort -n
```

FWIW, the top typos are:
* invokable (16)
* subsciption (15)
* decison (7)
* reques (3)
* dissallow (3)
* documenation (3)
* locahost (3)
* prerequistes (2)
* assinged (2)
* extenions (2)

---------

Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2024-10-09 15:43:52 -07:00
Joshua MacDonald dd054f1d5f
(batchprocessor): Multi/single-shard consistent start method and field names (#11314)
#### Description
There are two implementations of the `batcher` interface with several
inconsistencies. Notably, the single-shard case would start a goroutine
before `Start()` is called, which can be confusing when the goroutine
leak checker notices it. This makes the single-shard batcher wait until
Start() to create its single shard. A confusing field name `batcher` in
this case becomes `single`, and a new field is added for use in start
named `processor` to create the new shard.

For the multi-shard batcher, `start()` does nothing, but this structure
confusingly embeds the batchProcessor. Rename the field `processor` for
consistency with the single-shard case.

#### Link to tracking issue
Part of #11308.
2024-09-30 19:51:09 -07:00
Bogdan Drutu 98230db9d3
Deprecate funcs that repeate processor in name (#11310)
Similar with
https://github.com/open-telemetry/opentelemetry-collector/pull/11287

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-09-30 15:31:44 -07:00
Joshua MacDonald c3bd972e1a
Refactor batch processor export method (#11309)
#### Description

Split the internal `batcher.export()` interface into three methods. This
is a refactoring that was applied in
https://github.com/open-telemetry/otel-arrow/tree/main/collector/processor/concurrentbatchprocessor
and is being back-ported as part of #11308. The reason this refactoring
is needed is that the parent context of the export() request will be
manipulated in common code (vs signal-specific code) for tracing
support.

#### Link to tracking issue
Part of #11308

#### Testing
Existing tests cover this.

---------

Co-authored-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-09-30 15:06:09 -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
Bogdan Drutu 15201f1e59
Prevent starting unnecessary goroutines (#9817)
Fixes
https://github.com/open-telemetry/opentelemetry-collector/issues/9739
Replaces
https://github.com/open-telemetry/opentelemetry-collector/pull/9814

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-03-22 09:55:17 -07:00
Alex Boten 834413537b
[telemetry] mark useOtelForInternalMetrics stable (#9102)
This marks the flag as stable. Leaving this as a draft until v0.92.0 is
released.

Closes https://github.com/open-telemetry/opentelemetry-collector/issues/8962
Fixes https://github.com/open-telemetry/opentelemetry-collector/issues/816

---------

Signed-off-by: Alex Boten <aboten@lightstep.com>
2024-01-16 15:38:21 -08:00
Bogdan Drutu e5a1330342
Change multiBatcher to use sync.Map, avoid global lock on fast path (#7714)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2023-05-23 08:44:09 -07:00
Bogdan Drutu 179d4be1ab
Fix return error for batch processor when consuming Metrics and Logs (#7711)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2023-05-22 17:56:28 -07:00
Bogdan Drutu bf6ca2bc95
Fix start/stop logic for batch processor (#7708)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2023-05-22 13:39:04 -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
Joshua MacDonald aa206e399c
Add batchprocessor support for client metadata (#7578) 2023-05-16 11:41:33 -07:00
Joshua MacDonald 27d3efb1e0
Batch processor support for split-only configuration (#7509)
Implement the fixes proposed in #7508. Otherwise, using a batchprocessor with Config{} passes validation but acts badly at runtime there is both a zero-duration timer and the call to sendItems never returns, constantly sending empty batches.
2023-04-07 15:35:55 -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 430fb80141
[chore] limit usage of the use otel feature gate, pass the bool directly to simplify usage (#6985)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2023-01-19 18:29:21 -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 d0fe772781
Deprecate component.Config.ID(), add helper for obsreporttest (#5870)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-11-29 14:35:49 -08:00
Gustavo Paiva 2da68656b8
Instrument `batch` processor with Otel Go (#6423)
- Instrument batch processor with OpenTelemetry Go.
- Also fixed a small typo on the bucket definition of the batch_send_size_bytes view of OpenCensus.
2022-11-16 15:08:28 -08:00
Bogdan Drutu bb193a24d0
Deprecate New[JSON|Proto][Marshaler|Unmarshale], expose the structs (#6340)
The main motivation is because we want to be able to extend these Marshaler/Unmarshaler implementation with possible options.

Because of that we have 2 options: 1. add Option to each New func, OR 2. expose the structs so that later users can configure different options inside these structs, similar with `jsonpb.Marshaler`.

I implemented the version 2 since it is simpler, and less code, and also common in the industry.

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

Signed-off-by: Bogdan <bogdandrutu@gmail.com>
2022-10-18 15:29:37 -07:00
Corbin Phelps f0d69d6822
[processor/batch] Removed casts to Sizer interface in batch processor (#5937)
* Removed casts to Sizer interface in batch processor

Signed-off-by: Corbin Phelps <corbin.phelps@bluemedora.com>

* Added changelog entry

Signed-off-by: Corbin Phelps <corbin.phelps@bluemedora.com>

* removed changelog

Signed-off-by: Corbin Phelps <corbin.phelps@bluemedora.com>

Signed-off-by: Corbin Phelps <corbin.phelps@bluemedora.com>
2022-08-19 09:31:09 -07:00
Bogdan Drutu e46dfb9a02
Remove unused func from internal interface batch (#5462)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-06-02 15:21:35 -07:00
Nathan Vērzemnieks 65b7b1be5d
Send correct batch stats when SendBatchMaxSize is set (#5385)
The stat was getting sent before the max batch size was
taken into account.
2022-06-02 14:18:07 -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
José Carlos Chávez 9d3a8a4608
Adds vanity import check (#4180)
* chore: adds porto and fixes vanity imports.

* chore: fixes target overriding.

* chore: fixes install of porto.

* chore: includes porto as a tool.

* chore: upgrades porto to check internals.

* chore: rebase and update vanity import.

* chore: removes unnecessary space.

* chore: rollsback vanity import in generated files.
2021-10-12 13:47:36 -07:00
Nathan Dias aa450a0bf2
all: remove OtlpProtoSize in favor of Sizer interface (#3818)
* all: remove OtlpProtoSize in favor of Sizer interface

* add {Metrics|Traces|Logs}Sizer, fix test commenting

* move size tests to pb_test, fix metrics+logs parameter names

* uncommented batch_processor tests + adjusted them to use *Sizer

* I forgot BenchmarkTraceSizeBytes :(

* Add docs for NewProtobof*Sizer + update docs for NewProtobuf*Marshaler

* cast *Marshaler to *Sizer for now

* add casts to batch_processor_test
2021-08-17 11:10:33 -07:00
Bogdan Drutu d1fced9688
Refactor MetricAndDataPointCount to DataPointCount (#3547)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2021-07-01 13:43:31 -07:00
Bogdan Drutu c63d0c68cd
Move pdata in the new package (#3483)
The new module go.opentelemetry.io/collector/model will be created later when the internal data will
also be moved.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2021-06-25 01:17:31 +03:00
kisieland 6d44f0d303
Make the batch processor limit data points rather than metrics. (#3141)
**Link to tracking Issue:** #2754

This change introduces a BenchmarkBatchMetricProcessor that stress tests batching logic.
Results before:
`BenchmarkBatchMetricProcessor-12           20000             80614 ns/op`
Results after the change:
`BenchmarkBatchMetricProcessor-12           20000             96184 ns/op`
2021-06-02 10:52:24 -04:00
Patryk Matyjasek 017aa1dad7
Standarize Settings, Params and Parameters in Processors (#3181)
* Replace ProcessorCreateParams with ProcessorCreateSettings.
Replace all dependencies in Processors.

Signed-off-by: Patryk Matyjasek <pmatyjasek@sumologic.com>

* Update changelog

Signed-off-by: Patryk Matyjasek <pmatyjasek@sumologic.com>

# Conflicts:
#	CHANGELOG.md

# Conflicts:
#	CHANGELOG.md

Co-authored-by: Bogdan Drutu <bogdandrutu@gmail.com>
2021-06-02 06:49:04 -07:00
Bogdan Drutu ffb332b37b
Add capabilities to consumer, remove from processor (#2770)
* Add capabilities to consumer, remove from processor

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

* Rename baseConsumer

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2021-05-11 16:13:47 -07:00
Bogdan Drutu 7b39a894e1
Fix batch processor traces reorder, improve performance (#3107)
Benchmarks Before:

```
goos: darwin
goarch: amd64
pkg: go.opentelemetry.io/collector/processor/batchprocessor
cpu: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
BenchmarkSplitTraces
BenchmarkSplitTraces-16    	    8277	    135600 ns/op	  222440 B/op	    1725 allocs/op
PASS
```

Benchmarks After:

```
goos: darwin
goarch: amd64
pkg: go.opentelemetry.io/collector/processor/batchprocessor
cpu: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
BenchmarkSplitTraces
BenchmarkSplitTraces-16    	    9896	    108060 ns/op	  172409 B/op	    1372 allocs/op
PASS
```

Benchmarks Reference Clone:

```
goos: darwin
goarch: amd64
pkg: go.opentelemetry.io/collector/processor/batchprocessor
cpu: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
BenchmarkCloneSpans
BenchmarkCloneSpans-16    	   12393	     97528 ns/op	  167896 B/op	    1303 allocs/op
PASS
```

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2021-05-05 15:19:29 -07:00
Bogdan Drutu 665e9657ac
Use config.ID for Processors config (#3077)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2021-05-03 14:46:10 -07:00
Bogdan Drutu 9df19a1b45
Fix batchprocessor to avoid reordering and send max size (#3029)
* The reordering could happen if during processing of an item other items were added to the newItems channel. This is fixed by avoiding to re-add the left items to the channel.
* The logic of spliting was wrong by forcing sendBatchSize instead of sendBatchMaxSize when split was called.
* Fix logic if a very large message is received > 2x sendBatchMaxSize to call export multiple times instead of once and reset the timer.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2021-04-26 16:01:08 -07:00
Bogdan Drutu 25da8cfb98
Small cleanups in batchprocessor (#3013)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2021-04-26 13:52:33 -07:00
Bogdan Drutu d6a0f9ab76
Fix comments for exported funcs/vars/consts (#2938)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2021-04-14 14:55:23 -07:00
Bogdan Drutu a409f2a1da
Remove duplicate metrics from memorylimiter (#2841)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2021-04-02 15:03:54 -07:00
gregoryfranklin 49ddca96c1
Support max batch size for logs (#2736) 2021-03-24 12:41:34 -07:00
Bogdan Drutu 0c6757ec71
Rename [Traces|Metrics|Logs]Consumer to [Traces|Metrics|Logs] (#2761)
* Rename [Traces|Metrics|Logs]Consumer to [Traces|Metrics|Logs]

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

* Update internal/testcomponents/example_exporter.go

Co-authored-by: Tigran Najaryan <4194920+tigrannajaryan@users.noreply.github.com>

Co-authored-by: Tigran Najaryan <4194920+tigrannajaryan@users.noreply.github.com>
2021-03-23 08:04:44 -07:00
Bogdan Drutu 94a6cdde67
Rename pdata Size to OtlpProtoSize, fix some other comments (#2726)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2021-03-19 14:30:25 -04:00
Bogdan Drutu 85804ff257
Rename pdata.Logs.SizeBytes to Size, consistent with metrics/traces (#2694)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2021-03-17 15:21:25 -07:00
Tigran Najaryan 0961efb54f
Fix Shutdown behavior for batchprocessor (#2537)
I added a Shutdown() test that does basic verification of the behavior of the
Shutdown() function. More verifications can be added later.

The test revealed a bug in batchprocessor Shutdown() function which would
not wait until all pending data was drained.
2021-03-02 13:43:58 -05:00
Daniel Dyla e479242ac7
Support max batch size for metrics (#2422)
* Support max batch size for metrics

* send batch max supported by trace and metric

* Avoid extra allocations
2021-02-09 12:28:23 -08:00
Ben Keith ab843b20c2
batchprocessor: Fix shutdown race (#1967)
The newItem channel cannot be closed ever since Shutdown is not
guaranteed to be called after all Consume* calls to the same processor.

Even after Shutdown is finished, there is not hard guarantee that
nothing will ever call Consume*, so we need to just leave the channel
open until GC will clean it up.
2020-11-03 10:00:41 -08:00
Bogdan Drutu a3fa0a9166
Rename processor component.TraceProcessor to component.TracesProcessor, and equivalent Create method feature request (#2026)
Fixes #1975

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2020-10-28 18:11:25 -04:00