| 1 |
// Code generated by mdatagen. DO NOT EDIT. |
| 2 |
|
| 3 |
package metadatatest |
| 4 |
|
| 5 |
import ( |
| 6 |
"context" |
| 7 |
"testing" |
| 8 |
|
| 9 |
"github.com/stretchr/testify/require" |
| 10 |
"go.opentelemetry.io/otel/metric" |
| 11 |
"go.opentelemetry.io/otel/sdk/metric/metricdata" |
| 12 |
"go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest" |
| 13 |
|
| 14 |
"go.opentelemetry.io/collector/component/componenttest" |
| 15 |
"go.opentelemetry.io/collector/processor/batchprocessor/internal/metadata" |
| 16 |
) |
| 17 |
|
| 18 |
func TestSetupTelemetry(t *testing.T) { |
| 19 |
testTel := componenttest.NewTelemetry() |
| 20 |
tb, err := metadata.NewTelemetryBuilder(testTel.NewTelemetrySettings()) |
| 21 |
require.NoError(t, err) |
| 22 |
defer tb.Shutdown() |
| 23 |
require.NoError(t, tb.RegisterProcessorBatchMetadataCardinalityCallback(func(_ context.Context, observer metric.Int64Observer) error { |
| 24 |
observer.Observe(1) |
| 25 |
return nil |
| 26 |
})) |
| 27 |
tb.ProcessorBatchBatchSendSize.Record(context.Background(), 1) |
| 28 |
tb.ProcessorBatchBatchSendSizeBytes.Record(context.Background(), 1) |
| 29 |
tb.ProcessorBatchBatchSizeTriggerSend.Add(context.Background(), 1) |
| 30 |
tb.ProcessorBatchTimeoutTriggerSend.Add(context.Background(), 1) |
| 31 |
AssertEqualProcessorBatchBatchSendSize(t, testTel, |
| 32 |
[]metricdata.HistogramDataPoint[int64]{{}}, metricdatatest.IgnoreValue(), |
| 33 |
metricdatatest.IgnoreTimestamp()) |
| 34 |
AssertEqualProcessorBatchBatchSendSizeBytes(t, testTel, |
| 35 |
[]metricdata.HistogramDataPoint[int64]{{}}, metricdatatest.IgnoreValue(), |
| 36 |
metricdatatest.IgnoreTimestamp()) |
| 37 |
AssertEqualProcessorBatchBatchSizeTriggerSend(t, testTel, |
| 38 |
[]metricdata.DataPoint[int64]{{Value: 1}}, |
| 39 |
metricdatatest.IgnoreTimestamp()) |
| 40 |
AssertEqualProcessorBatchMetadataCardinality(t, testTel, |
| 41 |
[]metricdata.DataPoint[int64]{{Value: 1}}, |
| 42 |
metricdatatest.IgnoreTimestamp()) |
| 43 |
AssertEqualProcessorBatchTimeoutTriggerSend(t, testTel, |
| 44 |
[]metricdata.DataPoint[int64]{{Value: 1}}, |
| 45 |
metricdatatest.IgnoreTimestamp()) |
| 46 |
|
| 47 |
require.NoError(t, testTel.Shutdown(context.Background())) |
| 48 |
} |