-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from lightstep/jmacd/review_expohisto
- Loading branch information
Showing
17 changed files
with
2,764 additions
and
3 deletions.
There are no files selected for viewing
128 changes: 128 additions & 0 deletions
128
lightstep/sdk/metric/aggregator/aggregation/aggregation.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//go:generate stringer -type=Category,Kind | ||
|
||
package aggregation // import "github.com/lightstep/otel-launcher-go/lightstep/sdk/metric/aggregator/aggregation" | ||
|
||
import ( | ||
"github.com/lightstep/otel-launcher-go/lightstep/sdk/metric/number" | ||
"github.com/lightstep/otel-launcher-go/lightstep/sdk/metric/sdkinstrument" | ||
) | ||
|
||
// These interfaces describe the various ways to access state from an | ||
// Aggregation. | ||
|
||
type ( | ||
// Aggregation is an interface returned by the Aggregator | ||
// containing an interval of metric data. | ||
Aggregation interface { | ||
Kind() Kind | ||
} | ||
|
||
// HasASum includes Sum and Histogram aggregators. | ||
HasASum interface { | ||
Sum() number.Number | ||
} | ||
|
||
// Sum returns an aggregated sum. | ||
Sum interface { | ||
// Review NOTE: Should this be Total() or Value()? | ||
HasASum | ||
IsMonotonic() bool | ||
} | ||
|
||
// Gauge returns the latest value that was aggregated. | ||
Gauge interface { | ||
Aggregation | ||
|
||
// Review NOTE: Should this be LastValue() or Value()? | ||
Gauge() number.Number | ||
} | ||
|
||
// Histogram returns the count of events in exponential-scale | ||
// buckets defined as a function of a scale parameter. See a | ||
// detailed explanation in the OpenTelemetry metrics data | ||
// model: | ||
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/datamodel.md#exponentialhistogram | ||
Histogram interface { | ||
Aggregation | ||
Count() uint64 | ||
HasASum | ||
Scale() int32 | ||
ZeroCount() uint64 | ||
Positive() Buckets | ||
Negative() Buckets | ||
} | ||
|
||
// Buckets describes a range of consecutive buckets, starting | ||
// at Offset(). This type is used to encode either the | ||
// positive or negative ranges of an Histogram. | ||
Buckets interface { | ||
Offset() int32 | ||
Len() uint32 | ||
At(uint32) uint64 | ||
} | ||
) | ||
|
||
// Category constants describe semantic kind. For the histogram | ||
// category there are multiple implementations, for those distinctions | ||
// as well as Drop, use Kind. | ||
type Category int | ||
|
||
const ( | ||
UndefinedCategory Category = iota | ||
MonotonicSumCategory | ||
NonMonotonicSumCategory | ||
GaugeCategory | ||
HistogramCategory | ||
) | ||
|
||
type Kind int | ||
|
||
const ( | ||
UndefinedKind Kind = iota | ||
DropKind | ||
AnySumKind | ||
MonotonicSumKind | ||
NonMonotonicSumKind | ||
GaugeKind | ||
HistogramKind | ||
) | ||
|
||
func (k Kind) Category(ik sdkinstrument.Kind) Category { | ||
switch k { | ||
case AnySumKind: | ||
switch ik { | ||
case sdkinstrument.HistogramKind, sdkinstrument.CounterKind, sdkinstrument.CounterObserverKind: | ||
return MonotonicSumCategory | ||
case sdkinstrument.UpDownCounterKind, sdkinstrument.UpDownCounterObserverKind: | ||
return NonMonotonicSumCategory | ||
} | ||
return UndefinedCategory | ||
case MonotonicSumKind: | ||
return MonotonicSumCategory | ||
case NonMonotonicSumKind: | ||
return NonMonotonicSumCategory | ||
case GaugeKind: | ||
return GaugeCategory | ||
case HistogramKind: | ||
return HistogramCategory | ||
default: | ||
return UndefinedCategory | ||
} | ||
} | ||
|
||
// KindSelector is a per-instrument-kind Kind choice. | ||
type KindSelector func(sdkinstrument.Kind) Kind |
50 changes: 50 additions & 0 deletions
50
lightstep/sdk/metric/aggregator/aggregation/category_string.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
lightstep/sdk/metric/aggregator/aggregation/temporality.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//go:generate stringer -type=Temporality | ||
|
||
package aggregation // import "github.com/lightstep/otel-launcher-go/lightstep/sdk/metric/aggregator/aggregation" | ||
|
||
import "github.com/lightstep/otel-launcher-go/lightstep/sdk/metric/sdkinstrument" | ||
|
||
type Temporality uint8 | ||
|
||
const ( | ||
// UndefinedTemporality indicates that temporality is not defined. | ||
UndefinedTemporality Temporality = 0 | ||
|
||
// CumulativeTemporality indicates that an Exporter expects a | ||
// Cumulative Aggregation. | ||
CumulativeTemporality Temporality = 1 | ||
|
||
// DeltaTemporality indicates that an Exporter expects a | ||
// Delta Aggregation. | ||
DeltaTemporality Temporality = 2 | ||
) | ||
|
||
type TemporalitySelector func(sdkinstrument.Kind) Temporality | ||
|
||
type TemporalityTrait interface { | ||
Temporality() Temporality | ||
} | ||
|
||
type DeltaTemporalityTrait struct{} | ||
type CumulativeTemporalityTrait struct{} | ||
|
||
func (DeltaTemporalityTrait) Temporality() Temporality { | ||
return DeltaTemporality | ||
} | ||
|
||
func (CumulativeTemporalityTrait) Temporality() Temporality { | ||
return CumulativeTemporality | ||
} |
25 changes: 25 additions & 0 deletions
25
lightstep/sdk/metric/aggregator/aggregation/temporality_string.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.