1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-28 21:09:17 +02:00
Commit Graph

12 Commits

Author SHA1 Message Date
Robert Pająk
69e235829e
sdk/log: SimpleProcessor synchronizes OnEmit calls (#5666)
From
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/sdk.md#export:

> `Export` will never be called concurrently for the same exporter
instance.

From our SDK perspective this change will make
https://pkg.go.dev/go.opentelemetry.io/otel/exporters/stdout/stdoutlog
concurrent-safe when used with the simple processor. Before the change,
there can be multiple goroutines calling `Write` in parallel (via
`json.Encoder.Encode`).

### Remarks

[Maybe we should simply state that "whole" exporter implementation does
not need to be
concurrent-safe?](https://github.com/open-telemetry/opentelemetry-specification/pull/4173#discussion_r1699958752)
However:
1. we would need to make complex changes in `BatchExporter` to
synchronize the `Export`, `Shutdown`, `ForceFlush` calls
2. we would need to update all exporters (remove synchronization) and
simple exporter (add locks to `Shutdown`, `ForceFlush`)
3. I am 100% not sure if this would be compliant with the specification
- I think it would be complaint because we would simply give stronger
safety-measures


We should probably discuss it separately, but I wanted to highlight my
though process.
Even if we decide that simple and batch processors to synchronize all
calls then I would prefer to address it in a separate PR.

Related spec clarification PR:
-
https://github.com/open-telemetry/opentelemetry-specification/pull/4173
2024-08-09 08:40:39 +02:00
Robert Pająk
5edfc73c67
Fix interfaces doc formatting (#5658)
The methods should be separated by lines if there are GoDoc comments.
2024-08-05 21:14:00 +02:00
renovate[bot]
7c5e64cccc
chore(deps): update dependency codespell to v2.3.0 (#5409)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
2024-05-24 18:09:31 +02:00
Tyler Yahn
4af9c20a80
Implement the BatchingProcessor (#5093)
* [WIP] Implement the BatchingProcessor

* Add TestExportSync

* Add TestChunker

* Test export error default to ErrorHandler

* Fix lint

* Fix chunk smaller than size error

* Add batch tests

* Fix lint

* Update OnEmit test

Check the len of records in eventually assertion given that is what we
are going to measure.

* Revert unneeded change to BatchingProcessor doc

* Add batch type

* Refactor testing of batching config

The BatchingProcessor is not expected to ultimately contain
configuration fields for queue size or export parameters (see #5093).
This will break TestNewBatchingProcessorConfiguration which tests the
configuration by evaluating the BatchingProcessor directly.

Instead, test the batchingConfig and rename the test to
TestNewBatchingConfig to match what is being tested.

* Implement the BatchingProcessor without polling

* Add TestBatchingProcessor

* Add ConcurrentSafe test

* Expand Shutdown tests

* Test context canceled for ForceFlush

* Refactor batch to queue

* Use exportSync

* Update docs and naming

* Split buffered export to its own type

* Update comments and naming

* Fix lint

* Remove redundant triggered type

* Add interval polling

* Refactor test structure

* Add custom ring implimementation

* Add BenchmarkBatchingProcessor

* Fix merge

* Remove custom ring impl

* Remove BenchmarkBatchingProcessor

* Update dev docs

* Test nil exporter

* Update OnEmit test

Ensure the poll goroutine will completely flush the queue of batches.

* Test RetriggerFlushNonBlocking

* Update ascii diagram

* Fix flaky OnEmit

* Revert unnecessary change to test pkg name

* Use batching term in docs

* Document EnqueueExport

* Return from EnqueueExport if blocked

Do not wait for the enqueue to succeed.

* Do not drop failed flush log records

* Use cancelable ctx in concurrency test

* Fix comments

* Apply feedback

Do not spawn a goroutine for the flush operation.

* Return true from EnqueueExport when stopped

* Update sdk/log/batch.go

Co-authored-by: Robert Pająk <pellared@hotmail.com>

* Remove TODO

* Comment re-trigger in poll

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
2024-04-18 07:48:19 -07:00
Robert Pająk
b9752eb5dc
sdk/log: Exporter has to be concurrent-safe (#5181) 2024-04-09 10:22:50 +02:00
Tyler Yahn
5449f083aa
Add the bufferExporter (#5119)
* Add the bufferExporter

* Fix TestExportSync

Reset default ErrorHandler

* Comment

* Clean up tests

* Remove context arg from EnqueueExport

* Join wrapped exporter error
2024-04-02 08:36:18 -07:00
Tyler Yahn
c4dffbf888
Add chunkExporter (#5104)
* Add chunker exporter

The batching log processor needs to be able to export payloads in
chuncks. This adds a chunker type that will forward all Shutdown and
ForceFlush calls to the embedded exporter and chunk data passed to
Export.

* Concurrent safe testExporter

* Add test for zero size

* Fix lint

* Refactor chunker into chunkExporter

* Remove ExportTrigger
2024-04-02 07:44:38 -07:00
Tyler Yahn
bddfbc68ca
Add timeoutExporter (#5118) 2024-04-01 09:17:07 -07:00
Tyler Yahn
321219b2a6
Add export sync (#5105)
* Add export sync

The batching log processor will generate records from 4 different
locations (polling, OnEmit, ForceFlush, Shutdown). In order to ensure an
Exporter is called serially, as is required by the interface, this
function will be used in the processor to centralize the interaction
with its Exporter.

Part of #5063.

See #5093 for the implementation use.

* Concurrent safe testExporter

---------

Co-authored-by: Sam Xie <sam@samxie.me>
2024-03-27 11:45:35 -07:00
Tyler Yahn
12c5651ec7
Do not alloc multiple noop exporters (#5083) 2024-03-19 10:33:57 -07:00
Tyler Yahn
3542ee68a9
Implement the SimpleProcessor (#5079)
* Implement the SimpleProcessor

* Add BenchmarkSimpleProcessorOnEmit

* Remove stale comment

* Run benchmarks in parallel
2024-03-17 07:47:05 -07:00
Robert Pająk
54b6ee4174
sdk/log: Scaffolding (#5068) 2024-03-13 17:47:07 +01:00