From 7c5e3d8fb65963b857f5c69453a7c6c912b6535b Mon Sep 17 00:00:00 2001 From: Ziqi Zhao Date: Thu, 10 Nov 2022 21:31:23 +0800 Subject: [PATCH] Signed-off-by: Ziqi Zhao prevent conflict metric info --- CHANGELOG.md | 1 + exporters/prometheus/exporter.go | 82 +++++- exporters/prometheus/exporter_test.go | 262 ++++++++++++++++++ exporters/prometheus/go.mod | 4 +- .../testdata/conflict_help_two_counters_1.txt | 11 + .../testdata/conflict_help_two_counters_2.txt | 11 + .../conflict_help_two_histograms_1.txt | 45 +++ .../conflict_help_two_histograms_2.txt | 45 +++ .../conflict_help_two_updowncounters_1.txt | 11 + .../conflict_help_two_updowncounters_2.txt | 11 + ...flict_type_counter_and_updowncounter_1.txt | 9 + ...flict_type_counter_and_updowncounter_2.txt | 9 + ...ict_type_histogram_and_updowncounter_1.txt | 9 + ...ict_type_histogram_and_updowncounter_2.txt | 26 ++ .../testdata/conflict_unit_two_counters.txt | 11 + .../testdata/conflict_unit_two_histograms.txt | 45 +++ .../conflict_unit_two_updowncounters.txt | 11 + .../testdata/no_conflict_two_counters.txt | 11 + .../testdata/no_conflict_two_histograms.txt | 45 +++ .../no_conflict_two_updowncounters.txt | 11 + 20 files changed, 660 insertions(+), 10 deletions(-) create mode 100644 exporters/prometheus/testdata/conflict_help_two_counters_1.txt create mode 100644 exporters/prometheus/testdata/conflict_help_two_counters_2.txt create mode 100644 exporters/prometheus/testdata/conflict_help_two_histograms_1.txt create mode 100644 exporters/prometheus/testdata/conflict_help_two_histograms_2.txt create mode 100644 exporters/prometheus/testdata/conflict_help_two_updowncounters_1.txt create mode 100644 exporters/prometheus/testdata/conflict_help_two_updowncounters_2.txt create mode 100644 exporters/prometheus/testdata/conflict_type_counter_and_updowncounter_1.txt create mode 100644 exporters/prometheus/testdata/conflict_type_counter_and_updowncounter_2.txt create mode 100644 exporters/prometheus/testdata/conflict_type_histogram_and_updowncounter_1.txt create mode 100644 exporters/prometheus/testdata/conflict_type_histogram_and_updowncounter_2.txt create mode 100644 exporters/prometheus/testdata/conflict_unit_two_counters.txt create mode 100644 exporters/prometheus/testdata/conflict_unit_two_histograms.txt create mode 100644 exporters/prometheus/testdata/conflict_unit_two_updowncounters.txt create mode 100644 exporters/prometheus/testdata/no_conflict_two_counters.txt create mode 100644 exporters/prometheus/testdata/no_conflict_two_histograms.txt create mode 100644 exporters/prometheus/testdata/no_conflict_two_updowncounters.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index daa5584bed7..949ea926d7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Asynchronous callbacks are only called if they are registered with at least one instrument that does not use drop aggragation. (#3408) - Do not report empty partial-success responses in the `go.opentelemetry.io/otel/exporters/otlp` exporters. (#3438, #3432) - Handle partial success responses in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric` exporters. (#3162, #3440) +- Prevent duplicate Prometheus description, unit, and type. (#3469) - Prevents panic when using incorrect `attribute.Value.As[Type]Slice()`. (#3489) ## Removed diff --git a/exporters/prometheus/exporter.go b/exporters/prometheus/exporter.go index 2cb23cc19fb..734d6315b4c 100644 --- a/exporters/prometheus/exporter.go +++ b/exporters/prometheus/exporter.go @@ -16,6 +16,7 @@ package prometheus // import "go.opentelemetry.io/otel/exporters/prometheus" import ( "context" + "errors" "fmt" "sort" "strings" @@ -24,9 +25,12 @@ import ( "unicode/utf8" "github.com/prometheus/client_golang/prometheus" + dto "github.com/prometheus/client_model/go" + "google.golang.org/protobuf/proto" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/internal/global" "go.opentelemetry.io/otel/metric/unit" "go.opentelemetry.io/otel/sdk/instrumentation" "go.opentelemetry.io/otel/sdk/metric" @@ -62,6 +66,7 @@ type collector struct { disableScopeInfo bool createTargetInfoOnce sync.Once scopeInfos map[instrumentation.Scope]prometheus.Metric + metricFamilies map[string]*dto.MetricFamily } // prometheus counters MUST have a _total suffix: @@ -83,6 +88,7 @@ func New(opts ...Option) (*Exporter, error) { withoutUnits: cfg.withoutUnits, disableScopeInfo: cfg.disableScopeInfo, scopeInfos: make(map[instrumentation.Scope]prometheus.Metric), + metricFamilies: make(map[string]*dto.MetricFamily), } if err := cfg.registerer.Register(collector); err != nil { @@ -149,22 +155,30 @@ func (c *collector) Collect(ch chan<- prometheus.Metric) { for _, m := range scopeMetrics.Metrics { switch v := m.Data.(type) { case metricdata.Histogram: - addHistogramMetric(ch, v, m, keys, values, c.getName(m)) + addHistogramMetric(ch, v, m, keys, values, c.getName(m), c.metricFamilies) case metricdata.Sum[int64]: - addSumMetric(ch, v, m, keys, values, c.getName(m)) + addSumMetric(ch, v, m, keys, values, c.getName(m), c.metricFamilies) case metricdata.Sum[float64]: - addSumMetric(ch, v, m, keys, values, c.getName(m)) + addSumMetric(ch, v, m, keys, values, c.getName(m), c.metricFamilies) case metricdata.Gauge[int64]: - addGaugeMetric(ch, v, m, keys, values, c.getName(m)) + addGaugeMetric(ch, v, m, keys, values, c.getName(m), c.metricFamilies) case metricdata.Gauge[float64]: - addGaugeMetric(ch, v, m, keys, values, c.getName(m)) + addGaugeMetric(ch, v, m, keys, values, c.getName(m), c.metricFamilies) } } } } -func addHistogramMetric(ch chan<- prometheus.Metric, histogram metricdata.Histogram, m metricdata.Metrics, ks, vs [2]string, name string) { +func addHistogramMetric(ch chan<- prometheus.Metric, histogram metricdata.Histogram, m metricdata.Metrics, ks, vs [2]string, name string, mfs map[string]*dto.MetricFamily) { // TODO(https://github.com/open-telemetry/opentelemetry-go/issues/3163): support exemplars + drop, help := validateMetrics(name, m.Description, dto.MetricType_HISTOGRAM.Enum(), mfs) + if drop { + return + } + if help != "" { + m.Description = help + } + for _, dp := range histogram.DataPoints { keys, values := getAttrs(dp.Attributes, ks, vs) @@ -185,15 +199,26 @@ func addHistogramMetric(ch chan<- prometheus.Metric, histogram metricdata.Histog } } -func addSumMetric[N int64 | float64](ch chan<- prometheus.Metric, sum metricdata.Sum[N], m metricdata.Metrics, ks, vs [2]string, name string) { +func addSumMetric[N int64 | float64](ch chan<- prometheus.Metric, sum metricdata.Sum[N], m metricdata.Metrics, ks, vs [2]string, name string, mfs map[string]*dto.MetricFamily) { valueType := prometheus.CounterValue + metricType := dto.MetricType_COUNTER if !sum.IsMonotonic { valueType = prometheus.GaugeValue + metricType = dto.MetricType_GAUGE } if sum.IsMonotonic { // Add _total suffix for counters name += counterSuffix } + + drop, help := validateMetrics(name, m.Description, metricType.Enum(), mfs) + if drop { + return + } + if help != "" { + m.Description = help + } + for _, dp := range sum.DataPoints { keys, values := getAttrs(dp.Attributes, ks, vs) @@ -207,7 +232,15 @@ func addSumMetric[N int64 | float64](ch chan<- prometheus.Metric, sum metricdata } } -func addGaugeMetric[N int64 | float64](ch chan<- prometheus.Metric, gauge metricdata.Gauge[N], m metricdata.Metrics, ks, vs [2]string, name string) { +func addGaugeMetric[N int64 | float64](ch chan<- prometheus.Metric, gauge metricdata.Gauge[N], m metricdata.Metrics, ks, vs [2]string, name string, mfs map[string]*dto.MetricFamily) { + drop, help := validateMetrics(name, m.Description, dto.MetricType_GAUGE.Enum(), mfs) + if drop { + return + } + if help != "" { + m.Description = help + } + for _, dp := range gauge.DataPoints { keys, values := getAttrs(dp.Attributes, ks, vs) @@ -344,3 +377,36 @@ func sanitizeName(n string) string { return b.String() } + +func validateMetrics(name, description string, metricType *dto.MetricType, mfs map[string]*dto.MetricFamily) (drop bool, help string) { + emf, exist := mfs[name] + if !exist { + mfs[name] = &dto.MetricFamily{ + Name: proto.String(name), + Help: proto.String(description), + Type: metricType, + } + return false, "" + } + if emf.GetType() != *metricType { + global.Error( + errors.New("instrument type conflict"), + "Using existing type definition.", + "instrument", name, + "existing", emf.GetType(), + "dropped", *metricType, + ) + return true, "" + } + if emf.GetHelp() != description { + global.Info( + "Instrument description conflict, using existing", + "instrument", name, + "existing", emf.GetHelp(), + "dropped", description, + ) + return false, emf.GetHelp() + } + + return false, "" +} diff --git a/exporters/prometheus/exporter_test.go b/exporters/prometheus/exporter_test.go index 4edf11ba48a..88027fe7fc4 100644 --- a/exporters/prometheus/exporter_test.go +++ b/exporters/prometheus/exporter_test.go @@ -386,3 +386,265 @@ func TestMultiScopes(t *testing.T) { err = testutil.GatherAndCompare(registry, file) require.NoError(t, err) } + +func TestDuplicateMetrics(t *testing.T) { + testCases := []struct { + name string + customResouceAttrs []attribute.KeyValue + recordMetrics func(ctx context.Context, meterA, meterB otelmetric.Meter) + options []Option + possibleExpectedFiles []string + }{ + { + name: "no_conflict_two_counters", + recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { + fooA, err := meterA.SyncInt64().Counter("foo", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter counter foo")) + assert.NoError(t, err) + fooA.Add(ctx, 100, attribute.String("A", "B")) + + fooB, err := meterB.SyncInt64().Counter("foo", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter counter foo")) + assert.NoError(t, err) + fooB.Add(ctx, 100, attribute.String("A", "B")) + }, + possibleExpectedFiles: []string{"testdata/no_conflict_two_counters.txt"}, + }, + { + name: "no_conflict_two_updowncounters", + recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { + fooA, err := meterA.SyncInt64().UpDownCounter("foo", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter gauge foo")) + assert.NoError(t, err) + fooA.Add(ctx, 100, attribute.String("A", "B")) + + fooB, err := meterB.SyncInt64().UpDownCounter("foo", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter gauge foo")) + assert.NoError(t, err) + fooB.Add(ctx, 100, attribute.String("A", "B")) + }, + possibleExpectedFiles: []string{"testdata/no_conflict_two_updowncounters.txt"}, + }, + { + name: "no_conflict_two_histograms", + recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { + fooA, err := meterA.SyncInt64().Histogram("foo", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter histogram foo")) + assert.NoError(t, err) + fooA.Record(ctx, 100, attribute.String("A", "B")) + + fooB, err := meterB.SyncInt64().Histogram("foo", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter histogram foo")) + assert.NoError(t, err) + fooB.Record(ctx, 100, attribute.String("A", "B")) + }, + possibleExpectedFiles: []string{"testdata/no_conflict_two_histograms.txt"}, + }, + { + name: "conflict_help_two_counters", + recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { + barA, err := meterA.SyncInt64().Counter("bar", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter a bar")) + assert.NoError(t, err) + barA.Add(ctx, 100, attribute.String("type", "bar")) + + barB, err := meterB.SyncInt64().Counter("bar", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter b bar")) + assert.NoError(t, err) + barB.Add(ctx, 100, attribute.String("type", "bar")) + }, + possibleExpectedFiles: []string{ + "testdata/conflict_help_two_counters_1.txt", + "testdata/conflict_help_two_counters_2.txt", + }, + }, + { + name: "conflict_help_two_updowncounters", + recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { + barA, err := meterA.SyncInt64().UpDownCounter("bar", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter a bar")) + assert.NoError(t, err) + barA.Add(ctx, 100, attribute.String("type", "bar")) + + barB, err := meterB.SyncInt64().UpDownCounter("bar", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter b bar")) + assert.NoError(t, err) + barB.Add(ctx, 100, attribute.String("type", "bar")) + }, + possibleExpectedFiles: []string{ + "testdata/conflict_help_two_updowncounters_1.txt", + "testdata/conflict_help_two_updowncounters_2.txt", + }, + }, + { + name: "conflict_help_two_histograms", + recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { + barA, err := meterA.SyncInt64().Histogram("bar", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter a bar")) + assert.NoError(t, err) + barA.Record(ctx, 100, attribute.String("A", "B")) + + barB, err := meterB.SyncInt64().Histogram("bar", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter b bar")) + assert.NoError(t, err) + barB.Record(ctx, 100, attribute.String("A", "B")) + }, + possibleExpectedFiles: []string{ + "testdata/conflict_help_two_histograms_1.txt", + "testdata/conflict_help_two_histograms_2.txt", + }, + }, + { + name: "conflict_unit_two_counters", + recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { + bazA, err := meterA.SyncInt64().Counter("bar", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter bar")) + assert.NoError(t, err) + bazA.Add(ctx, 100, attribute.String("type", "bar")) + + bazB, err := meterB.SyncInt64().Counter("bar", + instrument.WithUnit(unit.Milliseconds), + instrument.WithDescription("meter bar")) + assert.NoError(t, err) + bazB.Add(ctx, 100, attribute.String("type", "bar")) + }, + options: []Option{WithoutUnits()}, + possibleExpectedFiles: []string{"testdata/conflict_unit_two_counters.txt"}, + }, + { + name: "conflict_unit_two_updowncounters", + recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { + barA, err := meterA.SyncInt64().UpDownCounter("bar", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter gauge bar")) + assert.NoError(t, err) + barA.Add(ctx, 100, attribute.String("type", "bar")) + + barB, err := meterB.SyncInt64().UpDownCounter("bar", + instrument.WithUnit(unit.Milliseconds), + instrument.WithDescription("meter gauge bar")) + assert.NoError(t, err) + barB.Add(ctx, 100, attribute.String("type", "bar")) + }, + options: []Option{WithoutUnits()}, + possibleExpectedFiles: []string{"testdata/conflict_unit_two_updowncounters.txt"}, + }, + { + name: "conflict_unit_two_histograms", + recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { + barA, err := meterA.SyncInt64().Histogram("bar", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter histogram bar")) + assert.NoError(t, err) + barA.Record(ctx, 100, attribute.String("A", "B")) + + barB, err := meterB.SyncInt64().Histogram("bar", + instrument.WithUnit(unit.Milliseconds), + instrument.WithDescription("meter histogram bar")) + assert.NoError(t, err) + barB.Record(ctx, 100, attribute.String("A", "B")) + }, + options: []Option{WithoutUnits()}, + possibleExpectedFiles: []string{"testdata/conflict_unit_two_histograms.txt"}, + }, + { + name: "conflict_type_counter_and_updowncounter", + recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { + counter, err := meterA.SyncInt64().Counter("foo", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter foo")) + assert.NoError(t, err) + counter.Add(ctx, 100, attribute.String("type", "foo")) + + gauge, err := meterA.SyncInt64().UpDownCounter("foo_total", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter foo")) + assert.NoError(t, err) + gauge.Add(ctx, 200, attribute.String("type", "foo")) + }, + options: []Option{WithoutUnits()}, + possibleExpectedFiles: []string{ + "testdata/conflict_type_counter_and_updowncounter_1.txt", + "testdata/conflict_type_counter_and_updowncounter_2.txt", + }, + }, + { + name: "conflict_type_histogram_and_updowncounter", + recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { + fooA, err := meterA.SyncInt64().UpDownCounter("foo", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter gauge foo")) + assert.NoError(t, err) + fooA.Add(ctx, 100, attribute.String("A", "B")) + + fooHistogramA, err := meterA.SyncInt64().Histogram("foo", + instrument.WithUnit(unit.Bytes), + instrument.WithDescription("meter histogram foo")) + assert.NoError(t, err) + fooHistogramA.Record(ctx, 100, attribute.String("A", "B")) + }, + possibleExpectedFiles: []string{ + "testdata/conflict_type_histogram_and_updowncounter_1.txt", + "testdata/conflict_type_histogram_and_updowncounter_2.txt", + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + // initialize registry exporter + ctx := context.Background() + registry := prometheus.NewRegistry() + exporter, err := New(append(tc.options, WithRegisterer(registry))...) + require.NoError(t, err) + + // initialize resource + res, err := resource.New(ctx, + resource.WithAttributes(semconv.ServiceNameKey.String("prometheus_test")), + resource.WithAttributes(semconv.TelemetrySDKVersionKey.String("latest")), + ) + require.NoError(t, err) + res, err = resource.Merge(resource.Default(), res) + require.NoError(t, err) + + // initialize provider + provider := metric.NewMeterProvider( + metric.WithReader(exporter), + metric.WithResource(res), + ) + + // initialize two meter a, b + meterA := provider.Meter("ma", otelmetric.WithInstrumentationVersion("v0.1.0")) + meterB := provider.Meter("mb", otelmetric.WithInstrumentationVersion("v0.1.0")) + + tc.recordMetrics(ctx, meterA, meterB) + + var match = false + for _, filename := range tc.possibleExpectedFiles { + file, ferr := os.Open(filename) + require.NoError(t, ferr) + t.Cleanup(func() { require.NoError(t, file.Close()) }) + + err = testutil.GatherAndCompare(registry, file) + if err == nil { + match = true + break + } + } + require.Truef(t, match, "expected export not produced: %v", err) + }) + } +} diff --git a/exporters/prometheus/go.mod b/exporters/prometheus/go.mod index 731be2dfd70..33743742181 100644 --- a/exporters/prometheus/go.mod +++ b/exporters/prometheus/go.mod @@ -4,11 +4,13 @@ go 1.18 require ( github.com/prometheus/client_golang v1.14.0 + github.com/prometheus/client_model v0.3.0 github.com/stretchr/testify v1.8.1 go.opentelemetry.io/otel v1.11.1 go.opentelemetry.io/otel/metric v0.33.0 go.opentelemetry.io/otel/sdk v1.11.1 go.opentelemetry.io/otel/sdk/metric v0.33.0 + google.golang.org/protobuf v1.28.1 ) require ( @@ -20,12 +22,10 @@ require ( github.com/golang/protobuf v1.5.2 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/common v0.37.0 // indirect github.com/prometheus/procfs v0.8.0 // indirect go.opentelemetry.io/otel/trace v1.11.1 // indirect golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 // indirect - google.golang.org/protobuf v1.28.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/exporters/prometheus/testdata/conflict_help_two_counters_1.txt b/exporters/prometheus/testdata/conflict_help_two_counters_1.txt new file mode 100644 index 00000000000..103c42bd863 --- /dev/null +++ b/exporters/prometheus/testdata/conflict_help_two_counters_1.txt @@ -0,0 +1,11 @@ +# HELP bar_bytes_total meter a bar +# TYPE bar_bytes_total counter +bar_bytes_total{otel_scope_name="ma",otel_scope_version="v0.1.0",type="bar"} 100 +bar_bytes_total{otel_scope_name="mb",otel_scope_version="v0.1.0",type="bar"} 100 +# HELP otel_scope_info Instrumentation Scope metadata +# TYPE otel_scope_info gauge +otel_scope_info{otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +otel_scope_info{otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +# HELP target_info Target metadata +# TYPE target_info gauge +target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 diff --git a/exporters/prometheus/testdata/conflict_help_two_counters_2.txt b/exporters/prometheus/testdata/conflict_help_two_counters_2.txt new file mode 100644 index 00000000000..68405422e99 --- /dev/null +++ b/exporters/prometheus/testdata/conflict_help_two_counters_2.txt @@ -0,0 +1,11 @@ +# HELP bar_bytes_total meter b bar +# TYPE bar_bytes_total counter +bar_bytes_total{otel_scope_name="ma",otel_scope_version="v0.1.0",type="bar"} 100 +bar_bytes_total{otel_scope_name="mb",otel_scope_version="v0.1.0",type="bar"} 100 +# HELP otel_scope_info Instrumentation Scope metadata +# TYPE otel_scope_info gauge +otel_scope_info{otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +otel_scope_info{otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +# HELP target_info Target metadata +# TYPE target_info gauge +target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 diff --git a/exporters/prometheus/testdata/conflict_help_two_histograms_1.txt b/exporters/prometheus/testdata/conflict_help_two_histograms_1.txt new file mode 100644 index 00000000000..3bdccfc05a7 --- /dev/null +++ b/exporters/prometheus/testdata/conflict_help_two_histograms_1.txt @@ -0,0 +1,45 @@ +# HELP bar_bytes meter a bar +# TYPE bar_bytes histogram +bar_bytes_bucket{A="B",le="0",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="5",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="10",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="25",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="50",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="75",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="100",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="250",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="500",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="750",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="1000",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="2500",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="5000",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="7500",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="10000",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="+Inf",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_sum{A="B",otel_scope_name="ma",otel_scope_version="v0.1.0"} 100 +bar_bytes_count{A="B",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="0",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="5",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="10",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="25",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="50",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="75",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="100",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="250",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="500",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="750",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="1000",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="2500",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="5000",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="7500",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="10000",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="+Inf",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_sum{A="B",otel_scope_name="mb",otel_scope_version="v0.1.0"} 100 +bar_bytes_count{A="B",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +# HELP otel_scope_info Instrumentation Scope metadata +# TYPE otel_scope_info gauge +otel_scope_info{otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +otel_scope_info{otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +# HELP target_info Target metadata +# TYPE target_info gauge +target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 diff --git a/exporters/prometheus/testdata/conflict_help_two_histograms_2.txt b/exporters/prometheus/testdata/conflict_help_two_histograms_2.txt new file mode 100644 index 00000000000..2d9e5c966d9 --- /dev/null +++ b/exporters/prometheus/testdata/conflict_help_two_histograms_2.txt @@ -0,0 +1,45 @@ +# HELP bar_bytes meter b bar +# TYPE bar_bytes histogram +bar_bytes_bucket{A="B",le="0",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="5",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="10",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="25",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="50",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="75",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="100",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="250",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="500",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="750",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="1000",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="2500",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="5000",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="7500",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="10000",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="+Inf",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_sum{A="B",otel_scope_name="ma",otel_scope_version="v0.1.0"} 100 +bar_bytes_count{A="B",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="0",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="5",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="10",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="25",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="50",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="75",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +bar_bytes_bucket{A="B",le="100",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="250",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="500",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="750",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="1000",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="2500",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="5000",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="7500",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="10000",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_bucket{A="B",le="+Inf",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bytes_sum{A="B",otel_scope_name="mb",otel_scope_version="v0.1.0"} 100 +bar_bytes_count{A="B",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +# HELP otel_scope_info Instrumentation Scope metadata +# TYPE otel_scope_info gauge +otel_scope_info{otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +otel_scope_info{otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +# HELP target_info Target metadata +# TYPE target_info gauge +target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 diff --git a/exporters/prometheus/testdata/conflict_help_two_updowncounters_1.txt b/exporters/prometheus/testdata/conflict_help_two_updowncounters_1.txt new file mode 100644 index 00000000000..72fd145eab4 --- /dev/null +++ b/exporters/prometheus/testdata/conflict_help_two_updowncounters_1.txt @@ -0,0 +1,11 @@ +# HELP bar_bytes meter a bar +# TYPE bar_bytes gauge +bar_bytes{otel_scope_name="ma",otel_scope_version="v0.1.0",type="bar"} 100 +bar_bytes{otel_scope_name="mb",otel_scope_version="v0.1.0",type="bar"} 100 +# HELP otel_scope_info Instrumentation Scope metadata +# TYPE otel_scope_info gauge +otel_scope_info{otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +otel_scope_info{otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +# HELP target_info Target metadata +# TYPE target_info gauge +target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 diff --git a/exporters/prometheus/testdata/conflict_help_two_updowncounters_2.txt b/exporters/prometheus/testdata/conflict_help_two_updowncounters_2.txt new file mode 100644 index 00000000000..2e2cef1004b --- /dev/null +++ b/exporters/prometheus/testdata/conflict_help_two_updowncounters_2.txt @@ -0,0 +1,11 @@ +# HELP bar_bytes meter b bar +# TYPE bar_bytes gauge +bar_bytes{otel_scope_name="ma",otel_scope_version="v0.1.0",type="bar"} 100 +bar_bytes{otel_scope_name="mb",otel_scope_version="v0.1.0",type="bar"} 100 +# HELP otel_scope_info Instrumentation Scope metadata +# TYPE otel_scope_info gauge +otel_scope_info{otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +otel_scope_info{otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +# HELP target_info Target metadata +# TYPE target_info gauge +target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 diff --git a/exporters/prometheus/testdata/conflict_type_counter_and_updowncounter_1.txt b/exporters/prometheus/testdata/conflict_type_counter_and_updowncounter_1.txt new file mode 100644 index 00000000000..885fb3c7259 --- /dev/null +++ b/exporters/prometheus/testdata/conflict_type_counter_and_updowncounter_1.txt @@ -0,0 +1,9 @@ +# HELP foo_total meter foo +# TYPE foo_total counter +foo_total{otel_scope_name="ma",otel_scope_version="v0.1.0",type="foo"} 100 +# HELP otel_scope_info Instrumentation Scope metadata +# TYPE otel_scope_info gauge +otel_scope_info{otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +# HELP target_info Target metadata +# TYPE target_info gauge +target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 diff --git a/exporters/prometheus/testdata/conflict_type_counter_and_updowncounter_2.txt b/exporters/prometheus/testdata/conflict_type_counter_and_updowncounter_2.txt new file mode 100644 index 00000000000..62275c98260 --- /dev/null +++ b/exporters/prometheus/testdata/conflict_type_counter_and_updowncounter_2.txt @@ -0,0 +1,9 @@ +# HELP foo_total meter foo +# TYPE foo_total gauge +foo_total{otel_scope_name="ma",otel_scope_version="v0.1.0",type="foo"} 100 +# HELP otel_scope_info Instrumentation Scope metadata +# TYPE otel_scope_info gauge +otel_scope_info{otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +# HELP target_info Target metadata +# TYPE target_info gauge +target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 diff --git a/exporters/prometheus/testdata/conflict_type_histogram_and_updowncounter_1.txt b/exporters/prometheus/testdata/conflict_type_histogram_and_updowncounter_1.txt new file mode 100644 index 00000000000..91f1ef774f9 --- /dev/null +++ b/exporters/prometheus/testdata/conflict_type_histogram_and_updowncounter_1.txt @@ -0,0 +1,9 @@ +# HELP foo_bytes meter gauge foo +# TYPE foo_bytes gauge +foo_bytes{A="B",otel_scope_name="ma",otel_scope_version="v0.1.0"} 100 +# HELP otel_scope_info Instrumentation Scope metadata +# TYPE otel_scope_info gauge +otel_scope_info{otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +# HELP target_info Target metadata +# TYPE target_info gauge +target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 diff --git a/exporters/prometheus/testdata/conflict_type_histogram_and_updowncounter_2.txt b/exporters/prometheus/testdata/conflict_type_histogram_and_updowncounter_2.txt new file mode 100644 index 00000000000..15e9a9c570a --- /dev/null +++ b/exporters/prometheus/testdata/conflict_type_histogram_and_updowncounter_2.txt @@ -0,0 +1,26 @@ +# HELP foo_bytes meter histogram foo +# TYPE foo_bytes histogram +foo_bytes_bucket{A="B",le="0",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +foo_bytes_bucket{A="B",le="5",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +foo_bytes_bucket{A="B",le="10",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +foo_bytes_bucket{A="B",le="25",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +foo_bytes_bucket{A="B",le="50",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +foo_bytes_bucket{A="B",le="75",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +foo_bytes_bucket{A="B",le="100",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="250",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="500",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="750",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="1000",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="2500",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="5000",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="7500",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="10000",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="+Inf",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_sum{A="B",otel_scope_name="ma",otel_scope_version="v0.1.0"} 100 +foo_bytes_count{A="B",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +# HELP otel_scope_info Instrumentation Scope metadata +# TYPE otel_scope_info gauge +otel_scope_info{otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +# HELP target_info Target metadata +# TYPE target_info gauge +target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 diff --git a/exporters/prometheus/testdata/conflict_unit_two_counters.txt b/exporters/prometheus/testdata/conflict_unit_two_counters.txt new file mode 100644 index 00000000000..07efc2e5549 --- /dev/null +++ b/exporters/prometheus/testdata/conflict_unit_two_counters.txt @@ -0,0 +1,11 @@ +# HELP bar_total meter bar +# TYPE bar_total counter +bar_total{otel_scope_name="ma",otel_scope_version="v0.1.0",type="bar"} 100 +bar_total{otel_scope_name="mb",otel_scope_version="v0.1.0",type="bar"} 100 +# HELP otel_scope_info Instrumentation Scope metadata +# TYPE otel_scope_info gauge +otel_scope_info{otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +otel_scope_info{otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +# HELP target_info Target metadata +# TYPE target_info gauge +target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 diff --git a/exporters/prometheus/testdata/conflict_unit_two_histograms.txt b/exporters/prometheus/testdata/conflict_unit_two_histograms.txt new file mode 100644 index 00000000000..e41a7812e9a --- /dev/null +++ b/exporters/prometheus/testdata/conflict_unit_two_histograms.txt @@ -0,0 +1,45 @@ +# HELP bar meter histogram bar +# TYPE bar histogram +bar_bucket{A="B",le="0",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +bar_bucket{A="B",le="5",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +bar_bucket{A="B",le="10",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +bar_bucket{A="B",le="25",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +bar_bucket{A="B",le="50",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +bar_bucket{A="B",le="75",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +bar_bucket{A="B",le="100",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="250",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="500",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="750",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="1000",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="2500",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="5000",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="7500",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="10000",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="+Inf",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_sum{A="B",otel_scope_name="ma",otel_scope_version="v0.1.0"} 100 +bar_count{A="B",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="0",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +bar_bucket{A="B",le="5",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +bar_bucket{A="B",le="10",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +bar_bucket{A="B",le="25",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +bar_bucket{A="B",le="50",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +bar_bucket{A="B",le="75",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +bar_bucket{A="B",le="100",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="250",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="500",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="750",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="1000",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="2500",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="5000",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="7500",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="10000",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_bucket{A="B",le="+Inf",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +bar_sum{A="B",otel_scope_name="mb",otel_scope_version="v0.1.0"} 100 +bar_count{A="B",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +# HELP otel_scope_info Instrumentation Scope metadata +# TYPE otel_scope_info gauge +otel_scope_info{otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +otel_scope_info{otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +# HELP target_info Target metadata +# TYPE target_info gauge +target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 diff --git a/exporters/prometheus/testdata/conflict_unit_two_updowncounters.txt b/exporters/prometheus/testdata/conflict_unit_two_updowncounters.txt new file mode 100644 index 00000000000..54b608484e1 --- /dev/null +++ b/exporters/prometheus/testdata/conflict_unit_two_updowncounters.txt @@ -0,0 +1,11 @@ +# HELP bar meter gauge bar +# TYPE bar gauge +bar{otel_scope_name="ma",otel_scope_version="v0.1.0",type="bar"} 100 +bar{otel_scope_name="mb",otel_scope_version="v0.1.0",type="bar"} 100 +# HELP otel_scope_info Instrumentation Scope metadata +# TYPE otel_scope_info gauge +otel_scope_info{otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +otel_scope_info{otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +# HELP target_info Target metadata +# TYPE target_info gauge +target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 diff --git a/exporters/prometheus/testdata/no_conflict_two_counters.txt b/exporters/prometheus/testdata/no_conflict_two_counters.txt new file mode 100644 index 00000000000..4a1a1f5db3c --- /dev/null +++ b/exporters/prometheus/testdata/no_conflict_two_counters.txt @@ -0,0 +1,11 @@ +# HELP foo_bytes_total meter counter foo +# TYPE foo_bytes_total counter +foo_bytes_total{A="B",otel_scope_name="ma",otel_scope_version="v0.1.0"} 100 +foo_bytes_total{A="B",otel_scope_name="mb",otel_scope_version="v0.1.0"} 100 +# HELP otel_scope_info Instrumentation Scope metadata +# TYPE otel_scope_info gauge +otel_scope_info{otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +otel_scope_info{otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +# HELP target_info Target metadata +# TYPE target_info gauge +target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 diff --git a/exporters/prometheus/testdata/no_conflict_two_histograms.txt b/exporters/prometheus/testdata/no_conflict_two_histograms.txt new file mode 100644 index 00000000000..10b472032de --- /dev/null +++ b/exporters/prometheus/testdata/no_conflict_two_histograms.txt @@ -0,0 +1,45 @@ +# HELP foo_bytes meter histogram foo +# TYPE foo_bytes histogram +foo_bytes_bucket{A="B",le="0",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +foo_bytes_bucket{A="B",le="5",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +foo_bytes_bucket{A="B",le="10",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +foo_bytes_bucket{A="B",le="25",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +foo_bytes_bucket{A="B",le="50",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +foo_bytes_bucket{A="B",le="75",otel_scope_name="ma",otel_scope_version="v0.1.0"} 0 +foo_bytes_bucket{A="B",le="100",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="250",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="500",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="750",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="1000",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="2500",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="5000",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="7500",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="10000",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="+Inf",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_sum{A="B",otel_scope_name="ma",otel_scope_version="v0.1.0"} 100 +foo_bytes_count{A="B",otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="0",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +foo_bytes_bucket{A="B",le="5",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +foo_bytes_bucket{A="B",le="10",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +foo_bytes_bucket{A="B",le="25",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +foo_bytes_bucket{A="B",le="50",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +foo_bytes_bucket{A="B",le="75",otel_scope_name="mb",otel_scope_version="v0.1.0"} 0 +foo_bytes_bucket{A="B",le="100",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="250",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="500",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="750",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="1000",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="2500",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="5000",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="7500",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="10000",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +foo_bytes_bucket{A="B",le="+Inf",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +foo_bytes_sum{A="B",otel_scope_name="mb",otel_scope_version="v0.1.0"} 100 +foo_bytes_count{A="B",otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +# HELP otel_scope_info Instrumentation Scope metadata +# TYPE otel_scope_info gauge +otel_scope_info{otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +otel_scope_info{otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +# HELP target_info Target metadata +# TYPE target_info gauge +target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 diff --git a/exporters/prometheus/testdata/no_conflict_two_updowncounters.txt b/exporters/prometheus/testdata/no_conflict_two_updowncounters.txt new file mode 100644 index 00000000000..f2531f48b2d --- /dev/null +++ b/exporters/prometheus/testdata/no_conflict_two_updowncounters.txt @@ -0,0 +1,11 @@ +# HELP foo_bytes meter gauge foo +# TYPE foo_bytes gauge +foo_bytes{A="B",otel_scope_name="ma",otel_scope_version="v0.1.0"} 100 +foo_bytes{A="B",otel_scope_name="mb",otel_scope_version="v0.1.0"} 100 +# HELP otel_scope_info Instrumentation Scope metadata +# TYPE otel_scope_info gauge +otel_scope_info{otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 +otel_scope_info{otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 +# HELP target_info Target metadata +# TYPE target_info gauge +target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1