You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-09-16 09:26:25 +02:00
Merge branch 'main' into internal_logging
This commit is contained in:
19
CHANGELOG.md
19
CHANGELOG.md
@@ -8,7 +8,14 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## Changed
|
||||
### Removed
|
||||
|
||||
- Remove the metric Processor's ability to convert cumulative to delta aggregation temporality. (#2350)
|
||||
- Remove the metric Bound Instruments interface and implementations. (#2399)
|
||||
|
||||
## [1.2.0] - 2021-11-12
|
||||
|
||||
### Changed
|
||||
|
||||
- Metric SDK `export.ExportKind`, `export.ExportKindSelector` types have been renamed to `aggregation.Temporality` and `aggregation.TemporalitySelector` respectively to keep in line with current specification and protocol along with built-in selectors (e.g., `aggregation.CumulativeTemporalitySelector`, ...). (#2274)
|
||||
- The Metric `Exporter` interface now requires a `TemporalitySelector` method instead of an `ExportKindSelector`. (#2274)
|
||||
@@ -18,14 +25,19 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
- The No-op implementations of sync and async instruments are no longer exported, new functions `sdkapi.NewNoopAsyncInstrument()` and `sdkapi.NewNoopSyncInstrument()` are provided instead. (#2271)
|
||||
- Update the SDK `BatchSpanProcessor` to export all queued spans when `ForceFlush` is called. (#2080, #2335)
|
||||
- The default ErrorHandler now uses the internal logger. The default of logging to stderr is unchanged.
|
||||
- Change `resource.Default` to be evaluated the first time it is called, rather than on import. This allows the caller the option to update `OTEL_RESOURCE_ATTRIBUTES` first, such as with `os.Setenv`. (#2371)
|
||||
|
||||
### Added
|
||||
|
||||
- Add the `"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc".WithGRPCConn` option so the exporter can reuse an existing gRPC connection. (#2002)
|
||||
- Added a new `schema` module to help parse Schema Files in OTEP 0152 format. (#2267)
|
||||
- Added a new `MapCarrier` to the `go.opentelemetry.io/otel/propagation` package to hold propagated coss-cutting concerns as a `map[string]string` held in memory. (#2334)
|
||||
- Added a new `MapCarrier` to the `go.opentelemetry.io/otel/propagation` package to hold propagated cross-cutting concerns as a `map[string]string` held in memory. (#2334)
|
||||
- Added an internal Logger. This can be used by the SDK and API to provide users with feedback of the internal state. To enable verbose logs configure the logger which will print V(1) logs. For debugging information confgure to print V(5) logs.
|
||||
|
||||
### Removed
|
||||
|
||||
- Metric SDK removes the "exact" aggregator for histogram instruments, as it performed a non-standard aggregation for OTLP export (creating repeated Gauge points) and worked its way into a number of confusing examples. (#2348)
|
||||
|
||||
## [1.1.0] - 2021-10-27
|
||||
|
||||
### Added
|
||||
@@ -1597,7 +1609,8 @@ It contains api and sdk for trace and meter.
|
||||
- CircleCI build CI manifest files.
|
||||
- CODEOWNERS file to track owners of this project.
|
||||
|
||||
[Unreleased]: https://github.com/open-telemetry/opentelemetry-go/compare/v1.1.0...HEAD
|
||||
[Unreleased]: https://github.com/open-telemetry/opentelemetry-go/compare/v1.2.0...HEAD
|
||||
[1.2.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.2.0
|
||||
[1.1.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.1.0
|
||||
[1.0.1]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.0.1
|
||||
[Metrics 0.24.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/metric/v0.24.0
|
||||
|
@@ -31,127 +31,109 @@ var (
|
||||
errBadPoint = errors.New("point cannot be converted")
|
||||
)
|
||||
|
||||
// aggregationWithEndTime is an aggregation that can also provide the timestamp
|
||||
// of the last recorded point.
|
||||
type aggregationWithEndTime interface {
|
||||
aggregation.Aggregation
|
||||
end() time.Time
|
||||
}
|
||||
type recordFunc func(agg aggregation.Aggregation, end time.Time) error
|
||||
|
||||
// newAggregationFromPoints creates an OpenTelemetry aggregation from
|
||||
// OpenCensus points. Points may not be empty and must be either
|
||||
// recordAggregationsFromPoints records one OpenTelemetry aggregation for
|
||||
// each OpenCensus point. Points may not be empty and must be either
|
||||
// all (int|float)64 or all *metricdata.Distribution.
|
||||
func newAggregationFromPoints(points []metricdata.Point) (aggregationWithEndTime, error) {
|
||||
func recordAggregationsFromPoints(points []metricdata.Point, recorder recordFunc) error {
|
||||
if len(points) == 0 {
|
||||
return nil, errEmpty
|
||||
return errEmpty
|
||||
}
|
||||
switch t := points[0].Value.(type) {
|
||||
case int64:
|
||||
return newExactAggregator(points)
|
||||
return recordGaugePoints(points, recorder)
|
||||
case float64:
|
||||
return newExactAggregator(points)
|
||||
return recordGaugePoints(points, recorder)
|
||||
case *metricdata.Distribution:
|
||||
return newDistributionAggregator(points)
|
||||
return recordDistributionPoint(points, recorder)
|
||||
default:
|
||||
// TODO add *metricdata.Summary support
|
||||
return nil, fmt.Errorf("%w: %v", errIncompatibleType, t)
|
||||
return fmt.Errorf("%w: %v", errIncompatibleType, t)
|
||||
}
|
||||
}
|
||||
|
||||
var _ aggregation.Aggregation = &ocExactAggregator{}
|
||||
var _ aggregation.LastValue = &ocExactAggregator{}
|
||||
var _ aggregation.Points = &ocExactAggregator{}
|
||||
var _ aggregation.Aggregation = &ocRawAggregator{}
|
||||
var _ aggregation.LastValue = &ocRawAggregator{}
|
||||
|
||||
// newExactAggregator creates an OpenTelemetry aggreation from OpenCensus points.
|
||||
// recordGaugePoints creates an OpenTelemetry aggregation from OpenCensus points.
|
||||
// Points may not be empty, and must only contain integers or floats.
|
||||
func newExactAggregator(pts []metricdata.Point) (aggregationWithEndTime, error) {
|
||||
points := make([]aggregation.Point, len(pts))
|
||||
for i, pt := range pts {
|
||||
func recordGaugePoints(pts []metricdata.Point, recorder recordFunc) error {
|
||||
for _, pt := range pts {
|
||||
switch t := pt.Value.(type) {
|
||||
case int64:
|
||||
points[i] = aggregation.Point{
|
||||
Number: number.NewInt64Number(pt.Value.(int64)),
|
||||
Time: pt.Time,
|
||||
if err := recorder(&ocRawAggregator{
|
||||
value: number.NewInt64Number(pt.Value.(int64)),
|
||||
time: pt.Time,
|
||||
}, pt.Time); err != nil {
|
||||
return err
|
||||
}
|
||||
case float64:
|
||||
points[i] = aggregation.Point{
|
||||
Number: number.NewFloat64Number(pt.Value.(float64)),
|
||||
Time: pt.Time,
|
||||
if err := recorder(&ocRawAggregator{
|
||||
value: number.NewFloat64Number(pt.Value.(float64)),
|
||||
time: pt.Time,
|
||||
}, pt.Time); err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("%w: %v", errIncompatibleType, t)
|
||||
return fmt.Errorf("%w: %v", errIncompatibleType, t)
|
||||
}
|
||||
}
|
||||
return &ocExactAggregator{
|
||||
points: points,
|
||||
}, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
type ocExactAggregator struct {
|
||||
points []aggregation.Point
|
||||
type ocRawAggregator struct {
|
||||
value number.Number
|
||||
time time.Time
|
||||
}
|
||||
|
||||
// Kind returns the kind of aggregation this is.
|
||||
func (o *ocExactAggregator) Kind() aggregation.Kind {
|
||||
return aggregation.ExactKind
|
||||
}
|
||||
|
||||
// Points returns access to the raw data set.
|
||||
func (o *ocExactAggregator) Points() ([]aggregation.Point, error) {
|
||||
return o.points, nil
|
||||
func (o *ocRawAggregator) Kind() aggregation.Kind {
|
||||
return aggregation.LastValueKind
|
||||
}
|
||||
|
||||
// LastValue returns the last point.
|
||||
func (o *ocExactAggregator) LastValue() (number.Number, time.Time, error) {
|
||||
last := o.points[len(o.points)-1]
|
||||
return last.Number, last.Time, nil
|
||||
}
|
||||
|
||||
// end returns the timestamp of the last point
|
||||
func (o *ocExactAggregator) end() time.Time {
|
||||
_, t, _ := o.LastValue()
|
||||
return t
|
||||
func (o *ocRawAggregator) LastValue() (number.Number, time.Time, error) {
|
||||
return o.value, o.time, nil
|
||||
}
|
||||
|
||||
var _ aggregation.Aggregation = &ocDistAggregator{}
|
||||
var _ aggregation.Histogram = &ocDistAggregator{}
|
||||
|
||||
// newDistributionAggregator creates an OpenTelemetry aggreation from
|
||||
// recordDistributionPoint creates an OpenTelemetry aggregation from
|
||||
// OpenCensus points. Points may not be empty, and must only contain
|
||||
// Distributions. The most recent disribution will be used in the aggregation.
|
||||
func newDistributionAggregator(pts []metricdata.Point) (aggregationWithEndTime, error) {
|
||||
func recordDistributionPoint(pts []metricdata.Point, recorder recordFunc) error {
|
||||
// only use the most recent datapoint for now.
|
||||
pt := pts[len(pts)-1]
|
||||
val, ok := pt.Value.(*metricdata.Distribution)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("%w: %v", errBadPoint, pt.Value)
|
||||
return fmt.Errorf("%w: %v", errBadPoint, pt.Value)
|
||||
}
|
||||
bucketCounts := make([]uint64, len(val.Buckets))
|
||||
for i, bucket := range val.Buckets {
|
||||
if bucket.Count < 0 {
|
||||
return nil, fmt.Errorf("%w: bucket count may not be negative", errBadPoint)
|
||||
return fmt.Errorf("%w: bucket count may not be negative", errBadPoint)
|
||||
}
|
||||
bucketCounts[i] = uint64(bucket.Count)
|
||||
}
|
||||
if val.Count < 0 {
|
||||
return nil, fmt.Errorf("%w: count may not be negative", errBadPoint)
|
||||
return fmt.Errorf("%w: count may not be negative", errBadPoint)
|
||||
}
|
||||
return &ocDistAggregator{
|
||||
return recorder(&ocDistAggregator{
|
||||
sum: number.NewFloat64Number(val.Sum),
|
||||
count: uint64(val.Count),
|
||||
buckets: aggregation.Buckets{
|
||||
Boundaries: val.BucketOptions.Bounds,
|
||||
Counts: bucketCounts,
|
||||
},
|
||||
endTime: pts[len(pts)-1].Time,
|
||||
}, nil
|
||||
}, pts[len(pts)-1].Time)
|
||||
}
|
||||
|
||||
type ocDistAggregator struct {
|
||||
sum number.Number
|
||||
count uint64
|
||||
buckets aggregation.Buckets
|
||||
endTime time.Time
|
||||
}
|
||||
|
||||
// Kind returns the kind of aggregation this is.
|
||||
@@ -173,8 +155,3 @@ func (o *ocDistAggregator) Count() (uint64, error) {
|
||||
func (o *ocDistAggregator) Histogram() (aggregation.Buckets, error) {
|
||||
return o.buckets, nil
|
||||
}
|
||||
|
||||
// end returns the time the histogram was measured.
|
||||
func (o *ocDistAggregator) end() time.Time {
|
||||
return o.endTime
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ func TestNewAggregationFromPoints(t *testing.T) {
|
||||
Value: int64(23),
|
||||
},
|
||||
},
|
||||
expectedKind: aggregation.ExactKind,
|
||||
expectedKind: aggregation.LastValueKind,
|
||||
},
|
||||
{
|
||||
desc: "float point",
|
||||
@@ -54,7 +54,7 @@ func TestNewAggregationFromPoints(t *testing.T) {
|
||||
Value: float64(23),
|
||||
},
|
||||
},
|
||||
expectedKind: aggregation.ExactKind,
|
||||
expectedKind: aggregation.LastValueKind,
|
||||
},
|
||||
{
|
||||
desc: "distribution point",
|
||||
@@ -129,7 +129,7 @@ func TestNewAggregationFromPoints(t *testing.T) {
|
||||
expectedErr: errIncompatibleType,
|
||||
},
|
||||
{
|
||||
desc: "dist is incompatible with exact",
|
||||
desc: "dist is incompatible with raw points",
|
||||
input: []metricdata.Point{
|
||||
{
|
||||
Time: now,
|
||||
@@ -178,82 +178,57 @@ func TestNewAggregationFromPoints(t *testing.T) {
|
||||
},
|
||||
} {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
output, err := newAggregationFromPoints(tc.input)
|
||||
var output []aggregation.Aggregation
|
||||
err := recordAggregationsFromPoints(tc.input, func(agg aggregation.Aggregation, ts time.Time) error {
|
||||
last := tc.input[len(tc.input)-1]
|
||||
if ts != last.Time {
|
||||
t.Errorf("incorrect timestamp %v != %v", ts, last.Time)
|
||||
}
|
||||
output = append(output, agg)
|
||||
return nil
|
||||
})
|
||||
if !errors.Is(err, tc.expectedErr) {
|
||||
t.Errorf("newAggregationFromPoints(%v) = err(%v), want err(%v)", tc.input, err, tc.expectedErr)
|
||||
}
|
||||
if tc.expectedErr == nil && output.Kind() != tc.expectedKind {
|
||||
t.Errorf("newAggregationFromPoints(%v) = %v, want %v", tc.input, output.Kind(), tc.expectedKind)
|
||||
for _, out := range output {
|
||||
if tc.expectedErr == nil && out.Kind() != tc.expectedKind {
|
||||
t.Errorf("newAggregationFromPoints(%v) = %v, want %v", tc.input, out.Kind(), tc.expectedKind)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestPointsAggregation(t *testing.T) {
|
||||
now := time.Now()
|
||||
input := []metricdata.Point{
|
||||
{Value: int64(15)},
|
||||
{Value: int64(-23), Time: now},
|
||||
}
|
||||
output, err := newAggregationFromPoints(input)
|
||||
if err != nil {
|
||||
t.Fatalf("newAggregationFromPoints(%v) = err(%v), want <nil>", input, err)
|
||||
}
|
||||
if output.Kind() != aggregation.ExactKind {
|
||||
t.Errorf("newAggregationFromPoints(%v) = %v, want %v", input, output.Kind(), aggregation.ExactKind)
|
||||
}
|
||||
if output.end() != now {
|
||||
t.Errorf("newAggregationFromPoints(%v).end() = %v, want %v", input, output.end(), now)
|
||||
}
|
||||
pointsAgg, ok := output.(aggregation.Points)
|
||||
if !ok {
|
||||
t.Errorf("newAggregationFromPoints(%v) = %v does not implement the aggregation.Points interface", input, output)
|
||||
}
|
||||
points, err := pointsAgg.Points()
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected err: %v", err)
|
||||
}
|
||||
if len(points) != len(input) {
|
||||
t.Fatalf("newAggregationFromPoints(%v) resulted in %d points, want %d points", input, len(points), len(input))
|
||||
}
|
||||
for i := range points {
|
||||
inputPoint := input[i]
|
||||
outputPoint := points[i]
|
||||
if inputPoint.Value != outputPoint.AsInt64() {
|
||||
t.Errorf("newAggregationFromPoints(%v)[%d] = %v, want %v", input, i, outputPoint.AsInt64(), inputPoint.Value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLastValueAggregation(t *testing.T) {
|
||||
now := time.Now()
|
||||
input := []metricdata.Point{
|
||||
{Value: int64(15)},
|
||||
{Value: int64(15), Time: now.Add(-time.Minute)},
|
||||
{Value: int64(-23), Time: now},
|
||||
}
|
||||
output, err := newAggregationFromPoints(input)
|
||||
idx := 0
|
||||
err := recordAggregationsFromPoints(input, func(agg aggregation.Aggregation, end time.Time) error {
|
||||
if agg.Kind() != aggregation.LastValueKind {
|
||||
t.Errorf("recordAggregationsFromPoints(%v) = %v, want %v", input, agg.Kind(), aggregation.LastValueKind)
|
||||
}
|
||||
if end != input[idx].Time {
|
||||
t.Errorf("recordAggregationsFromPoints(%v).end() = %v, want %v", input, end, input[idx].Time)
|
||||
}
|
||||
pointsLV, ok := agg.(aggregation.LastValue)
|
||||
if !ok {
|
||||
t.Errorf("recordAggregationsFromPoints(%v) = %v does not implement the aggregation.LastValue interface", input, agg)
|
||||
}
|
||||
lv, ts, _ := pointsLV.LastValue()
|
||||
if lv.AsInt64() != input[idx].Value {
|
||||
t.Errorf("recordAggregationsFromPoints(%v) = %v, want %v", input, lv.AsInt64(), input[idx].Value)
|
||||
}
|
||||
if ts != input[idx].Time {
|
||||
t.Errorf("recordAggregationsFromPoints(%v) = %v, want %v", input, ts, input[idx].Time)
|
||||
}
|
||||
idx++
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("newAggregationFromPoints(%v) = err(%v), want <nil>", input, err)
|
||||
}
|
||||
if output.Kind() != aggregation.ExactKind {
|
||||
t.Errorf("newAggregationFromPoints(%v) = %v, want %v", input, output.Kind(), aggregation.ExactKind)
|
||||
}
|
||||
if output.end() != now {
|
||||
t.Errorf("newAggregationFromPoints(%v).end() = %v, want %v", input, output.end(), now)
|
||||
}
|
||||
lvAgg, ok := output.(aggregation.LastValue)
|
||||
if !ok {
|
||||
t.Errorf("newAggregationFromPoints(%v) = %v does not implement the aggregation.Points interface", input, output)
|
||||
}
|
||||
num, endTime, err := lvAgg.LastValue()
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected err: %v", err)
|
||||
}
|
||||
if endTime != now {
|
||||
t.Errorf("newAggregationFromPoints(%v).LastValue() = endTime: %v, want %v", input, endTime, now)
|
||||
}
|
||||
if num.AsInt64() != int64(-23) {
|
||||
t.Errorf("newAggregationFromPoints(%v).LastValue() = number: %v, want %v", input, num.AsInt64(), int64(-23))
|
||||
t.Errorf("recordAggregationsFromPoints(%v) = unexpected error %v", input, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,33 +263,39 @@ func TestHistogramAggregation(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
output, err := newAggregationFromPoints(input)
|
||||
var output aggregation.Aggregation
|
||||
var end time.Time
|
||||
err := recordAggregationsFromPoints(input, func(argAgg aggregation.Aggregation, argEnd time.Time) error {
|
||||
output = argAgg
|
||||
end = argEnd
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("newAggregationFromPoints(%v) = err(%v), want <nil>", input, err)
|
||||
t.Fatalf("recordAggregationsFromPoints(%v) = err(%v), want <nil>", input, err)
|
||||
}
|
||||
if output.Kind() != aggregation.HistogramKind {
|
||||
t.Errorf("newAggregationFromPoints(%v) = %v, want %v", input, output.Kind(), aggregation.HistogramKind)
|
||||
t.Errorf("recordAggregationsFromPoints(%v) = %v, want %v", input, output.Kind(), aggregation.HistogramKind)
|
||||
}
|
||||
if output.end() != now {
|
||||
t.Errorf("newAggregationFromPoints(%v).end() = %v, want %v", input, output.end(), now)
|
||||
if end != now {
|
||||
t.Errorf("recordAggregationsFromPoints(%v).end() = %v, want %v", input, end, now)
|
||||
}
|
||||
distAgg, ok := output.(aggregation.Histogram)
|
||||
if !ok {
|
||||
t.Errorf("newAggregationFromPoints(%v) = %v does not implement the aggregation.Points interface", input, output)
|
||||
t.Errorf("recordAggregationsFromPoints(%v) = %v does not implement the aggregation.Points interface", input, output)
|
||||
}
|
||||
sum, err := distAgg.Sum()
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected err: %v", err)
|
||||
}
|
||||
if sum.AsFloat64() != float64(55) {
|
||||
t.Errorf("newAggregationFromPoints(%v).Sum() = %v, want %v", input, sum.AsFloat64(), float64(55))
|
||||
t.Errorf("recordAggregationsFromPoints(%v).Sum() = %v, want %v", input, sum.AsFloat64(), float64(55))
|
||||
}
|
||||
count, err := distAgg.Count()
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected err: %v", err)
|
||||
}
|
||||
if count != 2 {
|
||||
t.Errorf("newAggregationFromPoints(%v).Count() = %v, want %v", input, count, 2)
|
||||
t.Errorf("recordAggregationsFromPoints(%v).Count() = %v, want %v", input, count, 2)
|
||||
}
|
||||
hist, err := distAgg.Histogram()
|
||||
if err != nil {
|
||||
@@ -322,20 +303,20 @@ func TestHistogramAggregation(t *testing.T) {
|
||||
}
|
||||
inputBucketBoundaries := []float64{20, 30}
|
||||
if len(hist.Boundaries) != len(inputBucketBoundaries) {
|
||||
t.Fatalf("newAggregationFromPoints(%v).Histogram() produced %d boundaries, want %d boundaries", input, len(hist.Boundaries), len(inputBucketBoundaries))
|
||||
t.Fatalf("recordAggregationsFromPoints(%v).Histogram() produced %d boundaries, want %d boundaries", input, len(hist.Boundaries), len(inputBucketBoundaries))
|
||||
}
|
||||
for i, b := range hist.Boundaries {
|
||||
if b != inputBucketBoundaries[i] {
|
||||
t.Errorf("newAggregationFromPoints(%v).Histogram().Boundaries[%d] = %v, want %v", input, i, b, inputBucketBoundaries[i])
|
||||
t.Errorf("recordAggregationsFromPoints(%v).Histogram().Boundaries[%d] = %v, want %v", input, i, b, inputBucketBoundaries[i])
|
||||
}
|
||||
}
|
||||
inputBucketCounts := []uint64{1, 1}
|
||||
if len(hist.Counts) != len(inputBucketCounts) {
|
||||
t.Fatalf("newAggregationFromPoints(%v).Histogram() produced %d buckets, want %d buckets", input, len(hist.Counts), len(inputBucketCounts))
|
||||
t.Fatalf("recordAggregationsFromPoints(%v).Histogram() produced %d buckets, want %d buckets", input, len(hist.Counts), len(inputBucketCounts))
|
||||
}
|
||||
for i, c := range hist.Counts {
|
||||
if c != inputBucketCounts[i] {
|
||||
t.Errorf("newAggregationFromPoints(%v).Histogram().Counts[%d] = %d, want %d", input, i, c, inputBucketCounts[i])
|
||||
t.Errorf("recordAggregationsFromPoints(%v).Histogram().Counts[%d] = %d, want %d", input, i, c, inputBucketCounts[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -19,6 +19,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"go.opencensus.io/metric/metricdata"
|
||||
"go.opencensus.io/metric/metricexport"
|
||||
@@ -95,18 +96,18 @@ func (d *metricReader) ForEach(_ aggregation.TemporalitySelector, f func(export.
|
||||
otel.Handle(err)
|
||||
continue
|
||||
}
|
||||
agg, err := newAggregationFromPoints(ts.Points)
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
continue
|
||||
}
|
||||
if err := f(export.NewRecord(
|
||||
&descriptor,
|
||||
&ls,
|
||||
agg,
|
||||
ts.StartTime,
|
||||
agg.end(),
|
||||
)); err != nil && !errors.Is(err, aggregation.ErrNoData) {
|
||||
err = recordAggregationsFromPoints(
|
||||
ts.Points,
|
||||
func(agg aggregation.Aggregation, end time.Time) error {
|
||||
return f(export.NewRecord(
|
||||
&descriptor,
|
||||
&ls,
|
||||
agg,
|
||||
ts.StartTime,
|
||||
end,
|
||||
))
|
||||
})
|
||||
if err != nil && !errors.Is(err, aggregation.ErrNoData) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@@ -21,11 +21,10 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
|
||||
"go.opencensus.io/metric/metricdata"
|
||||
ocresource "go.opencensus.io/resource"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/metrictest"
|
||||
@@ -142,7 +141,7 @@ func TestExportMetrics(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedHandledError: errIncompatibleType,
|
||||
exportErr: errIncompatibleType,
|
||||
},
|
||||
{
|
||||
desc: "success",
|
||||
@@ -172,13 +171,9 @@ func TestExportMetrics(t *testing.T) {
|
||||
export.NewRecord(
|
||||
&basicDesc,
|
||||
attribute.EmptySet(),
|
||||
&ocExactAggregator{
|
||||
points: []aggregation.Point{
|
||||
{
|
||||
Number: number.NewInt64Number(123),
|
||||
Time: now,
|
||||
},
|
||||
},
|
||||
&ocRawAggregator{
|
||||
value: number.NewInt64Number(123),
|
||||
time: now,
|
||||
},
|
||||
now,
|
||||
now,
|
||||
@@ -203,13 +198,9 @@ func TestExportMetrics(t *testing.T) {
|
||||
export.NewRecord(
|
||||
&basicDesc,
|
||||
attribute.EmptySet(),
|
||||
&ocExactAggregator{
|
||||
points: []aggregation.Point{
|
||||
{
|
||||
Number: number.NewInt64Number(123),
|
||||
Time: now,
|
||||
},
|
||||
},
|
||||
&ocRawAggregator{
|
||||
value: number.NewInt64Number(123),
|
||||
time: now,
|
||||
},
|
||||
now,
|
||||
now,
|
||||
@@ -237,13 +228,9 @@ func TestExportMetrics(t *testing.T) {
|
||||
export.NewRecord(
|
||||
&basicDesc,
|
||||
attribute.EmptySet(),
|
||||
&ocExactAggregator{
|
||||
points: []aggregation.Point{
|
||||
{
|
||||
Number: number.NewInt64Number(123),
|
||||
Time: now,
|
||||
},
|
||||
},
|
||||
&ocRawAggregator{
|
||||
value: number.NewInt64Number(123),
|
||||
time: now,
|
||||
},
|
||||
now,
|
||||
now,
|
||||
|
@@ -4,12 +4,12 @@ go 1.15
|
||||
|
||||
require (
|
||||
go.opencensus.io v0.22.6-0.20201102222123-380f4078db9f
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/metric v0.24.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel/sdk/export/metric v0.24.0
|
||||
go.opentelemetry.io/otel/sdk/metric v0.24.0
|
||||
go.opentelemetry.io/otel/trace v1.1.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/metric v0.25.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/otel/sdk/export/metric v0.25.0
|
||||
go.opentelemetry.io/otel/sdk/metric v0.25.0
|
||||
go.opentelemetry.io/otel/trace v1.2.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel => ../..
|
||||
|
@@ -4,10 +4,10 @@ go 1.15
|
||||
|
||||
require (
|
||||
go.opencensus.io v0.23.0
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/bridge/opencensus v0.24.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel/trace v1.1.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/bridge/opencensus v0.25.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/otel/trace v1.2.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel => ../../..
|
||||
|
@@ -6,8 +6,8 @@ replace go.opentelemetry.io/otel => ../..
|
||||
|
||||
require (
|
||||
github.com/opentracing/opentracing-go v1.2.0
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/trace v1.1.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/trace v1.2.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel/bridge/opencensus => ../opencensus
|
||||
|
@@ -22,11 +22,10 @@ import (
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/bridge/opentracing/migration"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
"go.opentelemetry.io/otel/bridge/opentracing/migration"
|
||||
)
|
||||
|
||||
//nolint:revive // ignoring missing comments for unexported global variables in an internal package.
|
||||
|
@@ -24,9 +24,8 @@ import (
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/baggage"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
"go.opentelemetry.io/otel/bridge/opentracing/internal"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
type mixedAPIsTestCase struct {
|
||||
|
@@ -17,9 +17,8 @@ package opentracing // import "go.opentelemetry.io/otel/bridge/opentracing"
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
"go.opentelemetry.io/otel/bridge/opentracing/migration"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
type WrapperTracerProvider struct {
|
||||
|
@@ -3,10 +3,10 @@ module go.opentelemetry.io/otel/example/fib
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.1.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel/trace v1.1.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.2.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/otel/trace v1.2.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel => ../..
|
||||
|
@@ -9,9 +9,9 @@ replace (
|
||||
)
|
||||
|
||||
require (
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.1.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.2.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel/bridge/opencensus => ../../bridge/opencensus
|
||||
|
@@ -22,7 +22,6 @@ import (
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/exporters/jaeger"
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
|
@@ -8,10 +8,10 @@ replace (
|
||||
)
|
||||
|
||||
require (
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.1.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel/trace v1.1.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.2.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/otel/trace v1.2.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel/bridge/opencensus => ../../bridge/opencensus
|
||||
|
@@ -10,12 +10,12 @@ replace (
|
||||
|
||||
require (
|
||||
go.opencensus.io v0.22.6-0.20201102222123-380f4078db9f
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/bridge/opencensus v0.24.0
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.24.0
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.1.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel/sdk/export/metric v0.24.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/bridge/opencensus v0.25.0
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.25.0
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.2.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/otel/sdk/export/metric v0.25.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel/bridge/opentracing => ../../bridge/opentracing
|
||||
|
@@ -20,9 +20,8 @@ import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"go.opencensus.io/metric/metricdata"
|
||||
|
||||
"go.opencensus.io/metric"
|
||||
"go.opencensus.io/metric/metricdata"
|
||||
"go.opencensus.io/metric/metricexport"
|
||||
"go.opencensus.io/metric/metricproducer"
|
||||
"go.opencensus.io/stats"
|
||||
|
@@ -8,10 +8,10 @@ replace (
|
||||
)
|
||||
|
||||
require (
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.1.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel/trace v1.1.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.2.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/otel/trace v1.2.0
|
||||
google.golang.org/grpc v1.42.0
|
||||
)
|
||||
|
||||
|
@@ -2,8 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/cenkalti/backoff/v4 v4.1.1 h1:G2HAfAmvm/GcKan2oOQpBXOd2tT2G57ZnZGWa1PxPBQ=
|
||||
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||
github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo=
|
||||
github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
@@ -61,8 +61,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
go.opentelemetry.io/proto/otlp v0.10.0 h1:n7brgtEbDvXEgGyKKo8SobKT1e9FewlDtXzkVP5djoE=
|
||||
go.opentelemetry.io/proto/otlp v0.10.0/go.mod h1:zG20xCK0szZ1xdokeSOwEcmlXu+x9kkdRe6N1DhKcfU=
|
||||
go.opentelemetry.io/proto/otlp v0.11.0 h1:cLDgIBTf4lLOlztkhzAEdQsJ4Lj+i5Wc9k6Nn0K1VyU=
|
||||
go.opentelemetry.io/proto/otlp v0.11.0/go.mod h1:QpEjXPrNQzrFDZgoTo49dgHR9RYRSrg3NAKnUGl9YpQ=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
@@ -111,7 +111,6 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
|
||||
google.golang.org/grpc v1.42.0 h1:XT2/MFpuPFsEX2fWh3YQtHkZ+WYZFQRfaUgLZYj/p6A=
|
||||
google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
|
@@ -3,10 +3,10 @@ module go.opentelemetry.io/otel/example/passthrough
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.1.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel/trace v1.1.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.2.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/otel/trace v1.2.0
|
||||
)
|
||||
|
||||
replace (
|
||||
|
@@ -9,11 +9,11 @@ replace (
|
||||
)
|
||||
|
||||
require (
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.24.0
|
||||
go.opentelemetry.io/otel/metric v0.24.0
|
||||
go.opentelemetry.io/otel/sdk/export/metric v0.24.0
|
||||
go.opentelemetry.io/otel/sdk/metric v0.24.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.25.0
|
||||
go.opentelemetry.io/otel/metric v0.25.0
|
||||
go.opentelemetry.io/otel/sdk/export/metric v0.25.0
|
||||
go.opentelemetry.io/otel/sdk/metric v0.25.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel/bridge/opencensus => ../../bridge/opencensus
|
||||
|
@@ -9,10 +9,10 @@ replace (
|
||||
)
|
||||
|
||||
require (
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/exporters/zipkin v1.1.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel/trace v1.1.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/exporters/zipkin v1.2.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/otel/trace v1.2.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel/bridge/opencensus => ../../bridge/opencensus
|
||||
|
@@ -23,10 +23,9 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/jaeger/internal/third_party/thrift/lib/go/thrift"
|
||||
|
||||
genAgent "go.opentelemetry.io/otel/exporters/jaeger/internal/gen-go/agent"
|
||||
gen "go.opentelemetry.io/otel/exporters/jaeger/internal/gen-go/jaeger"
|
||||
"go.opentelemetry.io/otel/exporters/jaeger/internal/third_party/thrift/lib/go/thrift"
|
||||
)
|
||||
|
||||
// udpPacketMaxLength is the max size of UDP packet we want to send, synced with jaeger-agent
|
||||
|
@@ -5,9 +5,9 @@ go 1.15
|
||||
require (
|
||||
github.com/google/go-cmp v0.5.6
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel/trace v1.1.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/otel/trace v1.2.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel/bridge/opencensus => ../../bridge/opencensus
|
||||
|
@@ -24,9 +24,8 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/jaeger/internal/third_party/thrift/lib/go/thrift"
|
||||
|
||||
gen "go.opentelemetry.io/otel/exporters/jaeger/internal/gen-go/jaeger"
|
||||
"go.opentelemetry.io/otel/exporters/jaeger/internal/third_party/thrift/lib/go/thrift"
|
||||
)
|
||||
|
||||
// batchUploader send a batch of spans to Jaeger
|
||||
|
@@ -3,15 +3,15 @@ module go.opentelemetry.io/otel/exporters/otlp/otlpmetric
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/cenkalti/backoff/v4 v4.1.1
|
||||
github.com/cenkalti/backoff/v4 v4.1.2
|
||||
github.com/google/go-cmp v0.5.6
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/metric v0.24.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel/sdk/export/metric v0.24.0
|
||||
go.opentelemetry.io/otel/sdk/metric v0.24.0
|
||||
go.opentelemetry.io/proto/otlp v0.10.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/metric v0.25.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/otel/sdk/export/metric v0.25.0
|
||||
go.opentelemetry.io/otel/sdk/metric v0.25.0
|
||||
go.opentelemetry.io/proto/otlp v0.11.0
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013
|
||||
google.golang.org/grpc v1.42.0
|
||||
google.golang.org/protobuf v1.27.1
|
||||
|
@@ -4,8 +4,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/benbjohnson/clock v1.2.0 h1:9Re3G2TWxkE06LdMWMpcY6KV81GLXMGiYpPYUPkFAws=
|
||||
github.com/benbjohnson/clock v1.2.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
github.com/cenkalti/backoff/v4 v4.1.1 h1:G2HAfAmvm/GcKan2oOQpBXOd2tT2G57ZnZGWa1PxPBQ=
|
||||
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||
github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo=
|
||||
github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
@@ -62,8 +62,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
go.opentelemetry.io/proto/otlp v0.10.0 h1:n7brgtEbDvXEgGyKKo8SobKT1e9FewlDtXzkVP5djoE=
|
||||
go.opentelemetry.io/proto/otlp v0.10.0/go.mod h1:zG20xCK0szZ1xdokeSOwEcmlXu+x9kkdRe6N1DhKcfU=
|
||||
go.opentelemetry.io/proto/otlp v0.11.0 h1:cLDgIBTf4lLOlztkhzAEdQsJ4Lj+i5Wc9k6Nn0K1VyU=
|
||||
go.opentelemetry.io/proto/otlp v0.11.0/go.mod h1:QpEjXPrNQzrFDZgoTo49dgHR9RYRSrg3NAKnUGl9YpQ=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
@@ -112,7 +112,6 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
|
||||
google.golang.org/grpc v1.42.0 h1:XT2/MFpuPFsEX2fWh3YQtHkZ+WYZFQRfaUgLZYj/p6A=
|
||||
google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
|
@@ -23,17 +23,15 @@ import (
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otlpconfig"
|
||||
|
||||
"github.com/cenkalti/backoff/v4"
|
||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/encoding/gzip"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"google.golang.org/grpc/encoding/gzip"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otlpconfig"
|
||||
)
|
||||
|
||||
type Connection struct {
|
||||
|
@@ -19,7 +19,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
@@ -16,9 +16,8 @@ package metrictransform // import "go.opentelemetry.io/otel/exporters/otlp/otlpm
|
||||
|
||||
import (
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
|
||||
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
|
||||
)
|
||||
|
||||
// KeyValues transforms a slice of attribute KeyValues into OTLP key-values.
|
||||
|
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package transform provides translations for opentelemetry-go concepts and
|
||||
// Package metrictransform provides translations for opentelemetry-go concepts and
|
||||
// structures to otlp structures.
|
||||
package metrictransform // import "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/metrictransform"
|
||||
|
||||
@@ -24,14 +24,13 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
|
||||
metricpb "go.opentelemetry.io/proto/otlp/metrics/v1"
|
||||
|
||||
"go.opentelemetry.io/otel/metric/number"
|
||||
export "go.opentelemetry.io/otel/sdk/export/metric"
|
||||
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
|
||||
"go.opentelemetry.io/otel/sdk/instrumentation"
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
|
||||
metricpb "go.opentelemetry.io/proto/otlp/metrics/v1"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -276,70 +275,11 @@ func Record(temporalitySelector aggregation.TemporalitySelector, r export.Record
|
||||
}
|
||||
return gaugePoint(r, value, time.Time{}, tm)
|
||||
|
||||
case aggregation.ExactKind:
|
||||
e, ok := agg.(aggregation.Points)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("%w: %T", ErrIncompatibleAgg, agg)
|
||||
}
|
||||
pts, err := e.Points()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return gaugeArray(r, pts)
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("%w: %T", ErrUnimplementedAgg, agg)
|
||||
}
|
||||
}
|
||||
|
||||
func gaugeArray(record export.Record, points []aggregation.Point) (*metricpb.Metric, error) {
|
||||
desc := record.Descriptor()
|
||||
labels := record.Labels()
|
||||
m := &metricpb.Metric{
|
||||
Name: desc.Name(),
|
||||
Description: desc.Description(),
|
||||
Unit: string(desc.Unit()),
|
||||
}
|
||||
|
||||
pbAttrs := Iterator(labels.Iter())
|
||||
|
||||
ndp := make([]*metricpb.NumberDataPoint, 0, len(points))
|
||||
switch nk := desc.NumberKind(); nk {
|
||||
case number.Int64Kind:
|
||||
for _, p := range points {
|
||||
ndp = append(ndp, &metricpb.NumberDataPoint{
|
||||
Attributes: pbAttrs,
|
||||
StartTimeUnixNano: toNanos(record.StartTime()),
|
||||
TimeUnixNano: toNanos(record.EndTime()),
|
||||
Value: &metricpb.NumberDataPoint_AsInt{
|
||||
AsInt: p.Number.CoerceToInt64(nk),
|
||||
},
|
||||
})
|
||||
}
|
||||
case number.Float64Kind:
|
||||
for _, p := range points {
|
||||
ndp = append(ndp, &metricpb.NumberDataPoint{
|
||||
Attributes: pbAttrs,
|
||||
StartTimeUnixNano: toNanos(record.StartTime()),
|
||||
TimeUnixNano: toNanos(record.EndTime()),
|
||||
Value: &metricpb.NumberDataPoint_AsDouble{
|
||||
AsDouble: p.Number.CoerceToFloat64(nk),
|
||||
},
|
||||
})
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("%w: %v", ErrUnknownValueType, nk)
|
||||
}
|
||||
|
||||
m.Data = &metricpb.Metric_Gauge{
|
||||
Gauge: &metricpb.Gauge{
|
||||
DataPoints: ndp,
|
||||
},
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func gaugePoint(record export.Record, num number.Number, start, end time.Time) (*metricpb.Metric, error) {
|
||||
desc := record.Descriptor()
|
||||
labels := record.Labels()
|
||||
|
@@ -30,12 +30,9 @@ import (
|
||||
"go.opentelemetry.io/otel/metric/sdkapi"
|
||||
export "go.opentelemetry.io/otel/sdk/export/metric"
|
||||
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
|
||||
arrAgg "go.opentelemetry.io/otel/sdk/metric/aggregator/exact"
|
||||
"go.opentelemetry.io/otel/sdk/metric/aggregator/lastvalue"
|
||||
lvAgg "go.opentelemetry.io/otel/sdk/metric/aggregator/lastvalue"
|
||||
"go.opentelemetry.io/otel/sdk/metric/aggregator/minmaxsumcount"
|
||||
"go.opentelemetry.io/otel/sdk/metric/aggregator/sum"
|
||||
sumAgg "go.opentelemetry.io/otel/sdk/metric/aggregator/sum"
|
||||
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
|
||||
metricpb "go.opentelemetry.io/proto/otlp/metrics/v1"
|
||||
)
|
||||
@@ -180,7 +177,7 @@ func TestMinMaxSumCountPropagatesErrors(t *testing.T) {
|
||||
func TestSumIntDataPoints(t *testing.T) {
|
||||
desc := metrictest.NewDescriptor("", sdkapi.HistogramInstrumentKind, number.Int64Kind)
|
||||
labels := attribute.NewSet(attribute.String("one", "1"))
|
||||
sums := sumAgg.New(2)
|
||||
sums := sum.New(2)
|
||||
s, ckpt := &sums[0], &sums[1]
|
||||
|
||||
assert.NoError(t, s.Update(context.Background(), number.Number(1), &desc))
|
||||
@@ -220,7 +217,7 @@ func TestSumIntDataPoints(t *testing.T) {
|
||||
func TestSumFloatDataPoints(t *testing.T) {
|
||||
desc := metrictest.NewDescriptor("", sdkapi.HistogramInstrumentKind, number.Float64Kind)
|
||||
labels := attribute.NewSet(attribute.String("one", "1"))
|
||||
sums := sumAgg.New(2)
|
||||
sums := sum.New(2)
|
||||
s, ckpt := &sums[0], &sums[1]
|
||||
|
||||
assert.NoError(t, s.Update(context.Background(), number.NewFloat64Number(1), &desc))
|
||||
@@ -258,7 +255,7 @@ func TestSumFloatDataPoints(t *testing.T) {
|
||||
func TestLastValueIntDataPoints(t *testing.T) {
|
||||
desc := metrictest.NewDescriptor("", sdkapi.HistogramInstrumentKind, number.Int64Kind)
|
||||
labels := attribute.NewSet(attribute.String("one", "1"))
|
||||
lvs := lvAgg.New(2)
|
||||
lvs := lastvalue.New(2)
|
||||
lv, ckpt := &lvs[0], &lvs[1]
|
||||
|
||||
assert.NoError(t, lv.Update(context.Background(), number.Number(100), &desc))
|
||||
@@ -290,79 +287,10 @@ func TestLastValueIntDataPoints(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestExactIntDataPoints(t *testing.T) {
|
||||
desc := metrictest.NewDescriptor("", sdkapi.HistogramInstrumentKind, number.Int64Kind)
|
||||
labels := attribute.NewSet(attribute.String("one", "1"))
|
||||
arrs := arrAgg.New(2)
|
||||
e, ckpt := &arrs[0], &arrs[1]
|
||||
|
||||
assert.NoError(t, e.Update(context.Background(), number.Number(100), &desc))
|
||||
require.NoError(t, e.SynchronizedMove(ckpt, &desc))
|
||||
record := export.NewRecord(&desc, &labels, ckpt.Aggregation(), intervalStart, intervalEnd)
|
||||
pts, err := ckpt.Points()
|
||||
require.NoError(t, err)
|
||||
|
||||
if m, err := gaugeArray(record, pts); assert.NoError(t, err) {
|
||||
assert.Equal(t, []*metricpb.NumberDataPoint{{
|
||||
StartTimeUnixNano: toNanos(intervalStart),
|
||||
TimeUnixNano: toNanos(intervalEnd),
|
||||
Attributes: []*commonpb.KeyValue{
|
||||
{
|
||||
Key: "one",
|
||||
Value: &commonpb.AnyValue{Value: &commonpb.AnyValue_StringValue{StringValue: "1"}},
|
||||
},
|
||||
},
|
||||
Value: &metricpb.NumberDataPoint_AsInt{
|
||||
AsInt: 100,
|
||||
},
|
||||
}}, m.GetGauge().DataPoints)
|
||||
assert.Nil(t, m.GetSum())
|
||||
assert.Nil(t, m.GetHistogram())
|
||||
assert.Nil(t, m.GetSummary())
|
||||
assert.Nil(t, m.GetIntGauge()) // nolint
|
||||
assert.Nil(t, m.GetIntSum()) // nolint
|
||||
assert.Nil(t, m.GetIntHistogram()) // nolint
|
||||
}
|
||||
}
|
||||
|
||||
func TestExactFloatDataPoints(t *testing.T) {
|
||||
desc := metrictest.NewDescriptor("", sdkapi.HistogramInstrumentKind, number.Float64Kind)
|
||||
labels := attribute.NewSet(attribute.String("one", "1"))
|
||||
arrs := arrAgg.New(2)
|
||||
e, ckpt := &arrs[0], &arrs[1]
|
||||
assert.NoError(t, e.Update(context.Background(), number.NewFloat64Number(100), &desc))
|
||||
require.NoError(t, e.SynchronizedMove(ckpt, &desc))
|
||||
record := export.NewRecord(&desc, &labels, ckpt.Aggregation(), intervalStart, intervalEnd)
|
||||
pts, err := ckpt.Points()
|
||||
require.NoError(t, err)
|
||||
|
||||
if m, err := gaugeArray(record, pts); assert.NoError(t, err) {
|
||||
assert.Equal(t, []*metricpb.NumberDataPoint{{
|
||||
Value: &metricpb.NumberDataPoint_AsDouble{
|
||||
AsDouble: 100,
|
||||
},
|
||||
StartTimeUnixNano: toNanos(intervalStart),
|
||||
TimeUnixNano: toNanos(intervalEnd),
|
||||
Attributes: []*commonpb.KeyValue{
|
||||
{
|
||||
Key: "one",
|
||||
Value: &commonpb.AnyValue{Value: &commonpb.AnyValue_StringValue{StringValue: "1"}},
|
||||
},
|
||||
},
|
||||
}}, m.GetGauge().DataPoints)
|
||||
assert.Nil(t, m.GetSum())
|
||||
assert.Nil(t, m.GetHistogram())
|
||||
assert.Nil(t, m.GetSummary())
|
||||
assert.Nil(t, m.GetIntGauge()) // nolint
|
||||
assert.Nil(t, m.GetIntSum()) // nolint
|
||||
assert.Nil(t, m.GetIntHistogram()) // nolint
|
||||
}
|
||||
}
|
||||
|
||||
func TestSumErrUnknownValueType(t *testing.T) {
|
||||
desc := metrictest.NewDescriptor("", sdkapi.HistogramInstrumentKind, number.Kind(-1))
|
||||
labels := attribute.NewSet()
|
||||
s := &sumAgg.New(1)[0]
|
||||
s := &sum.New(1)[0]
|
||||
record := export.NewRecord(&desc, &labels, s, intervalStart, intervalEnd)
|
||||
value, err := s.Sum()
|
||||
require.NoError(t, err)
|
||||
@@ -471,12 +399,6 @@ func TestRecordAggregatorIncompatibleErrors(t *testing.T) {
|
||||
require.Error(t, err)
|
||||
require.Nil(t, mpb)
|
||||
require.True(t, errors.Is(err, ErrIncompatibleAgg))
|
||||
|
||||
mpb, err = makeMpb(aggregation.ExactKind, &lastvalue.New(1)[0])
|
||||
|
||||
require.Error(t, err)
|
||||
require.Nil(t, mpb)
|
||||
require.True(t, errors.Is(err, ErrIncompatibleAgg))
|
||||
}
|
||||
|
||||
func TestRecordAggregatorUnexpectedErrors(t *testing.T) {
|
||||
|
@@ -15,9 +15,8 @@
|
||||
package metrictransform // import "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/metrictransform"
|
||||
|
||||
import (
|
||||
resourcepb "go.opentelemetry.io/proto/otlp/resource/v1"
|
||||
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
resourcepb "go.opentelemetry.io/proto/otlp/resource/v1"
|
||||
)
|
||||
|
||||
// Resource transforms a Resource into an OTLP Resource.
|
||||
|
@@ -19,9 +19,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otlpconfig"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otlpconfig"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@@ -20,13 +20,11 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
|
||||
metricpb "go.opentelemetry.io/proto/otlp/metrics/v1"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/number"
|
||||
"go.opentelemetry.io/otel/metric/sdkapi"
|
||||
@@ -34,6 +32,7 @@ import (
|
||||
controller "go.opentelemetry.io/otel/sdk/metric/controller/basic"
|
||||
processor "go.opentelemetry.io/otel/sdk/metric/processor/basic"
|
||||
"go.opentelemetry.io/otel/sdk/metric/selector/simple"
|
||||
metricpb "go.opentelemetry.io/proto/otlp/metrics/v1"
|
||||
)
|
||||
|
||||
// RunEndToEndTest can be used by protocol driver tests to validate
|
||||
|
@@ -25,7 +25,6 @@ import (
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/connection"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otlpconfig"
|
||||
|
||||
colmetricpb "go.opentelemetry.io/proto/otlp/collector/metrics/v1"
|
||||
metricpb "go.opentelemetry.io/proto/otlp/metrics/v1"
|
||||
)
|
||||
|
@@ -22,21 +22,19 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/encoding/gzip"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/types/known/durationpb"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otlpmetrictest"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc"
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
|
||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/types/known/durationpb"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/encoding/gzip"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -168,6 +166,8 @@ func TestNewExporter_invokeStartThenStopManyTimes(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNewExporter_collectorConnectionDiesThenReconnectsWhenInRestMode(t *testing.T) {
|
||||
// TODO: Fix this test #1527
|
||||
t.Skip("This test is flaky and needs to be rewritten")
|
||||
mc := runMockCollector(t)
|
||||
|
||||
reconnectionPeriod := 20 * time.Millisecond
|
||||
@@ -491,6 +491,8 @@ func newThrottlingError(code codes.Code, duration time.Duration) error {
|
||||
}
|
||||
|
||||
func TestNewExporter_collectorConnectionDiesThenReconnects(t *testing.T) {
|
||||
// TODO: Fix this test #1527
|
||||
t.Skip("This test is flaky and needs to be rewritten")
|
||||
mc := runMockCollector(t)
|
||||
|
||||
reconnectionPeriod := 50 * time.Millisecond
|
||||
|
@@ -19,17 +19,16 @@ import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc"
|
||||
"go.opentelemetry.io/otel/sdk/metric/selector/simple"
|
||||
|
||||
"google.golang.org/grpc/credentials"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/global"
|
||||
controller "go.opentelemetry.io/otel/sdk/metric/controller/basic"
|
||||
processor "go.opentelemetry.io/otel/sdk/metric/processor/basic"
|
||||
"go.opentelemetry.io/otel/sdk/metric/selector/simple"
|
||||
)
|
||||
|
||||
func Example_insecure() {
|
||||
@@ -49,7 +48,7 @@ func Example_insecure() {
|
||||
|
||||
pusher := controller.New(
|
||||
processor.NewFactory(
|
||||
simple.NewWithExactDistribution(),
|
||||
simple.NewWithHistogramDistribution(),
|
||||
exp,
|
||||
),
|
||||
controller.WithExporter(exp),
|
||||
@@ -108,7 +107,7 @@ func Example_withTLS() {
|
||||
|
||||
pusher := controller.New(
|
||||
processor.NewFactory(
|
||||
simple.NewWithExactDistribution(),
|
||||
simple.NewWithHistogramDistribution(),
|
||||
exp,
|
||||
),
|
||||
controller.WithExporter(exp),
|
||||
@@ -165,7 +164,7 @@ func Example_withDifferentSignalCollectors() {
|
||||
|
||||
pusher := controller.New(
|
||||
processor.NewFactory(
|
||||
simple.NewWithExactDistribution(),
|
||||
simple.NewWithHistogramDistribution(),
|
||||
exp,
|
||||
),
|
||||
controller.WithExporter(exp),
|
||||
|
@@ -4,12 +4,12 @@ go 1.15
|
||||
|
||||
require (
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.24.0
|
||||
go.opentelemetry.io/otel/metric v0.24.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel/sdk/metric v0.24.0
|
||||
go.opentelemetry.io/proto/otlp v0.10.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.25.0
|
||||
go.opentelemetry.io/otel/metric v0.25.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/otel/sdk/metric v0.25.0
|
||||
go.opentelemetry.io/proto/otlp v0.11.0
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013
|
||||
google.golang.org/grpc v1.42.0
|
||||
google.golang.org/protobuf v1.27.1
|
||||
|
@@ -4,8 +4,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/benbjohnson/clock v1.2.0 h1:9Re3G2TWxkE06LdMWMpcY6KV81GLXMGiYpPYUPkFAws=
|
||||
github.com/benbjohnson/clock v1.2.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
github.com/cenkalti/backoff/v4 v4.1.1 h1:G2HAfAmvm/GcKan2oOQpBXOd2tT2G57ZnZGWa1PxPBQ=
|
||||
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||
github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo=
|
||||
github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
@@ -62,8 +62,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
go.opentelemetry.io/proto/otlp v0.10.0 h1:n7brgtEbDvXEgGyKKo8SobKT1e9FewlDtXzkVP5djoE=
|
||||
go.opentelemetry.io/proto/otlp v0.10.0/go.mod h1:zG20xCK0szZ1xdokeSOwEcmlXu+x9kkdRe6N1DhKcfU=
|
||||
go.opentelemetry.io/proto/otlp v0.11.0 h1:cLDgIBTf4lLOlztkhzAEdQsJ4Lj+i5Wc9k6Nn0K1VyU=
|
||||
go.opentelemetry.io/proto/otlp v0.11.0/go.mod h1:QpEjXPrNQzrFDZgoTo49dgHR9RYRSrg3NAKnUGl9YpQ=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
@@ -112,7 +112,6 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
|
||||
google.golang.org/grpc v1.42.0 h1:XT2/MFpuPFsEX2fWh3YQtHkZ+WYZFQRfaUgLZYj/p6A=
|
||||
google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
|
@@ -24,12 +24,10 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otlpmetrictest"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
collectormetricpb "go.opentelemetry.io/proto/otlp/collector/metrics/v1"
|
||||
metricpb "go.opentelemetry.io/proto/otlp/metrics/v1"
|
||||
)
|
||||
|
@@ -18,12 +18,11 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otlpconfig"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otlpconfig"
|
||||
)
|
||||
|
||||
// Option applies an option to the gRPC client.
|
||||
|
@@ -28,15 +28,13 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
|
||||
metricpb "go.opentelemetry.io/proto/otlp/metrics/v1"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otlpconfig"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otlpconfig"
|
||||
colmetricpb "go.opentelemetry.io/proto/otlp/collector/metrics/v1"
|
||||
metricpb "go.opentelemetry.io/proto/otlp/metrics/v1"
|
||||
)
|
||||
|
||||
const contentTypeProto = "application/x-protobuf"
|
||||
|
@@ -22,14 +22,13 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp"
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otlpmetrictest"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp"
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@@ -4,10 +4,10 @@ go 1.15
|
||||
|
||||
require (
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.24.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/proto/otlp v0.10.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.25.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/proto/otlp v0.11.0
|
||||
google.golang.org/protobuf v1.27.1
|
||||
)
|
||||
|
||||
|
@@ -4,7 +4,7 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/benbjohnson/clock v1.2.0 h1:9Re3G2TWxkE06LdMWMpcY6KV81GLXMGiYpPYUPkFAws=
|
||||
github.com/benbjohnson/clock v1.2.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||
github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
@@ -61,8 +61,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
go.opentelemetry.io/proto/otlp v0.10.0 h1:n7brgtEbDvXEgGyKKo8SobKT1e9FewlDtXzkVP5djoE=
|
||||
go.opentelemetry.io/proto/otlp v0.10.0/go.mod h1:zG20xCK0szZ1xdokeSOwEcmlXu+x9kkdRe6N1DhKcfU=
|
||||
go.opentelemetry.io/proto/otlp v0.11.0 h1:cLDgIBTf4lLOlztkhzAEdQsJ4Lj+i5Wc9k6Nn0K1VyU=
|
||||
go.opentelemetry.io/proto/otlp v0.11.0/go.mod h1:QpEjXPrNQzrFDZgoTo49dgHR9RYRSrg3NAKnUGl9YpQ=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
@@ -111,7 +111,6 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
|
||||
google.golang.org/grpc v1.42.0 h1:XT2/MFpuPFsEX2fWh3YQtHkZ+WYZFQRfaUgLZYj/p6A=
|
||||
google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
|
@@ -28,13 +28,12 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otlpconfig"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otlpmetrictest"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otlpconfig"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otlpmetrictest"
|
||||
collectormetricpb "go.opentelemetry.io/proto/otlp/collector/metrics/v1"
|
||||
metricpb "go.opentelemetry.io/proto/otlp/metrics/v1"
|
||||
)
|
||||
|
@@ -20,7 +20,6 @@ import (
|
||||
"sync"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform"
|
||||
|
||||
tracesdk "go.opentelemetry.io/otel/sdk/trace"
|
||||
)
|
||||
|
||||
|
@@ -3,13 +3,13 @@ module go.opentelemetry.io/otel/exporters/otlp/otlptrace
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/cenkalti/backoff/v4 v4.1.1
|
||||
github.com/cenkalti/backoff/v4 v4.1.2
|
||||
github.com/google/go-cmp v0.5.6
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel/trace v1.1.0
|
||||
go.opentelemetry.io/proto/otlp v0.10.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/otel/trace v1.2.0
|
||||
go.opentelemetry.io/proto/otlp v0.11.0
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013
|
||||
google.golang.org/grpc v1.42.0
|
||||
google.golang.org/protobuf v1.27.1
|
||||
|
@@ -2,8 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/cenkalti/backoff/v4 v4.1.1 h1:G2HAfAmvm/GcKan2oOQpBXOd2tT2G57ZnZGWa1PxPBQ=
|
||||
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||
github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo=
|
||||
github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
@@ -61,8 +61,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
go.opentelemetry.io/proto/otlp v0.10.0 h1:n7brgtEbDvXEgGyKKo8SobKT1e9FewlDtXzkVP5djoE=
|
||||
go.opentelemetry.io/proto/otlp v0.10.0/go.mod h1:zG20xCK0szZ1xdokeSOwEcmlXu+x9kkdRe6N1DhKcfU=
|
||||
go.opentelemetry.io/proto/otlp v0.11.0 h1:cLDgIBTf4lLOlztkhzAEdQsJ4Lj+i5Wc9k6Nn0K1VyU=
|
||||
go.opentelemetry.io/proto/otlp v0.11.0/go.mod h1:QpEjXPrNQzrFDZgoTo49dgHR9RYRSrg3NAKnUGl9YpQ=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
@@ -111,7 +111,6 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
|
||||
google.golang.org/grpc v1.42.0 h1:XT2/MFpuPFsEX2fWh3YQtHkZ+WYZFQRfaUgLZYj/p6A=
|
||||
google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
|
@@ -23,16 +23,14 @@ import (
|
||||
"unsafe"
|
||||
|
||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"google.golang.org/grpc/encoding/gzip"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/retry"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
type Connection struct {
|
||||
|
@@ -21,13 +21,12 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/retry"
|
||||
|
||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/types/known/durationpb"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/retry"
|
||||
)
|
||||
|
||||
func TestThrottleDuration(t *testing.T) {
|
||||
|
@@ -19,9 +19,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@@ -19,9 +19,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
||||
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
|
||||
|
@@ -16,9 +16,8 @@ package tracetransform // import "go.opentelemetry.io/otel/exporters/otlp/otlptr
|
||||
|
||||
import (
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
|
||||
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
|
||||
)
|
||||
|
||||
// KeyValues transforms a slice of attribute KeyValues into OTLP key-values.
|
||||
|
@@ -15,9 +15,8 @@
|
||||
package tracetransform // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform"
|
||||
|
||||
import (
|
||||
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
|
||||
|
||||
"go.opentelemetry.io/otel/sdk/instrumentation"
|
||||
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
|
||||
)
|
||||
|
||||
func InstrumentationLibrary(il instrumentation.Library) *commonpb.InstrumentationLibrary {
|
||||
|
@@ -15,9 +15,8 @@
|
||||
package tracetransform // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform"
|
||||
|
||||
import (
|
||||
resourcepb "go.opentelemetry.io/proto/otlp/resource/v1"
|
||||
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
resourcepb "go.opentelemetry.io/proto/otlp/resource/v1"
|
||||
)
|
||||
|
||||
// Resource transforms a Resource into an OTLP Resource.
|
||||
|
@@ -17,11 +17,10 @@ package tracetransform // import "go.opentelemetry.io/otel/exporters/otlp/otlptr
|
||||
import (
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
tracepb "go.opentelemetry.io/proto/otlp/trace/v1"
|
||||
|
||||
"go.opentelemetry.io/otel/sdk/instrumentation"
|
||||
tracesdk "go.opentelemetry.io/otel/sdk/trace"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
tracepb "go.opentelemetry.io/proto/otlp/trace/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@@ -20,13 +20,11 @@ import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/connection"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/connection"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig"
|
||||
coltracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
|
||||
tracepb "go.opentelemetry.io/proto/otlp/trace/v1"
|
||||
)
|
||||
|
@@ -21,20 +21,17 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/encoding/gzip"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlptracetest"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/encoding/gzip"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
||||
"go.opentelemetry.io/otel/sdk/trace/tracetest"
|
||||
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
|
||||
@@ -164,6 +161,8 @@ func TestNew_invokeStartThenStopManyTimes(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNew_collectorConnectionDiesThenReconnectsWhenInRestMode(t *testing.T) {
|
||||
// TODO: Fix this test #1527
|
||||
t.Skip("This test is flaky and needs to be rewritten")
|
||||
mc := runMockCollector(t)
|
||||
|
||||
reconnectionPeriod := 20 * time.Millisecond
|
||||
@@ -221,6 +220,8 @@ func TestNew_collectorConnectionDiesThenReconnectsWhenInRestMode(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNew_collectorConnectionDiesThenReconnects(t *testing.T) {
|
||||
// TODO: Fix this test #1527
|
||||
t.Skip("This test is flaky and needs to be rewritten")
|
||||
mc := runMockCollector(t)
|
||||
|
||||
reconnectionPeriod := 50 * time.Millisecond
|
||||
|
@@ -4,10 +4,10 @@ go 1.15
|
||||
|
||||
require (
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.1.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/proto/otlp v0.10.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.2.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/proto/otlp v0.11.0
|
||||
google.golang.org/grpc v1.42.0
|
||||
)
|
||||
|
||||
|
@@ -2,8 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/cenkalti/backoff/v4 v4.1.1 h1:G2HAfAmvm/GcKan2oOQpBXOd2tT2G57ZnZGWa1PxPBQ=
|
||||
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||
github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo=
|
||||
github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
@@ -61,8 +61,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
go.opentelemetry.io/proto/otlp v0.10.0 h1:n7brgtEbDvXEgGyKKo8SobKT1e9FewlDtXzkVP5djoE=
|
||||
go.opentelemetry.io/proto/otlp v0.10.0/go.mod h1:zG20xCK0szZ1xdokeSOwEcmlXu+x9kkdRe6N1DhKcfU=
|
||||
go.opentelemetry.io/proto/otlp v0.11.0 h1:cLDgIBTf4lLOlztkhzAEdQsJ4Lj+i5Wc9k6Nn0K1VyU=
|
||||
go.opentelemetry.io/proto/otlp v0.11.0/go.mod h1:QpEjXPrNQzrFDZgoTo49dgHR9RYRSrg3NAKnUGl9YpQ=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
@@ -111,7 +111,6 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
|
||||
google.golang.org/grpc v1.42.0 h1:XT2/MFpuPFsEX2fWh3YQtHkZ+WYZFQRfaUgLZYj/p6A=
|
||||
google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
|
@@ -24,11 +24,10 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlptracetest"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlptracetest"
|
||||
collectortracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
|
||||
tracepb "go.opentelemetry.io/proto/otlp/trace/v1"
|
||||
)
|
||||
|
@@ -18,12 +18,12 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/retry"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
)
|
||||
|
||||
// Option applies an option to the gRPC driver.
|
||||
|
@@ -29,15 +29,13 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
|
||||
tracepb "go.opentelemetry.io/proto/otlp/trace/v1"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/retry"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/retry"
|
||||
coltracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
|
||||
tracepb "go.opentelemetry.io/proto/otlp/trace/v1"
|
||||
)
|
||||
|
||||
const contentTypeProto = "application/x-protobuf"
|
||||
|
@@ -22,13 +22,12 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlptracetest"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@@ -4,11 +4,11 @@ go 1.15
|
||||
|
||||
require (
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.1.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel/trace v1.1.0
|
||||
go.opentelemetry.io/proto/otlp v0.10.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.2.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/otel/trace v1.2.0
|
||||
go.opentelemetry.io/proto/otlp v0.11.0
|
||||
google.golang.org/protobuf v1.27.1
|
||||
)
|
||||
|
||||
|
@@ -2,8 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/cenkalti/backoff/v4 v4.1.1 h1:G2HAfAmvm/GcKan2oOQpBXOd2tT2G57ZnZGWa1PxPBQ=
|
||||
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||
github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo=
|
||||
github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
@@ -61,8 +61,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
go.opentelemetry.io/proto/otlp v0.10.0 h1:n7brgtEbDvXEgGyKKo8SobKT1e9FewlDtXzkVP5djoE=
|
||||
go.opentelemetry.io/proto/otlp v0.10.0/go.mod h1:zG20xCK0szZ1xdokeSOwEcmlXu+x9kkdRe6N1DhKcfU=
|
||||
go.opentelemetry.io/proto/otlp v0.11.0 h1:cLDgIBTf4lLOlztkhzAEdQsJ4Lj+i5Wc9k6Nn0K1VyU=
|
||||
go.opentelemetry.io/proto/otlp v0.11.0/go.mod h1:QpEjXPrNQzrFDZgoTo49dgHR9RYRSrg3NAKnUGl9YpQ=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
@@ -111,7 +111,6 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
|
||||
google.golang.org/grpc v1.42.0 h1:XT2/MFpuPFsEX2fWh3YQtHkZ+WYZFQRfaUgLZYj/p6A=
|
||||
google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
|
@@ -28,13 +28,12 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlptracetest"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlptracetest"
|
||||
collectortracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
|
||||
tracepb "go.opentelemetry.io/proto/otlp/trace/v1"
|
||||
)
|
||||
|
@@ -5,11 +5,11 @@ go 1.15
|
||||
require (
|
||||
github.com/prometheus/client_golang v1.11.0
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/metric v0.24.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel/sdk/export/metric v0.24.0
|
||||
go.opentelemetry.io/otel/sdk/metric v0.24.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/metric v0.25.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/otel/sdk/export/metric v0.25.0
|
||||
go.opentelemetry.io/otel/sdk/metric v0.25.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel => ../..
|
||||
|
@@ -58,7 +58,7 @@ type Exporter struct {
|
||||
}
|
||||
|
||||
// ErrUnsupportedAggregator is returned for unrepresentable aggregator
|
||||
// types (e.g., exact).
|
||||
// types.
|
||||
var ErrUnsupportedAggregator = fmt.Errorf("unsupported aggregator type")
|
||||
|
||||
var _ http.Handler = &Exporter{}
|
||||
|
@@ -18,9 +18,8 @@ import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/stdout/stdoutmetric"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/exporters/stdout/stdoutmetric"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/global"
|
||||
controller "go.opentelemetry.io/otel/sdk/metric/controller/basic"
|
||||
|
@@ -9,11 +9,11 @@ replace (
|
||||
|
||||
require (
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/metric v0.24.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel/sdk/export/metric v0.24.0
|
||||
go.opentelemetry.io/otel/sdk/metric v0.24.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/metric v0.25.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/otel/sdk/export/metric v0.25.0
|
||||
go.opentelemetry.io/otel/sdk/metric v0.25.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel/bridge/opencensus => ../../../bridge/opencensus
|
||||
|
@@ -23,12 +23,11 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/stdout/stdoutmetric"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/exporters/stdout/stdoutmetric"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
|
||||
controller "go.opentelemetry.io/otel/sdk/metric/controller/basic"
|
||||
|
@@ -9,9 +9,9 @@ replace (
|
||||
|
||||
require (
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel/trace v1.1.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/otel/trace v1.2.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel/bridge/opencensus => ../../../bridge/opencensus
|
||||
|
@@ -6,9 +6,9 @@ require (
|
||||
github.com/google/go-cmp v0.5.6
|
||||
github.com/openzipkin/zipkin-go v0.3.0
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel/trace v1.1.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/otel/trace v1.2.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel/bridge/opencensus => ../../bridge/opencensus
|
||||
|
@@ -21,16 +21,15 @@ import (
|
||||
"net"
|
||||
"strconv"
|
||||
|
||||
zkmodel "github.com/openzipkin/zipkin-go/model"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
zkmodel "github.com/openzipkin/zipkin-go/model"
|
||||
|
||||
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
||||
tracesdk "go.opentelemetry.io/otel/sdk/trace"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
const (
|
||||
|
2
go.mod
2
go.mod
@@ -7,7 +7,7 @@ require (
|
||||
github.com/go-logr/stdr v1.2.0
|
||||
github.com/google/go-cmp v0.5.6
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.opentelemetry.io/otel/trace v1.1.0
|
||||
go.opentelemetry.io/otel/trace v1.2.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel => ./
|
||||
|
@@ -41,10 +41,6 @@ import (
|
||||
// in the MeterProvider and Meters ensure that each instrument has a delegate
|
||||
// before the global provider is set.
|
||||
//
|
||||
// Bound instrument operations are implemented by delegating to the
|
||||
// instrument after it is registered, with a sync.Once initializer to
|
||||
// protect against races with Release().
|
||||
//
|
||||
// Metric uniqueness checking is implemented by calling the exported
|
||||
// methods of the api/metric/registry package.
|
||||
|
||||
@@ -108,19 +104,9 @@ type AsyncImpler interface {
|
||||
AsyncImpl() sdkapi.AsyncImpl
|
||||
}
|
||||
|
||||
type syncHandle struct {
|
||||
delegate unsafe.Pointer // (*sdkapi.BoundInstrumentImpl)
|
||||
|
||||
inst *syncImpl
|
||||
labels []attribute.KeyValue
|
||||
|
||||
initialize sync.Once
|
||||
}
|
||||
|
||||
var _ metric.MeterProvider = &meterProvider{}
|
||||
var _ sdkapi.MeterImpl = &meterImpl{}
|
||||
var _ sdkapi.InstrumentImpl = &syncImpl{}
|
||||
var _ sdkapi.BoundSyncImpl = &syncHandle{}
|
||||
var _ sdkapi.AsyncImpl = &asyncImpl{}
|
||||
|
||||
func (inst *instrument) Descriptor() sdkapi.Descriptor {
|
||||
@@ -241,28 +227,6 @@ func (inst *syncImpl) Implementation() interface{} {
|
||||
return inst
|
||||
}
|
||||
|
||||
func (inst *syncImpl) Bind(labels []attribute.KeyValue) sdkapi.BoundSyncImpl {
|
||||
if implPtr := (*sdkapi.SyncImpl)(atomic.LoadPointer(&inst.delegate)); implPtr != nil {
|
||||
return (*implPtr).Bind(labels)
|
||||
}
|
||||
return &syncHandle{
|
||||
inst: inst,
|
||||
labels: labels,
|
||||
}
|
||||
}
|
||||
|
||||
func (bound *syncHandle) Unbind() {
|
||||
bound.initialize.Do(func() {})
|
||||
|
||||
implPtr := (*sdkapi.BoundSyncImpl)(atomic.LoadPointer(&bound.delegate))
|
||||
|
||||
if implPtr == nil {
|
||||
return
|
||||
}
|
||||
|
||||
(*implPtr).Unbind()
|
||||
}
|
||||
|
||||
// Async delegation
|
||||
|
||||
func (m *meterImpl) NewAsyncInstrument(
|
||||
@@ -325,37 +289,11 @@ func (inst *syncImpl) RecordOne(ctx context.Context, number number.Number, label
|
||||
}
|
||||
}
|
||||
|
||||
// Bound instrument initialization
|
||||
|
||||
func (bound *syncHandle) RecordOne(ctx context.Context, number number.Number) {
|
||||
instPtr := (*sdkapi.SyncImpl)(atomic.LoadPointer(&bound.inst.delegate))
|
||||
if instPtr == nil {
|
||||
return
|
||||
}
|
||||
var implPtr *sdkapi.BoundSyncImpl
|
||||
bound.initialize.Do(func() {
|
||||
implPtr = new(sdkapi.BoundSyncImpl)
|
||||
*implPtr = (*instPtr).Bind(bound.labels)
|
||||
atomic.StorePointer(&bound.delegate, unsafe.Pointer(implPtr))
|
||||
})
|
||||
if implPtr == nil {
|
||||
implPtr = (*sdkapi.BoundSyncImpl)(atomic.LoadPointer(&bound.delegate))
|
||||
}
|
||||
// This may still be nil if instrument was created and bound
|
||||
// without a delegate, then the instrument was set to have a
|
||||
// delegate and unbound.
|
||||
if implPtr == nil {
|
||||
return
|
||||
}
|
||||
(*implPtr).RecordOne(ctx, number)
|
||||
}
|
||||
|
||||
func AtomicFieldOffsets() map[string]uintptr {
|
||||
return map[string]uintptr{
|
||||
"meterProvider.delegate": unsafe.Offsetof(meterProvider{}.delegate),
|
||||
"meterImpl.delegate": unsafe.Offsetof(meterImpl{}.delegate),
|
||||
"syncImpl.delegate": unsafe.Offsetof(syncImpl{}.delegate),
|
||||
"asyncImpl.delegate": unsafe.Offsetof(asyncImpl{}.delegate),
|
||||
"syncHandle.delegate": unsafe.Offsetof(syncHandle{}.delegate),
|
||||
}
|
||||
}
|
||||
|
@@ -137,97 +137,6 @@ func TestDirect(t *testing.T) {
|
||||
)
|
||||
}
|
||||
|
||||
func TestBound(t *testing.T) {
|
||||
global.ResetForTest()
|
||||
|
||||
// Note: this test uses opposite Float64/Int64 number kinds
|
||||
// vs. the above, to cover all the instruments.
|
||||
ctx := context.Background()
|
||||
glob := metricglobal.Meter(
|
||||
"test",
|
||||
metric.WithInstrumentationVersion("semver:test-1.0"),
|
||||
metric.WithSchemaURL("schema://url"),
|
||||
)
|
||||
labels1 := []attribute.KeyValue{attribute.String("A", "B")}
|
||||
|
||||
counter := Must(glob).NewFloat64Counter("test.counter")
|
||||
boundC := counter.Bind(labels1...)
|
||||
boundC.Add(ctx, 1)
|
||||
boundC.Add(ctx, 1)
|
||||
|
||||
histogram := Must(glob).NewInt64Histogram("test.histogram")
|
||||
boundM := histogram.Bind(labels1...)
|
||||
boundM.Record(ctx, 1)
|
||||
boundM.Record(ctx, 2)
|
||||
|
||||
provider := metrictest.NewMeterProvider()
|
||||
metricglobal.SetMeterProvider(provider)
|
||||
|
||||
boundC.Add(ctx, 1)
|
||||
boundM.Record(ctx, 3)
|
||||
|
||||
library := metrictest.Library{
|
||||
InstrumentationName: "test",
|
||||
InstrumentationVersion: "semver:test-1.0",
|
||||
SchemaURL: "schema://url",
|
||||
}
|
||||
|
||||
require.EqualValues(t,
|
||||
[]metrictest.Measured{
|
||||
{
|
||||
Name: "test.counter",
|
||||
Library: library,
|
||||
Labels: metrictest.LabelsToMap(labels1...),
|
||||
Number: asFloat(1),
|
||||
},
|
||||
{
|
||||
Name: "test.histogram",
|
||||
Library: library,
|
||||
Labels: metrictest.LabelsToMap(labels1...),
|
||||
Number: asInt(3),
|
||||
},
|
||||
},
|
||||
metrictest.AsStructs(provider.MeasurementBatches))
|
||||
|
||||
boundC.Unbind()
|
||||
boundM.Unbind()
|
||||
}
|
||||
|
||||
func TestUnbind(t *testing.T) {
|
||||
// Tests Unbind with SDK never installed.
|
||||
global.ResetForTest()
|
||||
|
||||
glob := metricglobal.Meter("test")
|
||||
labels1 := []attribute.KeyValue{attribute.String("A", "B")}
|
||||
|
||||
counter := Must(glob).NewFloat64Counter("test.counter")
|
||||
boundC := counter.Bind(labels1...)
|
||||
|
||||
histogram := Must(glob).NewInt64Histogram("test.histogram")
|
||||
boundM := histogram.Bind(labels1...)
|
||||
|
||||
boundC.Unbind()
|
||||
boundM.Unbind()
|
||||
}
|
||||
|
||||
func TestUnbindThenRecordOne(t *testing.T) {
|
||||
global.ResetForTest()
|
||||
|
||||
ctx := context.Background()
|
||||
provider := metrictest.NewMeterProvider()
|
||||
|
||||
meter := metricglobal.Meter("test")
|
||||
counter := Must(meter).NewInt64Counter("test.counter")
|
||||
boundC := counter.Bind()
|
||||
metricglobal.SetMeterProvider(provider)
|
||||
boundC.Unbind()
|
||||
|
||||
require.NotPanics(t, func() {
|
||||
boundC.Add(ctx, 1)
|
||||
})
|
||||
require.Equal(t, 0, len(provider.MeasurementBatches))
|
||||
}
|
||||
|
||||
type meterProviderWithConstructorError struct {
|
||||
metric.MeterProvider
|
||||
}
|
||||
|
@@ -4,8 +4,8 @@ go 1.15
|
||||
|
||||
require (
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/metric v0.24.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/metric v0.25.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel => ../..
|
||||
|
@@ -43,8 +43,8 @@ replace go.opentelemetry.io/otel/trace => ../trace
|
||||
require (
|
||||
github.com/google/go-cmp v0.5.6
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/internal/metric v0.24.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/internal/metric v0.25.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel/example/passthrough => ../example/passthrough
|
||||
|
@@ -260,11 +260,6 @@ type syncInstrument struct {
|
||||
instrument sdkapi.SyncImpl
|
||||
}
|
||||
|
||||
// syncBoundInstrument contains a BoundSyncImpl.
|
||||
type syncBoundInstrument struct {
|
||||
boundInstrument sdkapi.BoundSyncImpl
|
||||
}
|
||||
|
||||
// asyncInstrument contains a AsyncImpl.
|
||||
type asyncInstrument struct {
|
||||
instrument sdkapi.AsyncImpl
|
||||
@@ -280,10 +275,6 @@ func (s syncInstrument) SyncImpl() sdkapi.SyncImpl {
|
||||
return s.instrument
|
||||
}
|
||||
|
||||
func (s syncInstrument) bind(labels []attribute.KeyValue) syncBoundInstrument {
|
||||
return newSyncBoundInstrument(s.instrument.Bind(labels))
|
||||
}
|
||||
|
||||
func (s syncInstrument) float64Measurement(value float64) Measurement {
|
||||
return sdkapi.NewMeasurement(s.instrument, number.NewFloat64Number(value))
|
||||
}
|
||||
@@ -296,15 +287,6 @@ func (s syncInstrument) directRecord(ctx context.Context, number number.Number,
|
||||
s.instrument.RecordOne(ctx, number, labels)
|
||||
}
|
||||
|
||||
func (h syncBoundInstrument) directRecord(ctx context.Context, number number.Number) {
|
||||
h.boundInstrument.RecordOne(ctx, number)
|
||||
}
|
||||
|
||||
// Unbind calls SyncImpl.Unbind.
|
||||
func (h syncBoundInstrument) Unbind() {
|
||||
h.boundInstrument.Unbind()
|
||||
}
|
||||
|
||||
// checkNewAsync receives an AsyncImpl and potential
|
||||
// error, and returns the same types, checking for and ensuring that
|
||||
// the returned interface is not nil.
|
||||
@@ -340,12 +322,6 @@ func checkNewSync(instrument sdkapi.SyncImpl, err error) (syncInstrument, error)
|
||||
}, err
|
||||
}
|
||||
|
||||
func newSyncBoundInstrument(boundInstrument sdkapi.BoundSyncImpl) syncBoundInstrument {
|
||||
return syncBoundInstrument{
|
||||
boundInstrument: boundInstrument,
|
||||
}
|
||||
}
|
||||
|
||||
// wrapInt64CounterInstrument converts a SyncImpl into Int64Counter.
|
||||
func wrapInt64CounterInstrument(syncInst sdkapi.SyncImpl, err error) (Int64Counter, error) {
|
||||
common, err := checkNewSync(syncInst, err)
|
||||
@@ -392,34 +368,6 @@ type Int64Counter struct {
|
||||
syncInstrument
|
||||
}
|
||||
|
||||
// BoundFloat64Counter is a bound instrument for Float64Counter.
|
||||
//
|
||||
// It inherits the Unbind function from syncBoundInstrument.
|
||||
type BoundFloat64Counter struct {
|
||||
syncBoundInstrument
|
||||
}
|
||||
|
||||
// BoundInt64Counter is a boundInstrument for Int64Counter.
|
||||
//
|
||||
// It inherits the Unbind function from syncBoundInstrument.
|
||||
type BoundInt64Counter struct {
|
||||
syncBoundInstrument
|
||||
}
|
||||
|
||||
// Bind creates a bound instrument for this counter. The labels are
|
||||
// associated with values recorded via subsequent calls to Record.
|
||||
func (c Float64Counter) Bind(labels ...attribute.KeyValue) (h BoundFloat64Counter) {
|
||||
h.syncBoundInstrument = c.bind(labels)
|
||||
return
|
||||
}
|
||||
|
||||
// Bind creates a bound instrument for this counter. The labels are
|
||||
// associated with values recorded via subsequent calls to Record.
|
||||
func (c Int64Counter) Bind(labels ...attribute.KeyValue) (h BoundInt64Counter) {
|
||||
h.syncBoundInstrument = c.bind(labels)
|
||||
return
|
||||
}
|
||||
|
||||
// Measurement creates a Measurement object to use with batch
|
||||
// recording.
|
||||
func (c Float64Counter) Measurement(value float64) Measurement {
|
||||
@@ -444,18 +392,6 @@ func (c Int64Counter) Add(ctx context.Context, value int64, labels ...attribute.
|
||||
c.directRecord(ctx, number.NewInt64Number(value), labels)
|
||||
}
|
||||
|
||||
// Add adds the value to the counter's sum using the labels
|
||||
// previously bound to this counter via Bind()
|
||||
func (b BoundFloat64Counter) Add(ctx context.Context, value float64) {
|
||||
b.directRecord(ctx, number.NewFloat64Number(value))
|
||||
}
|
||||
|
||||
// Add adds the value to the counter's sum using the labels
|
||||
// previously bound to this counter via Bind()
|
||||
func (b BoundInt64Counter) Add(ctx context.Context, value int64) {
|
||||
b.directRecord(ctx, number.NewInt64Number(value))
|
||||
}
|
||||
|
||||
// Float64UpDownCounter is a metric instrument that sums floating
|
||||
// point values.
|
||||
type Float64UpDownCounter struct {
|
||||
@@ -467,34 +403,6 @@ type Int64UpDownCounter struct {
|
||||
syncInstrument
|
||||
}
|
||||
|
||||
// BoundFloat64UpDownCounter is a bound instrument for Float64UpDownCounter.
|
||||
//
|
||||
// It inherits the Unbind function from syncBoundInstrument.
|
||||
type BoundFloat64UpDownCounter struct {
|
||||
syncBoundInstrument
|
||||
}
|
||||
|
||||
// BoundInt64UpDownCounter is a boundInstrument for Int64UpDownCounter.
|
||||
//
|
||||
// It inherits the Unbind function from syncBoundInstrument.
|
||||
type BoundInt64UpDownCounter struct {
|
||||
syncBoundInstrument
|
||||
}
|
||||
|
||||
// Bind creates a bound instrument for this counter. The labels are
|
||||
// associated with values recorded via subsequent calls to Record.
|
||||
func (c Float64UpDownCounter) Bind(labels ...attribute.KeyValue) (h BoundFloat64UpDownCounter) {
|
||||
h.syncBoundInstrument = c.bind(labels)
|
||||
return
|
||||
}
|
||||
|
||||
// Bind creates a bound instrument for this counter. The labels are
|
||||
// associated with values recorded via subsequent calls to Record.
|
||||
func (c Int64UpDownCounter) Bind(labels ...attribute.KeyValue) (h BoundInt64UpDownCounter) {
|
||||
h.syncBoundInstrument = c.bind(labels)
|
||||
return
|
||||
}
|
||||
|
||||
// Measurement creates a Measurement object to use with batch
|
||||
// recording.
|
||||
func (c Float64UpDownCounter) Measurement(value float64) Measurement {
|
||||
@@ -519,18 +427,6 @@ func (c Int64UpDownCounter) Add(ctx context.Context, value int64, labels ...attr
|
||||
c.directRecord(ctx, number.NewInt64Number(value), labels)
|
||||
}
|
||||
|
||||
// Add adds the value to the counter's sum using the labels
|
||||
// previously bound to this counter via Bind()
|
||||
func (b BoundFloat64UpDownCounter) Add(ctx context.Context, value float64) {
|
||||
b.directRecord(ctx, number.NewFloat64Number(value))
|
||||
}
|
||||
|
||||
// Add adds the value to the counter's sum using the labels
|
||||
// previously bound to this counter via Bind()
|
||||
func (b BoundInt64UpDownCounter) Add(ctx context.Context, value int64) {
|
||||
b.directRecord(ctx, number.NewInt64Number(value))
|
||||
}
|
||||
|
||||
// Float64Histogram is a metric that records float64 values.
|
||||
type Float64Histogram struct {
|
||||
syncInstrument
|
||||
@@ -541,34 +437,6 @@ type Int64Histogram struct {
|
||||
syncInstrument
|
||||
}
|
||||
|
||||
// BoundFloat64Histogram is a bound instrument for Float64Histogram.
|
||||
//
|
||||
// It inherits the Unbind function from syncBoundInstrument.
|
||||
type BoundFloat64Histogram struct {
|
||||
syncBoundInstrument
|
||||
}
|
||||
|
||||
// BoundInt64Histogram is a bound instrument for Int64Histogram.
|
||||
//
|
||||
// It inherits the Unbind function from syncBoundInstrument.
|
||||
type BoundInt64Histogram struct {
|
||||
syncBoundInstrument
|
||||
}
|
||||
|
||||
// Bind creates a bound instrument for this Histogram. The labels are
|
||||
// associated with values recorded via subsequent calls to Record.
|
||||
func (c Float64Histogram) Bind(labels ...attribute.KeyValue) (h BoundFloat64Histogram) {
|
||||
h.syncBoundInstrument = c.bind(labels)
|
||||
return
|
||||
}
|
||||
|
||||
// Bind creates a bound instrument for this Histogram. The labels are
|
||||
// associated with values recorded via subsequent calls to Record.
|
||||
func (c Int64Histogram) Bind(labels ...attribute.KeyValue) (h BoundInt64Histogram) {
|
||||
h.syncBoundInstrument = c.bind(labels)
|
||||
return
|
||||
}
|
||||
|
||||
// Measurement creates a Measurement object to use with batch
|
||||
// recording.
|
||||
func (c Float64Histogram) Measurement(value float64) Measurement {
|
||||
@@ -594,15 +462,3 @@ func (c Float64Histogram) Record(ctx context.Context, value float64, labels ...a
|
||||
func (c Int64Histogram) Record(ctx context.Context, value int64, labels ...attribute.KeyValue) {
|
||||
c.directRecord(ctx, number.NewInt64Number(value), labels)
|
||||
}
|
||||
|
||||
// Record adds a new value to the Histogram's distribution using the labels
|
||||
// previously bound to the Histogram via Bind().
|
||||
func (b BoundFloat64Histogram) Record(ctx context.Context, value float64) {
|
||||
b.directRecord(ctx, number.NewFloat64Number(value))
|
||||
}
|
||||
|
||||
// Record adds a new value to the Histogram's distribution using the labels
|
||||
// previously bound to the Histogram via Bind().
|
||||
func (b BoundInt64Histogram) Record(ctx context.Context, value int64) {
|
||||
b.directRecord(ctx, number.NewInt64Number(value))
|
||||
}
|
||||
|
@@ -19,16 +19,16 @@ import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/metrictest"
|
||||
"go.opentelemetry.io/otel/metric/number"
|
||||
"go.opentelemetry.io/otel/metric/sdkapi"
|
||||
"go.opentelemetry.io/otel/metric/unit"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var Must = metric.Must
|
||||
@@ -250,11 +250,9 @@ func TestCounter(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
labels := []attribute.KeyValue{attribute.String("A", "B")}
|
||||
c.Add(ctx, 1994.1, labels...)
|
||||
boundInstrument := c.Bind(labels...)
|
||||
boundInstrument.Add(ctx, -742)
|
||||
meter.RecordBatch(ctx, labels, c.Measurement(42))
|
||||
checkSyncBatches(ctx, t, labels, provider, number.Float64Kind, sdkapi.CounterInstrumentKind, c.SyncImpl(),
|
||||
1994.1, -742, 42,
|
||||
1994.1, 42,
|
||||
)
|
||||
})
|
||||
t.Run("int64 counter", func(t *testing.T) {
|
||||
@@ -263,11 +261,9 @@ func TestCounter(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
labels := []attribute.KeyValue{attribute.String("A", "B"), attribute.String("C", "D")}
|
||||
c.Add(ctx, 42, labels...)
|
||||
boundInstrument := c.Bind(labels...)
|
||||
boundInstrument.Add(ctx, 4200)
|
||||
meter.RecordBatch(ctx, labels, c.Measurement(420000))
|
||||
checkSyncBatches(ctx, t, labels, provider, number.Int64Kind, sdkapi.CounterInstrumentKind, c.SyncImpl(),
|
||||
42, 4200, 420000,
|
||||
42, 420000,
|
||||
)
|
||||
|
||||
})
|
||||
@@ -277,11 +273,9 @@ func TestCounter(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
labels := []attribute.KeyValue{attribute.String("A", "B"), attribute.String("C", "D")}
|
||||
c.Add(ctx, 100, labels...)
|
||||
boundInstrument := c.Bind(labels...)
|
||||
boundInstrument.Add(ctx, -100)
|
||||
meter.RecordBatch(ctx, labels, c.Measurement(42))
|
||||
checkSyncBatches(ctx, t, labels, provider, number.Int64Kind, sdkapi.UpDownCounterInstrumentKind, c.SyncImpl(),
|
||||
100, -100, 42,
|
||||
100, 42,
|
||||
)
|
||||
})
|
||||
t.Run("float64 updowncounter", func(t *testing.T) {
|
||||
@@ -290,11 +284,9 @@ func TestCounter(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
labels := []attribute.KeyValue{attribute.String("A", "B"), attribute.String("C", "D")}
|
||||
c.Add(ctx, 100.1, labels...)
|
||||
boundInstrument := c.Bind(labels...)
|
||||
boundInstrument.Add(ctx, -76)
|
||||
meter.RecordBatch(ctx, labels, c.Measurement(-100.1))
|
||||
checkSyncBatches(ctx, t, labels, provider, number.Float64Kind, sdkapi.UpDownCounterInstrumentKind, c.SyncImpl(),
|
||||
100.1, -76, -100.1,
|
||||
100.1, -100.1,
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -306,11 +298,9 @@ func TestHistogram(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
labels := []attribute.KeyValue{}
|
||||
m.Record(ctx, 42, labels...)
|
||||
boundInstrument := m.Bind(labels...)
|
||||
boundInstrument.Record(ctx, 0)
|
||||
meter.RecordBatch(ctx, labels, m.Measurement(-100.5))
|
||||
checkSyncBatches(ctx, t, labels, provider, number.Float64Kind, sdkapi.HistogramInstrumentKind, m.SyncImpl(),
|
||||
42, 0, -100.5,
|
||||
42, -100.5,
|
||||
)
|
||||
})
|
||||
t.Run("int64 histogram", func(t *testing.T) {
|
||||
@@ -319,11 +309,9 @@ func TestHistogram(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
labels := []attribute.KeyValue{attribute.Int("I", 1)}
|
||||
m.Record(ctx, 173, labels...)
|
||||
boundInstrument := m.Bind(labels...)
|
||||
boundInstrument.Record(ctx, 80)
|
||||
meter.RecordBatch(ctx, labels, m.Measurement(0))
|
||||
checkSyncBatches(ctx, t, labels, provider, number.Int64Kind, sdkapi.HistogramInstrumentKind, m.SyncImpl(),
|
||||
173, 80, 0,
|
||||
173, 0,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
@@ -86,10 +86,9 @@ type (
|
||||
)
|
||||
|
||||
var (
|
||||
_ sdkapi.SyncImpl = &Sync{}
|
||||
_ sdkapi.BoundSyncImpl = &Handle{}
|
||||
_ sdkapi.MeterImpl = &MeterImpl{}
|
||||
_ sdkapi.AsyncImpl = &Async{}
|
||||
_ sdkapi.SyncImpl = &Sync{}
|
||||
_ sdkapi.MeterImpl = &MeterImpl{}
|
||||
_ sdkapi.AsyncImpl = &Async{}
|
||||
)
|
||||
|
||||
// NewDescriptor is a test helper for constructing test metric
|
||||
@@ -111,13 +110,6 @@ func (s *Sync) Implementation() interface{} {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Sync) Bind(labels []attribute.KeyValue) sdkapi.BoundSyncImpl {
|
||||
return &Handle{
|
||||
Instrument: s,
|
||||
Labels: labels,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Sync) RecordOne(ctx context.Context, number number.Number, labels []attribute.KeyValue) {
|
||||
s.meter.doRecordSingle(ctx, labels, s, number)
|
||||
}
|
||||
|
@@ -22,12 +22,10 @@ import (
|
||||
)
|
||||
|
||||
type noopInstrument struct{}
|
||||
type noopBoundInstrument struct{}
|
||||
type noopSyncInstrument struct{ noopInstrument }
|
||||
type noopAsyncInstrument struct{ noopInstrument }
|
||||
|
||||
var _ SyncImpl = noopSyncInstrument{}
|
||||
var _ BoundSyncImpl = noopBoundInstrument{}
|
||||
var _ AsyncImpl = noopAsyncInstrument{}
|
||||
|
||||
// NewNoopSyncInstrument returns a No-op implementation of the
|
||||
@@ -50,15 +48,5 @@ func (noopInstrument) Descriptor() Descriptor {
|
||||
return Descriptor{}
|
||||
}
|
||||
|
||||
func (noopBoundInstrument) RecordOne(context.Context, number.Number) {
|
||||
}
|
||||
|
||||
func (noopBoundInstrument) Unbind() {
|
||||
}
|
||||
|
||||
func (noopSyncInstrument) Bind([]attribute.KeyValue) BoundSyncImpl {
|
||||
return noopBoundInstrument{}
|
||||
}
|
||||
|
||||
func (noopSyncInstrument) RecordOne(context.Context, number.Number, []attribute.KeyValue) {
|
||||
}
|
||||
|
@@ -58,26 +58,10 @@ type InstrumentImpl interface {
|
||||
type SyncImpl interface {
|
||||
InstrumentImpl
|
||||
|
||||
// Bind creates an implementation-level bound instrument,
|
||||
// binding a label set with this instrument implementation.
|
||||
Bind(labels []attribute.KeyValue) BoundSyncImpl
|
||||
|
||||
// RecordOne captures a single synchronous metric event.
|
||||
RecordOne(ctx context.Context, number number.Number, labels []attribute.KeyValue)
|
||||
}
|
||||
|
||||
// BoundSyncImpl is the implementation-level interface to a
|
||||
// generic bound synchronous instrument
|
||||
type BoundSyncImpl interface {
|
||||
|
||||
// RecordOne captures a single synchronous metric event.
|
||||
RecordOne(ctx context.Context, number number.Number)
|
||||
|
||||
// Unbind frees the resources associated with this bound instrument. It
|
||||
// does not affect the metric this bound instrument was created through.
|
||||
Unbind()
|
||||
}
|
||||
|
||||
// AsyncImpl is an implementation-level interface to an
|
||||
// asynchronous instrument (e.g., Observer instruments).
|
||||
type AsyncImpl interface {
|
||||
|
@@ -64,22 +64,6 @@ type (
|
||||
LastValue() (number.Number, time.Time, error)
|
||||
}
|
||||
|
||||
// Points returns the raw values that were aggregated.
|
||||
Points interface {
|
||||
Aggregation
|
||||
|
||||
// Points returns points in the order they were
|
||||
// recorded. Points are approximately ordered by
|
||||
// timestamp, but this is not guaranteed.
|
||||
Points() ([]Point, error)
|
||||
}
|
||||
|
||||
// Point is a raw data point, consisting of a number and value.
|
||||
Point struct {
|
||||
number.Number
|
||||
time.Time
|
||||
}
|
||||
|
||||
// Buckets represents histogram buckets boundaries and counts.
|
||||
//
|
||||
// For a Histogram with N defined boundaries, e.g, [x, y, z].
|
||||
@@ -134,7 +118,6 @@ const (
|
||||
MinMaxSumCountKind Kind = "MinMaxSumCount"
|
||||
HistogramKind Kind = "Histogram"
|
||||
LastValueKind Kind = "Lastvalue"
|
||||
ExactKind Kind = "Exact"
|
||||
)
|
||||
|
||||
// Sentinel errors for Aggregation interface.
|
||||
@@ -142,7 +125,10 @@ var (
|
||||
ErrNegativeInput = fmt.Errorf("negative value is out of range for this instrument")
|
||||
ErrNaNInput = fmt.Errorf("NaN value is an invalid input")
|
||||
ErrInconsistentType = fmt.Errorf("inconsistent aggregator types")
|
||||
ErrNoSubtraction = fmt.Errorf("aggregator does not subtract")
|
||||
|
||||
// ErrNoCumulativeToDelta is returned when requesting delta
|
||||
// export kind for a precomputed sum instrument.
|
||||
ErrNoCumulativeToDelta = fmt.Errorf("cumulative to delta not implemented")
|
||||
|
||||
// ErrNoData is returned when (due to a race with collection)
|
||||
// the Aggregator is check-pointed before the first value is set.
|
||||
|
@@ -42,9 +42,9 @@ replace go.opentelemetry.io/otel/trace => ../../../trace
|
||||
|
||||
require (
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/metric v0.24.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/metric v0.25.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel/example/passthrough => ../../../example/passthrough
|
||||
|
@@ -193,16 +193,6 @@ type Aggregator interface {
|
||||
Merge(aggregator Aggregator, descriptor *sdkapi.Descriptor) error
|
||||
}
|
||||
|
||||
// Subtractor is an optional interface implemented by some
|
||||
// Aggregators. An Aggregator must support `Subtract()` in order to
|
||||
// be configured for a Precomputed-Sum instrument (CounterObserver,
|
||||
// UpDownCounterObserver) using a DeltaExporter.
|
||||
type Subtractor interface {
|
||||
// Subtract subtracts the `operand` from this Aggregator and
|
||||
// outputs the value in `result`.
|
||||
Subtract(operand, result Aggregator, descriptor *sdkapi.Descriptor) error
|
||||
}
|
||||
|
||||
// Exporter handles presentation of the checkpoint of aggregate
|
||||
// metrics. This is the final stage of a metrics export pipeline,
|
||||
// where metric data are formatted for a specific system.
|
||||
|
@@ -7,8 +7,8 @@ replace go.opentelemetry.io/otel => ../
|
||||
require (
|
||||
github.com/google/go-cmp v0.5.6
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/trace v1.1.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/trace v1.2.0
|
||||
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7
|
||||
)
|
||||
|
||||
|
@@ -1,130 +0,0 @@
|
||||
// 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.
|
||||
|
||||
package exact // import "go.opentelemetry.io/otel/sdk/metric/aggregator/exact"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/metric/number"
|
||||
"go.opentelemetry.io/otel/metric/sdkapi"
|
||||
export "go.opentelemetry.io/otel/sdk/export/metric"
|
||||
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
|
||||
"go.opentelemetry.io/otel/sdk/metric/aggregator"
|
||||
)
|
||||
|
||||
type (
|
||||
// Aggregator aggregates events that form a distribution, keeping
|
||||
// an array with the exact set of values.
|
||||
Aggregator struct {
|
||||
lock sync.Mutex
|
||||
samples []aggregation.Point
|
||||
}
|
||||
)
|
||||
|
||||
var _ export.Aggregator = &Aggregator{}
|
||||
var _ aggregation.Points = &Aggregator{}
|
||||
var _ aggregation.Count = &Aggregator{}
|
||||
|
||||
// New returns cnt many new exact aggregators, which aggregate recorded
|
||||
// measurements by storing them in an array. This type uses a mutex
|
||||
// for Update() and SynchronizedMove() concurrency.
|
||||
func New(cnt int) []Aggregator {
|
||||
return make([]Aggregator, cnt)
|
||||
}
|
||||
|
||||
// Aggregation returns an interface for reading the state of this aggregator.
|
||||
func (c *Aggregator) Aggregation() aggregation.Aggregation {
|
||||
return c
|
||||
}
|
||||
|
||||
// Kind returns aggregation.ExactKind.
|
||||
func (c *Aggregator) Kind() aggregation.Kind {
|
||||
return aggregation.ExactKind
|
||||
}
|
||||
|
||||
// Count returns the number of values in the checkpoint.
|
||||
func (c *Aggregator) Count() (uint64, error) {
|
||||
return uint64(len(c.samples)), nil
|
||||
}
|
||||
|
||||
// Points returns access to the raw data set.
|
||||
func (c *Aggregator) Points() ([]aggregation.Point, error) {
|
||||
return c.samples, nil
|
||||
}
|
||||
|
||||
// SynchronizedMove saves the current state to oa and resets the current state to
|
||||
// the empty set, taking a lock to prevent concurrent Update() calls.
|
||||
func (c *Aggregator) SynchronizedMove(oa export.Aggregator, desc *sdkapi.Descriptor) error {
|
||||
o, _ := oa.(*Aggregator)
|
||||
|
||||
if oa != nil && o == nil {
|
||||
return aggregator.NewInconsistentAggregatorError(c, oa)
|
||||
}
|
||||
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
if o != nil {
|
||||
o.samples = c.samples
|
||||
}
|
||||
c.samples = nil
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update adds the recorded measurement to the current data set.
|
||||
// Update takes a lock to prevent concurrent Update() and SynchronizedMove()
|
||||
// calls.
|
||||
func (c *Aggregator) Update(_ context.Context, number number.Number, desc *sdkapi.Descriptor) error {
|
||||
now := time.Now()
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
c.samples = append(c.samples, aggregation.Point{
|
||||
Number: number,
|
||||
Time: now,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Merge combines two data sets into one.
|
||||
func (c *Aggregator) Merge(oa export.Aggregator, desc *sdkapi.Descriptor) error {
|
||||
o, _ := oa.(*Aggregator)
|
||||
if o == nil {
|
||||
return aggregator.NewInconsistentAggregatorError(c, oa)
|
||||
}
|
||||
|
||||
c.samples = combine(c.samples, o.samples)
|
||||
return nil
|
||||
}
|
||||
|
||||
func combine(a, b []aggregation.Point) []aggregation.Point {
|
||||
result := make([]aggregation.Point, 0, len(a)+len(b))
|
||||
|
||||
for len(a) != 0 && len(b) != 0 {
|
||||
if a[0].Time.Before(b[0].Time) {
|
||||
result = append(result, a[0])
|
||||
a = a[1:]
|
||||
} else {
|
||||
result = append(result, b[0])
|
||||
b = b[1:]
|
||||
}
|
||||
}
|
||||
result = append(result, a...)
|
||||
result = append(result, b...)
|
||||
return result
|
||||
}
|
@@ -1,377 +0,0 @@
|
||||
// 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.
|
||||
|
||||
package exact
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/otel/metric/number"
|
||||
"go.opentelemetry.io/otel/metric/sdkapi"
|
||||
export "go.opentelemetry.io/otel/sdk/export/metric"
|
||||
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
|
||||
"go.opentelemetry.io/otel/sdk/metric/aggregator/aggregatortest"
|
||||
)
|
||||
|
||||
type updateTest struct {
|
||||
count int
|
||||
}
|
||||
|
||||
func requireNotAfter(t *testing.T, t1, t2 time.Time) {
|
||||
require.False(t, t1.After(t2), "expected %v ≤ %v", t1, t2)
|
||||
}
|
||||
|
||||
func checkZero(t *testing.T, agg *Aggregator, desc *sdkapi.Descriptor) {
|
||||
count, err := agg.Count()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, uint64(0), count)
|
||||
|
||||
pts, err := agg.Points()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 0, len(pts))
|
||||
}
|
||||
|
||||
func new2() (_, _ *Aggregator) {
|
||||
alloc := New(2)
|
||||
return &alloc[0], &alloc[1]
|
||||
}
|
||||
|
||||
func new4() (_, _, _, _ *Aggregator) {
|
||||
alloc := New(4)
|
||||
return &alloc[0], &alloc[1], &alloc[2], &alloc[3]
|
||||
}
|
||||
|
||||
func sumOf(samples []aggregation.Point, k number.Kind) number.Number {
|
||||
var n number.Number
|
||||
for _, s := range samples {
|
||||
n.AddNumber(k, s.Number)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (ut *updateTest) run(t *testing.T, profile aggregatortest.Profile) {
|
||||
descriptor := aggregatortest.NewAggregatorTest(sdkapi.HistogramInstrumentKind, profile.NumberKind)
|
||||
agg, ckpt := new2()
|
||||
|
||||
all := aggregatortest.NewNumbers(profile.NumberKind)
|
||||
|
||||
for i := 0; i < ut.count; i++ {
|
||||
x := profile.Random(+1)
|
||||
all.Append(x)
|
||||
advance()
|
||||
aggregatortest.CheckedUpdate(t, agg, x, descriptor)
|
||||
|
||||
y := profile.Random(-1)
|
||||
all.Append(y)
|
||||
advance()
|
||||
aggregatortest.CheckedUpdate(t, agg, y, descriptor)
|
||||
}
|
||||
|
||||
err := agg.SynchronizedMove(ckpt, descriptor)
|
||||
require.NoError(t, err)
|
||||
|
||||
checkZero(t, agg, descriptor)
|
||||
|
||||
all.Sort()
|
||||
|
||||
pts, err := ckpt.Points()
|
||||
require.Nil(t, err)
|
||||
sum := sumOf(pts, profile.NumberKind)
|
||||
allSum := all.Sum()
|
||||
require.InEpsilon(t,
|
||||
allSum.CoerceToFloat64(profile.NumberKind),
|
||||
sum.CoerceToFloat64(profile.NumberKind),
|
||||
0.0000001,
|
||||
"Same sum")
|
||||
count, err := ckpt.Count()
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, all.Count(), count, "Same count")
|
||||
}
|
||||
|
||||
func TestExactUpdate(t *testing.T) {
|
||||
// Test with an odd an even number of measurements
|
||||
for count := 999; count <= 1000; count++ {
|
||||
t.Run(fmt.Sprint("Odd=", count%2 == 1), func(t *testing.T) {
|
||||
ut := updateTest{
|
||||
count: count,
|
||||
}
|
||||
|
||||
// Test integer and floating point
|
||||
aggregatortest.RunProfiles(t, ut.run)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
type mergeTest struct {
|
||||
count int
|
||||
absolute bool
|
||||
}
|
||||
|
||||
func advance() {
|
||||
time.Sleep(time.Nanosecond)
|
||||
}
|
||||
|
||||
func (mt *mergeTest) run(t *testing.T, profile aggregatortest.Profile) {
|
||||
descriptor := aggregatortest.NewAggregatorTest(sdkapi.HistogramInstrumentKind, profile.NumberKind)
|
||||
agg1, agg2, ckpt1, ckpt2 := new4()
|
||||
|
||||
all := aggregatortest.NewNumbers(profile.NumberKind)
|
||||
|
||||
for i := 0; i < mt.count; i++ {
|
||||
x1 := profile.Random(+1)
|
||||
all.Append(x1)
|
||||
advance()
|
||||
aggregatortest.CheckedUpdate(t, agg1, x1, descriptor)
|
||||
|
||||
x2 := profile.Random(+1)
|
||||
all.Append(x2)
|
||||
advance()
|
||||
aggregatortest.CheckedUpdate(t, agg2, x2, descriptor)
|
||||
|
||||
if !mt.absolute {
|
||||
y1 := profile.Random(-1)
|
||||
all.Append(y1)
|
||||
advance()
|
||||
aggregatortest.CheckedUpdate(t, agg1, y1, descriptor)
|
||||
|
||||
y2 := profile.Random(-1)
|
||||
all.Append(y2)
|
||||
advance()
|
||||
aggregatortest.CheckedUpdate(t, agg2, y2, descriptor)
|
||||
}
|
||||
}
|
||||
|
||||
require.NoError(t, agg1.SynchronizedMove(ckpt1, descriptor))
|
||||
require.NoError(t, agg2.SynchronizedMove(ckpt2, descriptor))
|
||||
|
||||
checkZero(t, agg1, descriptor)
|
||||
checkZero(t, agg2, descriptor)
|
||||
|
||||
aggregatortest.CheckedMerge(t, ckpt1, ckpt2, descriptor)
|
||||
|
||||
pts, err := ckpt1.Points()
|
||||
require.Nil(t, err)
|
||||
|
||||
received := aggregatortest.NewNumbers(profile.NumberKind)
|
||||
for i, s := range pts {
|
||||
received.Append(s.Number)
|
||||
|
||||
if i > 0 {
|
||||
requireNotAfter(t, pts[i-1].Time, pts[i].Time)
|
||||
}
|
||||
}
|
||||
|
||||
allSum := all.Sum()
|
||||
sum := sumOf(pts, profile.NumberKind)
|
||||
require.InEpsilon(t,
|
||||
allSum.CoerceToFloat64(profile.NumberKind),
|
||||
sum.CoerceToFloat64(profile.NumberKind),
|
||||
0.0000001,
|
||||
"Same sum - absolute")
|
||||
count, err := ckpt1.Count()
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, all.Count(), count, "Same count - absolute")
|
||||
require.Equal(t, all, received, "Same ordered contents")
|
||||
}
|
||||
|
||||
func TestExactMerge(t *testing.T) {
|
||||
// Test with an odd an even number of measurements
|
||||
for count := 999; count <= 1000; count++ {
|
||||
t.Run(fmt.Sprint("Odd=", count%2 == 1), func(t *testing.T) {
|
||||
// Test absolute and non-absolute
|
||||
for _, absolute := range []bool{false, true} {
|
||||
t.Run(fmt.Sprint("Absolute=", absolute), func(t *testing.T) {
|
||||
mt := mergeTest{
|
||||
count: count,
|
||||
absolute: absolute,
|
||||
}
|
||||
|
||||
// Test integer and floating point
|
||||
aggregatortest.RunProfiles(t, mt.run)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestExactErrors(t *testing.T) {
|
||||
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
||||
agg, ckpt := new2()
|
||||
|
||||
descriptor := aggregatortest.NewAggregatorTest(sdkapi.HistogramInstrumentKind, profile.NumberKind)
|
||||
|
||||
advance()
|
||||
aggregatortest.CheckedUpdate(t, agg, number.Number(0), descriptor)
|
||||
|
||||
if profile.NumberKind == number.Float64Kind {
|
||||
advance()
|
||||
aggregatortest.CheckedUpdate(t, agg, number.NewFloat64Number(math.NaN()), descriptor)
|
||||
}
|
||||
require.NoError(t, agg.SynchronizedMove(ckpt, descriptor))
|
||||
|
||||
count, err := ckpt.Count()
|
||||
require.Equal(t, uint64(1), count, "NaN value was not counted")
|
||||
require.Nil(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
func TestExactFloat64(t *testing.T) {
|
||||
descriptor := aggregatortest.NewAggregatorTest(sdkapi.HistogramInstrumentKind, number.Float64Kind)
|
||||
|
||||
fpsf := func(sign int) []float64 {
|
||||
// Check behavior of a bunch of odd floating
|
||||
// points except for NaN, which is invalid.
|
||||
return []float64{
|
||||
0,
|
||||
1 / math.Inf(sign),
|
||||
1,
|
||||
2,
|
||||
1e100,
|
||||
math.MaxFloat64,
|
||||
math.SmallestNonzeroFloat64,
|
||||
math.MaxFloat32,
|
||||
math.SmallestNonzeroFloat32,
|
||||
math.E,
|
||||
math.Pi,
|
||||
math.Phi,
|
||||
math.Sqrt2,
|
||||
math.SqrtE,
|
||||
math.SqrtPi,
|
||||
math.SqrtPhi,
|
||||
math.Ln2,
|
||||
math.Log2E,
|
||||
math.Ln10,
|
||||
math.Log10E,
|
||||
}
|
||||
}
|
||||
|
||||
all := aggregatortest.NewNumbers(number.Float64Kind)
|
||||
|
||||
agg, ckpt := new2()
|
||||
|
||||
startTime := time.Now()
|
||||
|
||||
for _, f := range fpsf(1) {
|
||||
all.Append(number.NewFloat64Number(f))
|
||||
advance()
|
||||
aggregatortest.CheckedUpdate(t, agg, number.NewFloat64Number(f), descriptor)
|
||||
}
|
||||
|
||||
for _, f := range fpsf(-1) {
|
||||
all.Append(number.NewFloat64Number(f))
|
||||
advance()
|
||||
aggregatortest.CheckedUpdate(t, agg, number.NewFloat64Number(f), descriptor)
|
||||
}
|
||||
|
||||
endTime := time.Now()
|
||||
|
||||
require.NoError(t, agg.SynchronizedMove(ckpt, descriptor))
|
||||
|
||||
pts, err := ckpt.Points()
|
||||
require.Nil(t, err)
|
||||
|
||||
allSum := all.Sum()
|
||||
sum := sumOf(pts, number.Float64Kind)
|
||||
require.InEpsilon(t, allSum.AsFloat64(), sum.AsFloat64(), 0.0000001, "Same sum")
|
||||
|
||||
count, err := ckpt.Count()
|
||||
require.Equal(t, all.Count(), count, "Same count")
|
||||
require.Nil(t, err)
|
||||
|
||||
po, err := ckpt.Points()
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, all.Len(), len(po), "Points() must have same length of updates")
|
||||
for i := 0; i < len(po); i++ {
|
||||
require.Equal(t, all.Points()[i], po[i].Number, "Wrong point at position %d", i)
|
||||
if i > 0 {
|
||||
requireNotAfter(t, po[i-1].Time, po[i].Time)
|
||||
}
|
||||
}
|
||||
requireNotAfter(t, startTime, po[0].Time)
|
||||
requireNotAfter(t, po[len(po)-1].Time, endTime)
|
||||
}
|
||||
|
||||
func TestSynchronizedMoveReset(t *testing.T) {
|
||||
aggregatortest.SynchronizedMoveResetTest(
|
||||
t,
|
||||
sdkapi.HistogramInstrumentKind,
|
||||
func(desc *sdkapi.Descriptor) export.Aggregator {
|
||||
return &New(1)[0]
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func TestMergeBehavior(t *testing.T) {
|
||||
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
||||
for _, forward := range []bool{false, true} {
|
||||
t.Run(fmt.Sprint("Forward=", forward), func(t *testing.T) {
|
||||
descriptor := aggregatortest.NewAggregatorTest(sdkapi.HistogramInstrumentKind, profile.NumberKind)
|
||||
agg1, agg2, ckpt, _ := new4()
|
||||
|
||||
all := aggregatortest.NewNumbers(profile.NumberKind)
|
||||
|
||||
for i := 0; i < 100; i++ {
|
||||
x1 := profile.Random(+1)
|
||||
all.Append(x1)
|
||||
advance()
|
||||
aggregatortest.CheckedUpdate(t, agg1, x1, descriptor)
|
||||
}
|
||||
|
||||
for i := 0; i < 100; i++ {
|
||||
x2 := profile.Random(+1)
|
||||
all.Append(x2)
|
||||
advance()
|
||||
aggregatortest.CheckedUpdate(t, agg2, x2, descriptor)
|
||||
}
|
||||
|
||||
if forward {
|
||||
aggregatortest.CheckedMerge(t, ckpt, agg1, descriptor)
|
||||
aggregatortest.CheckedMerge(t, ckpt, agg2, descriptor)
|
||||
} else {
|
||||
aggregatortest.CheckedMerge(t, ckpt, agg2, descriptor)
|
||||
aggregatortest.CheckedMerge(t, ckpt, agg1, descriptor)
|
||||
}
|
||||
|
||||
pts, err := ckpt.Points()
|
||||
require.NoError(t, err)
|
||||
|
||||
received := aggregatortest.NewNumbers(profile.NumberKind)
|
||||
for i, s := range pts {
|
||||
received.Append(s.Number)
|
||||
|
||||
if i > 0 {
|
||||
requireNotAfter(t, pts[i-1].Time, pts[i].Time)
|
||||
}
|
||||
}
|
||||
|
||||
allSum := all.Sum()
|
||||
sum := sumOf(pts, profile.NumberKind)
|
||||
require.InEpsilon(t,
|
||||
allSum.CoerceToFloat64(profile.NumberKind),
|
||||
sum.CoerceToFloat64(profile.NumberKind),
|
||||
0.0000001,
|
||||
"Same sum - absolute")
|
||||
count, err := ckpt.Count()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, all.Count(), count, "Same count - absolute")
|
||||
require.Equal(t, all, received, "Same ordered contents")
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
@@ -32,7 +32,6 @@ type Aggregator struct {
|
||||
}
|
||||
|
||||
var _ export.Aggregator = &Aggregator{}
|
||||
var _ export.Subtractor = &Aggregator{}
|
||||
var _ aggregation.Sum = &Aggregator{}
|
||||
|
||||
// New returns a new counter aggregator implemented by atomic
|
||||
@@ -88,19 +87,3 @@ func (c *Aggregator) Merge(oa export.Aggregator, desc *sdkapi.Descriptor) error
|
||||
c.value.AddNumber(desc.NumberKind(), o.value)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Aggregator) Subtract(opAgg, resAgg export.Aggregator, descriptor *sdkapi.Descriptor) error {
|
||||
op, _ := opAgg.(*Aggregator)
|
||||
if op == nil {
|
||||
return aggregator.NewInconsistentAggregatorError(c, opAgg)
|
||||
}
|
||||
|
||||
res, _ := resAgg.(*Aggregator)
|
||||
if res == nil {
|
||||
return aggregator.NewInconsistentAggregatorError(c, resAgg)
|
||||
}
|
||||
|
||||
res.value = c.value
|
||||
res.value.AddNumber(descriptor.NumberKind(), number.NewNumberSignChange(descriptor.NumberKind(), op.value))
|
||||
return nil
|
||||
}
|
||||
|
@@ -60,16 +60,6 @@ func (f *benchFixture) meterMust() metric.MeterMust {
|
||||
return metric.Must(f.meter)
|
||||
}
|
||||
|
||||
func makeManyLabels(n int) [][]attribute.KeyValue {
|
||||
r := make([][]attribute.KeyValue, n)
|
||||
|
||||
for i := 0; i < n; i++ {
|
||||
r[i] = makeLabels(1)
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func makeLabels(n int) []attribute.KeyValue {
|
||||
used := map[string]bool{}
|
||||
l := make([]attribute.KeyValue, n)
|
||||
@@ -123,50 +113,6 @@ func BenchmarkInt64CounterAddWithLabels_16(b *testing.B) {
|
||||
// Note: performance does not depend on label set size for the
|
||||
// benchmarks below--all are benchmarked for a single attribute.
|
||||
|
||||
func BenchmarkAcquireNewHandle(b *testing.B) {
|
||||
fix := newFixture(b)
|
||||
labelSets := makeManyLabels(b.N)
|
||||
cnt := fix.meterMust().NewInt64Counter("int64.sum")
|
||||
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
cnt.Bind(labelSets[i]...)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkAcquireExistingHandle(b *testing.B) {
|
||||
fix := newFixture(b)
|
||||
labelSets := makeManyLabels(b.N)
|
||||
cnt := fix.meterMust().NewInt64Counter("int64.sum")
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
cnt.Bind(labelSets[i]...).Unbind()
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
cnt.Bind(labelSets[i]...)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkAcquireReleaseExistingHandle(b *testing.B) {
|
||||
fix := newFixture(b)
|
||||
labelSets := makeManyLabels(b.N)
|
||||
cnt := fix.meterMust().NewInt64Counter("int64.sum")
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
cnt.Bind(labelSets[i]...).Unbind()
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
cnt.Bind(labelSets[i]...).Unbind()
|
||||
}
|
||||
}
|
||||
|
||||
// Iterators
|
||||
|
||||
var benchmarkIteratorVar attribute.KeyValue
|
||||
@@ -241,20 +187,6 @@ func BenchmarkInt64CounterAdd(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkInt64CounterHandleAdd(b *testing.B) {
|
||||
ctx := context.Background()
|
||||
fix := newFixture(b)
|
||||
labs := makeLabels(1)
|
||||
cnt := fix.meterMust().NewInt64Counter("int64.sum")
|
||||
handle := cnt.Bind(labs...)
|
||||
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
handle.Add(ctx, 1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkFloat64CounterAdd(b *testing.B) {
|
||||
ctx := context.Background()
|
||||
fix := newFixture(b)
|
||||
@@ -268,20 +200,6 @@ func BenchmarkFloat64CounterAdd(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkFloat64CounterHandleAdd(b *testing.B) {
|
||||
ctx := context.Background()
|
||||
fix := newFixture(b)
|
||||
labs := makeLabels(1)
|
||||
cnt := fix.meterMust().NewFloat64Counter("float64.sum")
|
||||
handle := cnt.Bind(labs...)
|
||||
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
handle.Add(ctx, 1.1)
|
||||
}
|
||||
}
|
||||
|
||||
// LastValue
|
||||
|
||||
func BenchmarkInt64LastValueAdd(b *testing.B) {
|
||||
@@ -297,20 +215,6 @@ func BenchmarkInt64LastValueAdd(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkInt64LastValueHandleAdd(b *testing.B) {
|
||||
ctx := context.Background()
|
||||
fix := newFixture(b)
|
||||
labs := makeLabels(1)
|
||||
mea := fix.meterMust().NewInt64Histogram("int64.lastvalue")
|
||||
handle := mea.Bind(labs...)
|
||||
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
handle.Record(ctx, int64(i))
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkFloat64LastValueAdd(b *testing.B) {
|
||||
ctx := context.Background()
|
||||
fix := newFixture(b)
|
||||
@@ -324,20 +228,6 @@ func BenchmarkFloat64LastValueAdd(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkFloat64LastValueHandleAdd(b *testing.B) {
|
||||
ctx := context.Background()
|
||||
fix := newFixture(b)
|
||||
labs := makeLabels(1)
|
||||
mea := fix.meterMust().NewFloat64Histogram("float64.lastvalue")
|
||||
handle := mea.Bind(labs...)
|
||||
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
handle.Record(ctx, float64(i))
|
||||
}
|
||||
}
|
||||
|
||||
// Histograms
|
||||
|
||||
func benchmarkInt64HistogramAdd(b *testing.B, name string) {
|
||||
@@ -353,20 +243,6 @@ func benchmarkInt64HistogramAdd(b *testing.B, name string) {
|
||||
}
|
||||
}
|
||||
|
||||
func benchmarkInt64HistogramHandleAdd(b *testing.B, name string) {
|
||||
ctx := context.Background()
|
||||
fix := newFixture(b)
|
||||
labs := makeLabels(1)
|
||||
mea := fix.meterMust().NewInt64Histogram(name)
|
||||
handle := mea.Bind(labs...)
|
||||
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
handle.Record(ctx, int64(i))
|
||||
}
|
||||
}
|
||||
|
||||
func benchmarkFloat64HistogramAdd(b *testing.B, name string) {
|
||||
ctx := context.Background()
|
||||
fix := newFixture(b)
|
||||
@@ -380,20 +256,6 @@ func benchmarkFloat64HistogramAdd(b *testing.B, name string) {
|
||||
}
|
||||
}
|
||||
|
||||
func benchmarkFloat64HistogramHandleAdd(b *testing.B, name string) {
|
||||
ctx := context.Background()
|
||||
fix := newFixture(b)
|
||||
labs := makeLabels(1)
|
||||
mea := fix.meterMust().NewFloat64Histogram(name)
|
||||
handle := mea.Bind(labs...)
|
||||
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
handle.Record(ctx, float64(i))
|
||||
}
|
||||
}
|
||||
|
||||
// Observers
|
||||
|
||||
func BenchmarkObserverRegistration(b *testing.B) {
|
||||
@@ -447,36 +309,20 @@ func BenchmarkInt64MaxSumCountAdd(b *testing.B) {
|
||||
benchmarkInt64HistogramAdd(b, "int64.minmaxsumcount")
|
||||
}
|
||||
|
||||
func BenchmarkInt64MaxSumCountHandleAdd(b *testing.B) {
|
||||
benchmarkInt64HistogramHandleAdd(b, "int64.minmaxsumcount")
|
||||
}
|
||||
|
||||
func BenchmarkFloat64MaxSumCountAdd(b *testing.B) {
|
||||
benchmarkFloat64HistogramAdd(b, "float64.minmaxsumcount")
|
||||
}
|
||||
|
||||
func BenchmarkFloat64MaxSumCountHandleAdd(b *testing.B) {
|
||||
benchmarkFloat64HistogramHandleAdd(b, "float64.minmaxsumcount")
|
||||
}
|
||||
|
||||
// Exact
|
||||
|
||||
func BenchmarkInt64ExactAdd(b *testing.B) {
|
||||
benchmarkInt64HistogramAdd(b, "int64.exact")
|
||||
}
|
||||
|
||||
func BenchmarkInt64ExactHandleAdd(b *testing.B) {
|
||||
benchmarkInt64HistogramHandleAdd(b, "int64.exact")
|
||||
}
|
||||
|
||||
func BenchmarkFloat64ExactAdd(b *testing.B) {
|
||||
benchmarkFloat64HistogramAdd(b, "float64.exact")
|
||||
}
|
||||
|
||||
func BenchmarkFloat64ExactHandleAdd(b *testing.B) {
|
||||
benchmarkFloat64HistogramHandleAdd(b, "float64.exact")
|
||||
}
|
||||
|
||||
// BatchRecord
|
||||
|
||||
func benchmarkBatchRecord8Labels(b *testing.B, numInst int) {
|
||||
|
@@ -56,14 +56,9 @@ var ErrControllerStarted = fmt.Errorf("controller already started")
|
||||
// using the export.Reader RWLock interface. Collection will
|
||||
// be blocked by a pull request in the basic controller.
|
||||
type Controller struct {
|
||||
// lock protects libraries and synchronizes Start() and Stop().
|
||||
lock sync.Mutex
|
||||
// TODO: libraries is synchronized by lock, but could be
|
||||
// accomplished using a sync.Map. The SDK specification will
|
||||
// probably require this, as the draft already states that
|
||||
// Stop() and MeterProvider.Meter() should not block each
|
||||
// other.
|
||||
libraries map[instrumentation.Library]*registry.UniqueInstrumentMeterImpl
|
||||
// lock synchronizes Start() and Stop().
|
||||
lock sync.Mutex
|
||||
libraries sync.Map
|
||||
checkpointerFactory export.CheckpointerFactory
|
||||
|
||||
resource *resource.Resource
|
||||
@@ -93,21 +88,18 @@ func (c *Controller) Meter(instrumentationName string, opts ...metric.MeterOptio
|
||||
SchemaURL: cfg.SchemaURL(),
|
||||
}
|
||||
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
m, ok := c.libraries[library]
|
||||
m, ok := c.libraries.Load(library)
|
||||
if !ok {
|
||||
checkpointer := c.checkpointerFactory.NewCheckpointer()
|
||||
accumulator := sdk.NewAccumulator(checkpointer)
|
||||
m = registry.NewUniqueInstrumentMeterImpl(&accumulatorCheckpointer{
|
||||
Accumulator: accumulator,
|
||||
checkpointer: checkpointer,
|
||||
library: library,
|
||||
})
|
||||
|
||||
c.libraries[library] = m
|
||||
m, _ = c.libraries.LoadOrStore(
|
||||
library,
|
||||
registry.NewUniqueInstrumentMeterImpl(&accumulatorCheckpointer{
|
||||
Accumulator: sdk.NewAccumulator(checkpointer),
|
||||
checkpointer: checkpointer,
|
||||
library: library,
|
||||
}))
|
||||
}
|
||||
return metric.WrapMeterImpl(m)
|
||||
return metric.WrapMeterImpl(m.(*registry.UniqueInstrumentMeterImpl))
|
||||
}
|
||||
|
||||
type accumulatorCheckpointer struct {
|
||||
@@ -138,7 +130,6 @@ func New(checkpointerFactory export.CheckpointerFactory, opts ...Option) *Contro
|
||||
}
|
||||
}
|
||||
return &Controller{
|
||||
libraries: map[instrumentation.Library]*registry.UniqueInstrumentMeterImpl{},
|
||||
checkpointerFactory: checkpointerFactory,
|
||||
exporter: c.Exporter,
|
||||
resource: c.Resource,
|
||||
@@ -251,16 +242,14 @@ func (c *Controller) collect(ctx context.Context) error {
|
||||
// accumulatorList returns a snapshot of current accumulators
|
||||
// registered to this controller. This briefly locks the controller.
|
||||
func (c *Controller) accumulatorList() []*accumulatorCheckpointer {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
var r []*accumulatorCheckpointer
|
||||
for _, entry := range c.libraries {
|
||||
acc, ok := entry.MeterImpl().(*accumulatorCheckpointer)
|
||||
c.libraries.Range(func(key, value interface{}) bool {
|
||||
acc, ok := value.(*registry.UniqueInstrumentMeterImpl).MeterImpl().(*accumulatorCheckpointer)
|
||||
if ok {
|
||||
r = append(r, acc)
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
return r
|
||||
}
|
||||
|
||||
|
@@ -136,7 +136,7 @@ func TestInputRangeHistogram(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
meter, sdk, _, processor := newSDK(t)
|
||||
|
||||
histogram := Must(meter).NewFloat64Histogram("name.exact")
|
||||
histogram := Must(meter).NewFloat64Histogram("name.histogram")
|
||||
|
||||
histogram.Record(ctx, math.NaN())
|
||||
require.Equal(t, aggregation.ErrNaNInput, testHandler.Flush())
|
||||
@@ -151,7 +151,7 @@ func TestInputRangeHistogram(t *testing.T) {
|
||||
checkpointed = sdk.Collect(ctx)
|
||||
|
||||
require.Equal(t, map[string]float64{
|
||||
"name.exact//": 3,
|
||||
"name.histogram//": 3,
|
||||
}, processor.Values())
|
||||
require.Equal(t, 1, checkpointed)
|
||||
require.Nil(t, testHandler.Flush())
|
||||
@@ -450,8 +450,8 @@ func TestRecordBatch(t *testing.T) {
|
||||
|
||||
counter1 := Must(meter).NewInt64Counter("int64.sum")
|
||||
counter2 := Must(meter).NewFloat64Counter("float64.sum")
|
||||
histogram1 := Must(meter).NewInt64Histogram("int64.exact")
|
||||
histogram2 := Must(meter).NewFloat64Histogram("float64.exact")
|
||||
histogram1 := Must(meter).NewInt64Histogram("int64.histogram")
|
||||
histogram2 := Must(meter).NewFloat64Histogram("float64.histogram")
|
||||
|
||||
sdk.RecordBatch(
|
||||
ctx,
|
||||
@@ -468,10 +468,10 @@ func TestRecordBatch(t *testing.T) {
|
||||
sdk.Collect(ctx)
|
||||
|
||||
require.EqualValues(t, map[string]float64{
|
||||
"int64.sum/A=B,C=D/": 1,
|
||||
"float64.sum/A=B,C=D/": 2,
|
||||
"int64.exact/A=B,C=D/": 3,
|
||||
"float64.exact/A=B,C=D/": 4,
|
||||
"int64.sum/A=B,C=D/": 1,
|
||||
"float64.sum/A=B,C=D/": 2,
|
||||
"int64.histogram/A=B,C=D/": 3,
|
||||
"float64.histogram/A=B,C=D/": 4,
|
||||
}, processor.Values())
|
||||
}
|
||||
|
||||
@@ -483,16 +483,14 @@ func TestRecordPersistence(t *testing.T) {
|
||||
meter, sdk, selector, _ := newSDK(t)
|
||||
|
||||
c := Must(meter).NewFloat64Counter("name.sum")
|
||||
b := c.Bind(attribute.String("bound", "true"))
|
||||
uk := attribute.String("bound", "false")
|
||||
|
||||
for i := 0; i < 100; i++ {
|
||||
c.Add(ctx, 1, uk)
|
||||
b.Add(ctx, 1)
|
||||
sdk.Collect(ctx)
|
||||
}
|
||||
|
||||
require.Equal(t, 4, selector.newAggCount)
|
||||
require.Equal(t, 2, selector.newAggCount)
|
||||
}
|
||||
|
||||
func TestIncorrectInstruments(t *testing.T) {
|
||||
|
@@ -28,9 +28,7 @@ and asynchronous instruments. There are two constructors per instrument for
|
||||
the two kinds of number (int64, float64).
|
||||
|
||||
Synchronous instruments are managed by a sync.Map containing a *record
|
||||
with the current state for each synchronous instrument. A bound
|
||||
instrument encapsulates a direct pointer to the record, allowing
|
||||
bound metric events to bypass a sync.Map lookup. A lock-free
|
||||
with the current state for each synchronous instrument. A lock-free
|
||||
algorithm is used to protect against races when adding and removing
|
||||
items from the sync.Map.
|
||||
|
||||
@@ -45,7 +43,7 @@ record contains a set of recorders for every specific label set used in the
|
||||
callback.
|
||||
|
||||
A sync.Map maintains the mapping of current instruments and label sets to
|
||||
internal records. To create a new bound instrument, the SDK consults the Map to
|
||||
internal records. To find a record, the SDK consults the Map to
|
||||
locate an existing record, otherwise it constructs a new record. The SDK
|
||||
maintains a count of the number of references to each record, ensuring
|
||||
that records are not reclaimed from the Map while they are still active
|
||||
|
@@ -43,11 +43,11 @@ replace go.opentelemetry.io/otel/trace => ../../trace
|
||||
require (
|
||||
github.com/benbjohnson/clock v1.2.0 // do not upgrade to v1.1.x because it would require Go >= 1.15
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.opentelemetry.io/otel v1.1.0
|
||||
go.opentelemetry.io/otel/internal/metric v0.24.0
|
||||
go.opentelemetry.io/otel/metric v0.24.0
|
||||
go.opentelemetry.io/otel/sdk v1.1.0
|
||||
go.opentelemetry.io/otel/sdk/export/metric v0.24.0
|
||||
go.opentelemetry.io/otel v1.2.0
|
||||
go.opentelemetry.io/otel/internal/metric v0.25.0
|
||||
go.opentelemetry.io/otel/metric v0.25.0
|
||||
go.opentelemetry.io/otel/sdk v1.2.0
|
||||
go.opentelemetry.io/otel/sdk/export/metric v0.25.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel/example/passthrough => ../../example/passthrough
|
||||
|
@@ -76,11 +76,6 @@ type (
|
||||
// values in a single collection round.
|
||||
current export.Aggregator
|
||||
|
||||
// delta, if non-nil, refers to an Aggregator owned by
|
||||
// the processor used to compute deltas between
|
||||
// precomputed sums.
|
||||
delta export.Aggregator
|
||||
|
||||
// cumulative, if non-nil, refers to an Aggregator owned
|
||||
// by the processor used to store the last cumulative
|
||||
// value.
|
||||
@@ -94,9 +89,6 @@ type (
|
||||
sync.RWMutex
|
||||
values map[stateKey]*stateValue
|
||||
|
||||
// Note: the timestamp logic currently assumes all
|
||||
// exports are deltas.
|
||||
|
||||
processStart time.Time
|
||||
intervalStart time.Time
|
||||
intervalEnd time.Time
|
||||
@@ -124,8 +116,8 @@ var ErrInvalidTemporality = fmt.Errorf("invalid aggregation temporality")
|
||||
// New returns a basic Processor that is also a Checkpointer using the provided
|
||||
// AggregatorSelector to select Aggregators. The TemporalitySelector
|
||||
// is consulted to determine the kind(s) of exporter that will consume
|
||||
// data, so that this Processor can prepare to compute Delta or
|
||||
// Cumulative Aggregations as needed.
|
||||
// data, so that this Processor can prepare to compute Cumulative Aggregations
|
||||
// as needed.
|
||||
func New(aselector export.AggregatorSelector, tselector aggregation.TemporalitySelector, opts ...Option) *Processor {
|
||||
return NewFactory(aselector, tselector, opts...).NewCheckpointer().(*Processor)
|
||||
}
|
||||
@@ -191,13 +183,17 @@ func (b *Processor) Process(accum export.Accumulation) error {
|
||||
}
|
||||
if stateful {
|
||||
if desc.InstrumentKind().PrecomputedSum() {
|
||||
// If we know we need to compute deltas, allocate two aggregators.
|
||||
b.AggregatorFor(desc, &newValue.cumulative, &newValue.delta)
|
||||
} else {
|
||||
// In this case we are certain not to need a delta, only allocate
|
||||
// a cumulative aggregator.
|
||||
b.AggregatorFor(desc, &newValue.cumulative)
|
||||
// To convert precomputed sums to
|
||||
// deltas requires two aggregators to
|
||||
// be allocated, one for the prior
|
||||
// value and one for the output delta.
|
||||
// This functionality was removed from
|
||||
// the basic processor in PR #2350.
|
||||
return aggregation.ErrNoCumulativeToDelta
|
||||
}
|
||||
// In this case allocate one aggregator to
|
||||
// save the current state.
|
||||
b.AggregatorFor(desc, &newValue.cumulative)
|
||||
}
|
||||
b.state.values[key] = newValue
|
||||
return nil
|
||||
@@ -310,28 +306,15 @@ func (b *Processor) FinishCollection() error {
|
||||
continue
|
||||
}
|
||||
|
||||
// Update Aggregator state to support exporting either a
|
||||
// delta or a cumulative aggregation.
|
||||
var err error
|
||||
if mkind.PrecomputedSum() {
|
||||
if currentSubtractor, ok := value.current.(export.Subtractor); ok {
|
||||
// This line is equivalent to:
|
||||
// value.delta = currentSubtractor - value.cumulative
|
||||
err = currentSubtractor.Subtract(value.cumulative, value.delta, key.descriptor)
|
||||
|
||||
if err == nil {
|
||||
err = value.current.SynchronizedMove(value.cumulative, key.descriptor)
|
||||
}
|
||||
} else {
|
||||
err = aggregation.ErrNoSubtraction
|
||||
}
|
||||
} else {
|
||||
// The only kind of aggregators that are not stateless
|
||||
// are the ones needing delta to cumulative
|
||||
// conversion. Merge aggregator state in this case.
|
||||
if !mkind.PrecomputedSum() {
|
||||
// This line is equivalent to:
|
||||
// value.cumulative = value.cumulative + value.delta
|
||||
err = value.cumulative.Merge(value.current, key.descriptor)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
// value.cumulative = value.cumulative + value.current
|
||||
if err := value.cumulative.Merge(value.current, key.descriptor); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -350,13 +333,8 @@ func (b *state) ForEach(exporter aggregation.TemporalitySelector, f func(export.
|
||||
var agg aggregation.Aggregation
|
||||
var start time.Time
|
||||
|
||||
// If the processor does not have Config.Memory and it was not updated
|
||||
// in the prior round, do not visit this value.
|
||||
if !b.config.Memory && value.updated != (b.finishedCollection-1) {
|
||||
continue
|
||||
}
|
||||
|
||||
aggTemp := exporter.TemporalityFor(key.descriptor, value.current.Aggregation().Kind())
|
||||
|
||||
switch aggTemp {
|
||||
case aggregation.CumulativeTemporality:
|
||||
// If stateful, the sum has been computed. If stateless, the
|
||||
@@ -372,16 +350,23 @@ func (b *state) ForEach(exporter aggregation.TemporalitySelector, f func(export.
|
||||
case aggregation.DeltaTemporality:
|
||||
// Precomputed sums are a special case.
|
||||
if mkind.PrecomputedSum() {
|
||||
agg = value.delta.Aggregation()
|
||||
} else {
|
||||
agg = value.current.Aggregation()
|
||||
// This functionality was removed from
|
||||
// the basic processor in PR #2350.
|
||||
return aggregation.ErrNoCumulativeToDelta
|
||||
}
|
||||
agg = value.current.Aggregation()
|
||||
start = b.intervalStart
|
||||
|
||||
default:
|
||||
return fmt.Errorf("%v: %w", aggTemp, ErrInvalidTemporality)
|
||||
}
|
||||
|
||||
// If the processor does not have Config.Memory and it was not updated
|
||||
// in the prior round, do not visit this value.
|
||||
if !b.config.Memory && value.updated != (b.finishedCollection-1) {
|
||||
continue
|
||||
}
|
||||
|
||||
if err := f(export.NewRecord(
|
||||
key.descriptor,
|
||||
value.labels,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user