Skip to content

Commit

Permalink
Remove deprecated funcs form processorhelper.ObsReport
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu committed Sep 27, 2024
1 parent 40396d5 commit c70d910
Show file tree
Hide file tree
Showing 15 changed files with 501 additions and 634 deletions.
20 changes: 20 additions & 0 deletions .chloggen/rm-deprecated-func.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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 funcs form processorhelper.ObsReport

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

# 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: [api]
22 changes: 9 additions & 13 deletions component/componenttest/obsreporttest.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const (
scraperTag = "scraper"
transportTag = "transport"
exporterTag = "exporter"
processorTag = "processor"
)

type TestTelemetry struct {
Expand Down Expand Up @@ -77,22 +76,19 @@ func (tts *TestTelemetry) CheckExporterMetricGauge(metric string, val int64, ext
return checkIntGauge(tts.reader, metric, val, attrs)
}

// 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 int64) error {
return checkProcessorTraces(tts.reader, tts.id, acceptedSpans, refusedSpans, droppedSpans)
// Deprecated: [v0.111.0] deleted metrics, no-op.
func (tts *TestTelemetry) CheckProcessorTraces(_, _, _ int64) error {
return nil
}

// 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 int64) error {
return checkProcessorMetrics(tts.reader, tts.id, acceptedMetricPoints, refusedMetricPoints, droppedMetricPoints)
// Deprecated: [v0.111.0] deleted metrics, no-op.
func (tts *TestTelemetry) CheckProcessorMetrics(_, _, _ int64) error {
return nil
}

// 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 int64) error {
return checkProcessorLogs(tts.reader, tts.id, acceptedLogRecords, refusedLogRecords, droppedLogRecords)
// Deprecated: [v0.111.0] deleted metrics, no-op.
func (tts *TestTelemetry) CheckProcessorLogs(_, _, _ int64) error {
return nil
}

// CheckReceiverTraces checks that for the current exported values for trace receiver metrics match given values.
Expand Down
60 changes: 17 additions & 43 deletions component/componenttest/otelchecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,6 @@ func checkReceiver(reader *sdkmetric.ManualReader, receiver component.ID, dataty
checkIntSum(reader, fmt.Sprintf("otelcol_receiver_refused_%s", datatype), droppedMetricPoints, receiverAttrs))
}

func checkProcessorTraces(reader *sdkmetric.ManualReader, processor component.ID, accepted, refused, dropped int64) error {
return checkProcessor(reader, processor, "spans", accepted, refused, dropped)
}

func checkProcessorMetrics(reader *sdkmetric.ManualReader, processor component.ID, accepted, refused, dropped int64) error {
return checkProcessor(reader, processor, "metric_points", accepted, refused, dropped)
}

func checkProcessorLogs(reader *sdkmetric.ManualReader, processor component.ID, accepted, refused, dropped int64) error {
return checkProcessor(reader, processor, "log_records", accepted, refused, dropped)
}

func checkProcessor(reader *sdkmetric.ManualReader, processor component.ID, datatype string, accepted, refused, dropped int64) error {
processorAttrs := attributesForProcessorMetrics(processor)
return multierr.Combine(
checkIntSum(reader, fmt.Sprintf("otelcol_processor_accepted_%s", datatype), accepted, processorAttrs),
checkIntSum(reader, fmt.Sprintf("otelcol_processor_refused_%s", datatype), refused, processorAttrs),
checkIntSum(reader, fmt.Sprintf("otelcol_processor_dropped_%s", datatype), dropped, processorAttrs),
)
}

func checkExporterTraces(reader *sdkmetric.ManualReader, exporter component.ID, sent, sendFailed int64) error {
return checkExporter(reader, exporter, "spans", sent, sendFailed)
}
Expand Down Expand Up @@ -92,8 +71,8 @@ func checkExporterEnqueueFailed(reader *sdkmetric.ManualReader, exporter compone
return checkIntSum(reader, fmt.Sprintf("otelcol_exporter_enqueue_failed_%s", datatype), enqueueFailed, exporterAttrs)
}

