diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b4c3acdcead5..2a1add630da7 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -120,6 +120,7 @@ internal/collectd/ @open-telemetry/collect internal/coreinternal/ @open-telemetry/collector-contrib-approvers @open-telemetry/collector-approvers internal/datadog/ @open-telemetry/collector-contrib-approvers @mx-psi @dineshg13 internal/docker/ @open-telemetry/collector-contrib-approvers @rmfitzpatrick @jamesmoessis +internal/exp/metrics/ @open-telemetry/collector-contrib-approvers @sh0rez @RichieSams internal/filter/ @open-telemetry/collector-contrib-approvers @open-telemetry/collector-approvers internal/k8sconfig/ @open-telemetry/collector-contrib-approvers @dmitryax internal/k8stest/ @open-telemetry/collector-contrib-approvers @crobert-1 diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index c1a9b6ab3408..01011817dca6 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -118,6 +118,7 @@ body: - internal/core - internal/datadog - internal/docker + - internal/exp/metrics - internal/filter - internal/k8sconfig - internal/k8stest diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml index 5beccbc3d90a..c2d27c8c54b0 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yaml +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -112,6 +112,7 @@ body: - internal/core - internal/datadog - internal/docker + - internal/exp/metrics - internal/filter - internal/k8sconfig - internal/k8stest diff --git a/.github/ISSUE_TEMPLATE/other.yaml b/.github/ISSUE_TEMPLATE/other.yaml index 8bb53e45f08d..e2aaffa04b03 100644 --- a/.github/ISSUE_TEMPLATE/other.yaml +++ b/.github/ISSUE_TEMPLATE/other.yaml @@ -112,6 +112,7 @@ body: - internal/core - internal/datadog - internal/docker + - internal/exp/metrics - internal/filter - internal/k8sconfig - internal/k8stest diff --git a/internal/exp/metrics/Makefile b/internal/exp/metrics/Makefile new file mode 100644 index 000000000000..bdd863a203be --- /dev/null +++ b/internal/exp/metrics/Makefile @@ -0,0 +1 @@ +include ../../../Makefile.Common diff --git a/internal/exp/metrics/go.mod b/internal/exp/metrics/go.mod new file mode 100644 index 000000000000..c9cf2fbc1412 --- /dev/null +++ b/internal/exp/metrics/go.mod @@ -0,0 +1,28 @@ +module github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../../pkg/pdatautil + +require ( + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.0.0-00010101000000-000000000000 + go.opentelemetry.io/collector/pdata v1.1.0 +) + +require ( + github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + go.uber.org/multierr v1.11.0 // indirect + golang.org/x/net v0.18.0 // indirect + golang.org/x/sys v0.14.0 // indirect + golang.org/x/text v0.14.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect + google.golang.org/grpc v1.61.0 // indirect + google.golang.org/protobuf v1.32.0 // indirect +) + +go 1.21 + +toolchain go1.21.1 diff --git a/internal/exp/metrics/go.sum b/internal/exp/metrics/go.sum new file mode 100644 index 000000000000..5adb2808e4c4 --- /dev/null +++ b/internal/exp/metrics/go.sum @@ -0,0 +1,78 @@ +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.opentelemetry.io/collector/pdata v1.1.0 h1:cE6Al1rQieUjMHro6p6cKwcu3sjHXGG59BZ3kRVUvsM= +go.opentelemetry.io/collector/pdata v1.1.0/go.mod h1:IDkDj+B4Fp4wWOclBELN97zcb98HugJ8Q2gA4ZFsN8Q= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= +golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 h1:Jyp0Hsi0bmHXG6k9eATXoYtjd6e2UzZ1SCn/wIupY14= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:oQ5rr10WTTMvP4A36n8JpR1OrO1BEiV4f78CneXZxkA= +google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0= +google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/exp/metrics/identity/doc.go b/internal/exp/metrics/identity/doc.go new file mode 100644 index 000000000000..457bd7434496 --- /dev/null +++ b/internal/exp/metrics/identity/doc.go @@ -0,0 +1,8 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// identity types for metrics and sample streams. +// +// Use the `Of*(T) -> I` functions to obtain a unique, comparable (==) and +// hashable (map key) identity value I for T. +package identity // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics/identity" diff --git a/internal/exp/metrics/identity/metric.go b/internal/exp/metrics/identity/metric.go new file mode 100644 index 000000000000..ceaea90b8e0e --- /dev/null +++ b/internal/exp/metrics/identity/metric.go @@ -0,0 +1,71 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package identity // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics/identity" + +import ( + "hash" + + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" +) + +type metric = Metric + +type Metric struct { + scope + + name string + unit string + ty pmetric.MetricType + + monotonic bool + temporality pmetric.AggregationTemporality +} + +func (i Metric) Hash() hash.Hash64 { + sum := i.scope.Hash() + sum.Write([]byte(i.name)) + sum.Write([]byte(i.unit)) + + var mono byte + if i.monotonic { + mono = 1 + } + sum.Write([]byte{byte(i.ty), mono, byte(i.temporality)}) + return sum +} + +func (i Metric) Scope() Scope { + return i.scope +} + +func OfMetric(scope Scope, m pmetric.Metric) Metric { + id := Metric{ + scope: scope, + name: m.Name(), + unit: m.Unit(), + ty: m.Type(), + } + + switch m.Type() { + case pmetric.MetricTypeSum: + sum := m.Sum() + id.monotonic = sum.IsMonotonic() + id.temporality = sum.AggregationTemporality() + case pmetric.MetricTypeExponentialHistogram: + exp := m.ExponentialHistogram() + id.monotonic = true + id.temporality = exp.AggregationTemporality() + case pmetric.MetricTypeHistogram: + hist := m.Histogram() + id.monotonic = true + id.temporality = hist.AggregationTemporality() + } + + return id +} + +func OfResourceMetric(res pcommon.Resource, scope pcommon.InstrumentationScope, metric pmetric.Metric) Metric { + return OfMetric(OfScope(OfResource(res), scope), metric) +} diff --git a/internal/exp/metrics/identity/resource.go b/internal/exp/metrics/identity/resource.go new file mode 100644 index 000000000000..990fb71e64ea --- /dev/null +++ b/internal/exp/metrics/identity/resource.go @@ -0,0 +1,31 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package identity // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics/identity" + +import ( + "hash" + "hash/fnv" + + "go.opentelemetry.io/collector/pdata/pcommon" + + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil" +) + +type resource = Resource + +type Resource struct { + attrs [16]byte +} + +func (r Resource) Hash() hash.Hash64 { + sum := fnv.New64a() + sum.Write(r.attrs[:]) + return sum +} + +func OfResource(r pcommon.Resource) Resource { + return Resource{ + attrs: pdatautil.MapHash(r.Attributes()), + } +} diff --git a/internal/exp/metrics/identity/scope.go b/internal/exp/metrics/identity/scope.go new file mode 100644 index 000000000000..db516bc14c79 --- /dev/null +++ b/internal/exp/metrics/identity/scope.go @@ -0,0 +1,43 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package identity // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics/identity" + +import ( + "hash" + + "go.opentelemetry.io/collector/pdata/pcommon" + + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil" +) + +type scope = Scope + +type Scope struct { + resource resource + + name string + version string + attrs [16]byte +} + +func (s Scope) Hash() hash.Hash64 { + sum := s.resource.Hash() + sum.Write([]byte(s.name)) + sum.Write([]byte(s.version)) + sum.Write(s.attrs[:]) + return sum +} + +func (s Scope) Resource() Resource { + return s.resource +} + +func OfScope(res Resource, scope pcommon.InstrumentationScope) Scope { + return Scope{ + resource: res, + name: scope.Name(), + version: scope.Version(), + attrs: pdatautil.MapHash(scope.Attributes()), + } +} diff --git a/internal/exp/metrics/identity/stream.go b/internal/exp/metrics/identity/stream.go new file mode 100644 index 000000000000..8deb50f9b317 --- /dev/null +++ b/internal/exp/metrics/identity/stream.go @@ -0,0 +1,37 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package identity // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics/identity" + +import ( + "hash" + + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" + + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil" +) + +type Stream struct { + metric + attrs [16]byte +} + +func (i Stream) Hash() hash.Hash64 { + sum := i.metric.Hash() + sum.Write(i.attrs[:]) + return sum +} + +func (i Stream) Metric() Metric { + return i.metric +} + +func OfStream[DataPoint attrPoint](m Metric, dp DataPoint) Stream { + return Stream{metric: m, attrs: pdatautil.MapHash(dp.Attributes())} +} + +type attrPoint interface { + pmetric.NumberDataPoint | pmetric.HistogramDataPoint | pmetric.ExponentialHistogramDataPoint | pmetric.SummaryDataPoint + Attributes() pcommon.Map +} diff --git a/internal/exp/metrics/identity/strings.go b/internal/exp/metrics/identity/strings.go new file mode 100644 index 000000000000..7339f95a578c --- /dev/null +++ b/internal/exp/metrics/identity/strings.go @@ -0,0 +1,24 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package identity // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics/identity" + +import ( + "fmt" +) + +func (r Resource) String() string { + return fmt.Sprintf("resource/%x", r.Hash().Sum64()) +} + +func (s Scope) String() string { + return fmt.Sprintf("scope/%x", s.Hash().Sum64()) +} + +func (m Metric) String() string { + return fmt.Sprintf("metric/%x", m.Hash().Sum64()) +} + +func (s Stream) String() string { + return fmt.Sprintf("stream/%x", s.Hash().Sum64()) +} diff --git a/internal/exp/metrics/metadata.yaml b/internal/exp/metrics/metadata.yaml new file mode 100644 index 000000000000..05b65282244e --- /dev/null +++ b/internal/exp/metrics/metadata.yaml @@ -0,0 +1,3 @@ +status: + codeowners: + active: [sh0rez, RichieSams] diff --git a/versions.yaml b/versions.yaml index 08ed9f9d1aeb..abed3267a60c 100644 --- a/versions.yaml +++ b/versions.yaml @@ -116,6 +116,7 @@ module-sets: - github.com/open-telemetry/opentelemetry-collector-contrib/internal/common - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal - github.com/open-telemetry/opentelemetry-collector-contrib/internal/docker + - github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics - github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter - github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig - github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8stest