Skip to content

Commit

Permalink
[OTLP] Update OTel prw translator package to v0.76.3.
Browse files Browse the repository at this point in the history
- Enables OTel to Prometheus metric names conversion by default,
  see open-telemetry/opentelemetry-collector-contrib#20519
  • Loading branch information
kovrus committed May 2, 2023
1 parent 23e30d0 commit a6552cb
Show file tree
Hide file tree
Showing 19 changed files with 370 additions and 191 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Grafana Mimir

* [CHANGE] Store-gateway: change expanded postings and postings index cache key format. These caches will be invalidated when rolling out the new Mimir version. #4770
* [CHANGE] OTLP: Enable OpenTelemetry to Prometheus metric and labels names translation by default. This a breaking change because OTel metrics names and attributes will be converted to Prometheus metrics names and labels following [these](https://opentelemetry.io/docs/reference/specification/compatibility/prometheus_and_openmetrics/#metric-metadata-1) rules. #4871
* [ENHANCEMENT] Add per-tenant limit `-validation.max-native-histogram-buckets` to be able to ignore native histogram samples that have too many buckets. #4765
* [ENHANCEMENT] Store-gateway: reduce memory usage in some LabelValues calls. #4789
* [ENHANCEMENT] Store-gateway: add a `stage` label to the metric `cortex_bucket_store_series_data_touched`. This label now applies to `data_type="chunks"` and `data_type="series"`. The `stage` label has 2 values: `processed` - the number of series that parsed - and `returned` - the number of series selected from the processed bytes to satisfy the query. #4797 #4830
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ require (
golang.org/x/net v0.9.0
golang.org/x/sync v0.1.0
golang.org/x/time v0.3.0
google.golang.org/grpc v1.53.0
google.golang.org/grpc v1.54.0
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
)
Expand All @@ -63,13 +63,13 @@ require (
github.com/hashicorp/vault/api v1.9.0
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite v0.73.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite v0.76.3
github.com/thanos-io/objstore v0.0.0-20230201072718-11ffbc490204
github.com/xlab/treeprint v1.1.0
go.opentelemetry.io/collector/pdata v1.0.0-rc7
go.opentelemetry.io/collector/pdata v1.0.0-rcv0011
go.opentelemetry.io/otel v1.14.0
go.opentelemetry.io/otel/trace v1.14.0
go.uber.org/multierr v1.9.0
go.uber.org/multierr v1.11.0
golang.org/x/exp v0.0.0-20230321023759-10a507213a29
google.golang.org/api v0.114.0
gopkg.in/alecthomas/kingpin.v2 v2.2.6
Expand Down Expand Up @@ -198,7 +198,7 @@ require (
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/ncw/swift v1.0.53 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.73.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.76.3 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/common/sigv4 v0.1.0 // indirect
Expand All @@ -222,8 +222,8 @@ require (
go.etcd.io/etcd/client/v3 v3.5.4 // indirect
go.mongodb.org/mongo-driver v1.11.3 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/collector/featuregate v0.73.0 // indirect
go.opentelemetry.io/collector/semconv v0.73.0 // indirect
go.opentelemetry.io/collector/featuregate v0.76.1 // indirect
go.opentelemetry.io/collector/semconv v0.76.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.40.0 // indirect
go.opentelemetry.io/otel/metric v0.37.0 // indirect
go.uber.org/zap v1.21.0 // indirect
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -762,12 +762,12 @@ github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
github.com/onsi/gomega v1.24.0 h1:+0glovB9Jd6z3VR+ScSwQqXVTIfJcGA9UBM8yzQxhqg=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.73.0 h1:nUavTvhdE9+Gq11XvZIYIRpw0+njQqjUeDPq2FL1q7M=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.73.0 h1:1WpzAuX9TOKBUWZjJv/iDNcU59jKKc6/Ev+l03u4syU=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.73.0 h1:hmBMbcwJdbnxjPiabzo9ks1bseCzUGPGxQhklg2o9vc=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.73.0/go.mod h1:i1JP3T6TJRJNk/i1D2bHPF481FUvM4McFC+j0C1sj6I=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite v0.73.0 h1:nkUfL6+7gOyl9wrfRBGfjrHi3Th5IG5GG7I32vmTbQ4=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite v0.73.0/go.mod h1:Mx1IT+/6c8pyBilGzwepTGgzuW6Dl0Pk2vKkVHOavpY=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.76.3 h1:xU921u6vlhzpOBDH+aCELkQqmN8AEoZSalUHbtz0bRI=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.76.3 h1:EiiDThW4U/3aq9Z7iqDTwii0ZLVKEhOZfMrTIf0QtXg=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.76.3 h1:8jdIsnYh8DyoSh8LCIAN3jn+02jfhGcT8AoBliUP3JM=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.76.3/go.mod h1:E0dvk+GO4jnuBHZzE2awPZawFRhPkF4qsoZgEgBgltE=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite v0.76.3 h1:ybIM3sikCUyhxS4soO4KfXPerV8ETT4GnjuJHYP3mMs=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite v0.76.3/go.mod h1:r9nr3bFdNWEvL1R6CD+tbt3QANYwc2Z/IyIkGzNSed0=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM=
github.com/opentracing-contrib/go-grpc v0.0.0-20180928155321-4b5a12d3ff02/go.mod h1:JNdpVEzCpXBgIiv4ds+TzhN1hrtxq6ClLrTlT9OQRSc=
Expand Down Expand Up @@ -986,12 +986,12 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
go.opentelemetry.io/collector/featuregate v0.73.0 h1:hpHKXmRiJqMLefIzXwIuqDo9df2HcI/66IAKLo+g7nc=
go.opentelemetry.io/collector/featuregate v0.73.0/go.mod h1:oIrO4ysPfThwkYKoNlgpHjDU/TgS9kIv2OI74pDUkp4=
go.opentelemetry.io/collector/pdata v1.0.0-rc7 h1:W3wCN9rG/GMuUSQDEzi5FZPmA6pUJWtzKB9+L3t3k/w=
go.opentelemetry.io/collector/pdata v1.0.0-rc7/go.mod h1:YSlrEri/QKzmeaN8rio2iPYsxPUJo4WkL6fQc4Ph7fk=
go.opentelemetry.io/collector/semconv v0.73.0 h1:gF4f6z1q8YfWzzo/gPKysjFmmM4Pv4nC2bWrTPxTPaE=
go.opentelemetry.io/collector/semconv v0.73.0/go.mod h1:xt8oDOiwa1jy24tGUo8+SzpphI7ZredS2WM/0m8rtTA=
go.opentelemetry.io/collector/featuregate v0.76.1 h1:F9jP6cpIu446GsjsvHjzt4rC/ZJ/IPSPbXLzEngxUa8=
go.opentelemetry.io/collector/featuregate v0.76.1/go.mod h1:stbsuyEexJF0EyVB3AgMs4mEuGvP7MDj3fsNeNdGDMs=
go.opentelemetry.io/collector/pdata v1.0.0-rcv0011 h1:7lT0vseP89mHtUpvgmWYRvQZ0eY+SHbVsnXY20xkoMg=
go.opentelemetry.io/collector/pdata v1.0.0-rcv0011/go.mod h1:9vrXSQBeMRrdfGt9oMgYweqERJ8adaiQjN6LSbqRMMA=
go.opentelemetry.io/collector/semconv v0.76.1 h1:cY5z4uXLB15AuU7GkJFfFCTD82l83fqK7DBRqQ7sZCY=
go.opentelemetry.io/collector/semconv v0.76.1/go.mod h1:eRAIvw3omXfvZxt1GAt9o4R/NFGSruOVkZ6JiJwPo6U=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.40.0 h1:lE9EJyw3/JhrjWH/hEy9FptnalDQgj7vpbgC2KCCCxE=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.40.0/go.mod h1:pcQ3MM3SWvrA71U4GDqv9UFDJ3HQsW7y5ZO3tDTlUdI=
go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM=
Expand All @@ -1010,8 +1010,8 @@ go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8=
go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
Expand Down
47 changes: 42 additions & 5 deletions pkg/util/push/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,42 @@ func TestHandlerOTLPPush(t *testing.T) {
}
}

func TestHandler_NormalizeMetricNameByDefault(t *testing.T) {
md := pmetric.NewMetrics()

metric := md.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics().AppendEmpty()
metric.SetName("sum.test")
metric.SetUnit("s")

sum := metric.SetEmptySum()
sum.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative)
sum.SetIsMonotonic(true)

dp := sum.DataPoints().AppendEmpty()
dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Now()))
dp.SetDoubleValue(0)
dp.Attributes().PutStr("diff.label", "bar")

req := createOTLPRequest(t, pmetricotlp.NewExportRequestFromMetrics(md), false)
resp := httptest.NewRecorder()
handler := OTLPHandler(100000, nil, false, nil, func(ctx context.Context, pushReq *Request) (response *mimirpb.WriteResponse, err error) {
request, err := pushReq.WriteRequest()
assert.NoError(t, err)

assert.Len(t, request.Timeseries, 1)
assert.Equal(t, "__name__", request.Timeseries[0].Labels[0].Name)
assert.Equal(t, "sum_test_seconds_total", request.Timeseries[0].Labels[0].Value)

assert.Equal(t, "diff_label", request.Timeseries[0].Labels[1].Name)
assert.Equal(t, "bar", request.Timeseries[0].Labels[1].Value)

pushReq.CleanUp()
return &mimirpb.WriteResponse{}, nil
})
handler.ServeHTTP(resp, req)
assert.Equal(t, 200, resp.Code)
}

