From 384b4bb86af69eed21dc9e29579894576be9ce50 Mon Sep 17 00:00:00 2001 From: Alyson van Hardenberg Date: Thu, 10 Oct 2019 14:30:22 -0700 Subject: [PATCH] rename tag package to distributedContext (#178) * rename package tag to package distributedContext * rename Tag -> Entry * change distributed context -> dctx to avoid capitalization collision * change dctx -> distributedcontext * update stackdriver client example --- api/{tag => distributedcontext}/context.go | 10 ++-- api/{tag => distributedcontext}/doc.go | 2 +- api/{tag => distributedcontext}/map.go | 12 ++-- api/{tag => distributedcontext}/mutator.go | 2 +- api/trace/api.go | 6 +- api/trace/current_test.go | 6 +- api/trace/noop_span.go | 6 +- example/basic/main.go | 14 ++--- example/http-stackdriver/client/client.go | 6 +- example/http-stackdriver/server/server.go | 8 +-- example/http/client/client.go | 6 +- example/http/server/server.go | 8 +-- .../bridge/opentracing/internal/mock.go | 52 ++++++++--------- experimental/streaming/example/basic/main.go | 14 ++--- experimental/streaming/exporter/exporter.go | 14 ++--- .../exporter/reader/format/format.go | 10 ++-- .../streaming/exporter/reader/reader.go | 56 +++++++++---------- experimental/streaming/sdk/span.go | 6 +- internal/trace/mock_span.go | 6 +- plugin/httptrace/httptrace.go | 2 +- sdk/trace/span.go | 6 +- 21 files changed, 126 insertions(+), 126 deletions(-) rename api/{tag => distributedcontext}/context.go (87%) rename api/{tag => distributedcontext}/doc.go (87%) rename api/{tag => distributedcontext}/map.go (93%) rename api/{tag => distributedcontext}/mutator.go (97%) diff --git a/api/tag/context.go b/api/distributedcontext/context.go similarity index 87% rename from api/tag/context.go rename to api/distributedcontext/context.go index 985efce2d..131e0aa2d 100644 --- a/api/tag/context.go +++ b/api/distributedcontext/context.go @@ -12,21 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -package tag +package distributedcontext import ( "context" "runtime/pprof" ) -type ctxTagsType struct{} +type ctxEntriesType struct{} var ( - ctxTagsKey = &ctxTagsType{} + ctxEntriesKey = &ctxEntriesType{} ) func WithMap(ctx context.Context, m Map) context.Context { - return context.WithValue(ctx, ctxTagsKey, m) + return context.WithValue(ctx, ctxEntriesKey, m) } func NewContext(ctx context.Context, mutators ...Mutator) context.Context { @@ -36,7 +36,7 @@ func NewContext(ctx context.Context, mutators ...Mutator) context.Context { } func FromContext(ctx context.Context) Map { - if m, ok := ctx.Value(ctxTagsKey).(Map); ok { + if m, ok := ctx.Value(ctxEntriesKey).(Map); ok { return m } return NewEmptyMap() diff --git a/api/tag/doc.go b/api/distributedcontext/doc.go similarity index 87% rename from api/tag/doc.go rename to api/distributedcontext/doc.go index 62f127a17..a69eeef8b 100644 --- a/api/tag/doc.go +++ b/api/distributedcontext/doc.go @@ -12,4 +12,4 @@ // See the License for the specific language governing permissions and // limitations under the License. -package tag // import "go.opentelemetry.io/api/tag" +package distributedcontext // import "go.opentelemetry.io/api/distributedcontext" diff --git a/api/tag/map.go b/api/distributedcontext/map.go similarity index 93% rename from api/tag/map.go rename to api/distributedcontext/map.go index 9982627c1..5ffcbbef9 100644 --- a/api/tag/map.go +++ b/api/distributedcontext/map.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package tag +package distributedcontext import ( "go.opentelemetry.io/api/core" @@ -22,12 +22,12 @@ type MeasureMetadata struct { TTL int // -1 == infinite, 0 == do not propagate } -type tagContent struct { +type entry struct { value core.Value meta MeasureMetadata } -type rawMap map[core.Key]tagContent +type rawMap map[core.Key]entry type Map struct { m rawMap @@ -60,12 +60,12 @@ func (m Map) Apply(update MapUpdate) Map { r[k] = v } if update.SingleKV.Key.Defined() { - r[update.SingleKV.Key] = tagContent{ + r[update.SingleKV.Key] = entry{ value: update.SingleKV.Value, } } for _, kv := range update.MultiKV { - r[kv.Key] = tagContent{ + r[kv.Key] = entry{ value: kv.Value, } } @@ -111,7 +111,7 @@ func (m Map) Foreach(f func(kv core.KeyValue) bool) { func (r rawMap) apply(mutator Mutator) { key := mutator.KeyValue.Key - content := tagContent{ + content := entry{ value: mutator.KeyValue.Value, meta: mutator.MeasureMetadata, } diff --git a/api/tag/mutator.go b/api/distributedcontext/mutator.go similarity index 97% rename from api/tag/mutator.go rename to api/distributedcontext/mutator.go index 138221088..e39624e77 100644 --- a/api/tag/mutator.go +++ b/api/distributedcontext/mutator.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package tag +package distributedcontext import ( "go.opentelemetry.io/api/core" diff --git a/api/trace/api.go b/api/trace/api.go index 4eca96a24..f3cb82d95 100644 --- a/api/trace/api.go +++ b/api/trace/api.go @@ -21,7 +21,7 @@ import ( "google.golang.org/grpc/codes" "go.opentelemetry.io/api/core" - "go.opentelemetry.io/api/tag" + "go.opentelemetry.io/api/distributedcontext" ) type Tracer interface { @@ -90,8 +90,8 @@ type Span interface { SetAttributes(...core.KeyValue) // Modify and delete span attributes - ModifyAttribute(tag.Mutator) - ModifyAttributes(...tag.Mutator) + ModifyAttribute(distributedcontext.Mutator) + ModifyAttributes(...distributedcontext.Mutator) } // SpanOption apply changes to SpanOptions. diff --git a/api/trace/current_test.go b/api/trace/current_test.go index d3333e1c7..4b5903b89 100644 --- a/api/trace/current_test.go +++ b/api/trace/current_test.go @@ -8,7 +8,7 @@ import ( "google.golang.org/grpc/codes" "go.opentelemetry.io/api/core" - "go.opentelemetry.io/api/tag" + "go.opentelemetry.io/api/distributedcontext" "go.opentelemetry.io/api/trace" ) @@ -89,11 +89,11 @@ func (mockSpan) SetAttributes(attributes ...core.KeyValue) { } // ModifyAttribute does nothing. -func (mockSpan) ModifyAttribute(mutator tag.Mutator) { +func (mockSpan) ModifyAttribute(mutator distributedcontext.Mutator) { } // ModifyAttributes does nothing. -func (mockSpan) ModifyAttributes(mutators ...tag.Mutator) { +func (mockSpan) ModifyAttributes(mutators ...distributedcontext.Mutator) { } // End does nothing. diff --git a/api/trace/noop_span.go b/api/trace/noop_span.go index 47541e750..1618aa441 100644 --- a/api/trace/noop_span.go +++ b/api/trace/noop_span.go @@ -21,7 +21,7 @@ import ( "google.golang.org/grpc/codes" "go.opentelemetry.io/api/core" - "go.opentelemetry.io/api/tag" + "go.opentelemetry.io/api/distributedcontext" ) type NoopSpan struct { @@ -56,11 +56,11 @@ func (NoopSpan) SetAttributes(attributes ...core.KeyValue) { } // ModifyAttribute does nothing. -func (NoopSpan) ModifyAttribute(mutator tag.Mutator) { +func (NoopSpan) ModifyAttribute(mutator distributedcontext.Mutator) { } // ModifyAttributes does nothing. -func (NoopSpan) ModifyAttributes(mutators ...tag.Mutator) { +func (NoopSpan) ModifyAttributes(mutators ...distributedcontext.Mutator) { } // End does nothing. diff --git a/example/basic/main.go b/example/basic/main.go index 431386f28..53ca1c672 100644 --- a/example/basic/main.go +++ b/example/basic/main.go @@ -17,9 +17,9 @@ package main import ( "context" + "go.opentelemetry.io/api/distributedcontext" "go.opentelemetry.io/api/key" "go.opentelemetry.io/api/metric" - "go.opentelemetry.io/api/tag" "go.opentelemetry.io/api/trace" ) @@ -44,9 +44,9 @@ var ( func main() { ctx := context.Background() - ctx = tag.NewContext(ctx, - tag.Insert(fooKey.String("foo1")), - tag.Insert(barKey.String("bar1")), + ctx = distributedcontext.NewContext(ctx, + distributedcontext.Insert(fooKey.String("foo1")), + distributedcontext.Insert(barKey.String("bar1")), ) commonLabels := meter.DefineLabels(ctx, lemonsKey.Int(10)) @@ -64,9 +64,9 @@ func main() { gauge.Set(ctx, 1) meter.RecordBatch( - // Note: call-site variables added as context tags: - tag.NewContext(ctx, - tag.Insert(anotherKey.String("xyz"))), + // Note: call-site variables added as context Entries: + distributedcontext.NewContext(ctx, + distributedcontext.Insert(anotherKey.String("xyz"))), commonLabels, oneMetric.Measurement(1.0), diff --git a/example/http-stackdriver/client/client.go b/example/http-stackdriver/client/client.go index db4ed7c6d..7c768c9b9 100644 --- a/example/http-stackdriver/client/client.go +++ b/example/http-stackdriver/client/client.go @@ -26,8 +26,8 @@ import ( "google.golang.org/grpc/codes" + "go.opentelemetry.io/api/distributedcontext" "go.opentelemetry.io/api/key" - "go.opentelemetry.io/api/tag" "go.opentelemetry.io/api/trace" "go.opentelemetry.io/exporter/trace/stackdriver" "go.opentelemetry.io/plugin/httptrace" @@ -59,8 +59,8 @@ func main() { initTracer() client := http.DefaultClient - ctx := tag.NewContext(context.Background(), - tag.Insert(key.New("username").String("donuts")), + ctx := distributedcontext.NewContext(context.Background(), + distributedcontext.Insert(key.New("username").String("donuts")), ) var body []byte diff --git a/example/http-stackdriver/server/server.go b/example/http-stackdriver/server/server.go index 586e4f351..b1fbf5045 100644 --- a/example/http-stackdriver/server/server.go +++ b/example/http-stackdriver/server/server.go @@ -20,7 +20,7 @@ import ( "net/http" "os" - "go.opentelemetry.io/api/tag" + "go.opentelemetry.io/api/distributedcontext" "go.opentelemetry.io/api/trace" "go.opentelemetry.io/exporter/trace/stackdriver" "go.opentelemetry.io/plugin/httptrace" @@ -53,10 +53,10 @@ func main() { initTracer() helloHandler := func(w http.ResponseWriter, req *http.Request) { - attrs, tags, spanCtx := httptrace.Extract(req.Context(), req) + attrs, entries, spanCtx := httptrace.Extract(req.Context(), req) - req = req.WithContext(tag.WithMap(req.Context(), tag.NewMap(tag.MapUpdate{ - MultiKV: tags, + req = req.WithContext(distributedcontext.WithMap(req.Context(), distributedcontext.NewMap(distributedcontext.MapUpdate{ + MultiKV: entries, }))) ctx, span := trace.GlobalTracer().Start( diff --git a/example/http/client/client.go b/example/http/client/client.go index a7b02b7be..0499a3de4 100644 --- a/example/http/client/client.go +++ b/example/http/client/client.go @@ -25,8 +25,8 @@ import ( "google.golang.org/grpc/codes" + "go.opentelemetry.io/api/distributedcontext" "go.opentelemetry.io/api/key" - "go.opentelemetry.io/api/tag" "go.opentelemetry.io/api/trace" "go.opentelemetry.io/exporter/trace/stdout" "go.opentelemetry.io/plugin/httptrace" @@ -57,8 +57,8 @@ func main() { initTracer() client := http.DefaultClient - ctx := tag.NewContext(context.Background(), - tag.Insert(key.New("username").String("donuts")), + ctx := distributedcontext.NewContext(context.Background(), + distributedcontext.Insert(key.New("username").String("donuts")), ) var body []byte diff --git a/example/http/server/server.go b/example/http/server/server.go index f47673161..701337523 100644 --- a/example/http/server/server.go +++ b/example/http/server/server.go @@ -19,7 +19,7 @@ import ( "log" "net/http" - "go.opentelemetry.io/api/tag" + "go.opentelemetry.io/api/distributedcontext" "go.opentelemetry.io/api/trace" "go.opentelemetry.io/exporter/trace/stdout" "go.opentelemetry.io/plugin/httptrace" @@ -49,10 +49,10 @@ func main() { initTracer() helloHandler := func(w http.ResponseWriter, req *http.Request) { - attrs, tags, spanCtx := httptrace.Extract(req.Context(), req) + attrs, entries, spanCtx := httptrace.Extract(req.Context(), req) - req = req.WithContext(tag.WithMap(req.Context(), tag.NewMap(tag.MapUpdate{ - MultiKV: tags, + req = req.WithContext(distributedcontext.WithMap(req.Context(), distributedcontext.NewMap(distributedcontext.MapUpdate{ + MultiKV: entries, }))) ctx, span := trace.GlobalTracer().Start( diff --git a/experimental/bridge/opentracing/internal/mock.go b/experimental/bridge/opentracing/internal/mock.go index 958462b2b..9f155b48b 100644 --- a/experimental/bridge/opentracing/internal/mock.go +++ b/experimental/bridge/opentracing/internal/mock.go @@ -23,8 +23,8 @@ import ( "google.golang.org/grpc/codes" otelcore "go.opentelemetry.io/api/core" + oteldctx "go.opentelemetry.io/api/distributedcontext" otelkey "go.opentelemetry.io/api/key" - oteltag "go.opentelemetry.io/api/tag" oteltrace "go.opentelemetry.io/api/trace" migration "go.opentelemetry.io/experimental/bridge/opentracing/migration" @@ -44,7 +44,7 @@ type MockContextKeyValue struct { } type MockTracer struct { - Resources oteltag.Map + Resources oteldctx.Map FinishedSpans []*MockSpan SpareTraceIDs []otelcore.TraceID SpareSpanIDs []uint64 @@ -59,7 +59,7 @@ var _ migration.DeferredContextSetupTracerExtension = &MockTracer{} func NewMockTracer() *MockTracer { return &MockTracer{ - Resources: oteltag.NewEmptyMap(), + Resources: oteldctx.NewEmptyMap(), FinishedSpans: nil, SpareTraceIDs: nil, SpareSpanIDs: nil, @@ -107,7 +107,7 @@ func (t *MockTracer) Start(ctx context.Context, name string, opts ...oteltrace.S officialTracer: t, spanContext: spanContext, recording: spanOpts.RecordEvent, - Attributes: oteltag.NewMap(upsertMultiMapUpdate(spanOpts.Attributes...)), + Attributes: oteldctx.NewMap(upsertMultiMapUpdate(spanOpts.Attributes...)), StartTime: startTime, EndTime: time.Time{}, ParentSpanID: t.getParentSpanID(ctx, &spanOpts), @@ -201,10 +201,10 @@ func (t *MockTracer) DeferredContextSetupHook(ctx context.Context, span oteltrac } type MockEvent struct { - CtxAttributes oteltag.Map + CtxAttributes oteldctx.Map Timestamp time.Time Msg string - Attributes oteltag.Map + Attributes oteldctx.Map } type MockSpan struct { @@ -213,7 +213,7 @@ type MockSpan struct { spanContext otelcore.SpanContext recording bool - Attributes oteltag.Map + Attributes oteldctx.Map StartTime time.Time EndTime time.Time ParentSpanID uint64 @@ -251,19 +251,19 @@ func (s *MockSpan) SetAttributes(attributes ...otelcore.KeyValue) { s.applyUpdate(upsertMultiMapUpdate(attributes...)) } -func (s *MockSpan) ModifyAttribute(mutator oteltag.Mutator) { - s.applyUpdate(oteltag.MapUpdate{ +func (s *MockSpan) ModifyAttribute(mutator oteldctx.Mutator) { + s.applyUpdate(oteldctx.MapUpdate{ SingleMutator: mutator, }) } -func (s *MockSpan) ModifyAttributes(mutators ...oteltag.Mutator) { - s.applyUpdate(oteltag.MapUpdate{ +func (s *MockSpan) ModifyAttributes(mutators ...oteldctx.Mutator) { + s.applyUpdate(oteldctx.MapUpdate{ MultiMutator: mutators, }) } -func (s *MockSpan) applyUpdate(update oteltag.MapUpdate) { +func (s *MockSpan) applyUpdate(update oteldctx.MapUpdate) { s.Attributes = s.Attributes.Apply(update) } @@ -295,10 +295,10 @@ func (s *MockSpan) AddEvent(ctx context.Context, msg string, attrs ...otelcore.K func (s *MockSpan) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, msg string, attrs ...otelcore.KeyValue) { s.Events = append(s.Events, MockEvent{ - CtxAttributes: oteltag.FromContext(ctx), + CtxAttributes: oteldctx.FromContext(ctx), Timestamp: timestamp, Msg: msg, - Attributes: oteltag.NewMap(upsertMultiMapUpdate(attrs...)), + Attributes: oteldctx.NewMap(upsertMultiMapUpdate(attrs...)), }) } @@ -314,36 +314,36 @@ func (s *MockSpan) OverrideTracer(tracer oteltrace.Tracer) { s.officialTracer = tracer } -func upsertMapUpdate(kv otelcore.KeyValue) oteltag.MapUpdate { - return singleMutatorMapUpdate(oteltag.UPSERT, kv) +func upsertMapUpdate(kv otelcore.KeyValue) oteldctx.MapUpdate { + return singleMutatorMapUpdate(oteldctx.UPSERT, kv) } -func upsertMultiMapUpdate(kvs ...otelcore.KeyValue) oteltag.MapUpdate { - return multiMutatorMapUpdate(oteltag.UPSERT, kvs...) +func upsertMultiMapUpdate(kvs ...otelcore.KeyValue) oteldctx.MapUpdate { + return multiMutatorMapUpdate(oteldctx.UPSERT, kvs...) } -func singleMutatorMapUpdate(op oteltag.MutatorOp, kv otelcore.KeyValue) oteltag.MapUpdate { - return oteltag.MapUpdate{ +func singleMutatorMapUpdate(op oteldctx.MutatorOp, kv otelcore.KeyValue) oteldctx.MapUpdate { + return oteldctx.MapUpdate{ SingleMutator: keyValueToMutator(op, kv), } } -func multiMutatorMapUpdate(op oteltag.MutatorOp, kvs ...otelcore.KeyValue) oteltag.MapUpdate { - return oteltag.MapUpdate{ +func multiMutatorMapUpdate(op oteldctx.MutatorOp, kvs ...otelcore.KeyValue) oteldctx.MapUpdate { + return oteldctx.MapUpdate{ MultiMutator: keyValuesToMutators(op, kvs...), } } -func keyValuesToMutators(op oteltag.MutatorOp, kvs ...otelcore.KeyValue) []oteltag.Mutator { - var mutators []oteltag.Mutator +func keyValuesToMutators(op oteldctx.MutatorOp, kvs ...otelcore.KeyValue) []oteldctx.Mutator { + var mutators []oteldctx.Mutator for _, kv := range kvs { mutators = append(mutators, keyValueToMutator(op, kv)) } return mutators } -func keyValueToMutator(op oteltag.MutatorOp, kv otelcore.KeyValue) oteltag.Mutator { - return oteltag.Mutator{ +func keyValueToMutator(op oteldctx.MutatorOp, kv otelcore.KeyValue) oteldctx.Mutator { + return oteldctx.Mutator{ MutatorOp: op, KeyValue: kv, } diff --git a/experimental/streaming/example/basic/main.go b/experimental/streaming/example/basic/main.go index 42f9a70b2..1acfad63f 100644 --- a/experimental/streaming/example/basic/main.go +++ b/experimental/streaming/example/basic/main.go @@ -17,9 +17,9 @@ package main import ( "context" + "go.opentelemetry.io/api/distributedcontext" "go.opentelemetry.io/api/key" "go.opentelemetry.io/api/metric" - "go.opentelemetry.io/api/tag" "go.opentelemetry.io/api/trace" "go.opentelemetry.io/experimental/streaming/exporter/spanlog" @@ -47,9 +47,9 @@ var ( func main() { ctx := context.Background() - ctx = tag.NewContext(ctx, - tag.Insert(fooKey.String("foo1")), - tag.Insert(barKey.String("bar1")), + ctx = distributedcontext.NewContext(ctx, + distributedcontext.Insert(fooKey.String("foo1")), + distributedcontext.Insert(barKey.String("bar1")), ) commonLabels := meter.DefineLabels(ctx, lemonsKey.Int(10)) @@ -67,9 +67,9 @@ func main() { gauge.Set(ctx, 1) meter.RecordBatch( - // Note: call-site variables added as context tags: - tag.NewContext(ctx, - tag.Insert(anotherKey.String("xyz"))), + // Note: call-site variables added as context entries: + distributedcontext.NewContext(ctx, + distributedcontext.Insert(anotherKey.String("xyz"))), commonLabels, oneMetric.Measurement(1.0), diff --git a/experimental/streaming/exporter/exporter.go b/experimental/streaming/exporter/exporter.go index 29407999d..6ef0b4b4a 100644 --- a/experimental/streaming/exporter/exporter.go +++ b/experimental/streaming/exporter/exporter.go @@ -8,8 +8,8 @@ import ( "google.golang.org/grpc/codes" "go.opentelemetry.io/api/core" + "go.opentelemetry.io/api/distributedcontext" "go.opentelemetry.io/api/metric" - "go.opentelemetry.io/api/tag" ) type EventType int @@ -32,12 +32,12 @@ type Event struct { Context context.Context // core.FromContext() and scope.Active() // Arguments (type-specific) - Attribute core.KeyValue // SET_ATTRIBUTE - Attributes []core.KeyValue // SET_ATTRIBUTES - Mutator tag.Mutator // SET_ATTRIBUTE - Mutators []tag.Mutator // SET_ATTRIBUTES - Recovered interface{} // END_SPAN - Status codes.Code // SET_STATUS + Attribute core.KeyValue // SET_ATTRIBUTE + Attributes []core.KeyValue // SET_ATTRIBUTES + Mutator distributedcontext.Mutator // SET_ATTRIBUTE + Mutators []distributedcontext.Mutator // SET_ATTRIBUTES + Recovered interface{} // END_SPAN + Status codes.Code // SET_STATUS // Values String string // START_SPAN, EVENT, SET_NAME, ... diff --git a/experimental/streaming/exporter/reader/format/format.go b/experimental/streaming/exporter/reader/format/format.go index 322d3c858..25e34e113 100644 --- a/experimental/streaming/exporter/reader/format/format.go +++ b/experimental/streaming/exporter/reader/format/format.go @@ -19,9 +19,9 @@ import ( "strings" "go.opentelemetry.io/api/core" + "go.opentelemetry.io/api/distributedcontext" "go.opentelemetry.io/api/key" "go.opentelemetry.io/api/metric" - "go.opentelemetry.io/api/tag" "go.opentelemetry.io/experimental/streaming/exporter" "go.opentelemetry.io/experimental/streaming/exporter/reader" @@ -116,13 +116,13 @@ func AppendEvent(buf *strings.Builder, data reader.Event) { buf.WriteString(fmt.Sprintf("WAT? %d", data.Type)) } - // Attach the scope (span) attributes and context tags. + // Attach the scope (span) attributes and context entries. buf.WriteString(" [") if data.Attributes.Len() > 0 { data.Attributes.Foreach(f(false)) } - if data.Tags.Len() > 0 { - data.Tags.Foreach(f(true)) + if data.Entries.Len() > 0 { + data.Entries.Foreach(f(true)) } if data.SpanContext.HasSpanID() { f(false)(sdk.SpanIDKey.String(data.SpanContext.SpanIDString())) @@ -142,7 +142,7 @@ func formatMetricUpdate(buf *strings.Builder, m metric.Measurement) { buf.WriteString(m.Value.Emit(m.Descriptor.ValueKind())) } -func formatMetricLabels(buf *strings.Builder, l tag.Map) { +func formatMetricLabels(buf *strings.Builder, l distributedcontext.Map) { buf.WriteString(" {") i := 0 l.Foreach(func(kv core.KeyValue) bool { diff --git a/experimental/streaming/exporter/reader/reader.go b/experimental/streaming/exporter/reader/reader.go index 5a470b6d7..7972cad59 100644 --- a/experimental/streaming/exporter/reader/reader.go +++ b/experimental/streaming/exporter/reader/reader.go @@ -22,8 +22,8 @@ import ( "google.golang.org/grpc/codes" "go.opentelemetry.io/api/core" + "go.opentelemetry.io/api/distributedcontext" "go.opentelemetry.io/api/metric" - "go.opentelemetry.io/api/tag" "go.opentelemetry.io/api/trace" "go.opentelemetry.io/experimental/streaming/exporter" ) @@ -37,13 +37,13 @@ type Event struct { Time time.Time Sequence exporter.EventID SpanContext core.SpanContext - Tags tag.Map // context tags - Attributes tag.Map // span attributes, metric labels + Entries distributedcontext.Map // context entries + Attributes distributedcontext.Map // span attributes, metric labels Measurement metric.Measurement Measurements []metric.Measurement Parent core.SpanContext - ParentAttributes tag.Map + ParentAttributes distributedcontext.Map Duration time.Duration Name string @@ -59,11 +59,11 @@ type readerObserver struct { } type readerSpan struct { - name string - start time.Time - startTags tag.Map - spanContext core.SpanContext - status codes.Code + name string + start time.Time + startEntries distributedcontext.Map + spanContext core.SpanContext + status codes.Code *readerScope } @@ -71,7 +71,7 @@ type readerSpan struct { type readerScope struct { span *readerSpan parent exporter.EventID - attributes tag.Map + attributes distributedcontext.Map } // NewReaderObserver returns an implementation that computes the @@ -93,23 +93,23 @@ func (ro *readerObserver) orderedObserve(event exporter.Event) { read := Event{ Time: event.Time, Sequence: event.Sequence, - Attributes: tag.NewEmptyMap(), - Tags: tag.NewEmptyMap(), + Attributes: distributedcontext.NewEmptyMap(), + Entries: distributedcontext.NewEmptyMap(), } if event.Context != nil { - read.Tags = tag.FromContext(event.Context) + read.Entries = distributedcontext.FromContext(event.Context) } switch event.Type { case exporter.START_SPAN: - // Save the span context tags, initial attributes, start time, and name. + // Save the span context entries, initial attributes, start time, and name. span := &readerSpan{ - name: event.String, - start: event.Time, - startTags: tag.FromContext(event.Context), - spanContext: event.Scope.SpanContext, - readerScope: &readerScope{}, + name: event.String, + start: event.Time, + startEntries: distributedcontext.FromContext(event.Context), + spanContext: event.Scope.SpanContext, + readerScope: &readerScope{}, } rattrs, _ := ro.readScope(event.Scope) @@ -150,19 +150,19 @@ func (ro *readerObserver) orderedObserve(event exporter.Event) { read.Attributes = attrs read.Duration = event.Time.Sub(span.start) - read.Tags = span.startTags + read.Entries = span.startEntries read.SpanContext = span.spanContext // TODO: recovered case exporter.NEW_SCOPE, exporter.MODIFY_ATTR: var span *readerSpan - var m tag.Map + var m distributedcontext.Map sid := event.Scope if sid.EventID == 0 { - m = tag.NewEmptyMap() + m = distributedcontext.NewEmptyMap() } else { parentI, has := ro.scopes.Load(sid.EventID) if !has { @@ -181,7 +181,7 @@ func (ro *readerObserver) orderedObserve(event exporter.Event) { span: span, parent: sid.EventID, attributes: m.Apply( - tag.MapUpdate{ + distributedcontext.MapUpdate{ SingleKV: event.Attribute, MultiKV: event.Attributes, SingleMutator: event.Mutator, @@ -201,7 +201,7 @@ func (ro *readerObserver) orderedObserve(event exporter.Event) { if span != nil { read.SpanContext = span.spanContext - read.Tags = span.startTags + read.Entries = span.startEntries } case exporter.ADD_EVENT: @@ -209,7 +209,7 @@ func (ro *readerObserver) orderedObserve(event exporter.Event) { read.Message = event.String attrs, span := ro.readScope(event.Scope) - read.Attributes = attrs.Apply(tag.MapUpdate{ + read.Attributes = attrs.Apply(distributedcontext.MapUpdate{ MultiKV: event.Attributes, }) if span != nil { @@ -270,9 +270,9 @@ func (ro *readerObserver) orderedObserve(event exporter.Event) { } } -func (ro *readerObserver) readScope(id exporter.ScopeID) (tag.Map, *readerSpan) { +func (ro *readerObserver) readScope(id exporter.ScopeID) (distributedcontext.Map, *readerSpan) { if id.EventID == 0 { - return tag.NewEmptyMap(), nil + return distributedcontext.NewEmptyMap(), nil } ev, has := ro.scopes.Load(id.EventID) if !has { @@ -283,7 +283,7 @@ func (ro *readerObserver) readScope(id exporter.ScopeID) (tag.Map, *readerSpan) } else if sp, ok := ev.(*readerSpan); ok { return sp.attributes, sp } - return tag.NewEmptyMap(), nil + return distributedcontext.NewEmptyMap(), nil } func (ro *readerObserver) cleanupSpan(id exporter.EventID) { diff --git a/experimental/streaming/sdk/span.go b/experimental/streaming/sdk/span.go index e64cd2771..ddd60d1d8 100644 --- a/experimental/streaming/sdk/span.go +++ b/experimental/streaming/sdk/span.go @@ -21,7 +21,7 @@ import ( "google.golang.org/grpc/codes" "go.opentelemetry.io/api/core" - "go.opentelemetry.io/api/tag" + "go.opentelemetry.io/api/distributedcontext" "go.opentelemetry.io/api/trace" "go.opentelemetry.io/experimental/streaming/exporter" ) @@ -71,7 +71,7 @@ func (sp *span) SetAttributes(attributes ...core.KeyValue) { }) } -func (sp *span) ModifyAttribute(mutator tag.Mutator) { +func (sp *span) ModifyAttribute(mutator distributedcontext.Mutator) { sp.sdk.exporter.Record(exporter.Event{ Type: exporter.MODIFY_ATTR, Scope: sp.ScopeID(), @@ -79,7 +79,7 @@ func (sp *span) ModifyAttribute(mutator tag.Mutator) { }) } -func (sp *span) ModifyAttributes(mutators ...tag.Mutator) { +func (sp *span) ModifyAttributes(mutators ...distributedcontext.Mutator) { sp.sdk.exporter.Record(exporter.Event{ Type: exporter.MODIFY_ATTR, Scope: sp.ScopeID(), diff --git a/internal/trace/mock_span.go b/internal/trace/mock_span.go index 30e22ea11..96fcd29f3 100644 --- a/internal/trace/mock_span.go +++ b/internal/trace/mock_span.go @@ -21,7 +21,7 @@ import ( "google.golang.org/grpc/codes" "go.opentelemetry.io/api/core" - "go.opentelemetry.io/api/tag" + "go.opentelemetry.io/api/distributedcontext" apitrace "go.opentelemetry.io/api/trace" ) @@ -64,11 +64,11 @@ func (ms *MockSpan) SetAttributes(attributes ...core.KeyValue) { } // ModifyAttribute does nothing. -func (ms *MockSpan) ModifyAttribute(mutator tag.Mutator) { +func (ms *MockSpan) ModifyAttribute(mutator distributedcontext.Mutator) { } // ModifyAttributes does nothing. -func (ms *MockSpan) ModifyAttributes(mutators ...tag.Mutator) { +func (ms *MockSpan) ModifyAttributes(mutators ...distributedcontext.Mutator) { } // End does nothing. diff --git a/plugin/httptrace/httptrace.go b/plugin/httptrace/httptrace.go index 86a64c5cd..12771650c 100644 --- a/plugin/httptrace/httptrace.go +++ b/plugin/httptrace/httptrace.go @@ -34,7 +34,7 @@ var ( propagator = propagation.HttpTraceContextPropagator() ) -// Returns the Attributes, Context Tags, and SpanContext that were encoded by Inject. +// Returns the Attributes, Context Entries, and SpanContext that were encoded by Inject. func Extract(ctx context.Context, req *http.Request) ([]core.KeyValue, []core.KeyValue, core.SpanContext) { sc := propagator.Extract(ctx, req.Header) diff --git a/sdk/trace/span.go b/sdk/trace/span.go index 5be09d1c0..0decdc2b2 100644 --- a/sdk/trace/span.go +++ b/sdk/trace/span.go @@ -22,7 +22,7 @@ import ( "google.golang.org/grpc/codes" "go.opentelemetry.io/api/core" - apitag "go.opentelemetry.io/api/tag" + apidctx "go.opentelemetry.io/api/distributedcontext" apitrace "go.opentelemetry.io/api/trace" "go.opentelemetry.io/sdk/export" "go.opentelemetry.io/sdk/internal" @@ -100,11 +100,11 @@ func (s *span) SetAttributes(attributes ...core.KeyValue) { } // ModifyAttribute does nothing. -func (s *span) ModifyAttribute(mutator apitag.Mutator) { +func (s *span) ModifyAttribute(mutator apidctx.Mutator) { } // ModifyAttributes does nothing. -func (s *span) ModifyAttributes(mutators ...apitag.Mutator) { +func (s *span) ModifyAttributes(mutators ...apidctx.Mutator) { } func (s *span) End(options ...apitrace.EndOption) {