Skip to content

Commit

Permalink
fix: Fix throughput measurement name changes (#1786)
Browse files Browse the repository at this point in the history
fix throughput measurements metric name changing
  • Loading branch information
BinaryFissionGames authored Aug 7, 2024
1 parent 9399155 commit 18a99a7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
17 changes: 10 additions & 7 deletions processor/throughputmeasurementprocessor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/pdata/ptrace"
"go.opentelemetry.io/collector/processor/processorhelper"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.uber.org/zap"
Expand All @@ -46,7 +45,7 @@ func newThroughputMeasurementProcessor(logger *zap.Logger, mp metric.MeterProvid
meter := mp.Meter("github.com/observiq/bindplane-agent/processor/throughputmeasurementprocessor")

logSize, err := meter.Int64Counter(
processorhelper.BuildCustomMetricName(componentType.String(), "log_data_size"),
metricName("log_data_size"),
metric.WithDescription("Size of the log package passed to the processor"),
metric.WithUnit("By"),
)
Expand All @@ -55,7 +54,7 @@ func newThroughputMeasurementProcessor(logger *zap.Logger, mp metric.MeterProvid
}

metricSize, err := meter.Int64Counter(
processorhelper.BuildCustomMetricName(componentType.String(), "metric_data_size"),
metricName("metric_data_size"),
metric.WithDescription("Size of the metric package passed to the processor"),
metric.WithUnit("By"),
)
Expand All @@ -64,7 +63,7 @@ func newThroughputMeasurementProcessor(logger *zap.Logger, mp metric.MeterProvid
}

traceSize, err := meter.Int64Counter(
processorhelper.BuildCustomMetricName(componentType.String(), "trace_data_size"),
metricName("trace_data_size"),
metric.WithDescription("Size of the trace package passed to the processor"),
metric.WithUnit("By"),
)
Expand All @@ -73,7 +72,7 @@ func newThroughputMeasurementProcessor(logger *zap.Logger, mp metric.MeterProvid
}

logCount, err := meter.Int64Counter(
processorhelper.BuildCustomMetricName(componentType.String(), "log_count"),
metricName("log_count"),
metric.WithDescription("Count of the number log records passed to the processor"),
metric.WithUnit("{logs}"),
)
Expand All @@ -82,7 +81,7 @@ func newThroughputMeasurementProcessor(logger *zap.Logger, mp metric.MeterProvid
}

datapointCount, err := meter.Int64Counter(
processorhelper.BuildCustomMetricName(componentType.String(), "metric_count"),
metricName("metric_count"),
metric.WithDescription("Count of the number datapoints passed to the processor"),
metric.WithUnit("{datapoints}"),
)
Expand All @@ -91,7 +90,7 @@ func newThroughputMeasurementProcessor(logger *zap.Logger, mp metric.MeterProvid
}

spanCount, err := meter.Int64Counter(
processorhelper.BuildCustomMetricName(componentType.String(), "trace_count"),
metricName("trace_count"),
metric.WithDescription("Count of the number spans passed to the processor"),
metric.WithUnit("{spans}"),
)
Expand Down Expand Up @@ -151,3 +150,7 @@ func (tmp *throughputMeasurementProcessor) processMetrics(ctx context.Context, m

return md, nil
}

func metricName(metric string) string {
return fmt.Sprintf("otelcol_processor_throughputmeasurement_%s", metric)
}
20 changes: 10 additions & 10 deletions processor/throughputmeasurementprocessor/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestProcessor_Logs(t *testing.T) {
for _, sm := range rm.ScopeMetrics {
for _, metric := range sm.Metrics {
switch metric.Name {
case "processor_throughputmeasurement_log_data_size":
case "otelcol_processor_throughputmeasurement_log_data_size":
sum := metric.Data.(metricdata.Sum[int64])
require.Equal(t, 1, len(sum.DataPoints))

Expand All @@ -75,7 +75,7 @@ func TestProcessor_Logs(t *testing.T) {

logSize = sum.DataPoints[0].Value

case "processor_throughputmeasurement_log_count":
case "otelcol_processor_throughputmeasurement_log_count":
sum := metric.Data.(metricdata.Sum[int64])
require.Equal(t, 1, len(sum.DataPoints))

Expand Down Expand Up @@ -128,7 +128,7 @@ func TestProcessor_Metrics(t *testing.T) {
for _, sm := range rm.ScopeMetrics {
for _, metric := range sm.Metrics {
switch metric.Name {
case "processor_throughputmeasurement_metric_data_size":
case "otelcol_processor_throughputmeasurement_metric_data_size":
sum := metric.Data.(metricdata.Sum[int64])
require.Equal(t, 1, len(sum.DataPoints))

Expand All @@ -138,7 +138,7 @@ func TestProcessor_Metrics(t *testing.T) {

metricSize = sum.DataPoints[0].Value

case "processor_throughputmeasurement_metric_count":
case "otelcol_processor_throughputmeasurement_metric_count":
sum := metric.Data.(metricdata.Sum[int64])
require.Equal(t, 1, len(sum.DataPoints))

Expand Down Expand Up @@ -191,7 +191,7 @@ func TestProcessor_Traces(t *testing.T) {
for _, sm := range rm.ScopeMetrics {
for _, metric := range sm.Metrics {
switch metric.Name {
case "processor_throughputmeasurement_trace_data_size":
case "otelcol_processor_throughputmeasurement_trace_data_size":
sum := metric.Data.(metricdata.Sum[int64])
require.Equal(t, 1, len(sum.DataPoints))

Expand All @@ -201,7 +201,7 @@ func TestProcessor_Traces(t *testing.T) {

traceSize = sum.DataPoints[0].Value

case "processor_throughputmeasurement_trace_count":
case "otelcol_processor_throughputmeasurement_trace_count":
sum := metric.Data.(metricdata.Sum[int64])
require.Equal(t, 1, len(sum.DataPoints))

Expand Down Expand Up @@ -261,7 +261,7 @@ func TestProcessor_Logs_TwoInstancesSameID(t *testing.T) {
for _, sm := range rm.ScopeMetrics {
for _, metric := range sm.Metrics {
switch metric.Name {
case "processor_throughputmeasurement_log_data_size":
case "otelcol_processor_throughputmeasurement_log_data_size":
sum := metric.Data.(metricdata.Sum[int64])
require.Equal(t, 1, len(sum.DataPoints))

Expand All @@ -271,7 +271,7 @@ func TestProcessor_Logs_TwoInstancesSameID(t *testing.T) {

logSize = sum.DataPoints[0].Value

case "processor_throughputmeasurement_log_count":
case "otelcol_processor_throughputmeasurement_log_count":
sum := metric.Data.(metricdata.Sum[int64])
require.Equal(t, 1, len(sum.DataPoints))

Expand Down Expand Up @@ -335,7 +335,7 @@ func TestProcessor_Logs_TwoInstancesDifferentID(t *testing.T) {
for _, sm := range rm.ScopeMetrics {
for _, metric := range sm.Metrics {
switch metric.Name {
case "processor_throughputmeasurement_log_data_size":
case "otelcol_processor_throughputmeasurement_log_data_size":
sum := metric.Data.(metricdata.Sum[int64])
require.Equal(t, 2, len(sum.DataPoints))

Expand All @@ -353,7 +353,7 @@ func TestProcessor_Logs_TwoInstancesDifferentID(t *testing.T) {
}
}

case "processor_throughputmeasurement_log_count":
case "otelcol_processor_throughputmeasurement_log_count":
sum := metric.Data.(metricdata.Sum[int64])
require.Equal(t, 2, len(sum.DataPoints))

Expand Down

0 comments on commit 18a99a7

Please sign in to comment.