-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Stdoutlog exporter metrics #7351
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
base: main
Are you sure you want to change the base?
Stdoutlog exporter metrics #7351
Conversation
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.
Review only the functional parts; the unit tests will be reviewed after the functional adjustments.
|
||
e.inst.inflightMetric.Add(ctx, count, e.inst.attrs...) | ||
|
||
bufPtrAny := attrPool.Get() |
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.
Can we refer to the standard for the changes in this section: https://github.com/open-telemetry/opentelemetry-go/blob/main/CONTRIBUTING.md#attribute-and-option-allocation-management
CHANGELOG.md
Outdated
### Added | ||
|
||
- Add experimental self-observability log exporter metrics in `go.opentelemetry.io/otel/exporters/stdout/stdoutlog`. | ||
Check the `go.opentelemetry.io/otel/exporters/stdout/stdoutlog/internal/x` package documentation for more information. |
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.
Check the `go.opentelemetry.io/otel/exporters/stdout/stdoutlog/internal/x` package documentation for more information. | |
Check the `go.opentelemetry.io/otel/exporters/stdout/stdoutlog/internal/x` package documentation for more information. (#7351) |
CHANGELOG.md
Outdated
|
||
### Added | ||
|
||
- Add experimental self-observability log exporter metrics in `go.opentelemetry.io/otel/exporters/stdout/stdoutlog`. |
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.
Usually we place it at the very bottom of this small node.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7351 +/- ##
======================================
Coverage 85.5% 85.5%
======================================
Files 278 281 +3
Lines 24654 24808 +154
======================================
+ Hits 21088 21224 +136
- Misses 3187 3200 +13
- Partials 379 384 +5
🚀 New features to boost your workflow:
|
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 take a look at the project guidelines regarding observability. The check list for the issue this is resolving should all be checked and completed before this PR is ready to be reviewed.
CHANGELOG.md
Outdated
|
||
### Added | ||
|
||
- Add experimental self-observability log exporter metrics in `go.opentelemetry.io/otel/exporters/stdout/stdoutlog`. |
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 experimental self-observability log exporter metrics in `go.opentelemetry.io/otel/exporters/stdout/stdoutlog`. | |
- Add experimental observability for the log exporter in `go.opentelemetry.io/otel/exporters/stdout/stdoutlog`. |
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.
Do not use the term "self observability". It should just be "observability".
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.
This has not been addressed.
Signed-off-by: Praful <holiodin@gmail.com>
Signed-off-by: Praful <holiodin@gmail.com>
Signed-off-by: Praful <holiodin@gmail.com>
…internal/x Signed-off-by: Praful <holiodin@gmail.com>
Signed-off-by: Praful <holiodin@gmail.com> follow existing convention for including experimental features in an internal/x Signed-off-by: Praful <holiodin@gmail.com>
Signed-off-by: Praful <holiodin@gmail.com>
Signed-off-by: Praful <holiodin@gmail.com> fix: resolve linter err Signed-off-by: Praful <holiodin@gmail.com>
…servability Signed-off-by: Praful <holiodin@gmail.com> refactor: test case from TestSelfObservability to TestNewSelfObservability Signed-off-by: Praful <holiodin@gmail.com>
…rvability Signed-off-by: Praful <holiodin@gmail.com>
…contributing guidelines Signed-off-by: Praful Khanduri <holiodin@gmail.com> added chloggen Signed-off-by: Praful Khanduri <holiodin@gmail.com> fix: return err Signed-off-by: Praful Khanduri <holiodin@gmail.com>
Signed-off-by: Praful <holiodin@gmail.com>
ada09f6
to
6eac6ed
Compare
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.
Thank you for the contribution. Please see the instrumentation checklist and the project instrumentation guidelines. Please ensure that these things are followed and the PR is updated to address all the mentioned issues.
// Version is the current version of this instrumentation. | ||
// | ||
// This matches the version of the exporter. | ||
Version = internal.Version |
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.
This adds to the public API of the package, it should not be exported.
It does not seem needed either. Using just internal.Version
should be adequate.
|
||
// otelComponentType is a name identifying the type of the OpenTelemetry component. | ||
const ( | ||
otelComponentType = "go.opentelemetry.io/otel/exporters/stdout/stdoutlog" |
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.
This should be defined in observ
not here. It is only used there and passed from here. This is an unneeded coupling.
|
||
// Export exports log records to writer. | ||
func (e *Exporter) Export(ctx context.Context, records []log.Record) error { | ||
if inst := e.instrumentation; inst != nil { |
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.
Just shorten the field name to inst
if you want to do things like this.
if inst := e.instrumentation; inst != nil { | ||
done := inst.ExportLogs(ctx, len(records)) | ||
exported, err := e.exportRecords(ctx, records) | ||
done(exported, err) | ||
return err | ||
} | ||
|
||
_, err := e.exportRecords(ctx, records) | ||
return err |
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.
This should not be needed to be called in two different code paths. Use defer
:
if inst := e.instrumentation; inst != nil { | |
done := inst.ExportLogs(ctx, len(records)) | |
exported, err := e.exportRecords(ctx, records) | |
done(exported, err) | |
return err | |
} | |
_, err := e.exportRecords(ctx, records) | |
return err | |
var n int64 | |
var err error | |
if inst := e.instrumentation; inst != nil { | |
done := inst.ExportLogs(ctx, len(records)) | |
defer func() { done(n, err) }() | |
} | |
n, err = e.exportRecords(ctx, records) | |
return err |
"go.opentelemetry.io/otel/exporters/stdout/stdoutlog/internal/counter" | ||
"go.opentelemetry.io/otel/log" | ||
"go.opentelemetry.io/otel/sdk/instrumentation" | ||
sdkinstrumentation "go.opentelemetry.io/otel/sdk/instrumentation" |
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.
Why rename the package import?
var exportedMetric metricdata.Metrics | ||
exportedInstrument := otelconv.SDKExporterLogExported{} | ||
for _, m := range got.Metrics { | ||
if m.Name == exportedInstrument.Name() { | ||
exportedMetric = m | ||
break | ||
} | ||
} | ||
require.NotEmpty(t, exportedMetric, "exported metric not found") | ||
|
||
data := exportedMetric.Data.(metricdata.Sum[int64]) | ||
require.Len(t, data.DataPoints, 1) | ||
|
||
dataPoint := data.DataPoints[0] | ||
assert.Equal(t, int64(2), dataPoint.Value) |
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.
This is an incomplete evaluation of what is expected. A full test needs to be done for this testing scenario.
// ExportLogs instruments the exporter Export method. It returns a callback that | ||
// MUST be invoked when the export completes with the number of successfully | ||
// exported records and the resulting error. | ||
func (i *Instrumentation) ExportLogs(ctx context.Context, total int) ExportLogsDone { |
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.
Returning ExportLogsDone
will add an additional allocation.
Benchmarking should be done to evaluate switching to a solution similar to
opentelemetry-go/exporters/stdout/stdouttrace/internal/observ/instrumentation.go
Line 150 in 5f5f4af
func (i *Instrumentation) ExportSpans(ctx context.Context, nSpans int) ExportOp { |
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.
There are no tests or benchmarks for this instrumentation or package.
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.
This has not been addressed.
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 revert these changes. They do not belong this PR.
This PR adds self-observability metrics to the
stdoutlog
exporter, gated by the environment variable:What's added
otel.sdk.exporter.log.inflight
otel.sdk.exporter.log.exported
(success and error support)otel.sdk.exporter.operation.duration
🔗 Related Issues & PRs