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

[exporterhelper] Add exporter dropped metrics #11077

Closed
Closed
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
25 changes: 25 additions & 0 deletions .chloggen/exporter-dropped-metric.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Adds `exporter_dropped_spans`, `exporter_dropped_metric_points`, and `exporter_dropped_log_records` to record when an exporter has dropped data forever.

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

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
24 changes: 24 additions & 0 deletions exporter/exporterhelper/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,30 @@

The following telemetry is emitted by this component.

### otelcol_exporter_dropped_log_records

Number of log records dropped after failing to export.

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| {records} | Sum | Int | true |

### otelcol_exporter_dropped_metric_points

Number of metric points dropped after failing to export.

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| {datapoints} | Sum | Int | true |

### otelcol_exporter_dropped_spans

Number of spans dropped after failing to export.

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| {spans} | Sum | Int | true |

### otelcol_exporter_enqueue_failed_log_records

Number of log records failed to be added to the sending queue.
Expand Down
13 changes: 13 additions & 0 deletions exporter/exporterhelper/internal/base_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func NewBaseExporter(set exporter.Settings, signal component.DataType, osf Obsre
func (be *BaseExporter) Send(ctx context.Context, req internal.Request) error {
err := be.QueueSender.Send(ctx, req)
if err != nil {
recordDroppedMetric(ctx, be.Obsrep, int64(req.ItemsCount()))
be.Set.Logger.Error("Exporting failed. Rejecting data."+be.ExportFailureMessage,
zap.Error(err), zap.Int("rejected_items", req.ItemsCount()))
}
Expand Down Expand Up @@ -339,3 +340,15 @@ func CheckStatus(t *testing.T, sd sdktrace.ReadOnlySpan, err error) {
require.Equal(t, codes.Unset, sd.Status().Code, "SpanData %v", sd)
}
}

func recordDroppedMetric(ctx context.Context, obsrep *ObsReport, count int64) {
if obsrep.DataType == component.DataTypeTraces {
obsrep.TelemetryBuilder.ExporterDroppedSpans.Add(ctx, count)
}
if obsrep.DataType == component.DataTypeMetrics {
obsrep.TelemetryBuilder.ExporterDroppedMetricPoints.Add(ctx, count)
}
if obsrep.DataType == component.DataTypeLogs {
obsrep.TelemetryBuilder.ExporterDroppedLogRecords.Add(ctx, count)
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions exporter/exporterhelper/internal/queue_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func NewQueueSender(q exporterqueue.Queue[internal.Request], set exporter.Settin
consumeFunc := func(ctx context.Context, req internal.Request) error {
err := qs.NextSender.Send(ctx, req)
if err != nil {
recordDroppedMetric(ctx, qs.obsrep, int64(req.ItemsCount()))
set.Logger.Error("Exporting failed. Dropping data."+exportFailureMessage,
zap.Error(err), zap.Int("dropped_items", req.ItemsCount()))
}
Expand Down
24 changes: 24 additions & 0 deletions exporter/exporterhelper/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,27 @@ telemetry:
gauge:
value_type: int
async: true

exporter_dropped_spans:
enabled: true
description: Number of spans dropped after failing to export.
unit: "{spans}"
sum:
value_type: int
monotonic: true

exporter_dropped_metric_points:
enabled: true
description: Number of metric points dropped after failing to export.
unit: "{datapoints}"
sum:
value_type: int
monotonic: true

exporter_dropped_log_records:
enabled: true
description: Number of log records dropped after failing to export.
unit: "{records}"
sum:
value_type: int
monotonic: true
Loading