| 1 |
|
| 2 |
|
| 3 |
package metadatatest |
| 4 |
|
| 5 |
import ( |
| 6 |
"testing" |
| 7 |
|
| 8 |
"github.com/stretchr/testify/require" |
| 9 |
"go.opentelemetry.io/otel/sdk/metric/metricdata" |
| 10 |
"go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest" |
| 11 |
|
| 12 |
"go.opentelemetry.io/collector/component/componenttest" |
| 13 |
) |
| 14 |
|
| 15 |
func AssertEqualExporterEnqueueFailedLogRecords(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) { |
| 16 |
want := metricdata.Metrics{ |
| 17 |
Name: "otelcol_exporter_enqueue_failed_log_records", |
| 18 |
Description: "Number of log records failed to be added to the sending queue. [Alpha]", |
| 19 |
Unit: "{records}", |
| 20 |
Data: metricdata.Sum[int64]{ |
| 21 |
Temporality: metricdata.CumulativeTemporality, |
| 22 |
IsMonotonic: true, |
| 23 |
DataPoints: dps, |
| 24 |
}, |
| 25 |
} |
| 26 |
got, err := tt.GetMetric("otelcol_exporter_enqueue_failed_log_records") |
| 27 |
require.NoError(t, err) |
| 28 |
metricdatatest.AssertEqual(t, want, got, opts...) |
| 29 |
} |
| 30 |
|
| 31 |
func AssertEqualExporterEnqueueFailedMetricPoints(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) { |
| 32 |
want := metricdata.Metrics{ |
| 33 |
Name: "otelcol_exporter_enqueue_failed_metric_points", |
| 34 |
Description: "Number of metric points failed to be added to the sending queue. [Alpha]", |
| 35 |
Unit: "{datapoints}", |
| 36 |
Data: metricdata.Sum[int64]{ |
| 37 |
Temporality: metricdata.CumulativeTemporality, |
| 38 |
IsMonotonic: true, |
| 39 |
DataPoints: dps, |
| 40 |
}, |
| 41 |
} |
| 42 |
got, err := tt.GetMetric("otelcol_exporter_enqueue_failed_metric_points") |
| 43 |
require.NoError(t, err) |
| 44 |
metricdatatest.AssertEqual(t, want, got, opts...) |
| 45 |
} |
| 46 |
|
| 47 |
func AssertEqualExporterEnqueueFailedSpans(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) { |
| 48 |
want := metricdata.Metrics{ |
| 49 |
Name: "otelcol_exporter_enqueue_failed_spans", |
| 50 |
Description: "Number of spans failed to be added to the sending queue. [Alpha]", |
| 51 |
Unit: "{spans}", |
| 52 |
Data: metricdata.Sum[int64]{ |
| 53 |
Temporality: metricdata.CumulativeTemporality, |
| 54 |
IsMonotonic: true, |
| 55 |
DataPoints: dps, |
| 56 |
}, |
| 57 |
} |
| 58 |
got, err := tt.GetMetric("otelcol_exporter_enqueue_failed_spans") |
| 59 |
require.NoError(t, err) |
| 60 |
metricdatatest.AssertEqual(t, want, got, opts...) |
| 61 |
} |
| 62 |
|
| 63 |
func AssertEqualExporterQueueBatchSendSize(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.HistogramDataPoint[int64], opts ...metricdatatest.Option) { |
| 64 |
want := metricdata.Metrics{ |
| 65 |
Name: "otelcol_exporter_queue_batch_send_size", |
| 66 |
Description: "Number of units in the batch [Development]", |
| 67 |
Unit: "{units}", |
| 68 |
Data: metricdata.Histogram[int64]{ |
| 69 |
Temporality: metricdata.CumulativeTemporality, |
| 70 |
DataPoints: dps, |
| 71 |
}, |
| 72 |
} |
| 73 |
got, err := tt.GetMetric("otelcol_exporter_queue_batch_send_size") |
| 74 |
require.NoError(t, err) |
| 75 |
metricdatatest.AssertEqual(t, want, got, opts...) |
| 76 |
} |
| 77 |
|
| 78 |
func AssertEqualExporterQueueBatchSendSizeBytes(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.HistogramDataPoint[int64], opts ...metricdatatest.Option) { |
| 79 |
want := metricdata.Metrics{ |
| 80 |
Name: "otelcol_exporter_queue_batch_send_size_bytes", |
| 81 |
Description: "Number of bytes in batch that was sent. Only available on detailed level. [Development]", |
| 82 |
Unit: "By", |
| 83 |
Data: metricdata.Histogram[int64]{ |
| 84 |
Temporality: metricdata.CumulativeTemporality, |
| 85 |
DataPoints: dps, |
| 86 |
}, |
| 87 |
} |
| 88 |
got, err := tt.GetMetric("otelcol_exporter_queue_batch_send_size_bytes") |
| 89 |
require.NoError(t, err) |
| 90 |
metricdatatest.AssertEqual(t, want, got, opts...) |
| 91 |
} |
| 92 |
|
| 93 |
func AssertEqualExporterQueueCapacity(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) { |
| 94 |
want := metricdata.Metrics{ |
| 95 |
Name: "otelcol_exporter_queue_capacity", |
| 96 |
Description: "Fixed capacity of the retry queue (in batches). [Alpha]", |
| 97 |
Unit: "{batches}", |
| 98 |
Data: metricdata.Gauge[int64]{ |
| 99 |
DataPoints: dps, |
| 100 |
}, |
| 101 |
} |
| 102 |
got, err := tt.GetMetric("otelcol_exporter_queue_capacity") |
| 103 |
require.NoError(t, err) |
| 104 |
metricdatatest.AssertEqual(t, want, got, opts...) |
| 105 |
} |
| 106 |
|
| 107 |
func AssertEqualExporterQueueSize(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) { |
| 108 |
want := metricdata.Metrics{ |
| 109 |
Name: "otelcol_exporter_queue_size", |
| 110 |
Description: "Current size of the retry queue (in batches). [Alpha]", |
| 111 |
Unit: "{batches}", |
| 112 |
Data: metricdata.Gauge[int64]{ |
| 113 |
DataPoints: dps, |
| 114 |
}, |
| 115 |
} |
| 116 |
got, err := tt.GetMetric("otelcol_exporter_queue_size") |
| 117 |
require.NoError(t, err) |
| 118 |
metricdatatest.AssertEqual(t, want, got, opts...) |
| 119 |
} |
| 120 |
|
| 121 |
func AssertEqualExporterSendFailedLogRecords(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) { |
| 122 |
want := metricdata.Metrics{ |
| 123 |
Name: "otelcol_exporter_send_failed_log_records", |
| 124 |
Description: "Number of log records in failed attempts to send to destination. [Alpha]", |
| 125 |
Unit: "{records}", |
| 126 |
Data: metricdata.Sum[int64]{ |
| 127 |
Temporality: metricdata.CumulativeTemporality, |
| 128 |
IsMonotonic: true, |
| 129 |
DataPoints: dps, |
| 130 |
}, |
| 131 |
} |
| 132 |
got, err := tt.GetMetric("otelcol_exporter_send_failed_log_records") |
| 133 |
require.NoError(t, err) |
| 134 |
metricdatatest.AssertEqual(t, want, got, opts...) |
| 135 |
} |
| 136 |
|
| 137 |
func AssertEqualExporterSendFailedMetricPoints(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) { |
| 138 |
want := metricdata.Metrics{ |
| 139 |
Name: "otelcol_exporter_send_failed_metric_points", |
| 140 |
Description: "Number of metric points in failed attempts to send to destination. [Alpha]", |
| 141 |
Unit: "{datapoints}", |
| 142 |
Data: metricdata.Sum[int64]{ |
| 143 |
Temporality: metricdata.CumulativeTemporality, |
| 144 |
IsMonotonic: true, |
| 145 |
DataPoints: dps, |
| 146 |
}, |
| 147 |
} |
| 148 |
got, err := tt.GetMetric("otelcol_exporter_send_failed_metric_points") |
| 149 |
require.NoError(t, err) |
| 150 |
metricdatatest.AssertEqual(t, want, got, opts...) |
| 151 |
} |
| 152 |
|
| 153 |
func AssertEqualExporterSendFailedSpans(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) { |
| 154 |
want := metricdata.Metrics{ |
| 155 |
Name: "otelcol_exporter_send_failed_spans", |
| 156 |
Description: "Number of spans in failed attempts to send to destination. [Alpha]", |
| 157 |
Unit: "{spans}", |
| 158 |
Data: metricdata.Sum[int64]{ |
| 159 |
Temporality: metricdata.CumulativeTemporality, |
| 160 |
IsMonotonic: true, |
| 161 |
DataPoints: dps, |
| 162 |
}, |
| 163 |
} |
| 164 |
got, err := tt.GetMetric("otelcol_exporter_send_failed_spans") |
| 165 |
require.NoError(t, err) |
| 166 |
metricdatatest.AssertEqual(t, want, got, opts...) |
| 167 |
} |
| 168 |
|
| 169 |
func AssertEqualExporterSentLogRecords(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) { |
| 170 |
want := metricdata.Metrics{ |
| 171 |
Name: "otelcol_exporter_sent_log_records", |
| 172 |
Description: "Number of log record successfully sent to destination. [Alpha]", |
| 173 |
Unit: "{records}", |
| 174 |
Data: metricdata.Sum[int64]{ |
| 175 |
Temporality: metricdata.CumulativeTemporality, |
| 176 |
IsMonotonic: true, |
| 177 |
DataPoints: dps, |
| 178 |
}, |
| 179 |
} |
| 180 |
got, err := tt.GetMetric("otelcol_exporter_sent_log_records") |
| 181 |
require.NoError(t, err) |
| 182 |
metricdatatest.AssertEqual(t, want, got, opts...) |
| 183 |
} |
| 184 |
|
| 185 |
func AssertEqualExporterSentMetricPoints(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) { |
| 186 |
want := metricdata.Metrics{ |
| 187 |
Name: "otelcol_exporter_sent_metric_points", |
| 188 |
Description: "Number of metric points successfully sent to destination. [Alpha]", |
| 189 |
Unit: "{datapoints}", |
| 190 |
Data: metricdata.Sum[int64]{ |
| 191 |
Temporality: metricdata.CumulativeTemporality, |
| 192 |
IsMonotonic: true, |
| 193 |
DataPoints: dps, |
| 194 |
}, |
| 195 |
} |
| 196 |
got, err := tt.GetMetric("otelcol_exporter_sent_metric_points") |
| 197 |
require.NoError(t, err) |
| 198 |
metricdatatest.AssertEqual(t, want, got, opts...) |
| 199 |
} |
| 200 |
|
| 201 |
func AssertEqualExporterSentSpans(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) { |
| 202 |
want := metricdata.Metrics{ |
| 203 |
Name: "otelcol_exporter_sent_spans", |
| 204 |
Description: "Number of spans successfully sent to destination. [Alpha]", |
| 205 |
Unit: "{spans}", |
| 206 |
Data: metricdata.Sum[int64]{ |
| 207 |
Temporality: metricdata.CumulativeTemporality, |
| 208 |
IsMonotonic: true, |
| 209 |
DataPoints: dps, |
| 210 |
}, |
| 211 |
} |
| 212 |
got, err := tt.GetMetric("otelcol_exporter_sent_spans") |
| 213 |
require.NoError(t, err) |
| 214 |
metricdatatest.AssertEqual(t, want, got, opts...) |
| 215 |
} |