Commit Graph

22 Commits

Author SHA1 Message Date
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 d39dd7a13a
[chore] Move test code under _test (#11621)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-11-07 12:25:14 -08:00
Matthieu MOREL e053173aed
[chore]: enable perfsprint linter (#11599)
#### Description

[perfsprint](https://golangci-lint.run/usage/linters/#perfsprint) checks
that fmt.Sprintf can be replaced with a faster alternative.

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-11-05 14:37:07 -08:00
Matthieu MOREL 0204d957e5
[chore]: enable whitespace linter (#11579)
#### Description

[whitespace](https://golangci-lint.run/usage/linters/#whitespace) is a
linter that checks for unnecessary newlines at the start and end of
functions.

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-31 12:15:54 -07:00
Sindy Li ef79a0e1a9
[exporterqueue][chore] Moving queue start and shutdown out side of queue consumer (#11534)
#### Description

This PR moves queue start and shutdown outside of queue consumer.

Consumer should be in charge of "consuming" the queue but not managing
the life cycle.
2024-10-24 16:58:47 -07:00
Bogdan Drutu 4f2a8d3ef0
[chore] Remove unused/unnecessary queue.Sizer types (#11455)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-10-15 19:37:48 -07:00
renovate[bot] 49f657f6a7
fix(deps): update module github.com/golangci/golangci-lint to v1.61.0 (#10935)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[github.com/golangci/golangci-lint](https://redirect.github.com/golangci/golangci-lint)
| `v1.60.1` -> `v1.61.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fgolangci%2fgolangci-lint/v1.61.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fgolangci%2fgolangci-lint/v1.61.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fgolangci%2fgolangci-lint/v1.60.1/v1.61.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fgolangci%2fgolangci-lint/v1.60.1/v1.61.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>golangci/golangci-lint
(github.com/golangci/golangci-lint)</summary>

###
[`v1.61.0`](https://redirect.github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v1610)

[Compare
Source](https://redirect.github.com/golangci/golangci-lint/compare/v1.60.3...v1.61.0)

1.  Enhancements
    -   Add `junit-xml-extended` format
    -   Exclude Swagger Codegen files by default
2.  Updated linters
    -   `dupword`: from 0.0.14 to 0.1.1
    -   `fatcontext`: from 0.4.0 to 0.5.2
    -   `gci`: from 0.13.4 to 0.13.5 (new option `no-lex-order`)
- `go-ruleguard`: from 0.4.2 to
[`0fe6f58`](https://redirect.github.com/golangci/golangci-lint/commit/0fe6f58b47b1)
(fix panic with custom linters)
    -   `godot`: from 1.4.16 to 1.4.17
    -   `gomodguard`: from 1.3.3 to 1.3.5
    -   `gosec`: disable temporarily `G407`
- `gosec`: from
[`ab3f6c1`](https://redirect.github.com/golangci/golangci-lint/commit/ab3f6c1c83a0)
to 2.21.2 (partially fix `G115`)
    -   `intrange`: from 0.1.2 to 0.2.0
    -   `nolintlint`: remove the empty line in the directive replacement
3.  Misc.
    -   Improve runtime version parsing
4.  Documentation
    -   Add additional info about `typecheck`

###
[`v1.60.3`](https://redirect.github.com/golangci/golangci-lint/compare/v1.60.2...v1.60.3)

[Compare
Source](https://redirect.github.com/golangci/golangci-lint/compare/v1.60.2...v1.60.3)

###
[`v1.60.2`](https://redirect.github.com/golangci/golangci-lint/compare/v1.60.1...v1.60.2)

[Compare
Source](https://redirect.github.com/golangci/golangci-lint/compare/v1.60.1...v1.60.2)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "on tuesday" (UTC), Automerge - At any
time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/open-telemetry/opentelemetry-collector).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yNi4xIiwidXBkYXRlZEluVmVyIjoiMzguMTE1LjEiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbImRlcGVuZGVuY2llcyIsInJlbm92YXRlYm90Il19-->

---------

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: opentelemetrybot <107717825+opentelemetrybot@users.noreply.github.com>
Co-authored-by: Bogdan Drutu <bogdandrutu@gmail.com>
2024-10-12 16:13:55 -07:00
Sindy Li 28d0d57c35
[exporter] exporter queue Read() (#11396)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

This PR adds a public function `GetNextItem` to queue (both persistent
queue and bounded memory queue)

Why this change?
Instead of blocking until consumption of the item is done, we would like
to separate the API for reading and committing consumption.

Before:
`Consume(consumeFunc)`

After:
`idx, item = Read()`
`OnProcessingFinished(idx)`

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

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

<!--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.-->
2024-10-11 10:17:38 -07: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
Sindy Li fed6dfe76d
[exporter] internal/persistent_queue::OnProcessingFinished is changed to a class function instead of a callback (#11338)
#### Description

Why this change?
Each request from the queue contains multiple items, and those items
could be merge-split into multiple batches when they are sent out (see
https://github.com/open-telemetry/opentelemetry-collector/issues/8122
for more about exporter batcher). We would like to book-keep those
cases, and only call `onProcessingFinished` when all such batches has
gone out. In this PR, `onProcessingFinished` is changed from a callback
to a method function because it is easier to book keep index instead of
functions.

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

#### Testing
`exporter/internal/queue/persistent_queue_test.go`

#### Documentation

This is an internal change invisible to the users.

---------

Co-authored-by: Dmitrii Anoshin <anoshindx@gmail.com>
2024-10-04 19:59:22 -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
Alex Boten fbffbb0820
[chore] small test improvements (#11211)
Clean up some inconsistencies in the test code across the components.

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2024-09-18 13:47:25 -07:00
Matthieu MOREL 51f321ad53
[chore]: enable go-require rule from testifylint (#11174)
#### Description

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

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

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-09-17 11:17:17 -07:00
Eric L 2c22ed77c1
return queue is full error if sized_channel is full (#11063)
#### Description
This change fixes a potential deadlock bug for persistent queue.

There is a race condition in persistent queue that caused `used` in
`sizedChannel` to become out of sync with `ch` len. This causes `Offer`
to be deadlocked in specific race condition. For example:
1. Multiple consumers are calling Consume
2. Multiple producers are calling Offer to insert into the queue
  a. All elements are taken from consumers. ch is empty
3. One consumer completes consume, calls onProcessingFinished
a. Inside sizedChannel, syncSize is invoked, used is reset to 0 when
other consumers are still waiting for lock to consume
4. More Offer is called inserting elements -> used and ch len should
equal
5. As step 3a consumers completes, used is decreased -> used is lower
than ch len
a. More Offer is called inserting since used is below capacity. however,
ch is full.
b. goroutine calling offer is holding the mutex but can’t release it as
ch is full.
c. no consumer can acquire mutex to complete previous
onProcessingFinished

This change returns an error if channel is full instead of waiting for
it to unblock.

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

#### Testing
- Added concurrent test in persistent queue that can reproduce the
problem(note: need to re-run it 100 times as the race condition is not
consistent).
- Added unit test for sizedChannel

#### Documentation
Added comment in the block explaining it

---------

Co-authored-by: Dmitrii Anoshin <anoshindx@gmail.com>
2024-09-06 13:03:00 -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
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
Dmitrii Anoshin b7b7e51d1d
[chore] [exporterhelper] Integrate capacity limiting into the communication channel (#9232)
Integrate capacity limiting into internal channels used by both memory
and persistent queues. Otherwise, with the independent capacity limiter,
it's hard to ensure that queue size is always accurate going forward.

Benchmarks before:
```
goos: darwin
goarch: arm64
Benchmark_QueueUsage_1000_requests-10      	    3252	    325010 ns/op	  246059 B/op	      10 allocs/op
Benchmark_QueueUsage_100000_requests-10    	      39	  29811116 ns/op	24002870 B/op	      10 allocs/op
Benchmark_QueueUsage_10000_items-10        	    3404	    349753 ns/op	  246052 B/op	      10 allocs/op
Benchmark_QueueUsage_1M_items-10           	      40	  29415583 ns/op	24002858 B/op	      10 allocs/op
BenchmarkPersistentQueue_TraceSpans
BenchmarkPersistentQueue_TraceSpans/#traces:_1_#spansPerTrace:_1-10         	  338180	      3836 ns/op	    2851 B/op	      78 allocs/op
BenchmarkPersistentQueue_TraceSpans/#traces:_1_#spansPerTrace:_10-10        	   81369	     15822 ns/op	   14598 B/op	     289 allocs/op
BenchmarkPersistentQueue_TraceSpans/#traces:_10_#spansPerTrace:_10-10       	   13066	     90155 ns/op	  130087 B/op	    2417 allocs/op
```

Benchmarks after:
```
Benchmark_QueueUsage_1000_requests-10      	    4210	    278175 ns/op	  246055 B/op	      10 allocs/op
Benchmark_QueueUsage_100000_requests-10    	      42	  25835945 ns/op	24002968 B/op	      10 allocs/op
Benchmark_QueueUsage_10000_items-10        	    4376	    279571 ns/op	  246056 B/op	      10 allocs/op
Benchmark_QueueUsage_1M_items-10           	      42	  26483907 ns/op	24002995 B/op	      10 allocs/op
BenchmarkPersistentQueue_TraceSpans
BenchmarkPersistentQueue_TraceSpans/#traces:_1_#spansPerTrace:_1-10         	  328268	      4251 ns/op	    2854 B/op	      78 allocs/op
BenchmarkPersistentQueue_TraceSpans/#traces:_1_#spansPerTrace:_10-10        	  101683	     12238 ns/op	   14582 B/op	     289 allocs/op
BenchmarkPersistentQueue_TraceSpans/#traces:_10_#spansPerTrace:_10-10       	   13382	     86464 ns/op	  130154 B/op	    2417 allocs/op
```
2024-05-04 09:20:48 -07:00
Dmitrii Anoshin cc88aee675
[chore] [exporterhelper] Move shutdown error from queue package (#9554)
The error is created by the retry sender and used by the queue sender.
It doesn't belong to queue package
2024-02-13 16:04:23 -08: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
Alex Boten 4688461318
[chore] fix unused params (#9578)
Related to #9577

Signed-off-by: Alex Boten <aboten@lightstep.com>
2024-02-13 11:04:48 -08:00
Dmitrii Anoshin bdbb5f3d51
[exporterhelper] Add WithRequestQueue option to the exporter (#8853)
Introduce a way to enable queue in the new exporter helper with a
developer interface suggested in
https://github.com/open-telemetry/opentelemetry-collector/pull/8248#discussion_r1302102261.

The new configuration interface for the end users provides a new
`queue_size_items` option to limit the queue by a number of spans, log
records, or metric data points. The previous way to limit the queue by
number of requests is preserved under the same field, `queue_size,`
which will later be deprecated through a longer transition process.

Tracking issue:
https://github.com/open-telemetry/opentelemetry-collector/issues/8122
2024-02-03 09:24:05 -08:00