mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-02-03 13:11:53 +02:00
add opencensus tracing bridge (#1305)
This commit is contained in:
parent
27aa1f6011
commit
f6df5df938
10
.github/dependabot.yml
vendored
10
.github/dependabot.yml
vendored
@ -36,6 +36,16 @@ updates:
|
||||
schedule:
|
||||
day: sunday
|
||||
interval: weekly
|
||||
-
|
||||
package-ecosystem: gomod
|
||||
directory: /bridge/opencensus
|
||||
labels:
|
||||
- dependencies
|
||||
- go
|
||||
- "Skip Changelog"
|
||||
schedule:
|
||||
day: sunday
|
||||
interval: weekly
|
||||
-
|
||||
package-ecosystem: gomod
|
||||
directory: /example/basic
|
||||
|
@ -13,6 +13,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
- `EventOption` and the related `NewEventConfig` function are added to the `go.opentelemetry.io/otel` package to configure Span events. (#1254)
|
||||
- A `TextMapPropagator` and associated `TextMapCarrier` are added to the `go.opentelemetry.io/otel/oteltest` package to test TextMap type propagators and their use. (#1259)
|
||||
- `SpanContextFromContext` returns `SpanContext` from context. (#1255)
|
||||
- Add an opencensus to opentelemetry tracing bridge. (#1305)
|
||||
|
||||
### Changed
|
||||
|
||||
|
217
bridge/opencensus/bridge.go
Normal file
217
bridge/opencensus/bridge.go
Normal file
@ -0,0 +1,217 @@
|
||||
// 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 opencensus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
octrace "go.opencensus.io/trace"
|
||||
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/global"
|
||||
"go.opentelemetry.io/otel/label"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
// NewTracer returns an implementation of the OpenCensus Tracer interface which
|
||||
// uses OpenTelemetry APIs. Using this implementation of Tracer "upgrades"
|
||||
// libraries that use OpenCensus to OpenTelemetry to facilitate a migration.
|
||||
func NewTracer(tracer trace.Tracer) octrace.Tracer {
|
||||
return &otelTracer{tracer: tracer}
|
||||
}
|
||||
|
||||
type otelTracer struct {
|
||||
tracer trace.Tracer
|
||||
}
|
||||
|
||||
var _ octrace.Tracer = (*otelTracer)(nil)
|
||||
|
||||
func (o *otelTracer) StartSpan(ctx context.Context, name string, s ...octrace.StartOption) (context.Context, *octrace.Span) {
|
||||
ctx, sp := o.tracer.Start(ctx, name, convertStartOptions(s, name)...)
|
||||
return ctx, octrace.NewSpan(&span{otSpan: sp})
|
||||
}
|
||||
|
||||
func convertStartOptions(optFns []octrace.StartOption, name string) []trace.SpanOption {
|
||||
var ocOpts octrace.StartOptions
|
||||
for _, fn := range optFns {
|
||||
fn(&ocOpts)
|
||||
}
|
||||
otOpts := []trace.SpanOption{}
|
||||
switch ocOpts.SpanKind {
|
||||
case octrace.SpanKindClient:
|
||||
otOpts = append(otOpts, trace.WithSpanKind(trace.SpanKindClient))
|
||||
case octrace.SpanKindServer:
|
||||
otOpts = append(otOpts, trace.WithSpanKind(trace.SpanKindServer))
|
||||
case octrace.SpanKindUnspecified:
|
||||
otOpts = append(otOpts, trace.WithSpanKind(trace.SpanKindUnspecified))
|
||||
}
|
||||
|
||||
if ocOpts.Sampler != nil {
|
||||
global.Handle(fmt.Errorf("ignoring custom sampler for span %q created by OpenCensus because OpenTelemetry does not support creating a span with a custom sampler", name))
|
||||
}
|
||||
return otOpts
|
||||
}
|
||||
|
||||
func (o *otelTracer) StartSpanWithRemoteParent(ctx context.Context, name string, parent octrace.SpanContext, s ...octrace.StartOption) (context.Context, *octrace.Span) {
|
||||
// make sure span context is zero'd out so we use the remote parent
|
||||
ctx = trace.ContextWithSpan(ctx, nil)
|
||||
ctx = trace.ContextWithRemoteSpanContext(ctx, ocSpanContextToOTel(parent))
|
||||
return o.StartSpan(ctx, name, s...)
|
||||
}
|
||||
|
||||
func (o *otelTracer) FromContext(ctx context.Context) *octrace.Span {
|
||||
otSpan := trace.SpanFromContext(ctx)
|
||||
return octrace.NewSpan(&span{otSpan: otSpan})
|
||||
}
|
||||
|
||||
func (o *otelTracer) NewContext(parent context.Context, s *octrace.Span) context.Context {
|
||||
if otSpan, ok := s.Internal().(*span); ok {
|
||||
return trace.ContextWithSpan(parent, otSpan.otSpan)
|
||||
}
|
||||
global.Handle(fmt.Errorf("unable to create context with span %q, since it was created using a different tracer", s.String()))
|
||||
return parent
|
||||
}
|
||||
|
||||
type span struct {
|
||||
otSpan trace.Span
|
||||
}
|
||||
|
||||
func (s *span) IsRecordingEvents() bool {
|
||||
return s.otSpan.IsRecording()
|
||||
}
|
||||
|
||||
func (s *span) End() {
|
||||
s.otSpan.End()
|
||||
}
|
||||
|
||||
func (s *span) SpanContext() octrace.SpanContext {
|
||||
return otelSpanContextToOc(s.otSpan.SpanContext())
|
||||
}
|
||||
|
||||
func (s *span) SetName(name string) {
|
||||
s.otSpan.SetName(name)
|
||||
}
|
||||
|
||||
func (s *span) SetStatus(status octrace.Status) {
|
||||
s.otSpan.SetStatus(codes.Code(status.Code), status.Message)
|
||||
}
|
||||
|
||||
func (s *span) AddAttributes(attributes ...octrace.Attribute) {
|
||||
s.otSpan.SetAttributes(convertAttributes(attributes)...)
|
||||
}
|
||||
|
||||
func convertAttributes(attributes []octrace.Attribute) []label.KeyValue {
|
||||
otAttributes := make([]label.KeyValue, len(attributes))
|
||||
for i, a := range attributes {
|
||||
otAttributes[i] = label.KeyValue{
|
||||
Key: label.Key(a.Key()),
|
||||
Value: convertValue(a.Value()),
|
||||
}
|
||||
}
|
||||
return otAttributes
|
||||
}
|
||||
|
||||
func convertValue(ocval interface{}) label.Value {
|
||||
switch v := ocval.(type) {
|
||||
case bool:
|
||||
return label.BoolValue(v)
|
||||
case int64:
|
||||
return label.Int64Value(v)
|
||||
case float64:
|
||||
return label.Float64Value(v)
|
||||
case string:
|
||||
return label.StringValue(v)
|
||||
default:
|
||||
return label.StringValue("unknown")
|
||||
}
|
||||
}
|
||||
|
||||
func (s *span) Annotate(attributes []octrace.Attribute, str string) {
|
||||
s.otSpan.AddEvent(str, trace.WithAttributes(convertAttributes(attributes)...))
|
||||
}
|
||||
|
||||
func (s *span) Annotatef(attributes []octrace.Attribute, format string, a ...interface{}) {
|
||||
s.Annotate(attributes, fmt.Sprintf(format, a...))
|
||||
}
|
||||
|
||||
var (
|
||||
uncompressedKey = label.Key("uncompressed byte size")
|
||||
compressedKey = label.Key("compressed byte size")
|
||||
)
|
||||
|
||||
func (s *span) AddMessageSendEvent(messageID, uncompressedByteSize, compressedByteSize int64) {
|
||||
s.otSpan.AddEvent("message send",
|
||||
trace.WithAttributes(
|
||||
label.KeyValue{
|
||||
Key: uncompressedKey,
|
||||
Value: label.Int64Value(uncompressedByteSize),
|
||||
},
|
||||
label.KeyValue{
|
||||
Key: compressedKey,
|
||||
Value: label.Int64Value(compressedByteSize),
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
func (s *span) AddMessageReceiveEvent(messageID, uncompressedByteSize, compressedByteSize int64) {
|
||||
s.otSpan.AddEvent("message receive",
|
||||
trace.WithAttributes(
|
||||
label.KeyValue{
|
||||
Key: uncompressedKey,
|
||||
Value: label.Int64Value(uncompressedByteSize),
|
||||
},
|
||||
label.KeyValue{
|
||||
Key: compressedKey,
|
||||
Value: label.Int64Value(compressedByteSize),
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
func (s *span) AddLink(l octrace.Link) {
|
||||
global.Handle(fmt.Errorf("ignoring OpenCensus link %+v for span %q because OpenTelemetry doesn't support setting links after creation", l, s.String()))
|
||||
}
|
||||
|
||||
func (s *span) String() string {
|
||||
return fmt.Sprintf("span %s", s.otSpan.SpanContext().SpanID.String())
|
||||
}
|
||||
|
||||
func otelSpanContextToOc(sc trace.SpanContext) octrace.SpanContext {
|
||||
if sc.IsDebug() || sc.IsDeferred() {
|
||||
global.Handle(fmt.Errorf("ignoring OpenTelemetry Debug or Deferred trace flags for span %q because they are not supported by OpenCensus", sc.SpanID))
|
||||
}
|
||||
var to octrace.TraceOptions
|
||||
if sc.IsSampled() {
|
||||
// OpenCensus doesn't expose functions to directly set sampled
|
||||
to = 0x1
|
||||
}
|
||||
return octrace.SpanContext{
|
||||
TraceID: octrace.TraceID(sc.TraceID),
|
||||
SpanID: octrace.SpanID(sc.SpanID),
|
||||
TraceOptions: to,
|
||||
}
|
||||
}
|
||||
|
||||
func ocSpanContextToOTel(sc octrace.SpanContext) trace.SpanContext {
|
||||
var traceFlags byte
|
||||
if sc.IsSampled() {
|
||||
traceFlags = trace.FlagsSampled
|
||||
}
|
||||
return trace.SpanContext{
|
||||
TraceID: trace.TraceID(sc.TraceID),
|
||||
SpanID: trace.SpanID(sc.SpanID),
|
||||
TraceFlags: traceFlags,
|
||||
}
|
||||
}
|
276
bridge/opencensus/bridge_test.go
Normal file
276
bridge/opencensus/bridge_test.go
Normal file
@ -0,0 +1,276 @@
|
||||
// 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 opencensus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
octrace "go.opencensus.io/trace"
|
||||
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/label"
|
||||
"go.opentelemetry.io/otel/oteltest"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
func TestMixedAPIs(t *testing.T) {
|
||||
sr := new(oteltest.StandardSpanRecorder)
|
||||
tp := oteltest.NewTracerProvider(oteltest.WithSpanRecorder(sr))
|
||||
tracer := tp.Tracer("mixedapitracer")
|
||||
octrace.DefaultTracer = NewTracer(tracer)
|
||||
|
||||
func() {
|
||||
ctx := context.Background()
|
||||
var ocspan1 *octrace.Span
|
||||
ctx, ocspan1 = octrace.StartSpan(ctx, "OpenCensusSpan1")
|
||||
defer ocspan1.End()
|
||||
|
||||
var otspan1 trace.Span
|
||||
ctx, otspan1 = tracer.Start(ctx, "OpenTelemetrySpan1")
|
||||
defer otspan1.End()
|
||||
|
||||
var ocspan2 *octrace.Span
|
||||
ctx, ocspan2 = octrace.StartSpan(ctx, "OpenCensusSpan2")
|
||||
defer ocspan2.End()
|
||||
|
||||
var otspan2 trace.Span
|
||||
_, otspan2 = tracer.Start(ctx, "OpenTelemetrySpan2")
|
||||
defer otspan2.End()
|
||||
}()
|
||||
|
||||
spans := sr.Completed()
|
||||
|
||||
if len(spans) != 4 {
|
||||
for _, span := range spans {
|
||||
t.Logf("Span: %s", span.Name())
|
||||
}
|
||||
t.Fatalf("Got %d spans, exepected %d.", len(spans), 4)
|
||||
}
|
||||
|
||||
parent := &oteltest.Span{}
|
||||
for i := range spans {
|
||||
// Reverse the order we look at the spans in, since they are listed in last-to-first order.
|
||||
i = len(spans) - i - 1
|
||||
// Verify that OpenCensus spans and opentelemetry spans have each other as parents.
|
||||
if spans[i].ParentSpanID() != parent.SpanContext().SpanID {
|
||||
t.Errorf("Span %v had parent %v. Expected %d", spans[i].Name(), spans[i].ParentSpanID(), parent.SpanContext().SpanID)
|
||||
}
|
||||
parent = spans[i]
|
||||
}
|
||||
}
|
||||
|
||||
func TestStartOptions(t *testing.T) {
|
||||
sr := new(oteltest.StandardSpanRecorder)
|
||||
tp := oteltest.NewTracerProvider(oteltest.WithSpanRecorder(sr))
|
||||
octrace.DefaultTracer = NewTracer(tp.Tracer("startoptionstracer"))
|
||||
|
||||
ctx := context.Background()
|
||||
_, span := octrace.StartSpan(ctx, "OpenCensusSpan", octrace.WithSpanKind(octrace.SpanKindClient))
|
||||
span.End()
|
||||
|
||||
spans := sr.Completed()
|
||||
|
||||
if len(spans) != 1 {
|
||||
t.Fatalf("Got %d spans, exepected %d", len(spans), 1)
|
||||
}
|
||||
|
||||
if spans[0].SpanKind() != trace.SpanKindClient {
|
||||
t.Errorf("Got span kind %v, exepected %d", spans[0].SpanKind(), trace.SpanKindClient)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStartSpanWithRemoteParent(t *testing.T) {
|
||||
sr := new(oteltest.StandardSpanRecorder)
|
||||
tp := oteltest.NewTracerProvider(oteltest.WithSpanRecorder(sr))
|
||||
tracer := tp.Tracer("remoteparent")
|
||||
octrace.DefaultTracer = NewTracer(tracer)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx, parent := tracer.Start(ctx, "OpenTelemetrySpan1")
|
||||
|
||||
_, span := octrace.StartSpanWithRemoteParent(ctx, "OpenCensusSpan", otelSpanContextToOc(parent.SpanContext()))
|
||||
span.End()
|
||||
|
||||
spans := sr.Completed()
|
||||
|
||||
if len(spans) != 1 {
|
||||
t.Fatalf("Got %d spans, exepected %d", len(spans), 1)
|
||||
}
|
||||
|
||||
if spans[0].ParentSpanID() != parent.SpanContext().SpanID {
|
||||
t.Errorf("Span %v, had parent %v. Expected %d", spans[0].Name(), spans[0].ParentSpanID(), parent.SpanContext().SpanID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestToFromContext(t *testing.T) {
|
||||
sr := new(oteltest.StandardSpanRecorder)
|
||||
tp := oteltest.NewTracerProvider(oteltest.WithSpanRecorder(sr))
|
||||
tracer := tp.Tracer("tofromcontext")
|
||||
octrace.DefaultTracer = NewTracer(tracer)
|
||||
|
||||
func() {
|
||||
ctx := context.Background()
|
||||
|
||||
_, otSpan1 := tracer.Start(ctx, "OpenTelemetrySpan1")
|
||||
defer otSpan1.End()
|
||||
|
||||
// Use NewContext instead of the context from Start
|
||||
ctx = octrace.NewContext(ctx, octrace.NewSpan(&span{otSpan: otSpan1}))
|
||||
|
||||
ctx, _ = tracer.Start(ctx, "OpenTelemetrySpan2")
|
||||
|
||||
// Get the opentelemetry span using the OpenCensus FromContext, and end it
|
||||
otSpan2 := octrace.FromContext(ctx)
|
||||
defer otSpan2.End()
|
||||
|
||||
}()
|
||||
|
||||
spans := sr.Completed()
|
||||
|
||||
if len(spans) != 2 {
|
||||
t.Fatalf("Got %d spans, exepected %d.", len(spans), 2)
|
||||
}
|
||||
|
||||
parent := &oteltest.Span{}
|
||||
for i := range spans {
|
||||
// Reverse the order we look at the spans in, since they are listed in last-to-first order.
|
||||
i = len(spans) - i - 1
|
||||
// Verify that OpenCensus spans and opentelemetry spans have each other as parents.
|
||||
if spans[i].ParentSpanID() != parent.SpanContext().SpanID {
|
||||
t.Errorf("Span %v had parent %v. Expected %d", spans[i].Name(), spans[i].ParentSpanID(), parent.SpanContext().SpanID)
|
||||
}
|
||||
parent = spans[i]
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsRecordingEvents(t *testing.T) {
|
||||
sr := new(oteltest.StandardSpanRecorder)
|
||||
tp := oteltest.NewTracerProvider(oteltest.WithSpanRecorder(sr))
|
||||
octrace.DefaultTracer = NewTracer(tp.Tracer("isrecordingevents"))
|
||||
|
||||
ctx := context.Background()
|
||||
_, ocspan := octrace.StartSpan(ctx, "OpenCensusSpan1")
|
||||
if !ocspan.IsRecordingEvents() {
|
||||
t.Errorf("Got %v, expected true", ocspan.IsRecordingEvents())
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetThings(t *testing.T) {
|
||||
sr := new(oteltest.StandardSpanRecorder)
|
||||
tp := oteltest.NewTracerProvider(oteltest.WithSpanRecorder(sr))
|
||||
octrace.DefaultTracer = NewTracer(tp.Tracer("setthings"))
|
||||
|
||||
ctx := context.Background()
|
||||
_, ocspan := octrace.StartSpan(ctx, "OpenCensusSpan1")
|
||||
ocspan.SetName("span-foo")
|
||||
ocspan.SetStatus(octrace.Status{Code: 1, Message: "foo"})
|
||||
ocspan.AddAttributes(
|
||||
octrace.BoolAttribute("bool", true),
|
||||
octrace.Int64Attribute("int64", 12345),
|
||||
octrace.Float64Attribute("float64", 12.345),
|
||||
octrace.StringAttribute("string", "stringval"),
|
||||
)
|
||||
ocspan.Annotate(
|
||||
[]octrace.Attribute{octrace.StringAttribute("string", "annotateval")},
|
||||
"annotate",
|
||||
)
|
||||
ocspan.Annotatef(
|
||||
[]octrace.Attribute{
|
||||
octrace.Int64Attribute("int64", 12345),
|
||||
octrace.Float64Attribute("float64", 12.345),
|
||||
},
|
||||
"annotate%d", 67890,
|
||||
)
|
||||
ocspan.AddMessageSendEvent(123, 456, 789)
|
||||
ocspan.AddMessageReceiveEvent(246, 135, 369)
|
||||
ocspan.End()
|
||||
|
||||
spans := sr.Completed()
|
||||
|
||||
if len(spans) != 1 {
|
||||
t.Fatalf("Got %d spans, exepected %d.", len(spans), 1)
|
||||
}
|
||||
s := spans[0]
|
||||
|
||||
if s.Name() != "span-foo" {
|
||||
t.Errorf("Got name %v, expected span-foo", s.Name())
|
||||
}
|
||||
|
||||
if s.StatusCode().String() != codes.Error.String() {
|
||||
t.Errorf("Got code %v, expected 1", s.StatusCode().String())
|
||||
}
|
||||
|
||||
if s.StatusMessage() != "foo" {
|
||||
t.Errorf("Got code %v, expected foo", s.StatusMessage())
|
||||
}
|
||||
|
||||
if v := s.Attributes()[label.Key("bool")]; !v.AsBool() {
|
||||
t.Errorf("Got attributes[bool] %v, expected true", v.AsBool())
|
||||
}
|
||||
if v := s.Attributes()[label.Key("int64")]; v.AsInt64() != 12345 {
|
||||
t.Errorf("Got attributes[int64] %v, expected 12345", v.AsInt64())
|
||||
}
|
||||
if v := s.Attributes()[label.Key("float64")]; v.AsFloat64() != 12.345 {
|
||||
t.Errorf("Got attributes[float64] %v, expected 12.345", v.AsFloat64())
|
||||
}
|
||||
if v := s.Attributes()[label.Key("string")]; v.AsString() != "stringval" {
|
||||
t.Errorf("Got attributes[string] %v, expected stringval", v.AsString())
|
||||
}
|
||||
|
||||
if len(s.Events()) != 4 {
|
||||
t.Fatalf("Got len(events) = %v, expected 4", len(s.Events()))
|
||||
}
|
||||
annotateEvent := s.Events()[0]
|
||||
annotatefEvent := s.Events()[1]
|
||||
sendEvent := s.Events()[2]
|
||||
receiveEvent := s.Events()[3]
|
||||
if v := annotateEvent.Attributes[label.Key("string")]; v.AsString() != "annotateval" {
|
||||
t.Errorf("Got annotateEvent.Attributes[string] = %v, expected annotateval", v.AsString())
|
||||
}
|
||||
if annotateEvent.Name != "annotate" {
|
||||
t.Errorf("Got annotateEvent.Name = %v, expected annotate", annotateEvent.Name)
|
||||
}
|
||||
if v := annotatefEvent.Attributes[label.Key("int64")]; v.AsInt64() != 12345 {
|
||||
t.Errorf("Got annotatefEvent.Attributes[int64] = %v, expected 12345", v.AsInt64())
|
||||
}
|
||||
if v := annotatefEvent.Attributes[label.Key("float64")]; v.AsFloat64() != 12.345 {
|
||||
t.Errorf("Got annotatefEvent.Attributes[float64] = %v, expected 12.345", v.AsFloat64())
|
||||
}
|
||||
if annotatefEvent.Name != "annotate67890" {
|
||||
t.Errorf("Got annotatefEvent.Name = %v, expected annotate67890", annotatefEvent.Name)
|
||||
}
|
||||
if v := annotateEvent.Attributes[label.Key("string")]; v.AsString() != "annotateval" {
|
||||
t.Errorf("Got annotateEvent.Attributes[string] = %v, expected annotateval", v.AsString())
|
||||
}
|
||||
if sendEvent.Name != "message send" {
|
||||
t.Errorf("Got sendEvent.Name = %v, expected message send", sendEvent.Name)
|
||||
}
|
||||
if v := sendEvent.Attributes[uncompressedKey]; v.AsInt64() != 456 {
|
||||
t.Errorf("Got sendEvent.Attributes[uncompressedKey] = %v, expected 456", v.AsInt64())
|
||||
}
|
||||
if v := sendEvent.Attributes[compressedKey]; v.AsInt64() != 789 {
|
||||
t.Errorf("Got sendEvent.Attributes[compressedKey] = %v, expected 789", v.AsInt64())
|
||||
}
|
||||
if receiveEvent.Name != "message receive" {
|
||||
t.Errorf("Got receiveEvent.Name = %v, expected message receive", receiveEvent.Name)
|
||||
}
|
||||
if v := receiveEvent.Attributes[uncompressedKey]; v.AsInt64() != 135 {
|
||||
t.Errorf("Got receiveEvent.Attributes[uncompressedKey] = %v, expected 135", v.AsInt64())
|
||||
}
|
||||
if v := receiveEvent.Attributes[compressedKey]; v.AsInt64() != 369 {
|
||||
t.Errorf("Got receiveEvent.Attributes[compressedKey] = %v, expected 369", v.AsInt64())
|
||||
}
|
||||
}
|
10
bridge/opencensus/go.mod
Normal file
10
bridge/opencensus/go.mod
Normal file
@ -0,0 +1,10 @@
|
||||
module go.opentelemetry.io/opentelemetry-go/bridge/opencensus
|
||||
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
go.opencensus.io v0.22.6-0.20201102222123-380f4078db9f
|
||||
go.opentelemetry.io/otel v0.13.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel => ../..
|
59
bridge/opencensus/go.sum
Normal file
59
bridge/opencensus/go.sum
Normal file
@ -0,0 +1,59 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 h1:ZgQEtGgCBiWRM39fZuwSd1LwSqqSW0hOdXCYYDX0R3I=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
go.opencensus.io v0.22.6-0.20201102222123-380f4078db9f h1:IUmbcoP9XyEXW+R9AbrZgDvaYVfTbISN92Y5RIV+Mx4=
|
||||
go.opencensus.io v0.22.6-0.20201102222123-380f4078db9f/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
Loading…
x
Reference in New Issue
Block a user