func checkIntGauge(reader *sdkmetric.ManualReader, metric string, expected int64, attrs []attribute.KeyValue) error {
dp, err := getGaugeDataPoint[int64](reader, metric, attrs)
func checkIntGauge(reader *sdkmetric.ManualReader, metric string, expected int64, expectedAttrs attribute.Set) error {
dp, err := getGaugeDataPoint[int64](reader, metric, expectedAttrs)
if err != nil {
return err
}
Expand All @@ -105,8 +84,8 @@ func checkIntGauge(reader *sdkmetric.ManualReader, metric string, expected int64
return nil
}

func checkIntSum(reader *sdkmetric.ManualReader, expectedMetric string, expected int64, attrs []attribute.KeyValue) error {
dp, err := getSumDataPoint[int64](reader, expectedMetric, attrs)
func checkIntSum(reader *sdkmetric.ManualReader, expectedMetric string, expected int64, expectedAttrs attribute.Set) error {
dp, err := getSumDataPoint[int64](reader, expectedMetric, expectedAttrs)
if err != nil {
return err
}
Expand All @@ -118,7 +97,7 @@ func checkIntSum(reader *sdkmetric.ManualReader, expectedMetric string, expected
return nil
}

func getSumDataPoint[N int64 | float64](reader *sdkmetric.ManualReader, expectedName string, expectedAttrs []attribute.KeyValue) (metricdata.DataPoint[N], error) {
func getSumDataPoint[N int64 | float64](reader *sdkmetric.ManualReader, expectedName string, expectedAttrs attribute.Set) (metricdata.DataPoint[N], error) {
m, err := getMetric(reader, expectedName)
if err != nil {
return metricdata.DataPoint[N]{}, err
Expand All @@ -132,7 +111,7 @@ func getSumDataPoint[N int64 | float64](reader *sdkmetric.ManualReader, expected
}
}

func getGaugeDataPoint[N int64 | float64](reader *sdkmetric.ManualReader, expectedName string, expectedAttrs []attribute.KeyValue) (metricdata.DataPoint[N], error) {
func getGaugeDataPoint[N int64 | float64](reader *sdkmetric.ManualReader, expectedName string, expectedAttrs attribute.Set) (metricdata.DataPoint[N], error) {
m, err := getMetric(reader, expectedName)
if err != nil {
return metricdata.DataPoint[N]{}, err
Expand All @@ -146,14 +125,13 @@ func getGaugeDataPoint[N int64 | float64](reader *sdkmetric.ManualReader, expect
}
}

func getDataPoint[N int64 | float64](dps []metricdata.DataPoint[N], expectedName string, expectedAttrs []attribute.KeyValue) (metricdata.DataPoint[N], error) {
expectedSet := attribute.NewSet(expectedAttrs...)
func getDataPoint[N int64 | float64](dps []metricdata.DataPoint[N], expectedName string, expectedAttrs attribute.Set) (metricdata.DataPoint[N], error) {
for _, dp := range dps {
if expectedSet.Equals(&dp.Attributes) {
if expectedAttrs.Equals(&dp.Attributes) {
return dp, nil
}
}
return metricdata.DataPoint[N]{}, fmt.Errorf("metric '%s' doesn't have a data point with the given attributes: %s", expectedName, expectedSet.Encoded(attribute.DefaultEncoder()))
return metricdata.DataPoint[N]{}, fmt.Errorf("metric '%s' doesn't have a data point with the given attributes: %s", expectedName, expectedAttrs.Encoded(attribute.DefaultEncoder()))
}

func getMetric(reader *sdkmetric.ManualReader, expectedName string) (metricdata.Metrics, error) {
Expand All @@ -172,26 +150,22 @@ func getMetric(reader *sdkmetric.ManualReader, expectedName string) (metricdata.
return metricdata.Metrics{}, fmt.Errorf("metric '%s' not found", expectedName)
}

func attributesForScraperMetrics(receiver component.ID, scraper component.ID) []attribute.KeyValue {
return []attribute.KeyValue{
func attributesForScraperMetrics(receiver component.ID, scraper component.ID) attribute.Set {
return attribute.NewSet(
attribute.String(receiverTag, receiver.String()),
attribute.String(scraperTag, scraper.String()),
}
)
}

// attributesForReceiverMetrics returns the attributes that are needed for the receiver metrics.
func attributesForReceiverMetrics(receiver component.ID, transport string) []attribute.KeyValue {
return []attribute.KeyValue{
func attributesForReceiverMetrics(receiver component.ID, transport string) attribute.Set {
return attribute.NewSet(
attribute.String(receiverTag, receiver.String()),
attribute.String(transportTag, transport),
}
}

func attributesForProcessorMetrics(processor component.ID) []attribute.KeyValue {
return []attribute.KeyValue{attribute.String(processorTag, processor.String())}
)
}

// attributesForExporterMetrics returns the attributes that are needed for the receiver metrics.
func attributesForExporterMetrics(exporter component.ID) []attribute.KeyValue {
return []attribute.KeyValue{attribute.String(exporterTag, exporter.String())}
func attributesForExporterMetrics(exporter component.ID) attribute.Set {
return attribute.NewSet(attribute.String(exporterTag, exporter.String()))
}
55 changes: 55 additions & 0 deletions processor/memorylimiterprocessor/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.)

# memory_limiter

## Internal Telemetry

The following telemetry is emitted by this component.

### otelcol_processor_accepted_log_records

Number of log records successfully pushed into the next component in the pipeline. [deprecated since v0.110.0]

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

### otelcol_processor_accepted_metric_points

Number of metric points successfully pushed into the next component in the pipeline. [deprecated since v0.110.0]

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

### otelcol_processor_accepted_spans

Number of spans successfully pushed into the next component in the pipeline. [deprecated since v0.110.0]

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

### otelcol_processor_refused_log_records

Number of log records that were rejected by the next component in the pipeline. [deprecated since v0.110.0]

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

### otelcol_processor_refused_metric_points

Number of metric points that were rejected by the next component in the pipeline. [deprecated since v0.110.0]

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

### otelcol_processor_refused_spans

Number of spans that were rejected by the next component in the pipeline. [deprecated since v0.110.0]

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

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

Loading

0 comments on commit c70d910

Please sign in to comment.