Skip to content

Commit

Permalink
Remove deprecated funcs form processorhelper.ObsReport (open-telemetr…
Browse files Browse the repository at this point in the history
…y#11289)

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored and jackgopack4 committed Oct 8, 2024
1 parent 3900312 commit 82fb307
Show file tree
Hide file tree
Showing 16 changed files with 517 additions and 642 deletions.
27 changes: 27 additions & 0 deletions .chloggen/rm-deprecated-func.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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) 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: The "otelcol_processor_dropped_log_records", "otelcol_processor_dropped_log_records" |
and "otelcol_processor_dropped_spans" metrics are complete removed, before they were always record with 0 values.


# 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]
25 changes: 10 additions & 15 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 @@ -72,27 +71,23 @@ func (tts *TestTelemetry) CheckExporterLogs(sentLogRecords, sendFailedLogRecords
}

func (tts *TestTelemetry) CheckExporterMetricGauge(metric string, val int64, extraAttrs ...attribute.KeyValue) error {
attrs := attributesForExporterMetrics(tts.id)
attrs = append(attrs, extraAttrs...)
attrs := attributesForExporterMetrics(tts.id, extraAttrs...)
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
62 changes: 19 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,24 @@ 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, extraAttrs ...attribute.KeyValue) attribute.Set {
attrs := []attribute.KeyValue{attribute.String(exporterTag, exporter.String())}
attrs = append(attrs, extraAttrs...)
return attribute.NewSet(attrs...)
}
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.

12 changes: 6 additions & 6 deletions processor/memorylimiterprocessor/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ require (
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/collector v0.110.0
go.opentelemetry.io/collector/component v0.110.0
go.opentelemetry.io/collector/config/configtelemetry v0.110.0
go.opentelemetry.io/collector/confmap v1.16.0
go.opentelemetry.io/collector/consumer v0.110.0
go.opentelemetry.io/collector/consumer/consumertest v0.110.0
go.opentelemetry.io/collector/pdata v1.16.0
go.opentelemetry.io/collector/pipeline v0.110.0
go.opentelemetry.io/collector/processor v0.110.0
go.opentelemetry.io/otel v1.30.0
go.opentelemetry.io/otel/metric v1.30.0
go.opentelemetry.io/otel/sdk/metric v1.30.0
go.opentelemetry.io/otel/trace v1.30.0
go.uber.org/goleak v1.3.0
)

Expand Down Expand Up @@ -38,18 +44,12 @@ require (
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.opentelemetry.io/collector/component/componentstatus v0.110.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.110.0 // indirect
go.opentelemetry.io/collector/consumer/consumerprofiles v0.110.0 // indirect
go.opentelemetry.io/collector/internal/globalsignal v0.110.0 // indirect
go.opentelemetry.io/collector/pdata/pprofile v0.110.0 // indirect
go.opentelemetry.io/collector/pdata/testdata v0.110.0 // indirect
go.opentelemetry.io/collector/pipeline v0.110.0 // indirect
go.opentelemetry.io/collector/processor/processorprofiles v0.110.0 // indirect
go.opentelemetry.io/otel v1.30.0 // indirect
go.opentelemetry.io/otel/metric v1.30.0 // indirect
go.opentelemetry.io/otel/sdk v1.30.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.30.0 // indirect
go.opentelemetry.io/otel/trace v1.30.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/net v0.28.0 // indirect
Expand Down
Loading

0 comments on commit 82fb307

Please sign in to comment.