Skip to content
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

Fix: correct the value of otelcol_exporter_send_failed_requests #4629

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

- Fix merge config map provider to close the watchers (#4570)
- Fix expand map provider to call close on the base provider (#4571)
- Fix correct the value of `otelcol_exporter_send_failed_requests` (#4629)
- `otlp` receiver: Fix legacy port cfg value override and HTTP server starting bug (#4631)

## v0.41.0 Beta
Expand Down
6 changes: 5 additions & 1 deletion obsreport/obsreport_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ func (exp *Exporter) recordMetrics(ctx context.Context, numSent, numFailedToSend
return
}
// Ignore the error for now. This should not happen.
_ = stats.RecordWithTags(ctx, exp.mutators, sentMeasure.M(numSent), failedToSendMeasure.M(numFailedToSend))
if numFailedToSend > 0 {
_ = stats.RecordWithTags(ctx, exp.mutators, sentMeasure.M(numSent), failedToSendMeasure.M(numFailedToSend))
bogdandrutu marked this conversation as resolved.
Show resolved Hide resolved
} else {
_ = stats.RecordWithTags(ctx, exp.mutators, sentMeasure.M(numSent))
}
}

func endSpan(ctx context.Context, err error, numSent, numFailedToSend int64, sentItemsKey, failedToSendItemsKey string) {
Expand Down
27 changes: 18 additions & 9 deletions obsreport/obsreporttest/obsreporttest.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,27 +105,36 @@ func SetupTelemetry() (TestTelemetry, error) {
// When this function is called it is required to also call SetupTelemetry as first thing.
func CheckExporterTraces(_ TestTelemetry, exporter config.ComponentID, sentSpans, sendFailedSpans int64) error {
exporterTags := tagsForExporterView(exporter)
return multierr.Combine(
checkValueForView(exporterTags, sentSpans, "exporter/sent_spans"),
checkValueForView(exporterTags, sendFailedSpans, "exporter/send_failed_spans"))
if sendFailedSpans > 0 {
return multierr.Combine(
checkValueForView(exporterTags, sentSpans, "exporter/sent_spans"),
checkValueForView(exporterTags, sendFailedSpans, "exporter/send_failed_spans"))
}
return checkValueForView(exporterTags, sentSpans, "exporter/sent_spans")
}

// CheckExporterMetrics checks that for the current exported values for metrics exporter metrics match given values.
// When this function is called it is required to also call SetupTelemetry as first thing.
func CheckExporterMetrics(_ TestTelemetry, exporter config.ComponentID, sentMetricsPoints, sendFailedMetricsPoints int64) error {
exporterTags := tagsForExporterView(exporter)
return multierr.Combine(
checkValueForView(exporterTags, sentMetricsPoints, "exporter/sent_metric_points"),
checkValueForView(exporterTags, sendFailedMetricsPoints, "exporter/send_failed_metric_points"))
if sendFailedMetricsPoints > 0 {
return multierr.Combine(
checkValueForView(exporterTags, sentMetricsPoints, "exporter/sent_metric_points"),
checkValueForView(exporterTags, sendFailedMetricsPoints, "exporter/send_failed_metric_points"))
}
return checkValueForView(exporterTags, sentMetricsPoints, "exporter/sent_metric_points")
}

// CheckExporterLogs checks that for the current exported values for logs exporter metrics match given values.
// When this function is called it is required to also call SetupTelemetry as first thing.
func CheckExporterLogs(_ TestTelemetry, exporter config.ComponentID, sentLogRecords, sendFailedLogRecords int64) error {
exporterTags := tagsForExporterView(exporter)
return multierr.Combine(
checkValueForView(exporterTags, sentLogRecords, "exporter/sent_log_records"),
checkValueForView(exporterTags, sendFailedLogRecords, "exporter/send_failed_log_records"))
if sendFailedLogRecords > 0 {
return multierr.Combine(
checkValueForView(exporterTags, sentLogRecords, "exporter/sent_log_records"),
checkValueForView(exporterTags, sendFailedLogRecords, "exporter/send_failed_log_records"))
}
return checkValueForView(exporterTags, sentLogRecords, "exporter/sent_log_records")
}

// CheckProcessorTraces checks that for the current exported values for trace exporter metrics match given values.
Expand Down