Skip to content

Commit

Permalink
Merge branch 'new_sdk/main' into mvg/new_sdk/fix-scope
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias authored Jul 14, 2022
2 parents b15b674 + a1c5b6f commit 0c26373
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 82 deletions.
10 changes: 6 additions & 4 deletions sdk/metric/export/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ func (Sum) privateAggregation() {}

// DataPoint is a single data point in a timeseries.
type DataPoint struct {
// Attributes is the set of key value pairs that uniquely identify the timeseries.
Attributes []attribute.KeyValue
// Attributes is the set of key value pairs that uniquely identify the
// timeseries.
Attributes attribute.Set
// StartTime is when the timeseries was started. (optional)
StartTime time.Time
// Time is the time when the timeseries was recorded. (optional)
Expand Down Expand Up @@ -126,8 +127,9 @@ func (Histogram) privateAggregation() {}

// HistogramDataPoint is a single histogram data point in a timeseries.
type HistogramDataPoint struct {
// Attributes is the set of key value pairs that uniquely identify the timeseries.
Attributes []attribute.KeyValue
// Attributes is the set of key value pairs that uniquely identify the
// timeseries.
Attributes attribute.Set
// StartTime is when the timeseries was started.
StartTime time.Time
// Time is the time when the timeseries was recorded.
Expand Down
61 changes: 0 additions & 61 deletions sdk/metric/internal/aggregation.go

This file was deleted.

11 changes: 7 additions & 4 deletions sdk/metric/internal/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@

package internal // import "go.opentelemetry.io/otel/sdk/metric/internal"

import "go.opentelemetry.io/otel/attribute"
import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/metric/export"
)

// Aggregator forms an aggregation from a collection of recorded measurements.
type Aggregator[N int64 | float64] interface {
// Aggregate records the measurement, scoped by attr, and aggregates it
// into an aggregation.
Aggregate(measurement N, attr attribute.Set)

// Aggregations returns a slice of Aggregation, one per each attribute set
// used to scope measurement aggregation, and ends an aggregation cycle.
Aggregations() []Aggregation
// Aggregation returns an Aggregation, for all the aggregated
// measurements made and ends an aggregation cycle.
Aggregation() export.Aggregation
}
12 changes: 6 additions & 6 deletions sdk/metric/internal/aggregator_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import (
"go.opentelemetry.io/otel/metric/instrument"
"go.opentelemetry.io/otel/metric/instrument/syncint64"
"go.opentelemetry.io/otel/sdk/metric/aggregation"
"go.opentelemetry.io/otel/sdk/metric/export"
)

type meter struct {
// When a reader initiates a collection, the meter would collect
// aggregations from each of these functions. In this process they will
// progress the aggregation period of each instrument's aggregator.
aggregationFuncs []func() []Aggregation
// aggregations from each of these functions.
aggregations []export.Aggregation
}

func (m *meter) SyncInt64() syncint64.InstrumentProvider {
Expand All @@ -51,7 +51,7 @@ func (p *syncInt64Provider) Counter(string, ...instrument.Option) (syncint64.Cou
aggregator := NewCumulativeSum[int64]()
count := inst{aggregateFunc: aggregator.Aggregate}

p.aggregationFuncs = append(p.aggregationFuncs, aggregator.Aggregations)
p.aggregations = append(p.aggregations, aggregator.Aggregation())

fmt.Printf("using %T aggregator for counter\n", aggregator)

Expand All @@ -69,7 +69,7 @@ func (p *syncInt64Provider) UpDownCounter(string, ...instrument.Option) (syncint
aggregator := NewLastValue[int64]()
upDownCount := inst{aggregateFunc: aggregator.Aggregate}

p.aggregationFuncs = append(p.aggregationFuncs, aggregator.Aggregations)
p.aggregations = append(p.aggregations, aggregator.Aggregation())

fmt.Printf("using %T aggregator for up-down counter\n", aggregator)

Expand All @@ -89,7 +89,7 @@ func (p *syncInt64Provider) Histogram(string, ...instrument.Option) (syncint64.H
})
hist := inst{aggregateFunc: aggregator.Aggregate}

p.aggregationFuncs = append(p.aggregationFuncs, aggregator.Aggregations)
p.aggregations = append(p.aggregations, aggregator.Aggregation())

fmt.Printf("using %T aggregator for histogram\n", aggregator)

Expand Down
5 changes: 3 additions & 2 deletions sdk/metric/internal/histogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package internal // import "go.opentelemetry.io/otel/sdk/metric/internal"
import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/metric/aggregation"
"go.opentelemetry.io/otel/sdk/metric/export"
)

// histogram summarizes a set of measurements as an histogram with
Expand Down Expand Up @@ -51,7 +52,7 @@ type deltaHistogram[N int64 | float64] struct {
// TODO(#2970): implement.
}

func (s *deltaHistogram[N]) Aggregations() []Aggregation {
func (s *deltaHistogram[N]) Aggregation() export.Aggregation {
// TODO(#2970): implement.
return nil
}
Expand All @@ -74,7 +75,7 @@ type cumulativeHistogram[N int64 | float64] struct {
// TODO(#2970): implement.
}

func (s *cumulativeHistogram[N]) Aggregations() []Aggregation {
func (s *cumulativeHistogram[N]) Aggregation() export.Aggregation {
// TODO(#2970): implement.
return nil
}
7 changes: 5 additions & 2 deletions sdk/metric/internal/lastvalue.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

package internal // import "go.opentelemetry.io/otel/sdk/metric/internal"

import "go.opentelemetry.io/otel/attribute"
import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/metric/export"
)

// lastValue summarizes a set of measurements as the last one made.
type lastValue[N int64 | float64] struct {
Expand All @@ -34,7 +37,7 @@ func (s *lastValue[N]) Aggregate(value N, attr attribute.Set) {
// TODO(#2971): implement.
}

func (s *lastValue[N]) Aggregations() []Aggregation {
func (s *lastValue[N]) Aggregation() export.Aggregation {
// TODO(#2971): implement.
return nil
}
9 changes: 6 additions & 3 deletions sdk/metric/internal/sum.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

package internal // import "go.opentelemetry.io/otel/sdk/metric/internal"

import "go.opentelemetry.io/otel/attribute"
import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/metric/export"
)

// sum summarizes a set of measurements as their arithmetic sum.
type sum[N int64 | float64] struct {
Expand Down Expand Up @@ -47,7 +50,7 @@ type deltaSum[N int64 | float64] struct {
// TODO(#2972): implement.
}

func (s *deltaSum[N]) Aggregations() []Aggregation {
func (s *deltaSum[N]) Aggregation() export.Aggregation {
// TODO(#2972): implement.
return nil
}
Expand All @@ -71,7 +74,7 @@ type cumulativeSum[N int64 | float64] struct {
// TODO(#2972): implement.
}

func (s *cumulativeSum[N]) Aggregations() []Aggregation {
func (s *cumulativeSum[N]) Aggregation() export.Aggregation {
// TODO(#2972): implement.
return nil
}

0 comments on commit 0c26373

Please sign in to comment.