1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-01-03 22:52:30 +02:00

Move export types into trace and metric-specific subdirs (#289)

This commit is contained in:
Joshua MacDonald 2019-11-05 13:08:55 -08:00 committed by GitHub
parent 17439d879c
commit 68bd627ac2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 165 additions and 183 deletions

View File

@ -24,7 +24,7 @@ import (
"go.opentelemetry.io/otel/api/core"
gen "go.opentelemetry.io/otel/exporter/trace/jaeger/internal/gen-go/jaeger"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/trace"
)
const defaultServiceName = "OpenTelemetry"

View File

@ -34,7 +34,7 @@ import (
"go.opentelemetry.io/otel/api/core"
gen "go.opentelemetry.io/otel/exporter/trace/jaeger/internal/gen-go/jaeger"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/trace"
)
func TestNewExporter(t *testing.T) {

View File

@ -26,7 +26,7 @@ import (
"google.golang.org/api/option"
"go.opentelemetry.io/otel/api/key"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/trace"
)
// Option is function type that is passed to the exporter initialization function.

View File

@ -21,7 +21,7 @@ import (
traceclient "cloud.google.com/go/trace/apiv2"
tracepb "google.golang.org/genproto/googleapis/devtools/cloudtrace/v2"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/trace"
)
// traceExporter is an imeplementation of trace.Exporter and trace.BatchExporter

View File

@ -29,7 +29,7 @@ import (
"go.opentelemetry.io/otel/api/core"
opentelemetry "go.opentelemetry.io/otel/sdk"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/trace"
)
const (

View File

@ -20,7 +20,7 @@ import (
"io"
"os"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/trace"
)
// Options are the options to be used when initializing a stdout export.

View File

@ -26,7 +26,7 @@ import (
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/key"
"go.opentelemetry.io/otel/api/trace"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/trace"
)
func TestExporter_ExportSpan(t *testing.T) {

View File

@ -26,7 +26,7 @@ import (
"go.opentelemetry.io/otel/api/key"
"go.opentelemetry.io/otel/global"
"go.opentelemetry.io/otel/plugin/httptrace"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/trace"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)

View File

@ -1,63 +0,0 @@
// Copyright 2019, 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 export
import (
"context"
)
// SpanSyncer is a type for functions that receive a single sampled trace span.
//
// The ExportSpan method is called synchronously. Therefore, it should not take
// forever to process the span.
//
// The SpanData should not be modified.
type SpanSyncer interface {
ExportSpan(context.Context, *SpanData)
}
// SpanBatcher is a type for functions that receive batched of sampled trace
// spans.
//
// The ExportSpans method is called asynchronously. However its should not take
// forever to process the spans.
//
// The SpanData should not be modified.
type SpanBatcher interface {
ExportSpans(context.Context, []*SpanData)
}
// MetricBatcher is responsible for deciding which kind of aggregation
// to use and gathering exported results from the SDK. The standard SDK
// supports binding only one of these interfaces, i.e., a single exporter.
//
// Multiple-exporters could be implemented by implementing this interface
// for a group of MetricBatcher.
type MetricBatcher interface {
// AggregatorFor should return the kind of aggregator
// suited to the requested export. Returning `nil`
// indicates to ignore the metric update.
//
// Note: This is context-free because the handle should not be
// bound to the incoming context. This call should not block.
AggregatorFor(MetricRecord) MetricAggregator
// Export receives pairs of records and aggregators
// during the SDK Collect(). Exporter implementations
// must access the specific aggregator to receive the
// exporter data, since the format of the data varies
// by aggregation.
Export(context.Context, MetricRecord, MetricAggregator)
}

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package export
package metric // import "go.opentelemetry.io/otel/sdk/export/metric"
import (
"context"
@ -21,26 +21,49 @@ import (
"go.opentelemetry.io/otel/api/unit"
)
// MetricAggregator implements a specific aggregation behavior, e.g.,
// Batcher is responsible for deciding which kind of aggregation
// to use and gathering exported results from the SDK. The standard SDK
// supports binding only one of these interfaces, i.e., a single exporter.
//
// Multiple-exporters could be implemented by implementing this interface
// for a group of Batcher.
type Batcher interface {
// AggregatorFor should return the kind of aggregator
// suited to the requested export. Returning `nil`
// indicates to ignore the metric update.
//
// Note: This is context-free because the handle should not be
// bound to the incoming context. This call should not block.
AggregatorFor(Record) Aggregator
// Export receives pairs of records and aggregators
// during the SDK Collect(). Exporter implementations
// must access the specific aggregator to receive the
// exporter data, since the format of the data varies
// by aggregation.
Export(context.Context, Record, Aggregator)
}
// Aggregator implements a specific aggregation behavior, e.g.,
// a counter, a gauge, a histogram.
type MetricAggregator interface {
type Aggregator interface {
// Update receives a new measured value and incorporates it
// into the aggregation.
Update(context.Context, core.Number, MetricRecord)
Update(context.Context, core.Number, Record)
// Collect is called during the SDK Collect() to
// finish one period of aggregation. Collect() is
// called in a single-threaded context. Update()
// calls may arrive concurrently.
Collect(context.Context, MetricRecord, MetricBatcher)
Collect(context.Context, Record, Batcher)
// Merge combines state from two aggregators into one.
Merge(MetricAggregator, *Descriptor)
Merge(Aggregator, *Descriptor)
}
// MetricRecord is the unit of export, pairing a metric
// Record is the unit of export, pairing a metric
// instrument and set of labels.
type MetricRecord interface {
type Record interface {
// Descriptor() describes the metric instrument.
Descriptor() *Descriptor
@ -49,19 +72,19 @@ type MetricRecord interface {
Labels() []core.KeyValue
}
// MetricKind describes the kind of instrument.
type MetricKind int8
// Kind describes the kind of instrument.
type Kind int8
const (
CounterMetricKind MetricKind = iota
GaugeMetricKind
MeasureMetricKind
CounterKind Kind = iota
GaugeKind
MeasureKind
)
// Descriptor describes a metric instrument to the exporter.
type Descriptor struct {
name string
metricKind MetricKind
metricKind Kind
keys []core.Key
description string
unit unit.Unit
@ -70,10 +93,10 @@ type Descriptor struct {
}
// NewDescriptor builds a new descriptor, for use by `Meter`
// implementations.
// implementations to interface with a metric export pipeline.
func NewDescriptor(
name string,
metricKind MetricKind,
metricKind Kind,
keys []core.Key,
description string,
unit unit.Unit,
@ -95,7 +118,7 @@ func (d *Descriptor) Name() string {
return d.name
}
func (d *Descriptor) MetricKind() MetricKind {
func (d *Descriptor) MetricKind() Kind {
return d.metricKind
}

View File

@ -12,9 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package export
package trace // import "go.opentelemetry.io/otel/sdk/export/trace"
import (
"context"
"time"
"google.golang.org/grpc/codes"
@ -23,6 +24,27 @@ import (
apitrace "go.opentelemetry.io/otel/api/trace"
)
// SpanSyncer is a type for functions that receive a single sampled trace span.
//
// The ExportSpan method is called synchronously. Therefore, it should not take
// forever to process the span.
//
// The SpanData should not be modified.
type SpanSyncer interface {
ExportSpan(context.Context, *SpanData)
}
// SpanBatcher is a type for functions that receive batched of sampled trace
// spans.
//
// The ExportSpans method is called asynchronously. However its should not take
// forever to process the spans.
//
// The SpanData should not be modified.
type SpanBatcher interface {
ExportSpans(context.Context, []*SpanData)
}
// SpanData contains all the information collected by a span.
type SpanData struct {
SpanContext core.SpanContext

View File

@ -22,7 +22,7 @@ import (
"unsafe"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/metric/aggregator"
)
@ -37,7 +37,7 @@ type (
Points []core.Number
)
var _ export.MetricAggregator = &Aggregator{}
var _ export.Aggregator = &Aggregator{}
func New() *Aggregator {
return &Aggregator{}
@ -68,7 +68,7 @@ func (c *Aggregator) Quantile(q float64) (core.Number, error) {
return c.checkpoint.Quantile(q)
}
func (c *Aggregator) Collect(ctx context.Context, rec export.MetricRecord, exp export.MetricBatcher) {
func (c *Aggregator) Collect(ctx context.Context, rec export.Record, exp export.Batcher) {
c.lock.Lock()
c.checkpoint, c.current = c.current, nil
c.lock.Unlock()
@ -87,7 +87,7 @@ func (c *Aggregator) Collect(ctx context.Context, rec export.MetricRecord, exp e
exp.Export(ctx, rec, c)
}
func (c *Aggregator) Update(_ context.Context, number core.Number, rec export.MetricRecord) {
func (c *Aggregator) Update(_ context.Context, number core.Number, rec export.Record) {
desc := rec.Descriptor()
kind := desc.NumberKind()
@ -107,7 +107,7 @@ func (c *Aggregator) Update(_ context.Context, number core.Number, rec export.Me
c.lock.Unlock()
}
func (c *Aggregator) Merge(oa export.MetricAggregator, desc *export.Descriptor) {
func (c *Aggregator) Merge(oa export.Aggregator, desc *export.Descriptor) {
o, _ := oa.(*Aggregator)
if o == nil {
// TODO warn

View File

@ -23,7 +23,7 @@ import (
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/metric/aggregator"
"go.opentelemetry.io/otel/sdk/metric/aggregator/test"
)
@ -36,7 +36,7 @@ type updateTest struct {
func (ut *updateTest) run(t *testing.T, profile test.Profile) {
ctx := context.Background()
batcher, record := test.NewAggregatorTest(export.MeasureMetricKind, profile.NumberKind, !ut.absolute)
batcher, record := test.NewAggregatorTest(export.MeasureKind, profile.NumberKind, !ut.absolute)
agg := New()
@ -106,7 +106,7 @@ type mergeTest struct {
func (mt *mergeTest) run(t *testing.T, profile test.Profile) {
ctx := context.Background()
batcher, record := test.NewAggregatorTest(export.MeasureMetricKind, profile.NumberKind, !mt.absolute)
batcher, record := test.NewAggregatorTest(export.MeasureKind, profile.NumberKind, !mt.absolute)
agg1 := New()
agg2 := New()
@ -198,7 +198,7 @@ func TestArrayErrors(t *testing.T) {
ctx := context.Background()
batcher, record := test.NewAggregatorTest(export.MeasureMetricKind, profile.NumberKind, false)
batcher, record := test.NewAggregatorTest(export.MeasureKind, profile.NumberKind, false)
agg.Update(ctx, core.Number(0), record)
@ -226,7 +226,7 @@ func TestArrayErrors(t *testing.T) {
func TestArrayFloat64(t *testing.T) {
for _, absolute := range []bool{false, true} {
t.Run(fmt.Sprint("Absolute=", absolute), func(t *testing.T) {
batcher, record := test.NewAggregatorTest(export.MeasureMetricKind, core.Float64NumberKind, !absolute)
batcher, record := test.NewAggregatorTest(export.MeasureKind, core.Float64NumberKind, !absolute)
fpsf := func(sign int) []float64 {
// Check behavior of a bunch of odd floating

View File

@ -18,7 +18,7 @@ import (
"context"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/metric"
)
// Aggregator aggregates counter events.
@ -30,7 +30,7 @@ type Aggregator struct {
checkpoint core.Number
}
var _ export.MetricAggregator = &Aggregator{}
var _ export.Aggregator = &Aggregator{}
// New returns a new counter aggregator. This aggregator computes an
// atomic sum.
@ -44,14 +44,14 @@ func (c *Aggregator) AsNumber() core.Number {
}
// Collect checkpoints the current value (atomically) and exports it.
func (c *Aggregator) Collect(ctx context.Context, rec export.MetricRecord, exp export.MetricBatcher) {
func (c *Aggregator) Collect(ctx context.Context, rec export.Record, exp export.Batcher) {
c.checkpoint = c.current.SwapNumberAtomic(core.Number(0))
exp.Export(ctx, rec, c)
}
// Update modifies the current value (atomically) for later export.
func (c *Aggregator) Update(_ context.Context, number core.Number, rec export.MetricRecord) {
func (c *Aggregator) Update(_ context.Context, number core.Number, rec export.Record) {
desc := rec.Descriptor()
kind := desc.NumberKind()
if !desc.Alternate() && number.IsNegative(kind) {
@ -62,7 +62,7 @@ func (c *Aggregator) Update(_ context.Context, number core.Number, rec export.Me
c.current.AddNumberAtomic(kind, number)
}
func (c *Aggregator) Merge(oa export.MetricAggregator, desc *export.Descriptor) {
func (c *Aggregator) Merge(oa export.Aggregator, desc *export.Descriptor) {
o, _ := oa.(*Aggregator)
if o == nil {
// TODO warn

View File

@ -21,7 +21,7 @@ import (
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/metric/aggregator/test"
)
@ -33,7 +33,7 @@ func TestCounterMonotonic(t *testing.T) {
test.RunProfiles(t, func(t *testing.T, profile test.Profile) {
agg := New()
batcher, record := test.NewAggregatorTest(export.CounterMetricKind, profile.NumberKind, false)
batcher, record := test.NewAggregatorTest(export.CounterKind, profile.NumberKind, false)
sum := core.Number(0)
for i := 0; i < count; i++ {
@ -54,7 +54,7 @@ func TestCounterMonotonicNegative(t *testing.T) {
test.RunProfiles(t, func(t *testing.T, profile test.Profile) {
agg := New()
batcher, record := test.NewAggregatorTest(export.CounterMetricKind, profile.NumberKind, false)
batcher, record := test.NewAggregatorTest(export.CounterKind, profile.NumberKind, false)
for i := 0; i < count; i++ {
agg.Update(ctx, profile.Random(-1), record)
@ -74,7 +74,7 @@ func TestCounterNonMonotonic(t *testing.T) {
test.RunProfiles(t, func(t *testing.T, profile test.Profile) {
agg := New()
batcher, record := test.NewAggregatorTest(export.CounterMetricKind, profile.NumberKind, true)
batcher, record := test.NewAggregatorTest(export.CounterKind, profile.NumberKind, true)
sum := core.Number(0)
for i := 0; i < count; i++ {
@ -99,7 +99,7 @@ func TestCounterMerge(t *testing.T) {
agg1 := New()
agg2 := New()
batcher, record := test.NewAggregatorTest(export.CounterMetricKind, profile.NumberKind, false)
batcher, record := test.NewAggregatorTest(export.CounterKind, profile.NumberKind, false)
sum := core.Number(0)
for i := 0; i < count; i++ {

View File

@ -21,7 +21,8 @@ import (
sdk "github.com/DataDog/sketches-go/ddsketch"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/metric/aggregator"
)
@ -34,7 +35,7 @@ type Aggregator struct {
checkpoint *sdk.DDSketch
}
var _ export.MetricAggregator = &Aggregator{}
var _ export.Aggregator = &Aggregator{}
// New returns a new DDSketch aggregator.
func New(cfg *sdk.Config, desc *export.Descriptor) *Aggregator {
@ -91,7 +92,7 @@ func (c *Aggregator) toNumber(f float64) core.Number {
}
// Collect checkpoints the current value (atomically) and exports it.
func (c *Aggregator) Collect(ctx context.Context, rec export.MetricRecord, exp export.MetricBatcher) {
func (c *Aggregator) Collect(ctx context.Context, rec export.Record, exp export.Batcher) {
replace := sdk.NewDDSketch(c.cfg)
c.lock.Lock()
@ -105,7 +106,7 @@ func (c *Aggregator) Collect(ctx context.Context, rec export.MetricRecord, exp e
}
// Update modifies the current value (atomically) for later export.
func (c *Aggregator) Update(_ context.Context, number core.Number, rec export.MetricRecord) {
func (c *Aggregator) Update(_ context.Context, number core.Number, rec export.Record) {
desc := rec.Descriptor()
kind := desc.NumberKind()
@ -119,7 +120,7 @@ func (c *Aggregator) Update(_ context.Context, number core.Number, rec export.Me
c.current.Add(number.CoerceToFloat64(kind))
}
func (c *Aggregator) Merge(oa export.MetricAggregator, d *export.Descriptor) {
func (c *Aggregator) Merge(oa export.Aggregator, d *export.Descriptor) {
o, _ := oa.(*Aggregator)
if o == nil {
// TODO warn

View File

@ -21,7 +21,7 @@ import (
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/metric/aggregator/test"
)
@ -33,8 +33,8 @@ type updateTest struct {
func (ut *updateTest) run(t *testing.T, profile test.Profile) {
ctx := context.Background()
batcher, record := test.NewAggregatorTest(export.MeasureMetricKind, profile.NumberKind, !ut.absolute)
batcher, record := test.NewAggregatorTest(export.MeasureKind, profile.NumberKind, !ut.absolute)
agg := New(NewDefaultConfig(), record.Descriptor())
all := test.NewNumbers(profile.NumberKind)
@ -96,8 +96,7 @@ type mergeTest struct {
func (mt *mergeTest) run(t *testing.T, profile test.Profile) {
ctx := context.Background()
batcher, record := test.NewAggregatorTest(export.MeasureMetricKind, profile.NumberKind, !mt.absolute)
batcher, record := test.NewAggregatorTest(export.MeasureKind, profile.NumberKind, !mt.absolute)
agg1 := New(NewDefaultConfig(), record.Descriptor())
agg2 := New(NewDefaultConfig(), record.Descriptor())

View File

@ -21,7 +21,7 @@ import (
"unsafe"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/metric"
)
// Note: This aggregator enforces the behavior of monotonic gauges to
@ -54,7 +54,7 @@ type (
}
)
var _ export.MetricAggregator = &Aggregator{}
var _ export.Aggregator = &Aggregator{}
// An unset gauge has zero timestamp and zero value.
var unsetGauge = &gaugeData{}
@ -79,14 +79,14 @@ func (g *Aggregator) Timestamp() time.Time {
}
// Collect checkpoints the current value (atomically) and exports it.
func (g *Aggregator) Collect(ctx context.Context, rec export.MetricRecord, exp export.MetricBatcher) {
func (g *Aggregator) Collect(ctx context.Context, rec export.Record, exp export.Batcher) {
g.checkpoint = atomic.LoadPointer(&g.current)
exp.Export(ctx, rec, g)
}
// Update modifies the current value (atomically) for later export.
func (g *Aggregator) Update(_ context.Context, number core.Number, rec export.MetricRecord) {
func (g *Aggregator) Update(_ context.Context, number core.Number, rec export.Record) {
desc := rec.Descriptor()
if !desc.Alternate() {
g.updateNonMonotonic(number)
@ -124,7 +124,7 @@ func (g *Aggregator) updateMonotonic(number core.Number, desc *export.Descriptor
}
}
func (g *Aggregator) Merge(oa export.MetricAggregator, desc *export.Descriptor) {
func (g *Aggregator) Merge(oa export.Aggregator, desc *export.Descriptor) {
o, _ := oa.(*Aggregator)
if o == nil {
// TODO warn

View File

@ -22,13 +22,13 @@ import (
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/metric/aggregator/test"
)
const count = 100
var _ export.MetricAggregator = &Aggregator{}
var _ export.Aggregator = &Aggregator{}
func TestGaugeNonMonotonic(t *testing.T) {
ctx := context.Background()
@ -36,7 +36,7 @@ func TestGaugeNonMonotonic(t *testing.T) {
test.RunProfiles(t, func(t *testing.T, profile test.Profile) {
agg := New()
batcher, record := test.NewAggregatorTest(export.GaugeMetricKind, profile.NumberKind, false)
batcher, record := test.NewAggregatorTest(export.GaugeKind, profile.NumberKind, false)
var last core.Number
for i := 0; i < count; i++ {
@ -57,7 +57,7 @@ func TestGaugeMonotonic(t *testing.T) {
test.RunProfiles(t, func(t *testing.T, profile test.Profile) {
agg := New()
batcher, record := test.NewAggregatorTest(export.GaugeMetricKind, profile.NumberKind, true)
batcher, record := test.NewAggregatorTest(export.GaugeKind, profile.NumberKind, true)
small := profile.Random(+1)
last := small
@ -79,7 +79,7 @@ func TestGaugeMonotonicDescending(t *testing.T) {
test.RunProfiles(t, func(t *testing.T, profile test.Profile) {
agg := New()
batcher, record := test.NewAggregatorTest(export.GaugeMetricKind, profile.NumberKind, true)
batcher, record := test.NewAggregatorTest(export.GaugeKind, profile.NumberKind, true)
first := profile.Random(+1)
agg.Update(ctx, first, record)
@ -102,7 +102,7 @@ func TestGaugeNormalMerge(t *testing.T) {
agg1 := New()
agg2 := New()
batcher, record := test.NewAggregatorTest(export.GaugeMetricKind, profile.NumberKind, false)
batcher, record := test.NewAggregatorTest(export.GaugeKind, profile.NumberKind, false)
first1 := profile.Random(+1)
first2 := profile.Random(+1)
@ -132,7 +132,7 @@ func TestGaugeMonotonicMerge(t *testing.T) {
agg1 := New()
agg2 := New()
batcher, record := test.NewAggregatorTest(export.GaugeMetricKind, profile.NumberKind, true)
batcher, record := test.NewAggregatorTest(export.GaugeKind, profile.NumberKind, true)
first1 := profile.Random(+1)
agg1.Update(ctx, first1, record)

View File

@ -18,7 +18,7 @@ import (
"context"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/metric"
)
type (
@ -36,7 +36,7 @@ type (
}
)
var _ export.MetricAggregator = &Aggregator{}
var _ export.Aggregator = &Aggregator{}
// New returns a new measure aggregator for computing max, sum, and count.
func New() *Aggregator {
@ -59,7 +59,7 @@ func (c *Aggregator) Max() (core.Number, error) {
}
// Collect checkpoints the current value (atomically) and exports it.
func (c *Aggregator) Collect(ctx context.Context, rec export.MetricRecord, exp export.MetricBatcher) {
func (c *Aggregator) Collect(ctx context.Context, rec export.Record, exp export.Batcher) {
// N.B. There is no atomic operation that can update all three
// values at once without a memory allocation.
//
@ -78,7 +78,7 @@ func (c *Aggregator) Collect(ctx context.Context, rec export.MetricRecord, exp e
}
// Update modifies the current value (atomically) for later export.
func (c *Aggregator) Update(_ context.Context, number core.Number, rec export.MetricRecord) {
func (c *Aggregator) Update(_ context.Context, number core.Number, rec export.Record) {
desc := rec.Descriptor()
kind := desc.NumberKind()
@ -102,7 +102,7 @@ func (c *Aggregator) Update(_ context.Context, number core.Number, rec export.Me
}
}
func (c *Aggregator) Merge(oa export.MetricAggregator, desc *export.Descriptor) {
func (c *Aggregator) Merge(oa export.Aggregator, desc *export.Descriptor) {
o, _ := oa.(*Aggregator)
if o == nil {
// TODO warn

View File

@ -20,7 +20,7 @@ import (
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/metric/aggregator/test"
)
@ -30,7 +30,7 @@ func TestMaxSumCountAbsolute(t *testing.T) {
ctx := context.Background()
test.RunProfiles(t, func(t *testing.T, profile test.Profile) {
batcher, record := test.NewAggregatorTest(export.MeasureMetricKind, profile.NumberKind, false)
batcher, record := test.NewAggregatorTest(export.MeasureKind, profile.NumberKind, false)
agg := New()
@ -66,7 +66,7 @@ func TestMaxSumCountMerge(t *testing.T) {
ctx := context.Background()
test.RunProfiles(t, func(t *testing.T, profile test.Profile) {
batcher, record := test.NewAggregatorTest(export.MeasureMetricKind, profile.NumberKind, false)
batcher, record := test.NewAggregatorTest(export.MeasureKind, profile.NumberKind, false)
agg1 := New()
agg2 := New()

View File

@ -21,11 +21,11 @@ import (
"testing"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/metric"
)
var _ export.MetricBatcher = &metricBatcher{}
var _ export.MetricRecord = &metricRecord{}
var _ export.Batcher = &metricBatcher{}
var _ export.Record = &metricRecord{}
const Magnitude = 1000
@ -59,7 +59,7 @@ type metricRecord struct {
descriptor *export.Descriptor
}
func NewAggregatorTest(mkind export.MetricKind, nkind core.NumberKind, alternate bool) (export.MetricBatcher, export.MetricRecord) {
func NewAggregatorTest(mkind export.Kind, nkind core.NumberKind, alternate bool) (export.Batcher, export.Record) {
desc := export.NewDescriptor("test.name", mkind, nil, "", "", nkind, alternate)
return &metricBatcher{}, &metricRecord{descriptor: desc}
}
@ -72,11 +72,11 @@ func (t *metricRecord) Labels() []core.KeyValue {
return nil
}
func (m *metricBatcher) AggregatorFor(rec export.MetricRecord) export.MetricAggregator {
func (m *metricBatcher) AggregatorFor(rec export.Record) export.Aggregator {
return nil
}
func (m *metricBatcher) Export(context.Context, export.MetricRecord, export.MetricAggregator) {
func (m *metricBatcher) Export(context.Context, export.Record, export.Aggregator) {
}
func RunProfiles(t *testing.T, f func(*testing.T, Profile)) {

View File

@ -23,7 +23,7 @@ import (
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/key"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/metric"
sdk "go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/aggregator/counter"
"go.opentelemetry.io/otel/sdk/metric/aggregator/ddsketch"
@ -45,13 +45,13 @@ func newFixture(b *testing.B) *benchFixture {
return bf
}
func (bf *benchFixture) AggregatorFor(rec export.MetricRecord) export.MetricAggregator {
func (bf *benchFixture) AggregatorFor(rec export.Record) export.Aggregator {
switch rec.Descriptor().MetricKind() {
case export.CounterMetricKind:
case export.CounterKind:
return counter.New()
case export.GaugeMetricKind:
case export.GaugeKind:
return gauge.New()
case export.MeasureMetricKind:
case export.MeasureKind:
if strings.HasSuffix(rec.Descriptor().Name(), "maxsumcount") {
return maxsumcount.New()
} else if strings.HasSuffix(rec.Descriptor().Name(), "ddsketch") {
@ -63,7 +63,7 @@ func (bf *benchFixture) AggregatorFor(rec export.MetricRecord) export.MetricAggr
return nil
}
func (bf *benchFixture) Export(ctx context.Context, rec export.MetricRecord, agg export.MetricAggregator) {
func (bf *benchFixture) Export(ctx context.Context, rec export.Record, agg export.Aggregator) {
}
func makeLabels(n int) []core.KeyValue {

View File

@ -24,7 +24,7 @@ import (
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/key"
"go.opentelemetry.io/otel/api/metric"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/metric"
sdk "go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/aggregator/gauge"
)
@ -37,11 +37,11 @@ type monotoneBatcher struct {
currentTime *time.Time
}
func (m *monotoneBatcher) AggregatorFor(rec export.MetricRecord) export.MetricAggregator {
func (m *monotoneBatcher) AggregatorFor(rec export.Record) export.Aggregator {
return gauge.New()
}
func (m *monotoneBatcher) Export(_ context.Context, record export.MetricRecord, agg export.MetricAggregator) {
func (m *monotoneBatcher) Export(_ context.Context, record export.Record, agg export.Aggregator) {
require.Equal(m.t, "my.gauge.name", record.Descriptor().Name())
require.Equal(m.t, 1, len(record.Labels()))
require.Equal(m.t, "a", string(record.Labels()[0].Key))

View File

@ -25,7 +25,7 @@ import (
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/metric"
api "go.opentelemetry.io/otel/api/metric"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/metric"
)
type (
@ -57,7 +57,7 @@ type (
currentEpoch int64
// exporter is the configured exporter+configuration.
exporter export.MetricBatcher
exporter export.Batcher
// collectLock prevents simultaneous calls to Collect().
collectLock sync.Mutex
@ -120,7 +120,7 @@ type (
// recorder implements the actual RecordOne() API,
// depending on the type of aggregation. If nil, the
// metric was disabled by the exporter.
recorder export.MetricAggregator
recorder export.Aggregator
// next contains the next pointer for both the primary
// and the reclaim lists.
@ -141,11 +141,11 @@ type (
)
var (
_ api.Meter = &SDK{}
_ api.LabelSet = &labels{}
_ api.InstrumentImpl = &instrument{}
_ api.HandleImpl = &record{}
_ export.MetricRecord = &record{}
_ api.Meter = &SDK{}
_ api.LabelSet = &labels{}
_ api.InstrumentImpl = &instrument{}
_ api.HandleImpl = &record{}
_ export.Record = &record{}
// hazardRecord is used as a pointer value that indicates the
// value is not included in any list. (`nil` would be
@ -209,7 +209,7 @@ func (i *instrument) RecordOne(ctx context.Context, number core.Number, ls api.L
// exporter will call Collect() when it receives a request to scrape
// current metric values. A push-based exporter should configure its
// own periodic collection.
func New(exporter export.MetricBatcher) *SDK {
func New(exporter export.Batcher) *SDK {
m := &SDK{
pool: sync.Pool{
New: func() interface{} {
@ -281,7 +281,7 @@ func (m *SDK) labsFor(ls api.LabelSet) *labels {
return &m.empty
}
func (m *SDK) newInstrument(name string, metricKind export.MetricKind, numberKind core.NumberKind, opts *api.Options) *instrument {
func (m *SDK) newInstrument(name string, metricKind export.Kind, numberKind core.NumberKind, opts *api.Options) *instrument {
descriptor := export.NewDescriptor(
name,
metricKind,
@ -299,19 +299,19 @@ func (m *SDK) newInstrument(name string, metricKind export.MetricKind, numberKin
func (m *SDK) newCounterInstrument(name string, numberKind core.NumberKind, cos ...api.CounterOptionApplier) *instrument {
opts := api.Options{}
api.ApplyCounterOptions(&opts, cos...)
return m.newInstrument(name, export.CounterMetricKind, numberKind, &opts)
return m.newInstrument(name, export.CounterKind, numberKind, &opts)
}
func (m *SDK) newGaugeInstrument(name string, numberKind core.NumberKind, gos ...api.GaugeOptionApplier) *instrument {
opts := api.Options{}
api.ApplyGaugeOptions(&opts, gos...)
return m.newInstrument(name, export.GaugeMetricKind, numberKind, &opts)
return m.newInstrument(name, export.GaugeKind, numberKind, &opts)
}
func (m *SDK) newMeasureInstrument(name string, numberKind core.NumberKind, mos ...api.MeasureOptionApplier) *instrument {
opts := api.Options{}
api.ApplyMeasureOptions(&opts, mos...)
return m.newInstrument(name, export.MeasureMetricKind, numberKind, &opts)
return m.newInstrument(name, export.MeasureKind, numberKind, &opts)
}
func (m *SDK) NewInt64Counter(name string, cos ...api.CounterOptionApplier) api.Int64Counter {
@ -358,7 +358,7 @@ func (m *SDK) saveFromReclaim(rec *record) {
// Collect traverses the list of active records and exports data for
// each active instrument. Collect() may not be called concurrently.
//
// During the collection pass, the export.MetricBatcher will receive
// During the collection pass, the export.Batcher will receive
// one Export() call per current aggregation.
func (m *SDK) Collect(ctx context.Context) {
m.collectLock.Lock()

View File

@ -35,7 +35,7 @@ import (
"go.opentelemetry.io/otel/api/key"
"go.opentelemetry.io/otel/api/metric"
api "go.opentelemetry.io/otel/api/metric"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/metric"
sdk "go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/aggregator/counter"
"go.opentelemetry.io/otel/sdk/metric/aggregator/gauge"
@ -227,18 +227,18 @@ func (f *testFixture) preCollect() {
f.dupCheck = map[testKey]int{}
}
func (f *testFixture) AggregatorFor(record export.MetricRecord) export.MetricAggregator {
func (f *testFixture) AggregatorFor(record export.Record) export.Aggregator {
switch record.Descriptor().MetricKind() {
case export.CounterMetricKind:
case export.CounterKind:
return counter.New()
case export.GaugeMetricKind:
case export.GaugeKind:
return gauge.New()
default:
panic("Not implemented for this test")
}
}
func (f *testFixture) Export(ctx context.Context, record export.MetricRecord, agg export.MetricAggregator) {
func (f *testFixture) Export(ctx context.Context, record export.Record, agg export.Aggregator) {
desc := record.Descriptor()
key := testKey{
labels: canonicalizeLabels(record.Labels()),
@ -253,9 +253,9 @@ func (f *testFixture) Export(ctx context.Context, record export.MetricRecord, ag
actual, _ := f.received.LoadOrStore(key, f.impl.newStore())
switch desc.MetricKind() {
case export.CounterMetricKind:
case export.CounterKind:
f.impl.storeCollect(actual, agg.(*counter.Aggregator).AsNumber(), time.Time{})
case export.GaugeMetricKind:
case export.GaugeKind:
gauge := agg.(*gauge.Aggregator)
f.impl.storeCollect(actual, gauge.AsNumber(), gauge.Timestamp())
default:

View File

@ -20,7 +20,7 @@ import (
"sync"
"time"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/trace"
)
const (

View File

@ -23,7 +23,7 @@ import (
"go.opentelemetry.io/otel/api/core"
apitrace "go.opentelemetry.io/otel/api/trace"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/trace"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)

View File

@ -18,7 +18,7 @@ import (
"sync"
"sync/atomic"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/trace"
apitrace "go.opentelemetry.io/otel/api/trace"
)

View File

@ -17,7 +17,7 @@ package trace
import (
"context"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/trace"
)
// SimpleSpanProcessor implements SpanProcessor interfaces. It is used by

View File

@ -20,7 +20,7 @@ import (
"go.opentelemetry.io/otel/api/core"
apitrace "go.opentelemetry.io/otel/api/trace"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/trace"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)

View File

@ -23,7 +23,7 @@ import (
"go.opentelemetry.io/otel/api/core"
apitrace "go.opentelemetry.io/otel/api/trace"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/trace"
"go.opentelemetry.io/otel/sdk/internal"
)

View File

@ -18,7 +18,7 @@ import (
"sync"
"sync/atomic"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/trace"
)
// SpanProcessor is interface to add hooks to start and end method invocations.

View File

@ -18,7 +18,7 @@ import (
"context"
"testing"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/trace"
)
type testSpanProcesor struct {

View File

@ -31,7 +31,7 @@ import (
"go.opentelemetry.io/otel/api/testharness"
"go.opentelemetry.io/otel/api/trace"
apitrace "go.opentelemetry.io/otel/api/trace"
"go.opentelemetry.io/otel/sdk/export"
export "go.opentelemetry.io/otel/sdk/export/trace"
)
var (