Skip to content

Commit

Permalink
[processorhelper] remove deprecated funcs (#11151)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
codeboten authored Sep 12, 2024
1 parent e17f728 commit 3bcb341
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 194 deletions.
25 changes: 25 additions & 0 deletions .chloggen/main.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: breaking

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Remove deprecated `[Traces|Metrics|Logs]`Inserted funcs"

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

# (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: []
12 changes: 6 additions & 6 deletions component/componenttest/obsreporttest.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,20 @@ func (tts *TestTelemetry) CheckExporterMetricGauge(metric string, val int64, ext

// CheckProcessorTraces checks that for the current exported values for trace exporter metrics match given values.
// Note: SetupTelemetry must be called before this function.
func (tts *TestTelemetry) CheckProcessorTraces(acceptedSpans, refusedSpans, droppedSpans, insertedSpans int64) error {
return tts.prometheusChecker.checkProcessorTraces(tts.id, acceptedSpans, refusedSpans, droppedSpans, insertedSpans)
func (tts *TestTelemetry) CheckProcessorTraces(acceptedSpans, refusedSpans, droppedSpans int64) error {
return tts.prometheusChecker.checkProcessorTraces(tts.id, acceptedSpans, refusedSpans, droppedSpans)
}

// CheckProcessorMetrics checks that for the current exported values for metrics exporter metrics match given values.
// Note: SetupTelemetry must be called before this function.
func (tts *TestTelemetry) CheckProcessorMetrics(acceptedMetricPoints, refusedMetricPoints, droppedMetricPoints, insertedMetricPoints int64) error {
return tts.prometheusChecker.checkProcessorMetrics(tts.id, acceptedMetricPoints, refusedMetricPoints, droppedMetricPoints, insertedMetricPoints)
func (tts *TestTelemetry) CheckProcessorMetrics(acceptedMetricPoints, refusedMetricPoints, droppedMetricPoints int64) error {
return tts.prometheusChecker.checkProcessorMetrics(tts.id, acceptedMetricPoints, refusedMetricPoints, droppedMetricPoints)
}

// CheckProcessorLogs checks that for the current exported values for logs exporter metrics match given values.
// Note: SetupTelemetry must be called before this function.
func (tts *TestTelemetry) CheckProcessorLogs(acceptedLogRecords, refusedLogRecords, droppedLogRecords, insertedLogRecords int64) error {
return tts.prometheusChecker.checkProcessorLogs(tts.id, acceptedLogRecords, refusedLogRecords, droppedLogRecords, insertedLogRecords)
func (tts *TestTelemetry) CheckProcessorLogs(acceptedLogRecords, refusedLogRecords, droppedLogRecords int64) error {
return tts.prometheusChecker.checkProcessorLogs(tts.id, acceptedLogRecords, refusedLogRecords, droppedLogRecords)
}

// CheckReceiverTraces checks that for the current exported values for trace receiver metrics match given values.
Expand Down
15 changes: 7 additions & 8 deletions component/componenttest/otelprometheuschecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,24 @@ func (pc *prometheusChecker) checkReceiver(receiver component.ID, datatype, prot
pc.checkCounter(fmt.Sprintf("receiver_refused_%s", datatype), droppedMetricPoints, receiverAttrs))
}

func (pc *prometheusChecker) checkProcessorTraces(processor component.ID, accepted, refused, dropped, inserted int64) error {
return pc.checkProcessor(processor, "spans", accepted, refused, dropped, inserted)
func (pc *prometheusChecker) checkProcessorTraces(processor component.ID, accepted, refused, dropped int64) error {
return pc.checkProcessor(processor, "spans", accepted, refused, dropped)
}

func (pc *prometheusChecker) checkProcessorMetrics(processor component.ID, accepted, refused, dropped, inserted int64) error {
return pc.checkProcessor(processor, "metric_points", accepted, refused, dropped, inserted)
func (pc *prometheusChecker) checkProcessorMetrics(processor component.ID, accepted, refused, dropped int64) error {
return pc.checkProcessor(processor, "metric_points", accepted, refused, dropped)
}

func (pc *prometheusChecker) checkProcessorLogs(processor component.ID, accepted, refused, dropped, inserted int64) error {
return pc.checkProcessor(processor, "log_records", accepted, refused, dropped, inserted)
func (pc *prometheusChecker) checkProcessorLogs(processor component.ID, accepted, refused, dropped int64) error {
return pc.checkProcessor(processor, "log_records", accepted, refused, dropped)
}

func (pc *prometheusChecker) checkProcessor(processor component.ID, datatype string, accepted, refused, dropped, inserted int64) error {
func (pc *prometheusChecker) checkProcessor(processor component.ID, datatype string, accepted, refused, dropped int64) error {
processorAttrs := attributesForProcessorMetrics(processor)
return multierr.Combine(
pc.checkCounter(fmt.Sprintf("processor_accepted_%s", datatype), accepted, processorAttrs),
pc.checkCounter(fmt.Sprintf("processor_refused_%s", datatype), refused, processorAttrs),
pc.checkCounter(fmt.Sprintf("processor_dropped_%s", datatype), dropped, processorAttrs),
pc.checkCounter(fmt.Sprintf("processor_inserted_%s", datatype), inserted, processorAttrs),
)
}

Expand Down
6 changes: 3 additions & 3 deletions component/componenttest/otelprometheuschecker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,17 @@ func TestPromChecker(t *testing.T) {
)

assert.NoError(t,
pc.checkProcessorTraces(processor, 42, 13, 7, 5),
pc.checkProcessorTraces(processor, 42, 13, 7),
"metrics from Receiver Traces should be valid",
)

assert.NoError(t,
pc.checkProcessorMetrics(processor, 7, 41, 13, 4),
pc.checkProcessorMetrics(processor, 7, 41, 13),
"metrics from Receiver Metrics should be valid",
)

assert.NoError(t,
pc.checkProcessorLogs(processor, 102, 35, 14, 3),
pc.checkProcessorLogs(processor, 102, 35, 14),
"metrics from Receiver Logs should be valid",
)

Expand Down
24 changes: 0 additions & 24 deletions processor/processorhelper/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,30 +78,6 @@ Number of spans passed to the processor.
| ---- | ----------- | ---------- | --------- |
| {spans} | Sum | Int | true |

### otelcol_processor_inserted_log_records

Number of log records that were inserted.

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

### otelcol_processor_inserted_metric_points

Number of metric points that were inserted.

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

### otelcol_processor_inserted_spans

Number of spans that were inserted.

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

### otelcol_processor_outgoing_log_records

Number of log records emitted from the processor.
Expand Down
21 changes: 0 additions & 21 deletions processor/processorhelper/internal/metadata/generated_telemetry.go

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

24 changes: 0 additions & 24 deletions processor/processorhelper/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,6 @@ telemetry:
value_type: int
monotonic: true

processor_inserted_spans:
enabled: true
description: Number of spans that were inserted.
unit: "{spans}"
sum:
value_type: int
monotonic: true

processor_accepted_metric_points:
enabled: true
description: Number of metric points successfully pushed into the next component in the pipeline.
Expand All @@ -114,14 +106,6 @@ telemetry:
value_type: int
monotonic: true

processor_inserted_metric_points:
enabled: true
description: Number of metric points that were inserted.
unit: "{datapoints}"
sum:
value_type: int
monotonic: true

processor_accepted_log_records:
enabled: true
description: Number of log records successfully pushed into the next component in the pipeline.
Expand All @@ -145,11 +129,3 @@ telemetry:
sum:
value_type: int
monotonic: true

processor_inserted_log_records:
enabled: true
description: Number of log records that were inserted.
unit: "{records}"
sum:
value_type: int
monotonic: true
47 changes: 11 additions & 36 deletions processor/processorhelper/obsreport.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,94 +78,69 @@ func (or *ObsReport) recordInOut(ctx context.Context, dataType component.DataTyp
outgoingCount.Add(ctx, int64(outgoing), metric.WithAttributes(or.otelAttrs...))
}

func (or *ObsReport) recordData(ctx context.Context, dataType component.DataType, accepted, refused, dropped, inserted int64) {
var acceptedCount, refusedCount, droppedCount, insertedCount metric.Int64Counter
func (or *ObsReport) recordData(ctx context.Context, dataType component.DataType, accepted, refused, dropped int64) {
var acceptedCount, refusedCount, droppedCount metric.Int64Counter
switch dataType {
case component.DataTypeTraces:
acceptedCount = or.telemetryBuilder.ProcessorAcceptedSpans
refusedCount = or.telemetryBuilder.ProcessorRefusedSpans
droppedCount = or.telemetryBuilder.ProcessorDroppedSpans
insertedCount = or.telemetryBuilder.ProcessorInsertedSpans
case component.DataTypeMetrics:
acceptedCount = or.telemetryBuilder.ProcessorAcceptedMetricPoints
refusedCount = or.telemetryBuilder.ProcessorRefusedMetricPoints
droppedCount = or.telemetryBuilder.ProcessorDroppedMetricPoints
insertedCount = or.telemetryBuilder.ProcessorInsertedMetricPoints
case component.DataTypeLogs:
acceptedCount = or.telemetryBuilder.ProcessorAcceptedLogRecords
refusedCount = or.telemetryBuilder.ProcessorRefusedLogRecords
droppedCount = or.telemetryBuilder.ProcessorDroppedLogRecords
insertedCount = or.telemetryBuilder.ProcessorInsertedLogRecords
}

acceptedCount.Add(ctx, accepted, metric.WithAttributes(or.otelAttrs...))
refusedCount.Add(ctx, refused, metric.WithAttributes(or.otelAttrs...))
droppedCount.Add(ctx, dropped, metric.WithAttributes(or.otelAttrs...))
insertedCount.Add(ctx, inserted, metric.WithAttributes(or.otelAttrs...))
}

// TracesAccepted reports that the trace data was accepted.
func (or *ObsReport) TracesAccepted(ctx context.Context, numSpans int) {
or.recordData(ctx, component.DataTypeTraces, int64(numSpans), int64(0), int64(0), int64(0))
or.recordData(ctx, component.DataTypeTraces, int64(numSpans), int64(0), int64(0))
}

// TracesRefused reports that the trace data was refused.
func (or *ObsReport) TracesRefused(ctx context.Context, numSpans int) {
or.recordData(ctx, component.DataTypeTraces, int64(0), int64(numSpans), int64(0), int64(0))
or.recordData(ctx, component.DataTypeTraces, int64(0), int64(numSpans), int64(0))
}

// TracesDropped reports that the trace data was dropped.
func (or *ObsReport) TracesDropped(ctx context.Context, numSpans int) {
or.recordData(ctx, component.DataTypeTraces, int64(0), int64(0), int64(numSpans), int64(0))
}

// TracesInserted reports that the trace data was inserted.
//
// Deprecated: [v0.109.0] This method was not used in core/contrib and it's unclear when it should have been used.
func (or *ObsReport) TracesInserted(ctx context.Context, numSpans int) {
or.recordData(ctx, component.DataTypeTraces, int64(0), int64(0), int64(0), int64(numSpans))
or.recordData(ctx, component.DataTypeTraces, int64(0), int64(0), int64(numSpans))
}

// MetricsAccepted reports that the metrics were accepted.
func (or *ObsReport) MetricsAccepted(ctx context.Context, numPoints int) {
or.recordData(ctx, component.DataTypeMetrics, int64(numPoints), int64(0), int64(0), int64(0))
or.recordData(ctx, component.DataTypeMetrics, int64(numPoints), int64(0), int64(0))
}

// MetricsRefused reports that the metrics were refused.
func (or *ObsReport) MetricsRefused(ctx context.Context, numPoints int) {
or.recordData(ctx, component.DataTypeMetrics, int64(0), int64(numPoints), int64(0), int64(0))
or.recordData(ctx, component.DataTypeMetrics, int64(0), int64(numPoints), int64(0))
}

// MetricsDropped reports that the metrics were dropped.
func (or *ObsReport) MetricsDropped(ctx context.Context, numPoints int) {
or.recordData(ctx, component.DataTypeMetrics, int64(0), int64(0), int64(numPoints), int64(0))
}

// MetricsInserted reports that the metrics were inserted.
//
// Deprecated: [v0.109.0] This method was not used in core/contrib and it's unclear when it should have been used.
func (or *ObsReport) MetricsInserted(ctx context.Context, numPoints int) {
or.recordData(ctx, component.DataTypeMetrics, int64(0), int64(0), int64(0), int64(numPoints))
or.recordData(ctx, component.DataTypeMetrics, int64(0), int64(0), int64(numPoints))
}

// LogsAccepted reports that the logs were accepted.
func (or *ObsReport) LogsAccepted(ctx context.Context, numRecords int) {
or.recordData(ctx, component.DataTypeLogs, int64(numRecords), int64(0), int64(0), int64(0))
or.recordData(ctx, component.DataTypeLogs, int64(numRecords), int64(0), int64(0))
}

// LogsRefused reports that the logs were refused.
func (or *ObsReport) LogsRefused(ctx context.Context, numRecords int) {
or.recordData(ctx, component.DataTypeLogs, int64(0), int64(numRecords), int64(0), int64(0))
or.recordData(ctx, component.DataTypeLogs, int64(0), int64(numRecords), int64(0))
}

// LogsDropped reports that the logs were dropped.
func (or *ObsReport) LogsDropped(ctx context.Context, numRecords int) {
or.recordData(ctx, component.DataTypeLogs, int64(0), int64(0), int64(numRecords), int64(0))
}

// LogsInserted reports that the logs were inserted.
//
// Deprecated: [v0.109.0] This method was not used in core/contrib and it's unclear when it should have been used.
func (or *ObsReport) LogsInserted(ctx context.Context, numRecords int) {
or.recordData(ctx, component.DataTypeLogs, int64(0), int64(0), int64(0), int64(numRecords))
or.recordData(ctx, component.DataTypeLogs, int64(0), int64(0), int64(numRecords))
}
Loading

0 comments on commit 3bcb341

Please sign in to comment.