mirror of
https://github.com/prometheus/prometheus.git
synced 2025-08-05 21:57:09 +02:00
OTLP receiver: Rename otlp.convert_scope_metadata
to otlp.promote_scope_metadata
(#16760)
* Rename otlp.convert_scope_metadata to otlp.promote_scope_metadata --------- Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> Co-authored-by: Julius Hinze <juliusmh@proton.me>
This commit is contained in:
parent
8f75da3fd6
commit
c701636034
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## main / unreleased
|
## main / unreleased
|
||||||
|
|
||||||
* [FEATURE] OTLP receiver: Support including scope attributes/name/version/schema URL as metric labels, via configuration parameter `otlp.convert_scope_metadata`. #16730
|
* [FEATURE] OTLP receiver: Support promoting OTel scope name/version/schema URL/attributes as metric labels, enable via configuration parameter `otlp.promote_scope_metadata`. #16730 #16760
|
||||||
|
|
||||||
## 3.4.2 / 2025-06-04
|
## 3.4.2 / 2025-06-04
|
||||||
|
|
||||||
|
@ -1562,9 +1562,9 @@ type OTLPConfig struct {
|
|||||||
TranslationStrategy translationStrategyOption `yaml:"translation_strategy,omitempty"`
|
TranslationStrategy translationStrategyOption `yaml:"translation_strategy,omitempty"`
|
||||||
KeepIdentifyingResourceAttributes bool `yaml:"keep_identifying_resource_attributes,omitempty"`
|
KeepIdentifyingResourceAttributes bool `yaml:"keep_identifying_resource_attributes,omitempty"`
|
||||||
ConvertHistogramsToNHCB bool `yaml:"convert_histograms_to_nhcb,omitempty"`
|
ConvertHistogramsToNHCB bool `yaml:"convert_histograms_to_nhcb,omitempty"`
|
||||||
// ConvertScopeMetadata controls whether to convert OTel scope metadata (i.e. name, version, schema URL, and attributes) to metric labels.
|
// PromoteScopeMetadata controls whether to promote OTel scope metadata (i.e. name, version, schema URL, and attributes) to metric labels.
|
||||||
// As per OTel spec, the aforementioned scope metadata should be identifying, i.e. made into metric labels.
|
// As per OTel spec, the aforementioned scope metadata should be identifying, i.e. made into metric labels.
|
||||||
ConvertScopeMetadata bool `yaml:"convert_scope_metadata,omitempty"`
|
PromoteScopeMetadata bool `yaml:"promote_scope_metadata,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalYAML implements the yaml.Unmarshaler interface.
|
// UnmarshalYAML implements the yaml.Unmarshaler interface.
|
||||||
|
@ -1808,9 +1808,9 @@ func TestOTLPConvertHistogramsToNHCB(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOTLPConvertScopeMetadata(t *testing.T) {
|
func TestOTLPPromoteScopeMetadata(t *testing.T) {
|
||||||
t.Run("good config", func(t *testing.T) {
|
t.Run("good config", func(t *testing.T) {
|
||||||
want, err := LoadFile(filepath.Join("testdata", "otlp_convert_scope_metadata.good.yml"), false, promslog.NewNopLogger())
|
want, err := LoadFile(filepath.Join("testdata", "otlp_promote_scope_metadata.good.yml"), false, promslog.NewNopLogger())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
out, err := yaml.Marshal(want)
|
out, err := yaml.Marshal(want)
|
||||||
@ -1818,7 +1818,7 @@ func TestOTLPConvertScopeMetadata(t *testing.T) {
|
|||||||
var got Config
|
var got Config
|
||||||
require.NoError(t, yaml.UnmarshalStrict(out, &got))
|
require.NoError(t, yaml.UnmarshalStrict(out, &got))
|
||||||
|
|
||||||
require.True(t, got.OTLPConfig.ConvertScopeMetadata)
|
require.True(t, got.OTLPConfig.PromoteScopeMetadata)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
otlp:
|
|
||||||
convert_scope_metadata: true
|
|
2
config/testdata/otlp_promote_scope_metadata.good.yml
vendored
Normal file
2
config/testdata/otlp_promote_scope_metadata.good.yml
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
otlp:
|
||||||
|
promote_scope_metadata: true
|
@ -214,9 +214,9 @@ otlp:
|
|||||||
[ keep_identifying_resource_attributes: <boolean> | default = false ]
|
[ keep_identifying_resource_attributes: <boolean> | default = false ]
|
||||||
# Configures optional translation of OTLP explicit bucket histograms into native histograms with custom buckets.
|
# Configures optional translation of OTLP explicit bucket histograms into native histograms with custom buckets.
|
||||||
[ convert_histograms_to_nhcb: <boolean> | default = false ]
|
[ convert_histograms_to_nhcb: <boolean> | default = false ]
|
||||||
# Enables translation of OTel scope metadata (i.e. name, version, schema URL, and attributes) into metric metadata.
|
# Enables promotion of OTel scope metadata (i.e. name, version, schema URL, and attributes) to metric labels.
|
||||||
# This is disabled by default for backwards compatibility, but according to OTel spec, scope metadata _should_ be identifying, i.e. translated to metric labels.
|
# This is disabled by default for backwards compatibility, but according to OTel spec, scope metadata _should_ be identifying, i.e. translated to metric labels.
|
||||||
[ convert_scope_metadata: <boolean> | default = false ]
|
[ promote_scope_metadata: <boolean> | default = false ]
|
||||||
|
|
||||||
# Settings related to the remote read feature.
|
# Settings related to the remote read feature.
|
||||||
remote_read:
|
remote_read:
|
||||||
|
@ -124,9 +124,9 @@ func createAttributes(resource pcommon.Resource, attributes pcommon.Map, scope s
|
|||||||
|
|
||||||
promotedAttrs := settings.PromoteResourceAttributes.promotedAttributes(resourceAttrs)
|
promotedAttrs := settings.PromoteResourceAttributes.promotedAttributes(resourceAttrs)
|
||||||
|
|
||||||
convertScope := settings.ConvertScopeMetadata && scope.name != ""
|
promoteScope := settings.PromoteScopeMetadata && scope.name != ""
|
||||||
scopeLabelCount := 0
|
scopeLabelCount := 0
|
||||||
if convertScope {
|
if promoteScope {
|
||||||
// Include name, version and schema URL.
|
// Include name, version and schema URL.
|
||||||
scopeLabelCount = scope.attributes.Len() + 3
|
scopeLabelCount = scope.attributes.Len() + 3
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ func createAttributes(resource pcommon.Resource, attributes pcommon.Map, scope s
|
|||||||
l[normalized] = lbl.Value
|
l[normalized] = lbl.Value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if convertScope {
|
if promoteScope {
|
||||||
l["otel_scope_name"] = scope.name
|
l["otel_scope_name"] = scope.name
|
||||||
l["otel_scope_version"] = scope.version
|
l["otel_scope_version"] = scope.version
|
||||||
l["otel_scope_schema_url"] = scope.schemaURL
|
l["otel_scope_schema_url"] = scope.schemaURL
|
||||||
|
@ -68,16 +68,16 @@ func TestCreateAttributes(t *testing.T) {
|
|||||||
scope scope
|
scope scope
|
||||||
promoteAllResourceAttributes bool
|
promoteAllResourceAttributes bool
|
||||||
promoteResourceAttributes []string
|
promoteResourceAttributes []string
|
||||||
convertScope bool
|
promoteScope bool
|
||||||
ignoreResourceAttributes []string
|
ignoreResourceAttributes []string
|
||||||
ignoreAttrs []string
|
ignoreAttrs []string
|
||||||
expectedLabels []prompb.Label
|
expectedLabels []prompb.Label
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Successful conversion without resource attribute promotion and without scope conversion",
|
name: "Successful conversion without resource attribute promotion and without scope promotion",
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
promoteResourceAttributes: nil,
|
promoteResourceAttributes: nil,
|
||||||
convertScope: false,
|
promoteScope: false,
|
||||||
expectedLabels: []prompb.Label{
|
expectedLabels: []prompb.Label{
|
||||||
{
|
{
|
||||||
Name: "__name__",
|
Name: "__name__",
|
||||||
@ -102,10 +102,10 @@ func TestCreateAttributes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Successful conversion without resource attribute promotion and with scope conversion",
|
name: "Successful conversion without resource attribute promotion and with scope promotion",
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
promoteResourceAttributes: nil,
|
promoteResourceAttributes: nil,
|
||||||
convertScope: true,
|
promoteScope: true,
|
||||||
expectedLabels: []prompb.Label{
|
expectedLabels: []prompb.Label{
|
||||||
{
|
{
|
||||||
Name: "__name__",
|
Name: "__name__",
|
||||||
@ -150,10 +150,10 @@ func TestCreateAttributes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Successful conversion without resource attribute promotion and with scope conversion, but without scope",
|
name: "Successful conversion without resource attribute promotion and with scope promotion, but without scope",
|
||||||
scope: scope{},
|
scope: scope{},
|
||||||
promoteResourceAttributes: nil,
|
promoteResourceAttributes: nil,
|
||||||
convertScope: true,
|
promoteScope: true,
|
||||||
expectedLabels: []prompb.Label{
|
expectedLabels: []prompb.Label{
|
||||||
{
|
{
|
||||||
Name: "__name__",
|
Name: "__name__",
|
||||||
@ -178,10 +178,10 @@ func TestCreateAttributes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Successful conversion with some attributes ignored and with scope conversion",
|
name: "Successful conversion with some attributes ignored and with scope promotion",
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
promoteResourceAttributes: nil,
|
promoteResourceAttributes: nil,
|
||||||
convertScope: true,
|
promoteScope: true,
|
||||||
ignoreAttrs: []string{"metric-attr-other"},
|
ignoreAttrs: []string{"metric-attr-other"},
|
||||||
expectedLabels: []prompb.Label{
|
expectedLabels: []prompb.Label{
|
||||||
{
|
{
|
||||||
@ -223,10 +223,10 @@ func TestCreateAttributes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Successful conversion with resource attribute promotion and with scope conversion",
|
name: "Successful conversion with resource attribute promotion and with scope promotion",
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
promoteResourceAttributes: []string{"non-existent-attr", "existent-attr"},
|
promoteResourceAttributes: []string{"non-existent-attr", "existent-attr"},
|
||||||
convertScope: true,
|
promoteScope: true,
|
||||||
expectedLabels: []prompb.Label{
|
expectedLabels: []prompb.Label{
|
||||||
{
|
{
|
||||||
Name: "__name__",
|
Name: "__name__",
|
||||||
@ -275,10 +275,10 @@ func TestCreateAttributes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Successful conversion with resource attribute promotion and with scope conversion, conflicting resource attributes are ignored",
|
name: "Successful conversion with resource attribute promotion and with scope promotion, conflicting resource attributes are ignored",
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
promoteResourceAttributes: []string{"non-existent-attr", "existent-attr", "metric-attr", "job", "instance"},
|
promoteResourceAttributes: []string{"non-existent-attr", "existent-attr", "metric-attr", "job", "instance"},
|
||||||
convertScope: true,
|
promoteScope: true,
|
||||||
expectedLabels: []prompb.Label{
|
expectedLabels: []prompb.Label{
|
||||||
{
|
{
|
||||||
Name: "__name__",
|
Name: "__name__",
|
||||||
@ -327,10 +327,10 @@ func TestCreateAttributes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Successful conversion with resource attribute promotion and with scope conversion, attributes are only promoted once",
|
name: "Successful conversion with resource attribute promotion and with scope promotion, attributes are only promoted once",
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
promoteResourceAttributes: []string{"existent-attr", "existent-attr"},
|
promoteResourceAttributes: []string{"existent-attr", "existent-attr"},
|
||||||
convertScope: true,
|
promoteScope: true,
|
||||||
expectedLabels: []prompb.Label{
|
expectedLabels: []prompb.Label{
|
||||||
{
|
{
|
||||||
Name: "__name__",
|
Name: "__name__",
|
||||||
@ -379,10 +379,10 @@ func TestCreateAttributes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Successful conversion promoting all resource attributes and with scope conversion",
|
name: "Successful conversion promoting all resource attributes and with scope promotion",
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
promoteAllResourceAttributes: true,
|
promoteAllResourceAttributes: true,
|
||||||
convertScope: true,
|
promoteScope: true,
|
||||||
expectedLabels: []prompb.Label{
|
expectedLabels: []prompb.Label{
|
||||||
{
|
{
|
||||||
Name: "__name__",
|
Name: "__name__",
|
||||||
@ -439,10 +439,10 @@ func TestCreateAttributes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Successful conversion promoting all resource attributes and with scope conversion, ignoring 'service.instance.id'",
|
name: "Successful conversion promoting all resource attributes and with scope promotion, ignoring 'service.instance.id'",
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
promoteAllResourceAttributes: true,
|
promoteAllResourceAttributes: true,
|
||||||
convertScope: true,
|
promoteScope: true,
|
||||||
ignoreResourceAttributes: []string{
|
ignoreResourceAttributes: []string{
|
||||||
"service.instance.id",
|
"service.instance.id",
|
||||||
},
|
},
|
||||||
@ -506,7 +506,7 @@ func TestCreateAttributes(t *testing.T) {
|
|||||||
PromoteResourceAttributes: tc.promoteResourceAttributes,
|
PromoteResourceAttributes: tc.promoteResourceAttributes,
|
||||||
IgnoreResourceAttributes: tc.ignoreResourceAttributes,
|
IgnoreResourceAttributes: tc.ignoreResourceAttributes,
|
||||||
}),
|
}),
|
||||||
ConvertScopeMetadata: tc.convertScope,
|
PromoteScopeMetadata: tc.promoteScope,
|
||||||
}
|
}
|
||||||
lbls := createAttributes(resource, attrs, tc.scope, settings, tc.ignoreAttrs, false, model.MetricNameLabel, "test_metric")
|
lbls := createAttributes(resource, attrs, tc.scope, settings, tc.ignoreAttrs, false, model.MetricNameLabel, "test_metric")
|
||||||
|
|
||||||
@ -551,11 +551,11 @@ func TestPrometheusConverter_AddSummaryDataPoints(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
metric func() pmetric.Metric
|
metric func() pmetric.Metric
|
||||||
scope scope
|
scope scope
|
||||||
convertScope bool
|
promoteScope bool
|
||||||
want func() map[uint64]*prompb.TimeSeries
|
want func() map[uint64]*prompb.TimeSeries
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "summary with start time and without scope conversion",
|
name: "summary with start time and without scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
metric := pmetric.NewMetric()
|
metric := pmetric.NewMetric()
|
||||||
metric.SetName("test_summary")
|
metric.SetName("test_summary")
|
||||||
@ -568,7 +568,7 @@ func TestPrometheusConverter_AddSummaryDataPoints(t *testing.T) {
|
|||||||
return metric
|
return metric
|
||||||
},
|
},
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
convertScope: false,
|
promoteScope: false,
|
||||||
want: func() map[uint64]*prompb.TimeSeries {
|
want: func() map[uint64]*prompb.TimeSeries {
|
||||||
countLabels := []prompb.Label{
|
countLabels := []prompb.Label{
|
||||||
{Name: model.MetricNameLabel, Value: "test_summary" + countStr},
|
{Name: model.MetricNameLabel, Value: "test_summary" + countStr},
|
||||||
@ -602,7 +602,7 @@ func TestPrometheusConverter_AddSummaryDataPoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "summary with start time and with scope conversion",
|
name: "summary with start time and with scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
metric := pmetric.NewMetric()
|
metric := pmetric.NewMetric()
|
||||||
metric.SetName("test_summary")
|
metric.SetName("test_summary")
|
||||||
@ -615,7 +615,7 @@ func TestPrometheusConverter_AddSummaryDataPoints(t *testing.T) {
|
|||||||
return metric
|
return metric
|
||||||
},
|
},
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
convertScope: true,
|
promoteScope: true,
|
||||||
want: func() map[uint64]*prompb.TimeSeries {
|
want: func() map[uint64]*prompb.TimeSeries {
|
||||||
scopeLabels := []prompb.Label{
|
scopeLabels := []prompb.Label{
|
||||||
{
|
{
|
||||||
@ -674,7 +674,7 @@ func TestPrometheusConverter_AddSummaryDataPoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "summary without start time and without scope conversion",
|
name: "summary without start time and without scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
metric := pmetric.NewMetric()
|
metric := pmetric.NewMetric()
|
||||||
metric.SetName("test_summary")
|
metric.SetName("test_summary")
|
||||||
@ -685,7 +685,7 @@ func TestPrometheusConverter_AddSummaryDataPoints(t *testing.T) {
|
|||||||
|
|
||||||
return metric
|
return metric
|
||||||
},
|
},
|
||||||
convertScope: false,
|
promoteScope: false,
|
||||||
want: func() map[uint64]*prompb.TimeSeries {
|
want: func() map[uint64]*prompb.TimeSeries {
|
||||||
countLabels := []prompb.Label{
|
countLabels := []prompb.Label{
|
||||||
{Name: model.MetricNameLabel, Value: "test_summary" + countStr},
|
{Name: model.MetricNameLabel, Value: "test_summary" + countStr},
|
||||||
@ -720,7 +720,7 @@ func TestPrometheusConverter_AddSummaryDataPoints(t *testing.T) {
|
|||||||
metric.Summary().DataPoints(),
|
metric.Summary().DataPoints(),
|
||||||
pcommon.NewResource(),
|
pcommon.NewResource(),
|
||||||
Settings{
|
Settings{
|
||||||
ConvertScopeMetadata: tt.convertScope,
|
PromoteScopeMetadata: tt.promoteScope,
|
||||||
ExportCreatedMetric: true,
|
ExportCreatedMetric: true,
|
||||||
},
|
},
|
||||||
metric.Name(),
|
metric.Name(),
|
||||||
@ -751,11 +751,11 @@ func TestPrometheusConverter_AddHistogramDataPoints(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
metric func() pmetric.Metric
|
metric func() pmetric.Metric
|
||||||
scope scope
|
scope scope
|
||||||
convertScope bool
|
promoteScope bool
|
||||||
want func() map[uint64]*prompb.TimeSeries
|
want func() map[uint64]*prompb.TimeSeries
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "histogram with start time and without scope conversion",
|
name: "histogram with start time and without scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
metric := pmetric.NewMetric()
|
metric := pmetric.NewMetric()
|
||||||
metric.SetName("test_hist")
|
metric.SetName("test_hist")
|
||||||
@ -768,7 +768,7 @@ func TestPrometheusConverter_AddHistogramDataPoints(t *testing.T) {
|
|||||||
return metric
|
return metric
|
||||||
},
|
},
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
convertScope: false,
|
promoteScope: false,
|
||||||
want: func() map[uint64]*prompb.TimeSeries {
|
want: func() map[uint64]*prompb.TimeSeries {
|
||||||
countLabels := []prompb.Label{
|
countLabels := []prompb.Label{
|
||||||
{Name: model.MetricNameLabel, Value: "test_hist" + countStr},
|
{Name: model.MetricNameLabel, Value: "test_hist" + countStr},
|
||||||
@ -803,7 +803,7 @@ func TestPrometheusConverter_AddHistogramDataPoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "histogram with start time and with scope conversion",
|
name: "histogram with start time and with scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
metric := pmetric.NewMetric()
|
metric := pmetric.NewMetric()
|
||||||
metric.SetName("test_hist")
|
metric.SetName("test_hist")
|
||||||
@ -816,7 +816,7 @@ func TestPrometheusConverter_AddHistogramDataPoints(t *testing.T) {
|
|||||||
return metric
|
return metric
|
||||||
},
|
},
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
convertScope: true,
|
promoteScope: true,
|
||||||
want: func() map[uint64]*prompb.TimeSeries {
|
want: func() map[uint64]*prompb.TimeSeries {
|
||||||
scopeLabels := []prompb.Label{
|
scopeLabels := []prompb.Label{
|
||||||
{
|
{
|
||||||
@ -920,7 +920,7 @@ func TestPrometheusConverter_AddHistogramDataPoints(t *testing.T) {
|
|||||||
pcommon.NewResource(),
|
pcommon.NewResource(),
|
||||||
Settings{
|
Settings{
|
||||||
ExportCreatedMetric: true,
|
ExportCreatedMetric: true,
|
||||||
ConvertScopeMetadata: tt.convertScope,
|
PromoteScopeMetadata: tt.promoteScope,
|
||||||
},
|
},
|
||||||
metric.Name(),
|
metric.Name(),
|
||||||
tt.scope,
|
tt.scope,
|
||||||
|
@ -636,11 +636,11 @@ func TestPrometheusConverter_addExponentialHistogramDataPoints(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
metric func() pmetric.Metric
|
metric func() pmetric.Metric
|
||||||
scope scope
|
scope scope
|
||||||
convertScope bool
|
promoteScope bool
|
||||||
wantSeries func() map[uint64]*prompb.TimeSeries
|
wantSeries func() map[uint64]*prompb.TimeSeries
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "histogram data points with same labels and without scope conversion",
|
name: "histogram data points with same labels and without scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
metric := pmetric.NewMetric()
|
metric := pmetric.NewMetric()
|
||||||
metric.SetName("test_hist")
|
metric.SetName("test_hist")
|
||||||
@ -665,7 +665,7 @@ func TestPrometheusConverter_addExponentialHistogramDataPoints(t *testing.T) {
|
|||||||
return metric
|
return metric
|
||||||
},
|
},
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
convertScope: false,
|
promoteScope: false,
|
||||||
wantSeries: func() map[uint64]*prompb.TimeSeries {
|
wantSeries: func() map[uint64]*prompb.TimeSeries {
|
||||||
labels := []prompb.Label{
|
labels := []prompb.Label{
|
||||||
{Name: model.MetricNameLabel, Value: "test_hist"},
|
{Name: model.MetricNameLabel, Value: "test_hist"},
|
||||||
@ -701,7 +701,7 @@ func TestPrometheusConverter_addExponentialHistogramDataPoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "histogram data points with same labels and with scope conversion",
|
name: "histogram data points with same labels and with scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
metric := pmetric.NewMetric()
|
metric := pmetric.NewMetric()
|
||||||
metric.SetName("test_hist")
|
metric.SetName("test_hist")
|
||||||
@ -726,7 +726,7 @@ func TestPrometheusConverter_addExponentialHistogramDataPoints(t *testing.T) {
|
|||||||
return metric
|
return metric
|
||||||
},
|
},
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
convertScope: true,
|
promoteScope: true,
|
||||||
wantSeries: func() map[uint64]*prompb.TimeSeries {
|
wantSeries: func() map[uint64]*prompb.TimeSeries {
|
||||||
labels := []prompb.Label{
|
labels := []prompb.Label{
|
||||||
{Name: model.MetricNameLabel, Value: "test_hist"},
|
{Name: model.MetricNameLabel, Value: "test_hist"},
|
||||||
@ -767,7 +767,7 @@ func TestPrometheusConverter_addExponentialHistogramDataPoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "histogram data points with different labels and without scope conversion",
|
name: "histogram data points with different labels and without scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
metric := pmetric.NewMetric()
|
metric := pmetric.NewMetric()
|
||||||
metric.SetName("test_hist")
|
metric.SetName("test_hist")
|
||||||
@ -792,7 +792,7 @@ func TestPrometheusConverter_addExponentialHistogramDataPoints(t *testing.T) {
|
|||||||
return metric
|
return metric
|
||||||
},
|
},
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
convertScope: false,
|
promoteScope: false,
|
||||||
wantSeries: func() map[uint64]*prompb.TimeSeries {
|
wantSeries: func() map[uint64]*prompb.TimeSeries {
|
||||||
labels := []prompb.Label{
|
labels := []prompb.Label{
|
||||||
{Name: model.MetricNameLabel, Value: "test_hist"},
|
{Name: model.MetricNameLabel, Value: "test_hist"},
|
||||||
@ -854,7 +854,7 @@ func TestPrometheusConverter_addExponentialHistogramDataPoints(t *testing.T) {
|
|||||||
pcommon.NewResource(),
|
pcommon.NewResource(),
|
||||||
Settings{
|
Settings{
|
||||||
ExportCreatedMetric: true,
|
ExportCreatedMetric: true,
|
||||||
ConvertScopeMetadata: tt.convertScope,
|
PromoteScopeMetadata: tt.promoteScope,
|
||||||
},
|
},
|
||||||
namer.Build(TranslatorMetricFromOtelMetric(metric)),
|
namer.Build(TranslatorMetricFromOtelMetric(metric)),
|
||||||
pmetric.AggregationTemporalityCumulative,
|
pmetric.AggregationTemporalityCumulative,
|
||||||
@ -1093,11 +1093,11 @@ func TestPrometheusConverter_addCustomBucketsHistogramDataPoints(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
metric func() pmetric.Metric
|
metric func() pmetric.Metric
|
||||||
scope scope
|
scope scope
|
||||||
convertScope bool
|
promoteScope bool
|
||||||
wantSeries func() map[uint64]*prompb.TimeSeries
|
wantSeries func() map[uint64]*prompb.TimeSeries
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "histogram data points with same labels and without scope conversion",
|
name: "histogram data points with same labels and without scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
metric := pmetric.NewMetric()
|
metric := pmetric.NewMetric()
|
||||||
metric.SetName("test_hist_to_nhcb")
|
metric.SetName("test_hist_to_nhcb")
|
||||||
@ -1122,7 +1122,7 @@ func TestPrometheusConverter_addCustomBucketsHistogramDataPoints(t *testing.T) {
|
|||||||
return metric
|
return metric
|
||||||
},
|
},
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
convertScope: false,
|
promoteScope: false,
|
||||||
wantSeries: func() map[uint64]*prompb.TimeSeries {
|
wantSeries: func() map[uint64]*prompb.TimeSeries {
|
||||||
labels := []prompb.Label{
|
labels := []prompb.Label{
|
||||||
{Name: model.MetricNameLabel, Value: "test_hist_to_nhcb"},
|
{Name: model.MetricNameLabel, Value: "test_hist_to_nhcb"},
|
||||||
@ -1158,7 +1158,7 @@ func TestPrometheusConverter_addCustomBucketsHistogramDataPoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "histogram data points with same labels and with scope conversion",
|
name: "histogram data points with same labels and with scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
metric := pmetric.NewMetric()
|
metric := pmetric.NewMetric()
|
||||||
metric.SetName("test_hist_to_nhcb")
|
metric.SetName("test_hist_to_nhcb")
|
||||||
@ -1183,7 +1183,7 @@ func TestPrometheusConverter_addCustomBucketsHistogramDataPoints(t *testing.T) {
|
|||||||
return metric
|
return metric
|
||||||
},
|
},
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
convertScope: true,
|
promoteScope: true,
|
||||||
wantSeries: func() map[uint64]*prompb.TimeSeries {
|
wantSeries: func() map[uint64]*prompb.TimeSeries {
|
||||||
labels := []prompb.Label{
|
labels := []prompb.Label{
|
||||||
{Name: model.MetricNameLabel, Value: "test_hist_to_nhcb"},
|
{Name: model.MetricNameLabel, Value: "test_hist_to_nhcb"},
|
||||||
@ -1224,7 +1224,7 @@ func TestPrometheusConverter_addCustomBucketsHistogramDataPoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "histogram data points with different labels and without scope conversion",
|
name: "histogram data points with different labels and without scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
metric := pmetric.NewMetric()
|
metric := pmetric.NewMetric()
|
||||||
metric.SetName("test_hist_to_nhcb")
|
metric.SetName("test_hist_to_nhcb")
|
||||||
@ -1249,7 +1249,7 @@ func TestPrometheusConverter_addCustomBucketsHistogramDataPoints(t *testing.T) {
|
|||||||
return metric
|
return metric
|
||||||
},
|
},
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
convertScope: false,
|
promoteScope: false,
|
||||||
wantSeries: func() map[uint64]*prompb.TimeSeries {
|
wantSeries: func() map[uint64]*prompb.TimeSeries {
|
||||||
labels := []prompb.Label{
|
labels := []prompb.Label{
|
||||||
{Name: model.MetricNameLabel, Value: "test_hist_to_nhcb"},
|
{Name: model.MetricNameLabel, Value: "test_hist_to_nhcb"},
|
||||||
@ -1312,7 +1312,7 @@ func TestPrometheusConverter_addCustomBucketsHistogramDataPoints(t *testing.T) {
|
|||||||
Settings{
|
Settings{
|
||||||
ExportCreatedMetric: true,
|
ExportCreatedMetric: true,
|
||||||
ConvertHistogramsToNHCB: true,
|
ConvertHistogramsToNHCB: true,
|
||||||
ConvertScopeMetadata: tt.convertScope,
|
PromoteScopeMetadata: tt.promoteScope,
|
||||||
},
|
},
|
||||||
namer.Build(TranslatorMetricFromOtelMetric(metric)),
|
namer.Build(TranslatorMetricFromOtelMetric(metric)),
|
||||||
pmetric.AggregationTemporalityCumulative,
|
pmetric.AggregationTemporalityCumulative,
|
||||||
|
@ -48,8 +48,8 @@ type Settings struct {
|
|||||||
KeepIdentifyingResourceAttributes bool
|
KeepIdentifyingResourceAttributes bool
|
||||||
ConvertHistogramsToNHCB bool
|
ConvertHistogramsToNHCB bool
|
||||||
AllowDeltaTemporality bool
|
AllowDeltaTemporality bool
|
||||||
// ConvertScopeMetadata controls whether to convert OTel scope metadata to metric labels.
|
// PromoteScopeMetadata controls whether to promote OTel scope metadata to metric labels.
|
||||||
ConvertScopeMetadata bool
|
PromoteScopeMetadata bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrometheusConverter converts from OTel write format to Prometheus remote write format.
|
// PrometheusConverter converts from OTel write format to Prometheus remote write format.
|
||||||
|
@ -46,11 +46,11 @@ func TestPrometheusConverter_addGaugeNumberDataPoints(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
metric func() pmetric.Metric
|
metric func() pmetric.Metric
|
||||||
scope scope
|
scope scope
|
||||||
convertScope bool
|
promoteScope bool
|
||||||
want func() map[uint64]*prompb.TimeSeries
|
want func() map[uint64]*prompb.TimeSeries
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "gauge without scope conversion",
|
name: "gauge without scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
return getIntGaugeMetric(
|
return getIntGaugeMetric(
|
||||||
"test",
|
"test",
|
||||||
@ -59,7 +59,7 @@ func TestPrometheusConverter_addGaugeNumberDataPoints(t *testing.T) {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
convertScope: false,
|
promoteScope: false,
|
||||||
want: func() map[uint64]*prompb.TimeSeries {
|
want: func() map[uint64]*prompb.TimeSeries {
|
||||||
labels := []prompb.Label{
|
labels := []prompb.Label{
|
||||||
{Name: model.MetricNameLabel, Value: "test"},
|
{Name: model.MetricNameLabel, Value: "test"},
|
||||||
@ -78,7 +78,7 @@ func TestPrometheusConverter_addGaugeNumberDataPoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "gauge with scope conversion",
|
name: "gauge with scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
return getIntGaugeMetric(
|
return getIntGaugeMetric(
|
||||||
"test",
|
"test",
|
||||||
@ -87,7 +87,7 @@ func TestPrometheusConverter_addGaugeNumberDataPoints(t *testing.T) {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
convertScope: true,
|
promoteScope: true,
|
||||||
want: func() map[uint64]*prompb.TimeSeries {
|
want: func() map[uint64]*prompb.TimeSeries {
|
||||||
labels := []prompb.Label{
|
labels := []prompb.Label{
|
||||||
{Name: model.MetricNameLabel, Value: "test"},
|
{Name: model.MetricNameLabel, Value: "test"},
|
||||||
@ -122,7 +122,7 @@ func TestPrometheusConverter_addGaugeNumberDataPoints(t *testing.T) {
|
|||||||
pcommon.NewResource(),
|
pcommon.NewResource(),
|
||||||
Settings{
|
Settings{
|
||||||
ExportCreatedMetric: true,
|
ExportCreatedMetric: true,
|
||||||
ConvertScopeMetadata: tt.convertScope,
|
PromoteScopeMetadata: tt.promoteScope,
|
||||||
},
|
},
|
||||||
metric.Name(),
|
metric.Name(),
|
||||||
tt.scope,
|
tt.scope,
|
||||||
@ -151,11 +151,11 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
metric func() pmetric.Metric
|
metric func() pmetric.Metric
|
||||||
scope scope
|
scope scope
|
||||||
convertScope bool
|
promoteScope bool
|
||||||
want func() map[uint64]*prompb.TimeSeries
|
want func() map[uint64]*prompb.TimeSeries
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "sum without scope conversion",
|
name: "sum without scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
return getIntSumMetric(
|
return getIntSumMetric(
|
||||||
"test",
|
"test",
|
||||||
@ -165,7 +165,7 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
convertScope: false,
|
promoteScope: false,
|
||||||
want: func() map[uint64]*prompb.TimeSeries {
|
want: func() map[uint64]*prompb.TimeSeries {
|
||||||
labels := []prompb.Label{
|
labels := []prompb.Label{
|
||||||
{Name: model.MetricNameLabel, Value: "test"},
|
{Name: model.MetricNameLabel, Value: "test"},
|
||||||
@ -184,7 +184,7 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "sum with scope conversion",
|
name: "sum with scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
return getIntSumMetric(
|
return getIntSumMetric(
|
||||||
"test",
|
"test",
|
||||||
@ -194,7 +194,7 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
convertScope: true,
|
promoteScope: true,
|
||||||
want: func() map[uint64]*prompb.TimeSeries {
|
want: func() map[uint64]*prompb.TimeSeries {
|
||||||
labels := []prompb.Label{
|
labels := []prompb.Label{
|
||||||
{Name: model.MetricNameLabel, Value: "test"},
|
{Name: model.MetricNameLabel, Value: "test"},
|
||||||
@ -218,7 +218,7 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "sum with exemplars and without scope conversion",
|
name: "sum with exemplars and without scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
m := getIntSumMetric(
|
m := getIntSumMetric(
|
||||||
"test",
|
"test",
|
||||||
@ -230,7 +230,7 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
|
|||||||
return m
|
return m
|
||||||
},
|
},
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
convertScope: false,
|
promoteScope: false,
|
||||||
want: func() map[uint64]*prompb.TimeSeries {
|
want: func() map[uint64]*prompb.TimeSeries {
|
||||||
labels := []prompb.Label{
|
labels := []prompb.Label{
|
||||||
{Name: model.MetricNameLabel, Value: "test"},
|
{Name: model.MetricNameLabel, Value: "test"},
|
||||||
@ -250,7 +250,7 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "monotonic cumulative sum with start timestamp and without scope conversion",
|
name: "monotonic cumulative sum with start timestamp and without scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
metric := pmetric.NewMetric()
|
metric := pmetric.NewMetric()
|
||||||
metric.SetName("test_sum")
|
metric.SetName("test_sum")
|
||||||
@ -265,7 +265,7 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
|
|||||||
return metric
|
return metric
|
||||||
},
|
},
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
convertScope: false,
|
promoteScope: false,
|
||||||
want: func() map[uint64]*prompb.TimeSeries {
|
want: func() map[uint64]*prompb.TimeSeries {
|
||||||
labels := []prompb.Label{
|
labels := []prompb.Label{
|
||||||
{Name: model.MetricNameLabel, Value: "test_sum"},
|
{Name: model.MetricNameLabel, Value: "test_sum"},
|
||||||
@ -290,7 +290,7 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "monotonic cumulative sum with no start time and without scope conversion",
|
name: "monotonic cumulative sum with no start time and without scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
metric := pmetric.NewMetric()
|
metric := pmetric.NewMetric()
|
||||||
metric.SetName("test_sum")
|
metric.SetName("test_sum")
|
||||||
@ -303,7 +303,7 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
|
|||||||
return metric
|
return metric
|
||||||
},
|
},
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
convertScope: false,
|
promoteScope: false,
|
||||||
want: func() map[uint64]*prompb.TimeSeries {
|
want: func() map[uint64]*prompb.TimeSeries {
|
||||||
labels := []prompb.Label{
|
labels := []prompb.Label{
|
||||||
{Name: model.MetricNameLabel, Value: "test_sum"},
|
{Name: model.MetricNameLabel, Value: "test_sum"},
|
||||||
@ -319,7 +319,7 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "non-monotonic cumulative sum with start time and without scope conversion",
|
name: "non-monotonic cumulative sum with start time and without scope promotion",
|
||||||
metric: func() pmetric.Metric {
|
metric: func() pmetric.Metric {
|
||||||
metric := pmetric.NewMetric()
|
metric := pmetric.NewMetric()
|
||||||
metric.SetName("test_sum")
|
metric.SetName("test_sum")
|
||||||
@ -332,7 +332,7 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
|
|||||||
return metric
|
return metric
|
||||||
},
|
},
|
||||||
scope: defaultScope,
|
scope: defaultScope,
|
||||||
convertScope: false,
|
promoteScope: false,
|
||||||
want: func() map[uint64]*prompb.TimeSeries {
|
want: func() map[uint64]*prompb.TimeSeries {
|
||||||
labels := []prompb.Label{
|
labels := []prompb.Label{
|
||||||
{Name: model.MetricNameLabel, Value: "test_sum"},
|
{Name: model.MetricNameLabel, Value: "test_sum"},
|
||||||
@ -360,7 +360,7 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
|
|||||||
metric,
|
metric,
|
||||||
Settings{
|
Settings{
|
||||||
ExportCreatedMetric: true,
|
ExportCreatedMetric: true,
|
||||||
ConvertScopeMetadata: tt.convertScope,
|
PromoteScopeMetadata: tt.promoteScope,
|
||||||
},
|
},
|
||||||
metric.Name(),
|
metric.Name(),
|
||||||
tt.scope,
|
tt.scope,
|
||||||
|
@ -596,7 +596,7 @@ func (rw *rwExporter) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) er
|
|||||||
KeepIdentifyingResourceAttributes: otlpCfg.KeepIdentifyingResourceAttributes,
|
KeepIdentifyingResourceAttributes: otlpCfg.KeepIdentifyingResourceAttributes,
|
||||||
ConvertHistogramsToNHCB: otlpCfg.ConvertHistogramsToNHCB,
|
ConvertHistogramsToNHCB: otlpCfg.ConvertHistogramsToNHCB,
|
||||||
AllowDeltaTemporality: rw.allowDeltaTemporality,
|
AllowDeltaTemporality: rw.allowDeltaTemporality,
|
||||||
ConvertScopeMetadata: otlpCfg.ConvertScopeMetadata,
|
PromoteScopeMetadata: otlpCfg.PromoteScopeMetadata,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rw.logger.Warn("Error translating OTLP metrics to Prometheus write request", "err", err)
|
rw.logger.Warn("Error translating OTLP metrics to Prometheus write request", "err", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user