-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exporters: add otlplogfile exporter #5743
base: main
Are you sure you want to change the base?
exporters: add otlplogfile exporter #5743
Conversation
02d2dab
to
64ee265
Compare
This commit adds a new experimental exporter `otlplogfile`, that outputs log records to a JSON line file. It is based on the following specification: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/file-exporter.md Signed-off-by: thomasgouveia <[email protected]>
Signed-off-by: thomasgouveia <[email protected]>
Signed-off-by: thomasgouveia <[email protected]>
Signed-off-by: thomasgouveia <[email protected]>
64ee265
to
37c4f5e
Compare
} | ||
|
||
// As stated in the specification, line separator is \n. | ||
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/file-exporter.md#json-lines-file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/file-exporter.md#json-lines-file | |
// https://github.com/open-telemetry/opentelemetry-specification/blob/v1.36.0/specification/protocol/file-exporter.md#json-lines-file |
Co-authored-by: Damien Mathieu <[email protected]>
Co-authored-by: Damien Mathieu <[email protected]>
Signed-off-by: thomasgouveia <[email protected]>
… f-add-otlplogfile-exporter
|
||
// WithWriter configures the destination where the exporter should output | ||
// the records. By default, if not specified, stdout is used. | ||
func WithWriter(w io.WriteCloser) Option { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exporter must not be responsible for closing the writer (like e.g. stdoutlog
)
Would you want to close stdout? Or what if someone uses one file for multiple purposes?
The caller should be responsible for closing the writer.
|
||
// WithFile configures a file where the records will be exported. | ||
// An error is returned if the file could not be created or opened. | ||
func WithFile(path string) Option { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need such option.
) | ||
|
||
// Option configures a field of the configuration or return an error if needed. | ||
type Option func(*config) (*config, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please implement Option
as described in https://github.com/open-telemetry/opentelemetry-go/blob/main/CONTRIBUTING.md#option. Consistency makes the maintenance easier for us.
) | ||
|
||
// Writer writes data to the configured io.WriteCloser. | ||
// It is buffered to reduce I/O operations to improve performance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Processors e.g. BatchProcessor
(see here) are responsible for buffering. Can we remove the WithFlushInterval
option and startFlusher
? The user can do it by himself, It is good enough if exporter.ForceFlush
will call a Flush
.
@@ -8,6 +8,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm | |||
|
|||
## [Unreleased] | |||
|
|||
### Added | |||
|
|||
- Add `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlplogfile ` experimental logs exporter. (#5743) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Add `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlplogfile ` experimental logs exporter. (#5743) | |
- Add `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlplogfile` experimental OTLP logs file exporter. (#5743) | |
I do not think we should accept this change. It adds an exporter that has not been stabilized at the specification level. This addition will add churn to our stabilization efforts of the log signal. I do not see why this cannot live in a fork as a PoC for the specification, or as an independent repository with its own maintainers outside of OTel. Adding this to the OTel development teams maintenance burden does not seem warranted at this time. |
From the SIG meeting:
|
Changing to draft as there is not work here currently. |
This PR introduces an experimental
otlplogfile
exporter based on the following specification: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/file-exporter.md.For the implementation, I decided to use a buffered file writer based on the existing fileexporter available in the opentelemetry-collector to reduce I/O and improve performance. Below is benchmark result:
To serialize the records to the OTLP JSON format, I used
protojson
.Closes #5408