Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[otlp] Update OTel Collector to latest release #3852

Merged
merged 2 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ require (
go.uber.org/atomic v1.10.0
go.uber.org/goleak v1.2.0
golang.org/x/crypto v0.3.0
golang.org/x/net v0.4.0
golang.org/x/net v0.5.0
golang.org/x/sync v0.1.0
golang.org/x/time v0.3.0
google.golang.org/grpc v1.51.0
Expand All @@ -60,14 +60,14 @@ require (
github.com/grafana-tools/sdk v0.0.0-20211220201350-966b3088eec9
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite v0.57.2
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite v0.69.0
github.com/thanos-io/objstore v0.0.0-20221213124554-e4d8ba6bc6f3
go.opentelemetry.io/collector/pdata v0.57.2
go.opentelemetry.io/collector/pdata v1.0.0-rc3.0.20230109164642-7d168dd20efd
go.opentelemetry.io/otel v1.11.2
go.opentelemetry.io/otel/trace v1.11.2
go.uber.org/multierr v1.8.0
go.uber.org/multierr v1.9.0
golang.org/x/exp v0.0.0-20221212164502-fae10dda9338
golang.org/x/sys v0.3.0
golang.org/x/sys v0.4.0
google.golang.org/api v0.104.0
gopkg.in/alecthomas/kingpin.v2 v2.2.6
sigs.k8s.io/kustomize/kyaml v0.13.7
Expand Down Expand Up @@ -180,7 +180,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.57.2 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.69.0 // 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 @@ -206,13 +206,14 @@ require (
go.mongodb.org/mongo-driver v1.11.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/collector v0.57.2 // indirect
go.opentelemetry.io/collector/semconv v0.57.2 // indirect
go.opentelemetry.io/collector/featuregate v0.69.0 // indirect
go.opentelemetry.io/collector/semconv v0.69.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.37.0 // indirect
go.opentelemetry.io/otel/metric v0.34.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/oauth2 v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
golang.org/x/text v0.6.0 // indirect
golang.org/x/tools v0.4.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand Down
40 changes: 21 additions & 19 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -725,12 +725,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.57.2 h1:DBdJtRrjhzx7zuqFAjAXs90gJJ4IgIxYKvnlr54nQfg=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.57.2 h1:4HeNNbZnqz15hj4oGm1O1x+yP+hPnvhz2UYqrApvPDk=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.57.2 h1:po61A+HQ1KnJ/s3TuOQGMo1haiKjDS/oh7QuBhoCfMY=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.57.2/go.mod h1:e2DoTAc1lTBWM06sptbNqEAuSzajjnK6vrtWKYebhAM=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite v0.57.2 h1:YcDLWVe2XmeawzGu5Yo/ykpuSpGMxIPFwNLm4MZr+38=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite v0.57.2/go.mod h1:usczt8Eymx/wg3hHWBksX/fWZ5VGdVgli8FM7sFmyCw=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.69.0 h1:dFApx4qc1INp2e14m9IeQaF0XVTQChuWX3wYNAYhamQ=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.69.0 h1:XRJPHV+JHf+8PGVd9UncG+S3w1Ym39Ztu8ZGE0ZXmxE=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.69.0 h1:YFJj77LUvaxI81Gd85Ko0OA5S0/NV10gSG6utbi5/3M=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.69.0/go.mod h1:/6u/f+pwP618Uo5PCv42Py++BfGas2dP4I8U0C4Z/0I=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite v0.69.0 h1:1KdOrloLENn8OXnFZpg3ixhgt6RnL/rbSokuoD2nUyY=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite v0.69.0/go.mod h1:JOUp6I3dlrtXffEUS74ZBsRq5z03axnf0CRyjPwFkVM=
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 @@ -942,10 +942,12 @@ 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 v0.57.2 h1:/J7twI5BlIK3I4GfDfLhqPgfgSjnhiDesXf24bmrXYM=
go.opentelemetry.io/collector v0.57.2/go.mod h1:9TwWyMRhbFNzaaGLtm/6poWNDJw+etvQMS6Fy+8/8Xs=
go.opentelemetry.io/collector/pdata v0.57.2 h1:w2w3NE7/3WzHloT1xV5caRmifV3qt95gc5iJhO/Bues=
go.opentelemetry.io/collector/pdata v0.57.2/go.mod h1:RU9I8lwBUxucwOsSYzHEcHi15M9QaX78hgQ2PRdSxV0=
go.opentelemetry.io/collector/semconv v0.57.2 h1:+lcI4yi8xUzoSNZgGTs0vytZcEAH95Tb33Ig+gooBV8=
go.opentelemetry.io/collector/semconv v0.57.2/go.mod h1:84YnUjmm+nhGu4YTDLnHCbxnL74ooWpismPG79tFD7w=
go.opentelemetry.io/collector/featuregate v0.69.0 h1:TI6zcWszEbAP1UGyVIWFDKoltaPx4VprjGbd5jsDBj8=
go.opentelemetry.io/collector/featuregate v0.69.0/go.mod h1:tewuFKJYalWBU0bmNKg++MC1ipINXUr6szYzOw2p1GI=
go.opentelemetry.io/collector/pdata v1.0.0-rc3.0.20230109164642-7d168dd20efd h1:Mv0AhUDD10YS9620bxXBf0zoTkQjwANcaqWJyxr88ks=
go.opentelemetry.io/collector/pdata v1.0.0-rc3.0.20230109164642-7d168dd20efd/go.mod h1:NggifanH3PY9reO9gUtcP8IqNpAabT+aDOCFZoIa7Ts=
go.opentelemetry.io/collector/semconv v0.69.0 h1:B4eMTnWM4ZRQS4RI/SZaTRoDcT6eFVPEymH7qJ31Pmk=
go.opentelemetry.io/collector/semconv v0.69.0/go.mod h1:5o9yhOa+ABt7g2E5JABDxGZ1PQPbtfxrKNbYn+LOTXU=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.37.0 h1:yt2NKzK7Vyo6h0+X8BA4FpreZQTlVEIarnsBP/H5mzs=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.37.0/go.mod h1:+ARmXlUlc51J7sZeCBkBJNdHGySrdOzgzxp6VWRWM1U=
go.opentelemetry.io/otel v1.11.2 h1:YBZcQlsVekzFsFbjygXMOXSs6pialIZxcjfO/mBDmR0=
Expand All @@ -966,8 +968,8 @@ go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
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/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8=
Expand Down Expand Up @@ -1094,8 +1096,8 @@ golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU=
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -1232,12 +1234,12 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.3.0 h1:qoo4akIqOcDME5bhc/NgxUdovd6BSS2uMsVjB56q1xI=
golang.org/x/term v0.4.0 h1:O7UWfv5+A2qiuulQk30kVinPoMtoIPeVaKLEgLpVkvg=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -1248,8 +1250,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down
20 changes: 10 additions & 10 deletions pkg/util/push/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ func OTLPHandler(
discardedDueToOtelParseError := validation.DiscardedSamplesCounter(reg, otelParseError)

return handler(maxRecvMsgSize, sourceIPs, allowSkipLabelNameValidation, push, func(ctx context.Context, r *http.Request, maxRecvMsgSize int, dst []byte, req *mimirpb.PreallocWriteRequest) ([]byte, error) {
var decoderFunc func(buf []byte) (pmetricotlp.Request, error)
var decoderFunc func(buf []byte) (pmetricotlp.ExportRequest, error)

logger := log.WithContext(ctx, log.Logger)

contentType := r.Header.Get("Content-Type")
switch contentType {
case pbContentType:
decoderFunc = func(buf []byte) (pmetricotlp.Request, error) {
req := pmetricotlp.NewRequest()
decoderFunc = func(buf []byte) (pmetricotlp.ExportRequest, error) {
req := pmetricotlp.NewExportRequest()
return req, req.UnmarshalProto(buf)
}

case jsonContentType:
decoderFunc = func(buf []byte) (pmetricotlp.Request, error) {
req := pmetricotlp.NewRequest()
decoderFunc = func(buf []byte) (pmetricotlp.ExportRequest, error) {
req := pmetricotlp.NewExportRequest()
return req, req.UnmarshalJSON(buf)
}

Expand Down Expand Up @@ -199,7 +199,7 @@ func promToMimirTimeseries(promTs *prompb.TimeSeries) mimirpb.PreallocTimeseries
}

// TimeseriesToOTLPRequest is used in tests.
func TimeseriesToOTLPRequest(timeseries []prompb.TimeSeries) pmetricotlp.Request {
func TimeseriesToOTLPRequest(timeseries []prompb.TimeSeries) pmetricotlp.ExportRequest {
d := pmetric.NewMetrics()

for _, ts := range timeseries {
Expand All @@ -212,20 +212,20 @@ func TimeseriesToOTLPRequest(timeseries []prompb.TimeSeries) pmetricotlp.Request
continue
}

attributes.InsertString(l.Name, l.Value)
attributes.PutStr(l.Name, l.Value)
}

metric := d.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics().AppendEmpty()
metric.SetName(name)
metric.SetDataType(pmetric.MetricDataTypeGauge)
metric.SetEmptyGauge()

for _, sample := range ts.Samples {
datapoint := metric.Gauge().DataPoints().AppendEmpty()
datapoint.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(0, int64(sample.Timestamp)*1000000)))
datapoint.SetDoubleVal(sample.Value)
datapoint.SetDoubleValue(sample.Value)
attributes.CopyTo(datapoint.Attributes())
}
}

return pmetricotlp.NewRequestFromMetrics(d)
return pmetricotlp.NewExportRequestFromMetrics(d)
}
48 changes: 24 additions & 24 deletions pkg/util/push/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,35 @@ func TestHandler_otlpDroppedMetricsPanic(t *testing.T) {
md := pmetric.NewMetrics()
const name = "foo"
attributes := pcommon.NewMap()
attributes.InsertString(model.MetricNameLabel, name)
attributes.PutStr(model.MetricNameLabel, name)

metric1 := md.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics().AppendEmpty()
metric1.SetName(name)
metric1.SetDataType(pmetric.MetricDataTypeGauge)
metric1.SetEmptyGauge()

datapoint1 := metric1.Gauge().DataPoints().AppendEmpty()
datapoint1.SetTimestamp(pcommon.NewTimestampFromTime(time.Now()))
datapoint1.SetDoubleVal(0)
datapoint1.SetDoubleValue(0)
attributes.CopyTo(datapoint1.Attributes())
datapoint1.Attributes().InsertString("diff_label", "bar")
datapoint1.Attributes().PutStr("diff_label", "bar")

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

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

metric2 := md.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics().AppendEmpty()
metric2.SetName(name)
metric2.SetDataType(pmetric.MetricDataTypeGauge)
metric2.SetEmptyGauge()

req := createOTLPRequest(t, pmetricotlp.NewRequestFromMetrics(md), false)
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()
Expand All @@ -108,25 +108,25 @@ func TestHandler_otlpDroppedMetricsPanic2(t *testing.T) {
md := pmetric.NewMetrics()
const name = "foo"
attributes := pcommon.NewMap()
attributes.InsertString(model.MetricNameLabel, name)
attributes.PutStr(model.MetricNameLabel, name)

resource1 := md.ResourceMetrics().AppendEmpty()
resource1.Resource().Attributes().InsertString("region", "us-central1")
resource1.Resource().Attributes().PutStr("region", "us-central1")

metric1 := resource1.ScopeMetrics().AppendEmpty().Metrics().AppendEmpty()
metric1.SetName(name)
metric1.SetDataType(pmetric.MetricDataTypeGauge)
metric1.SetEmptyGauge()
datapoint1 := metric1.Gauge().DataPoints().AppendEmpty()
datapoint1.SetTimestamp(pcommon.NewTimestampFromTime(time.Now()))
datapoint1.SetDoubleVal(0)
datapoint1.SetDoubleValue(0)
attributes.CopyTo(datapoint1.Attributes())
datapoint1.Attributes().InsertString("diff_label", "bar")
datapoint1.Attributes().PutStr("diff_label", "bar")

metric2 := resource1.ScopeMetrics().AppendEmpty().Metrics().AppendEmpty()
metric2.SetName(name)
metric2.SetDataType(pmetric.MetricDataTypeGauge)
metric2.SetEmptyGauge()

req := createOTLPRequest(t, pmetricotlp.NewRequestFromMetrics(md), false)
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()
Expand All @@ -142,17 +142,17 @@ 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.SetDataType(pmetric.MetricDataTypeHistogram)
metric3.Histogram().SetAggregationTemporality(pmetric.MetricAggregationTemporalityCumulative)
metric3.SetEmptyHistogram()
metric3.Histogram().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative)
datapoint3 := metric3.Histogram().DataPoints().AppendEmpty()
datapoint3.SetTimestamp(pcommon.NewTimestampFromTime(time.Now()))
datapoint3.SetCount(50)
datapoint3.SetSum(100)
datapoint3.SetExplicitBounds(pcommon.NewImmutableFloat64Slice([]float64{0.1, 0.2, 0.3, 0.4, 0.5}))
datapoint3.SetBucketCounts(pcommon.NewImmutableUInt64Slice([]uint64{10, 20, 30, 40, 50}))
datapoint3.ExplicitBounds().FromRaw([]float64{0.1, 0.2, 0.3, 0.4, 0.5})
datapoint3.BucketCounts().FromRaw([]uint64{10, 20, 30, 40, 50})
attributes.CopyTo(datapoint3.Attributes())

req = createOTLPRequest(t, pmetricotlp.NewRequestFromMetrics(md), false)
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()
Expand Down Expand Up @@ -386,7 +386,7 @@ func createRequest(t testing.TB, protobuf []byte) *http.Request {
return req
}

func createOTLPRequest(t testing.TB, metricRequest pmetricotlp.Request, compress bool) *http.Request {
func createOTLPRequest(t testing.TB, metricRequest pmetricotlp.ExportRequest, compress bool) *http.Request {
t.Helper()

rawBytes, err := metricRequest.MarshalProto()
Expand Down Expand Up @@ -421,7 +421,7 @@ func createOTLPRequest(t testing.TB, metricRequest pmetricotlp.Request, compress
return req
}

func createOTLPMetricRequest(t testing.TB) pmetricotlp.Request {
func createOTLPMetricRequest(t testing.TB) pmetricotlp.ExportRequest {
input := createPrometheusRemoteWriteProtobuf(t)
prwReq := &prompb.WriteRequest{}
require.NoError(t, proto.Unmarshal(input, prwReq))
Expand Down

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

Loading