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

[chore] Remove experimental dead code related to streams and staleness #36915

Merged
merged 1 commit into from
Dec 26, 2024
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
23 changes: 13 additions & 10 deletions internal/exp/metrics/identity/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
package identity // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics/identity"

import (
"fmt"
"hash"

"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/pmetric"
)

type metric = Metric

type Metric struct {
scope

Expand All @@ -23,21 +22,21 @@ type Metric struct {
temporality pmetric.AggregationTemporality
}

func (i Metric) Hash() hash.Hash64 {
sum := i.scope.Hash()
sum.Write([]byte(i.name))
sum.Write([]byte(i.unit))
func (m Metric) Hash() hash.Hash64 {
sum := m.scope.Hash()
sum.Write([]byte(m.name))
sum.Write([]byte(m.unit))

var mono byte
if i.monotonic {
if m.monotonic {
mono = 1
}
sum.Write([]byte{byte(i.ty), mono, byte(i.temporality)})
sum.Write([]byte{byte(m.ty), mono, byte(m.temporality)})
return sum
}

func (i Metric) Scope() Scope {
return i.scope
func (m Metric) Scope() Scope {
return m.scope
}

func OfMetric(scope Scope, m pmetric.Metric) Metric {
Expand Down Expand Up @@ -66,6 +65,10 @@ func OfMetric(scope Scope, m pmetric.Metric) Metric {
return id
}

func (m Metric) String() string {
return fmt.Sprintf("metric/%x", m.Hash().Sum64())
}

func OfResourceMetric(res pcommon.Resource, scope pcommon.InstrumentationScope, metric pmetric.Metric) Metric {
return OfMetric(OfScope(OfResource(res), scope), metric)
}
5 changes: 5 additions & 0 deletions internal/exp/metrics/identity/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package identity // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics/identity"

import (
"fmt"
"hash"
"hash/fnv"

Expand All @@ -24,6 +25,10 @@ func (r Resource) Hash() hash.Hash64 {
return sum
}

func (r Resource) String() string {
return fmt.Sprintf("resource/%x", r.Hash().Sum64())
}

func OfResource(r pcommon.Resource) Resource {
return Resource{
attrs: pdatautil.MapHash(r.Attributes()),
Expand Down
5 changes: 5 additions & 0 deletions internal/exp/metrics/identity/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package identity // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics/identity"

import (
"fmt"
"hash"

"go.opentelemetry.io/collector/pdata/pcommon"
Expand Down Expand Up @@ -33,6 +34,10 @@ func (s Scope) Resource() Resource {
return s.resource
}

func (s Scope) String() string {
return fmt.Sprintf("scope/%x", s.Hash().Sum64())
}

func OfScope(res Resource, scope pcommon.InstrumentationScope) Scope {
return Scope{
resource: res,
Expand Down
19 changes: 12 additions & 7 deletions internal/exp/metrics/identity/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package identity // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics/identity"

import (
"fmt"
"hash"

"go.opentelemetry.io/collector/pdata/pcommon"
Expand All @@ -12,18 +13,22 @@ import (
)

type Stream struct {
metric
attrs [16]byte
metric Metric
attrs [16]byte
}

func (i Stream) Hash() hash.Hash64 {
sum := i.metric.Hash()
sum.Write(i.attrs[:])
func (s Stream) Hash() hash.Hash64 {
sum := s.metric.Hash()
sum.Write(s.attrs[:])
return sum
}

func (i Stream) Metric() Metric {
return i.metric
func (s Stream) Metric() Metric {
return s.metric
}

func (s Stream) String() string {
return fmt.Sprintf("stream/%x", s.Hash().Sum64())
}

func OfStream[DataPoint attrPoint](m Metric, dp DataPoint) Stream {
Expand Down
24 changes: 0 additions & 24 deletions internal/exp/metrics/identity/strings.go

This file was deleted.

16 changes: 14 additions & 2 deletions internal/exp/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
package metrics // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics"

import (
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/pmetric"

"github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics/identity"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics/streams"
)

// Merge will merge the metrics data in mdB into mdA, then return mdA.
Expand Down Expand Up @@ -111,7 +111,7 @@ outer:
return smA
}

func mergeDataPoints[DPS streams.DataPointSlice[DP], DP streams.DataPoint[DP]](dataPointsA DPS, dataPointsB DPS) DPS {
func mergeDataPoints[DPS dataPointSlice[DP], DP dataPoint[DP]](dataPointsA DPS, dataPointsB DPS) DPS {
// Append all the datapoints from B to A
for i := 0; i < dataPointsB.Len(); i++ {
dpB := dataPointsB.At(i)
Expand All @@ -122,3 +122,15 @@ func mergeDataPoints[DPS streams.DataPointSlice[DP], DP streams.DataPoint[DP]](d

return dataPointsA
}

type dataPointSlice[DP dataPoint[DP]] interface {
Len() int
At(i int) DP
AppendEmpty() DP
}

type dataPoint[Self any] interface {
Timestamp() pcommon.Timestamp
Attributes() pcommon.Map
CopyTo(dest Self)
}
134 changes: 0 additions & 134 deletions internal/exp/metrics/staleness/staleness.go

This file was deleted.

Loading
Loading