You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-07-15 01:04:25 +02:00
prometheus exporter convert instrumentation scope to otel_scope_info metric (#3357)
* prometheus exporter convert instrumentation scope to otel_scope_info metric Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com> * fix for commits Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com> * fix for ci failed Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com> * add multi scopes test Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com> * fix ci failed Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com> Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
This commit is contained in:
@ -12,6 +12,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||||||
|
|
||||||
- The `WithView` `Option` is added to the `go.opentelemetry.io/otel/sdk/metric` package.
|
- The `WithView` `Option` is added to the `go.opentelemetry.io/otel/sdk/metric` package.
|
||||||
This option is used to configure the view(s) a `MeterProvider` will use for all `Reader`s that are registered with it. (#3387)
|
This option is used to configure the view(s) a `MeterProvider` will use for all `Reader`s that are registered with it. (#3387)
|
||||||
|
- Add Instrumentation Scope and Version as info metric and label in Prometheus exporter.
|
||||||
|
This can be disabled using the `WithoutScopeInfo()` option added to that package.(#3273, #3357)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ type config struct {
|
|||||||
disableTargetInfo bool
|
disableTargetInfo bool
|
||||||
withoutUnits bool
|
withoutUnits bool
|
||||||
aggregation metric.AggregationSelector
|
aggregation metric.AggregationSelector
|
||||||
|
disableScopeInfo bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// newConfig creates a validated config configured with options.
|
// newConfig creates a validated config configured with options.
|
||||||
@ -105,3 +106,13 @@ func WithoutUnits() Option {
|
|||||||
return cfg
|
return cfg
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithoutScopeInfo configures the Exporter to not export the otel_scope_info metric.
|
||||||
|
// If not specified, the Exporter will create a otel_scope_info metric containing
|
||||||
|
// the metrics' Instrumentation Scope, and also add labels about Instrumentation Scope to all metric points.
|
||||||
|
func WithoutScopeInfo() Option {
|
||||||
|
return optionFunc(func(cfg config) config {
|
||||||
|
cfg.disableScopeInfo = true
|
||||||
|
return cfg
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -28,6 +28,7 @@ import (
|
|||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"go.opentelemetry.io/otel/metric/unit"
|
"go.opentelemetry.io/otel/metric/unit"
|
||||||
|
"go.opentelemetry.io/otel/sdk/instrumentation"
|
||||||
"go.opentelemetry.io/otel/sdk/metric"
|
"go.opentelemetry.io/otel/sdk/metric"
|
||||||
"go.opentelemetry.io/otel/sdk/metric/metricdata"
|
"go.opentelemetry.io/otel/sdk/metric/metricdata"
|
||||||
"go.opentelemetry.io/otel/sdk/resource"
|
"go.opentelemetry.io/otel/sdk/resource"
|
||||||
@ -36,8 +37,13 @@ import (
|
|||||||
const (
|
const (
|
||||||
targetInfoMetricName = "target_info"
|
targetInfoMetricName = "target_info"
|
||||||
targetInfoDescription = "Target metadata"
|
targetInfoDescription = "Target metadata"
|
||||||
|
|
||||||
|
scopeInfoMetricName = "otel_scope_info"
|
||||||
|
scopeInfoDescription = "Instrumentation Scope metadata"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var scopeInfoKeys = [2]string{"otel_scope_name", "otel_scope_version"}
|
||||||
|
|
||||||
// Exporter is a Prometheus Exporter that embeds the OTel metric.Reader
|
// Exporter is a Prometheus Exporter that embeds the OTel metric.Reader
|
||||||
// interface for easy instantiation with a MeterProvider.
|
// interface for easy instantiation with a MeterProvider.
|
||||||
type Exporter struct {
|
type Exporter struct {
|
||||||
@ -53,7 +59,9 @@ type collector struct {
|
|||||||
disableTargetInfo bool
|
disableTargetInfo bool
|
||||||
withoutUnits bool
|
withoutUnits bool
|
||||||
targetInfo prometheus.Metric
|
targetInfo prometheus.Metric
|
||||||
|
disableScopeInfo bool
|
||||||
createTargetInfoOnce sync.Once
|
createTargetInfoOnce sync.Once
|
||||||
|
scopeInfos map[instrumentation.Scope]prometheus.Metric
|
||||||
}
|
}
|
||||||
|
|
||||||
// prometheus counters MUST have a _total suffix:
|
// prometheus counters MUST have a _total suffix:
|
||||||
@ -73,6 +81,8 @@ func New(opts ...Option) (*Exporter, error) {
|
|||||||
reader: reader,
|
reader: reader,
|
||||||
disableTargetInfo: cfg.disableTargetInfo,
|
disableTargetInfo: cfg.disableTargetInfo,
|
||||||
withoutUnits: cfg.withoutUnits,
|
withoutUnits: cfg.withoutUnits,
|
||||||
|
disableScopeInfo: cfg.disableScopeInfo,
|
||||||
|
scopeInfos: make(map[instrumentation.Scope]prometheus.Metric),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cfg.registerer.Register(collector); err != nil {
|
if err := cfg.registerer.Register(collector); err != nil {
|
||||||
@ -118,28 +128,46 @@ func (c *collector) Collect(ch chan<- prometheus.Metric) {
|
|||||||
if !c.disableTargetInfo {
|
if !c.disableTargetInfo {
|
||||||
ch <- c.targetInfo
|
ch <- c.targetInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, scopeMetrics := range metrics.ScopeMetrics {
|
for _, scopeMetrics := range metrics.ScopeMetrics {
|
||||||
|
var keys, values [2]string
|
||||||
|
|
||||||
|
if !c.disableScopeInfo {
|
||||||
|
scopeInfo, ok := c.scopeInfos[scopeMetrics.Scope]
|
||||||
|
if !ok {
|
||||||
|
scopeInfo, err = createScopeInfoMetric(scopeMetrics.Scope)
|
||||||
|
if err != nil {
|
||||||
|
otel.Handle(err)
|
||||||
|
}
|
||||||
|
c.scopeInfos[scopeMetrics.Scope] = scopeInfo
|
||||||
|
}
|
||||||
|
ch <- scopeInfo
|
||||||
|
keys = scopeInfoKeys
|
||||||
|
values = [2]string{scopeMetrics.Scope.Name, scopeMetrics.Scope.Version}
|
||||||
|
}
|
||||||
|
|
||||||
for _, m := range scopeMetrics.Metrics {
|
for _, m := range scopeMetrics.Metrics {
|
||||||
switch v := m.Data.(type) {
|
switch v := m.Data.(type) {
|
||||||
case metricdata.Histogram:
|
case metricdata.Histogram:
|
||||||
addHistogramMetric(ch, v, m, c.getName(m))
|
addHistogramMetric(ch, v, m, keys, values, c.getName(m))
|
||||||
case metricdata.Sum[int64]:
|
case metricdata.Sum[int64]:
|
||||||
addSumMetric(ch, v, m, c.getName(m))
|
addSumMetric(ch, v, m, keys, values, c.getName(m))
|
||||||
case metricdata.Sum[float64]:
|
case metricdata.Sum[float64]:
|
||||||
addSumMetric(ch, v, m, c.getName(m))
|
addSumMetric(ch, v, m, keys, values, c.getName(m))
|
||||||
case metricdata.Gauge[int64]:
|
case metricdata.Gauge[int64]:
|
||||||
addGaugeMetric(ch, v, m, c.getName(m))
|
addGaugeMetric(ch, v, m, keys, values, c.getName(m))
|
||||||
case metricdata.Gauge[float64]:
|
case metricdata.Gauge[float64]:
|
||||||
addGaugeMetric(ch, v, m, c.getName(m))
|
addGaugeMetric(ch, v, m, keys, values, c.getName(m))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func addHistogramMetric(ch chan<- prometheus.Metric, histogram metricdata.Histogram, m metricdata.Metrics, name string) {
|
func addHistogramMetric(ch chan<- prometheus.Metric, histogram metricdata.Histogram, m metricdata.Metrics, ks, vs [2]string, name string) {
|
||||||
// TODO(https://github.com/open-telemetry/opentelemetry-go/issues/3163): support exemplars
|
// TODO(https://github.com/open-telemetry/opentelemetry-go/issues/3163): support exemplars
|
||||||
for _, dp := range histogram.DataPoints {
|
for _, dp := range histogram.DataPoints {
|
||||||
keys, values := getAttrs(dp.Attributes)
|
keys, values := getAttrs(dp.Attributes, ks, vs)
|
||||||
|
|
||||||
desc := prometheus.NewDesc(name, m.Description, keys, nil)
|
desc := prometheus.NewDesc(name, m.Description, keys, nil)
|
||||||
buckets := make(map[float64]uint64, len(dp.Bounds))
|
buckets := make(map[float64]uint64, len(dp.Bounds))
|
||||||
|
|
||||||
@ -157,7 +185,7 @@ 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, name string) {
|
func addSumMetric[N int64 | float64](ch chan<- prometheus.Metric, sum metricdata.Sum[N], m metricdata.Metrics, ks, vs [2]string, name string) {
|
||||||
valueType := prometheus.CounterValue
|
valueType := prometheus.CounterValue
|
||||||
if !sum.IsMonotonic {
|
if !sum.IsMonotonic {
|
||||||
valueType = prometheus.GaugeValue
|
valueType = prometheus.GaugeValue
|
||||||
@ -167,7 +195,8 @@ func addSumMetric[N int64 | float64](ch chan<- prometheus.Metric, sum metricdata
|
|||||||
name += counterSuffix
|
name += counterSuffix
|
||||||
}
|
}
|
||||||
for _, dp := range sum.DataPoints {
|
for _, dp := range sum.DataPoints {
|
||||||
keys, values := getAttrs(dp.Attributes)
|
keys, values := getAttrs(dp.Attributes, ks, vs)
|
||||||
|
|
||||||
desc := prometheus.NewDesc(name, m.Description, keys, nil)
|
desc := prometheus.NewDesc(name, m.Description, keys, nil)
|
||||||
m, err := prometheus.NewConstMetric(desc, valueType, float64(dp.Value), values...)
|
m, err := prometheus.NewConstMetric(desc, valueType, float64(dp.Value), values...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -178,9 +207,10 @@ 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, name string) {
|
func addGaugeMetric[N int64 | float64](ch chan<- prometheus.Metric, gauge metricdata.Gauge[N], m metricdata.Metrics, ks, vs [2]string, name string) {
|
||||||
for _, dp := range gauge.DataPoints {
|
for _, dp := range gauge.DataPoints {
|
||||||
keys, values := getAttrs(dp.Attributes)
|
keys, values := getAttrs(dp.Attributes, ks, vs)
|
||||||
|
|
||||||
desc := prometheus.NewDesc(name, m.Description, keys, nil)
|
desc := prometheus.NewDesc(name, m.Description, keys, nil)
|
||||||
m, err := prometheus.NewConstMetric(desc, prometheus.GaugeValue, float64(dp.Value), values...)
|
m, err := prometheus.NewConstMetric(desc, prometheus.GaugeValue, float64(dp.Value), values...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -194,7 +224,7 @@ func addGaugeMetric[N int64 | float64](ch chan<- prometheus.Metric, gauge metric
|
|||||||
// getAttrs parses the attribute.Set to two lists of matching Prometheus-style
|
// getAttrs parses the attribute.Set to two lists of matching Prometheus-style
|
||||||
// keys and values. It sanitizes invalid characters and handles duplicate keys
|
// keys and values. It sanitizes invalid characters and handles duplicate keys
|
||||||
// (due to sanitization) by sorting and concatenating the values following the spec.
|
// (due to sanitization) by sorting and concatenating the values following the spec.
|
||||||
func getAttrs(attrs attribute.Set) ([]string, []string) {
|
func getAttrs(attrs attribute.Set, ks, vs [2]string) ([]string, []string) {
|
||||||
keysMap := make(map[string][]string)
|
keysMap := make(map[string][]string)
|
||||||
itr := attrs.Iter()
|
itr := attrs.Iter()
|
||||||
for itr.Next() {
|
for itr.Next() {
|
||||||
@ -217,15 +247,26 @@ func getAttrs(attrs attribute.Set) ([]string, []string) {
|
|||||||
})
|
})
|
||||||
values = append(values, strings.Join(vals, ";"))
|
values = append(values, strings.Join(vals, ";"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ks[0] != "" {
|
||||||
|
keys = append(keys, ks[:]...)
|
||||||
|
values = append(values, vs[:]...)
|
||||||
|
}
|
||||||
return keys, values
|
return keys, values
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *collector) createInfoMetric(name, description string, res *resource.Resource) (prometheus.Metric, error) {
|
func (c *collector) createInfoMetric(name, description string, res *resource.Resource) (prometheus.Metric, error) {
|
||||||
keys, values := getAttrs(*res.Set())
|
keys, values := getAttrs(*res.Set(), [2]string{}, [2]string{})
|
||||||
desc := prometheus.NewDesc(name, description, keys, nil)
|
desc := prometheus.NewDesc(name, description, keys, nil)
|
||||||
return prometheus.NewConstMetric(desc, prometheus.GaugeValue, float64(1), values...)
|
return prometheus.NewConstMetric(desc, prometheus.GaugeValue, float64(1), values...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func createScopeInfoMetric(scope instrumentation.Scope) (prometheus.Metric, error) {
|
||||||
|
keys := scopeInfoKeys[:]
|
||||||
|
desc := prometheus.NewDesc(scopeInfoMetricName, scopeInfoDescription, keys, nil)
|
||||||
|
return prometheus.NewConstMetric(desc, prometheus.GaugeValue, float64(1), scope.Name, scope.Version)
|
||||||
|
}
|
||||||
|
|
||||||
func sanitizeRune(r rune) rune {
|
func sanitizeRune(r rune) rune {
|
||||||
if unicode.IsLetter(r) || unicode.IsDigit(r) || r == ':' || r == '_' {
|
if unicode.IsLetter(r) || unicode.IsDigit(r) || r == ':' || r == '_' {
|
||||||
return r
|
return r
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/client_golang/prometheus/testutil"
|
"github.com/prometheus/client_golang/prometheus/testutil"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
@ -221,6 +222,44 @@ func TestPrometheusExporter(t *testing.T) {
|
|||||||
counter.Add(ctx, 9, attrs...)
|
counter.Add(ctx, 9, attrs...)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "without scope_info",
|
||||||
|
options: []Option{WithoutScopeInfo()},
|
||||||
|
expectedFile: "testdata/without_scope_info.txt",
|
||||||
|
recordMetrics: func(ctx context.Context, meter otelmetric.Meter) {
|
||||||
|
attrs := []attribute.KeyValue{
|
||||||
|
attribute.Key("A").String("B"),
|
||||||
|
attribute.Key("C").String("D"),
|
||||||
|
}
|
||||||
|
gauge, err := meter.SyncInt64().UpDownCounter(
|
||||||
|
"bar",
|
||||||
|
instrument.WithDescription("a fun little gauge"),
|
||||||
|
instrument.WithUnit(unit.Dimensionless),
|
||||||
|
)
|
||||||
|
require.NoError(t, err)
|
||||||
|
gauge.Add(ctx, 2, attrs...)
|
||||||
|
gauge.Add(ctx, -1, attrs...)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "without scope_info and target_info",
|
||||||
|
options: []Option{WithoutScopeInfo(), WithoutTargetInfo()},
|
||||||
|
expectedFile: "testdata/without_scope_and_target_info.txt",
|
||||||
|
recordMetrics: func(ctx context.Context, meter otelmetric.Meter) {
|
||||||
|
attrs := []attribute.KeyValue{
|
||||||
|
attribute.Key("A").String("B"),
|
||||||
|
attribute.Key("C").String("D"),
|
||||||
|
}
|
||||||
|
counter, err := meter.SyncInt64().Counter(
|
||||||
|
"bar",
|
||||||
|
instrument.WithDescription("a fun little counter"),
|
||||||
|
instrument.WithUnit(unit.Bytes),
|
||||||
|
)
|
||||||
|
require.NoError(t, err)
|
||||||
|
counter.Add(ctx, 2, attrs...)
|
||||||
|
counter.Add(ctx, 1, attrs...)
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
@ -263,7 +302,10 @@ func TestPrometheusExporter(t *testing.T) {
|
|||||||
metric.WithReader(exporter),
|
metric.WithReader(exporter),
|
||||||
metric.WithView(customBucketsView, defaultView),
|
metric.WithView(customBucketsView, defaultView),
|
||||||
)
|
)
|
||||||
meter := provider.Meter("testmeter")
|
meter := provider.Meter(
|
||||||
|
"testmeter",
|
||||||
|
otelmetric.WithInstrumentationVersion("v0.1.0"),
|
||||||
|
)
|
||||||
|
|
||||||
tc.recordMetrics(ctx, meter)
|
tc.recordMetrics(ctx, meter)
|
||||||
|
|
||||||
@ -306,3 +348,48 @@ func TestSantitizeName(t *testing.T) {
|
|||||||
require.Equalf(t, test.want, sanitizeName(test.input), "input: %q", test.input)
|
require.Equalf(t, test.want, sanitizeName(test.input), "input: %q", test.input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMultiScopes(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
registry := prometheus.NewRegistry()
|
||||||
|
exporter, err := New(WithRegisterer(registry))
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
res, err := resource.New(ctx,
|
||||||
|
// always specify service.name because the default depends on the running OS
|
||||||
|
resource.WithAttributes(semconv.ServiceNameKey.String("prometheus_test")),
|
||||||
|
// Overwrite the semconv.TelemetrySDKVersionKey value so we don't need to update every version
|
||||||
|
resource.WithAttributes(semconv.TelemetrySDKVersionKey.String("latest")),
|
||||||
|
)
|
||||||
|
require.NoError(t, err)
|
||||||
|
res, err = resource.Merge(resource.Default(), res)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
provider := metric.NewMeterProvider(
|
||||||
|
metric.WithReader(exporter),
|
||||||
|
metric.WithResource(res),
|
||||||
|
)
|
||||||
|
|
||||||
|
fooCounter, err := provider.Meter("meterfoo", otelmetric.WithInstrumentationVersion("v0.1.0")).
|
||||||
|
SyncInt64().Counter(
|
||||||
|
"foo",
|
||||||
|
instrument.WithUnit(unit.Milliseconds),
|
||||||
|
instrument.WithDescription("meter foo counter"))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
fooCounter.Add(ctx, 100, attribute.String("type", "foo"))
|
||||||
|
|
||||||
|
barCounter, err := provider.Meter("meterbar", otelmetric.WithInstrumentationVersion("v0.1.0")).
|
||||||
|
SyncInt64().Counter(
|
||||||
|
"bar",
|
||||||
|
instrument.WithUnit(unit.Milliseconds),
|
||||||
|
instrument.WithDescription("meter bar counter"))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
barCounter.Add(ctx, 200, attribute.String("type", "bar"))
|
||||||
|
|
||||||
|
file, err := os.Open("testdata/multi_scopes.txt")
|
||||||
|
require.NoError(t, err)
|
||||||
|
t.Cleanup(func() { require.NoError(t, file.Close()) })
|
||||||
|
|
||||||
|
err = testutil.GatherAndCompare(registry, file)
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
7
exporters/prometheus/testdata/counter.txt
vendored
7
exporters/prometheus/testdata/counter.txt
vendored
@ -1,7 +1,10 @@
|
|||||||
# HELP foo_milliseconds_total a simple counter
|
# HELP foo_milliseconds_total a simple counter
|
||||||
# TYPE foo_milliseconds_total counter
|
# TYPE foo_milliseconds_total counter
|
||||||
foo_milliseconds_total{A="B",C="D",E="true",F="42"} 24.3
|
foo_milliseconds_total{A="B",C="D",E="true",F="42",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 24.3
|
||||||
foo_milliseconds_total{A="D",C="B",E="true",F="42"} 5
|
foo_milliseconds_total{A="D",C="B",E="true",F="42",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 5
|
||||||
|
# HELP otel_scope_info Instrumentation Scope metadata
|
||||||
|
# TYPE otel_scope_info gauge
|
||||||
|
otel_scope_info{otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
# HELP target_info Target metadata
|
# HELP target_info Target metadata
|
||||||
# TYPE target_info gauge
|
# TYPE target_info gauge
|
||||||
target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1
|
target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
# HELP foo_total a simple counter
|
# HELP foo_total a simple counter
|
||||||
# TYPE foo_total counter
|
# TYPE foo_total counter
|
||||||
foo_total{A="B",C="D",E="true",F="42"} 24.3
|
foo_total{A="B",C="D",E="true",F="42",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 24.3
|
||||||
|
# HELP otel_scope_info Instrumentation Scope metadata
|
||||||
|
# TYPE otel_scope_info gauge
|
||||||
|
otel_scope_info{otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
# HELP target_info Target metadata
|
# HELP target_info Target metadata
|
||||||
# TYPE target_info gauge
|
# TYPE target_info gauge
|
||||||
target_info{A="B",C="D",service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1
|
target_info{A="B",C="D",service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
# HELP foo_total a simple counter
|
# HELP foo_total a simple counter
|
||||||
# TYPE foo_total counter
|
# TYPE foo_total counter
|
||||||
foo_total{A="B",C="D",E="true",F="42"} 24.3
|
foo_total{A="B",C="D",E="true",F="42",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 24.3
|
||||||
|
# HELP otel_scope_info Instrumentation Scope metadata
|
||||||
|
# TYPE otel_scope_info gauge
|
||||||
|
otel_scope_info{otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
# HELP target_info Target metadata
|
# HELP target_info Target metadata
|
||||||
# TYPE target_info gauge
|
# TYPE target_info gauge
|
||||||
target_info 1
|
target_info 1
|
||||||
|
5
exporters/prometheus/testdata/gauge.txt
vendored
5
exporters/prometheus/testdata/gauge.txt
vendored
@ -1,6 +1,9 @@
|
|||||||
# HELP bar_ratio a fun little gauge
|
# HELP bar_ratio a fun little gauge
|
||||||
# TYPE bar_ratio gauge
|
# TYPE bar_ratio gauge
|
||||||
bar_ratio{A="B",C="D"} .75
|
bar_ratio{A="B",C="D",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} .75
|
||||||
|
# HELP otel_scope_info Instrumentation Scope metadata
|
||||||
|
# TYPE otel_scope_info gauge
|
||||||
|
otel_scope_info{otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
# HELP target_info Target metadata
|
# HELP target_info Target metadata
|
||||||
# TYPE target_info gauge
|
# TYPE target_info gauge
|
||||||
target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1
|
target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1
|
||||||
|
29
exporters/prometheus/testdata/histogram.txt
vendored
29
exporters/prometheus/testdata/histogram.txt
vendored
@ -1,18 +1,21 @@
|
|||||||
# HELP histogram_baz_bytes a very nice histogram
|
# HELP histogram_baz_bytes a very nice histogram
|
||||||
# TYPE histogram_baz_bytes histogram
|
# TYPE histogram_baz_bytes histogram
|
||||||
histogram_baz_bytes_bucket{A="B",C="D",le="0"} 0
|
histogram_baz_bytes_bucket{A="B",C="D",le="0",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 0
|
||||||
histogram_baz_bytes_bucket{A="B",C="D",le="5"} 0
|
histogram_baz_bytes_bucket{A="B",C="D",le="5",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 0
|
||||||
histogram_baz_bytes_bucket{A="B",C="D",le="10"} 1
|
histogram_baz_bytes_bucket{A="B",C="D",le="10",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
histogram_baz_bytes_bucket{A="B",C="D",le="25"} 2
|
histogram_baz_bytes_bucket{A="B",C="D",le="25",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 2
|
||||||
histogram_baz_bytes_bucket{A="B",C="D",le="50"} 2
|
histogram_baz_bytes_bucket{A="B",C="D",le="50",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 2
|
||||||
histogram_baz_bytes_bucket{A="B",C="D",le="75"} 2
|
histogram_baz_bytes_bucket{A="B",C="D",le="75",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 2
|
||||||
histogram_baz_bytes_bucket{A="B",C="D",le="100"} 2
|
histogram_baz_bytes_bucket{A="B",C="D",le="100",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 2
|
||||||
histogram_baz_bytes_bucket{A="B",C="D",le="250"} 4
|
histogram_baz_bytes_bucket{A="B",C="D",le="250",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 4
|
||||||
histogram_baz_bytes_bucket{A="B",C="D",le="500"} 4
|
histogram_baz_bytes_bucket{A="B",C="D",le="500",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 4
|
||||||
histogram_baz_bytes_bucket{A="B",C="D",le="1000"} 4
|
histogram_baz_bytes_bucket{A="B",C="D",le="1000",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 4
|
||||||
histogram_baz_bytes_bucket{A="B",C="D",le="+Inf"} 4
|
histogram_baz_bytes_bucket{A="B",C="D",le="+Inf",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 4
|
||||||
histogram_baz_bytes_sum{A="B",C="D"} 236
|
histogram_baz_bytes_sum{A="B",C="D",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 236
|
||||||
histogram_baz_bytes_count{A="B",C="D"} 4
|
histogram_baz_bytes_count{A="B",C="D",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 4
|
||||||
|
# HELP otel_scope_info Instrumentation Scope metadata
|
||||||
|
# TYPE otel_scope_info gauge
|
||||||
|
otel_scope_info{otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
# HELP target_info Target metadata
|
# HELP target_info Target metadata
|
||||||
# TYPE target_info gauge
|
# TYPE target_info gauge
|
||||||
target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1
|
target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1
|
||||||
|
13
exporters/prometheus/testdata/multi_scopes.txt
vendored
Normal file
13
exporters/prometheus/testdata/multi_scopes.txt
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# HELP bar_milliseconds_total meter bar counter
|
||||||
|
# TYPE bar_milliseconds_total counter
|
||||||
|
bar_milliseconds_total{otel_scope_name="meterbar",otel_scope_version="v0.1.0",type="bar"} 200
|
||||||
|
# HELP foo_milliseconds_total meter foo counter
|
||||||
|
# TYPE foo_milliseconds_total counter
|
||||||
|
foo_milliseconds_total{otel_scope_name="meterfoo",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="meterfoo",otel_scope_version="v0.1.0"} 1
|
||||||
|
otel_scope_info{otel_scope_name="meterbar",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
|
@ -1,6 +1,9 @@
|
|||||||
# HELP foo_total a sanitary counter
|
# HELP foo_total a sanitary counter
|
||||||
# TYPE foo_total counter
|
# TYPE foo_total counter
|
||||||
foo_total{A_B="Q",C_D="Y;Z"} 24.3
|
foo_total{A_B="Q",C_D="Y;Z",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 24.3
|
||||||
|
# HELP otel_scope_info Instrumentation Scope metadata
|
||||||
|
# TYPE otel_scope_info gauge
|
||||||
|
otel_scope_info{otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
# HELP target_info Target metadata
|
# HELP target_info Target metadata
|
||||||
# TYPE target_info gauge
|
# TYPE target_info gauge
|
||||||
target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1
|
target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1
|
||||||
|
@ -1,32 +1,35 @@
|
|||||||
# HELP bar a fun little gauge
|
# HELP bar a fun little gauge
|
||||||
# TYPE bar gauge
|
# TYPE bar gauge
|
||||||
bar{A="B",C="D"} 75
|
bar{A="B",C="D",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 75
|
||||||
# HELP _0invalid_counter_name_total a counter with an invalid name
|
# HELP _0invalid_counter_name_total a counter with an invalid name
|
||||||
# TYPE _0invalid_counter_name_total counter
|
# TYPE _0invalid_counter_name_total counter
|
||||||
_0invalid_counter_name_total{A="B",C="D"} 100
|
_0invalid_counter_name_total{A="B",C="D",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 100
|
||||||
# HELP invalid_gauge_name a gauge with an invalid name
|
# HELP invalid_gauge_name a gauge with an invalid name
|
||||||
# TYPE invalid_gauge_name gauge
|
# TYPE invalid_gauge_name gauge
|
||||||
invalid_gauge_name{A="B",C="D"} 100
|
invalid_gauge_name{A="B",C="D",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 100
|
||||||
# HELP invalid_hist_name a histogram with an invalid name
|
# HELP invalid_hist_name a histogram with an invalid name
|
||||||
# TYPE invalid_hist_name histogram
|
# TYPE invalid_hist_name histogram
|
||||||
invalid_hist_name_bucket{A="B",C="D",le="0"} 0
|
invalid_hist_name_bucket{A="B",C="D",le="0",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 0
|
||||||
invalid_hist_name_bucket{A="B",C="D",le="5"} 0
|
invalid_hist_name_bucket{A="B",C="D",le="5",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 0
|
||||||
invalid_hist_name_bucket{A="B",C="D",le="10"} 0
|
invalid_hist_name_bucket{A="B",C="D",le="10",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 0
|
||||||
invalid_hist_name_bucket{A="B",C="D",le="25"} 1
|
invalid_hist_name_bucket{A="B",C="D",le="25",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
invalid_hist_name_bucket{A="B",C="D",le="50"} 1
|
invalid_hist_name_bucket{A="B",C="D",le="50",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
invalid_hist_name_bucket{A="B",C="D",le="75"} 1
|
invalid_hist_name_bucket{A="B",C="D",le="75",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
invalid_hist_name_bucket{A="B",C="D",le="100"} 1
|
invalid_hist_name_bucket{A="B",C="D",le="100",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
invalid_hist_name_bucket{A="B",C="D",le="250"} 1
|
invalid_hist_name_bucket{A="B",C="D",le="250",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
invalid_hist_name_bucket{A="B",C="D",le="500"} 1
|
invalid_hist_name_bucket{A="B",C="D",le="500",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
invalid_hist_name_bucket{A="B",C="D",le="750"} 1
|
invalid_hist_name_bucket{A="B",C="D",le="750",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
invalid_hist_name_bucket{A="B",C="D",le="1000"} 1
|
invalid_hist_name_bucket{A="B",C="D",le="1000",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
invalid_hist_name_bucket{A="B",C="D",le="2500"} 1
|
invalid_hist_name_bucket{A="B",C="D",le="2500",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
invalid_hist_name_bucket{A="B",C="D",le="5000"} 1
|
invalid_hist_name_bucket{A="B",C="D",le="5000",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
invalid_hist_name_bucket{A="B",C="D",le="7500"} 1
|
invalid_hist_name_bucket{A="B",C="D",le="7500",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
invalid_hist_name_bucket{A="B",C="D",le="10000"} 1
|
invalid_hist_name_bucket{A="B",C="D",le="10000",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
invalid_hist_name_bucket{A="B",C="D",le="+Inf"} 1
|
invalid_hist_name_bucket{A="B",C="D",le="+Inf",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
invalid_hist_name_sum{A="B",C="D"} 23
|
invalid_hist_name_sum{A="B",C="D",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 23
|
||||||
invalid_hist_name_count{A="B",C="D"} 1
|
invalid_hist_name_count{A="B",C="D",otel_scope_name="testmeter",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="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
# HELP target_info Target metadata
|
# HELP target_info Target metadata
|
||||||
# TYPE target_info gauge
|
# TYPE target_info gauge
|
||||||
target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1
|
target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1
|
||||||
|
3
exporters/prometheus/testdata/without_scope_and_target_info.txt
vendored
Normal file
3
exporters/prometheus/testdata/without_scope_and_target_info.txt
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# HELP bar_bytes_total a fun little counter
|
||||||
|
# TYPE bar_bytes_total counter
|
||||||
|
bar_bytes_total{A="B",C="D"} 3
|
6
exporters/prometheus/testdata/without_scope_info.txt
vendored
Normal file
6
exporters/prometheus/testdata/without_scope_info.txt
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# HELP bar_ratio a fun little gauge
|
||||||
|
# TYPE bar_ratio gauge
|
||||||
|
bar_ratio{A="B",C="D"} 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
|
@ -1,3 +1,6 @@
|
|||||||
# HELP foo_total a simple counter
|
# HELP foo_total a simple counter
|
||||||
# TYPE foo_total counter
|
# TYPE foo_total counter
|
||||||
foo_total{A="B",C="D",E="true",F="42"} 24.3
|
foo_total{A="B",C="D",E="true",F="42",otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 24.3
|
||||||
|
# HELP otel_scope_info Instrumentation Scope metadata
|
||||||
|
# TYPE otel_scope_info gauge
|
||||||
|
otel_scope_info{otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1
|
||||||
|
Reference in New Issue
Block a user