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 otelcol_exporter_send_failed_requests count error #7527

Merged
merged 1 commit into from
Apr 24, 2023
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
12 changes: 12 additions & 0 deletions .chloggen/fix-send_failed_requests-counter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: obsreport

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: fix issue where send_failed_requests counter was reporting an incorrect value.

# One or more tracking issues or pull requests related to the change
issues: [7456]

17 changes: 12 additions & 5 deletions obsreport/obsreport_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,18 @@ func (exp *Exporter) recordWithOC(ctx context.Context, dataType component.DataTy
failedMeasure = obsmetrics.ExporterFailedToSendLogRecords
}

_ = stats.RecordWithTags(
ctx,
exp.mutators,
sentMeasure.M(sent),
failedMeasure.M(failed))
if failed > 0 {
_ = stats.RecordWithTags(
ctx,
exp.mutators,
sentMeasure.M(sent),
failedMeasure.M(failed))
} else {
_ = stats.RecordWithTags(
ctx,
exp.mutators,
sentMeasure.M(sent))
}
}

func endSpan(ctx context.Context, err error, numSent, numFailedToSend int64, sentItemsKey, failedToSendItemsKey string) {
Expand Down
24 changes: 18 additions & 6 deletions obsreport/obsreporttest/otelprometheuschecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,35 @@ func (pc *prometheusChecker) checkProcessorLogs(processor component.ID, accepted

func (pc *prometheusChecker) checkExporterTraces(exporter component.ID, sentSpans, sendFailedSpans int64) error {
exporterAttrs := attributesForExporterMetrics(exporter)
if sendFailedSpans > 0 {
return multierr.Combine(
pc.checkCounter("exporter_sent_spans", sentSpans, exporterAttrs),
pc.checkCounter("exporter_send_failed_spans", sendFailedSpans, exporterAttrs))
}
return multierr.Combine(
pc.checkCounter("exporter_sent_spans", sentSpans, exporterAttrs),
pc.checkCounter("exporter_send_failed_spans", sendFailedSpans, exporterAttrs))
pc.checkCounter("exporter_sent_spans", sentSpans, exporterAttrs))
}

func (pc *prometheusChecker) checkExporterLogs(exporter component.ID, sentLogRecords, sendFailedLogRecords int64) error {
exporterAttrs := attributesForExporterMetrics(exporter)
if sendFailedLogRecords > 0 {
return multierr.Combine(
pc.checkCounter("exporter_sent_log_records", sentLogRecords, exporterAttrs),
pc.checkCounter("exporter_send_failed_log_records", sendFailedLogRecords, exporterAttrs))
}
return multierr.Combine(
pc.checkCounter("exporter_sent_log_records", sentLogRecords, exporterAttrs),
pc.checkCounter("exporter_send_failed_log_records", sendFailedLogRecords, exporterAttrs))
pc.checkCounter("exporter_sent_log_records", sentLogRecords, exporterAttrs))
}

func (pc *prometheusChecker) checkExporterMetrics(exporter component.ID, sentMetricPoints, sendFailedMetricPoints int64) error {
exporterAttrs := attributesForExporterMetrics(exporter)
if sendFailedMetricPoints > 0 {
return multierr.Combine(
pc.checkCounter("exporter_sent_metric_points", sentMetricPoints, exporterAttrs),
pc.checkCounter("exporter_send_failed_metric_points", sendFailedMetricPoints, exporterAttrs))
}
return multierr.Combine(
pc.checkCounter("exporter_sent_metric_points", sentMetricPoints, exporterAttrs),
pc.checkCounter("exporter_send_failed_metric_points", sendFailedMetricPoints, exporterAttrs))
pc.checkCounter("exporter_sent_metric_points", sentMetricPoints, exporterAttrs))
}

func (pc *prometheusChecker) checkCounter(expectedMetric string, value int64, attrs []attribute.KeyValue) error {
Expand Down