func TestHandler_otlpDroppedMetricsPanic(t *testing.T) {
// https://github.com/grafana/mimir/issues/3037 is triggered by a single metric
// having two different datapoints that correspond to different Prometheus metrics.
Expand All @@ -194,19 +230,19 @@ func TestHandler_otlpDroppedMetricsPanic(t *testing.T) {
datapoint1.SetTimestamp(pcommon.NewTimestampFromTime(time.Now()))
datapoint1.SetDoubleValue(0)
attributes.CopyTo(datapoint1.Attributes())
datapoint1.Attributes().PutStr("diff_label", "bar")
datapoint1.Attributes().PutStr("diff.label", "bar")

datapoint2 := metric1.Gauge().DataPoints().AppendEmpty()
datapoint2.SetTimestamp(pcommon.NewTimestampFromTime(time.Now()))
datapoint2.SetDoubleValue(0)
attributes.CopyTo(datapoint2.Attributes())
datapoint2.Attributes().PutStr("diff_label", "baz")
datapoint2.Attributes().PutStr("diff.label", "baz")

datapoint3 := metric1.Gauge().DataPoints().AppendEmpty()
datapoint3.SetTimestamp(pcommon.NewTimestampFromTime(time.Now()))
datapoint3.SetDoubleValue(0)
attributes.CopyTo(datapoint3.Attributes())
datapoint3.Attributes().PutStr("diff_label", "food")
datapoint3.Attributes().PutStr("diff.label", "food")

metric2 := md.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics().AppendEmpty()
metric2.SetName(name)
Expand Down Expand Up @@ -246,7 +282,7 @@ func TestHandler_otlpDroppedMetricsPanic2(t *testing.T) {
datapoint1.SetTimestamp(pcommon.NewTimestampFromTime(time.Now()))
datapoint1.SetDoubleValue(0)
attributes.CopyTo(datapoint1.Attributes())
datapoint1.Attributes().PutStr("diff_label", "bar")
datapoint1.Attributes().PutStr("diff.label", "bar")

metric2 := resource1.ScopeMetrics().AppendEmpty().Metrics().AppendEmpty()
metric2.SetName(name)
Expand All @@ -267,7 +303,8 @@ func TestHandler_otlpDroppedMetricsPanic2(t *testing.T) {

// Second case is to make sure that histogram metrics are counted correctly.
metric3 := resource1.ScopeMetrics().AppendEmpty().Metrics().AppendEmpty()
metric3.SetName("http_request_duration_seconds")
metric3.SetName("http.request.duration")
metric3.SetUnit("s")
metric3.SetEmptyHistogram()
metric3.Histogram().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative)
datapoint3 := metric3.Histogram().DataPoints().AppendEmpty()
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions vendor/go.opentelemetry.io/collector/featuregate/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions vendor/go.opentelemetry.io/collector/featuregate/flag.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 0 additions & 77 deletions vendor/go.opentelemetry.io/collector/featuregate/flags.go

This file was deleted.

Loading

0 comments on commit a6552cb

Please sign in to comment.