Repository: lightstep/otel-launcher-go
Pull request #35 (2020-11-21 03:46:01)

Updating dependencies to 0.14.0
Bumping dependencies to 0.14.0


Patch:
diff --git a/examples/tracing/trace.go b/examples/tracing/trace.go
index 9d69442..df94351 100644
--- a/examples/tracing/trace.go
+++ b/examples/tracing/trace.go
@@ -23,18 +23,18 @@ import (
 	"github.com/lightstep/otel-launcher-go/launcher"
 	"go.opentelemetry.io/collector/translator/conventions"
 	"go.opentelemetry.io/otel"
-	"go.opentelemetry.io/otel/api/global"
-	"go.opentelemetry.io/otel/api/trace"
+	"go.opentelemetry.io/otel/baggage"
 	"go.opentelemetry.io/otel/codes"
 	"go.opentelemetry.io/otel/label"
 	"go.opentelemetry.io/otel/sdk/resource"
 	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+	"go.opentelemetry.io/otel/trace"
 )
 
 func main() {
-	otel := launcher.ConfigureOpentelemetry()
-	defer otel.Shutdown()
-	tracer := global.Tracer("ex.com/basic")
+	lsLauncher := launcher.ConfigureOpentelemetry()
+	defer lsLauncher.Shutdown()
+	tracer := otel.Tracer("ex.com/basic")
 
 	ctx0 := context.Background()
 
@@ -74,22 +74,22 @@ func addAttribute(ctx context.Context) {
 // example of adding an event to a span
 func addEvent(ctx context.Context) {
 	span := trace.SpanFromContext(ctx)
-	span.AddEvent(ctx, "event1", []label.KeyValue{
+	span.AddEvent("event1", trace.WithAttributes([]label.KeyValue{
 		label.String("event-attr1", "event-string1"),
 		label.Int64("event-attr2", 10),
-	}...)
+	}...))
 }
 
 // example of recording an exception
 func recordException(ctx context.Context) {
 	span := trace.SpanFromContext(ctx)
-	span.RecordError(ctx, errors.New("exception has occurred"))
+	span.RecordError(errors.New("exception has occurred"))
 	span.SetStatus(codes.Error, "internal error")
 }
 
 // example of creating a child span
 func createChild(ctx context.Context, tracer trace.Tracer) {
-	// span := trace.SpanFromContext(ctx)
+	// span := otel.SpanFromContext(ctx)
 	_, childSpan := tracer.Start(ctx, "child")
 	defer childSpan.End()
 	fmt.Printf("child span: %v\n", childSpan)
@@ -104,20 +104,18 @@ func setResourceAttributes() {
 		label.String(conventions.AttributeHostName, host),
 	}
 	tp := sdktrace.NewTracerProvider(
-		sdktrace.WithResource(resource.New(attributes...)),
+		sdktrace.WithResource(resource.NewWithAttributes(attributes...)),
 	)
-	global.SetTracerProvider(tp)
+	otel.SetTracerProvider(tp)
 }
 
 // example of setting baggage
 func setBaggage() {
-	ctx := otel.ContextWithBaggageValues(context.Background(),
+	ctx := baggage.ContextWithValues(context.Background(),
 		label.String("keyone", "foo1"),
 		label.String("keytwo", "bar1"),
 	)
-	bags := otel.Baggage(ctx)
 
-	for iter := bags.Iter(); iter.Next(); {
-		fmt.Printf("key %s: %s\n", iter.Label().Key, iter.Label().Value.AsString())
-	}
+	fmt.Printf("key keyone: %v\n", baggage.Value(ctx, "keyone"))
+	fmt.Printf("key keytwo: %v\n", baggage.Value(ctx, "keytwo"))
 }
diff --git a/go.mod b/go.mod
index 2c5bae5..f41728a 100644
--- a/go.mod
+++ b/go.mod
@@ -6,11 +6,11 @@ require (
 	github.com/sethvargo/go-envconfig v0.3.0
 	github.com/stretchr/testify v1.6.1
 	go.opentelemetry.io/collector v0.7.0
-	go.opentelemetry.io/contrib/instrumentation/host v0.13.0
-	go.opentelemetry.io/contrib/instrumentation/runtime v0.13.0
-	go.opentelemetry.io/contrib/propagators v0.13.0
-	go.opentelemetry.io/otel v0.13.0
-	go.opentelemetry.io/otel/exporters/otlp v0.13.0
-	go.opentelemetry.io/otel/sdk v0.13.0
+	go.opentelemetry.io/contrib/instrumentation/host v0.14.0
+	go.opentelemetry.io/contrib/instrumentation/runtime v0.14.0
+	go.opentelemetry.io/contrib/propagators v0.14.0
+	go.opentelemetry.io/otel v0.14.0
+	go.opentelemetry.io/otel/exporters/otlp v0.14.0
+	go.opentelemetry.io/otel/sdk v0.14.0
 	google.golang.org/grpc v1.32.0
 )
diff --git a/go.sum b/go.sum
index fd8da13..d0df18f 100644
--- a/go.sum
+++ b/go.sum
@@ -392,8 +392,8 @@ github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
 github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/google/go-cmp v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k=
 github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-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/google/go-cmp v0.5.3 h1:x95R7cp+rSeeqAMI2knLtQ0DKlaBhv2NrtrOvafPHRo=
+github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
 github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
@@ -877,20 +877,20 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
 go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
 go.opentelemetry.io/collector v0.7.0 h1:hZK0e2R/uvOrNe0bwqUzRygx3/4U4pkM0CcsfwFks8E=
 go.opentelemetry.io/collector v0.7.0/go.mod h1:E+8jXieKLiZHvPXt6/ZR5Arx6kVjS2RQrePN+lG+4fw=
-go.opentelemetry.io/contrib v0.13.0 h1:q34CFu5REx9Dt2ksESHC/doIjFJkEg1oV3aSwlL5JR0=
-go.opentelemetry.io/contrib v0.13.0/go.mod h1:HzCu6ebm0ywgNxGaEfs3izyJOMP4rZnzxycyTgpI5Sg=
-go.opentelemetry.io/contrib/instrumentation/host v0.13.0 h1:NGT5j2yX3w5WnyG6gKtfape2ecS+SD8K+2njvbP/Hag=
-go.opentelemetry.io/contrib/instrumentation/host v0.13.0/go.mod h1:eh7NEINMuXjFV8/TcPfLU0/4FKNif2kZRGjkc9XQMcw=
-go.opentelemetry.io/contrib/instrumentation/runtime v0.13.0 h1:U5EXyt+Dq46yQ93Bf8h5+u/8Aal6H/BUDnBip1kzx2k=
-go.opentelemetry.io/contrib/instrumentation/runtime v0.13.0/go.mod h1:HIznjbLjna24masZxJ9nmullwSXrVNm/WFDhEPPD0JY=
-go.opentelemetry.io/contrib/propagators v0.13.0 h1:kvhyo7uEkOHzKLBCp0w6b5ZMukRHFOxgRgGQ7lLWFoM=
-go.opentelemetry.io/contrib/propagators v0.13.0/go.mod h1:UYroyL3i60+ruw9LER9RhHNvBRo495v/LNpRwU/CJyQ=
-go.opentelemetry.io/otel v0.13.0 h1:2isEnyzjjJZq6r2EKMsFj4TxiQiexsM04AVhwbR/oBA=
-go.opentelemetry.io/otel v0.13.0/go.mod h1:dlSNewoRYikTkotEnxdmuBHgzT+k/idJSfDv/FxEnOY=
-go.opentelemetry.io/otel/exporters/otlp v0.13.0 h1:iithmYmMAfLFgCW5TcRXHpXR5NTWO7nGtX3WcBiusVE=
-go.opentelemetry.io/otel/exporters/otlp v0.13.0/go.mod h1:YHH58UrGcqCKtBkY7sl3zPKpxBzfC1HUUYMRQONJJ9E=
-go.opentelemetry.io/otel/sdk v0.13.0 h1:4VCfpKamZ8GtnepXxMRurSpHpMKkcxhtO33z1S4rGDQ=
-go.opentelemetry.io/otel/sdk v0.13.0/go.mod h1:dKvLH8Uu8LcEPlSAUsfW7kMGaJBhk/1NYvpPZ6wIMbU=
+go.opentelemetry.io/contrib v0.14.0 h1:ntrQmEKqYQL6z2YNCk+3Cg4lpJwd9aHK/JMOFpda8yc=
+go.opentelemetry.io/contrib v0.14.0/go.mod h1:G/EtFaa6qaN7+LxqfIAT3GiZa7Wv5DTBUzl5H4LY0Kc=
+go.opentelemetry.io/contrib/instrumentation/host v0.14.0 h1:tT3jdYG4iSbxI8uBkv+aZJT/pehiKeScGwMYzocnRsw=
+go.opentelemetry.io/contrib/instrumentation/host v0.14.0/go.mod h1:edzbgOSv1yqovZIumtiDlJ6SVGiWMAezkJ3Ilpl591s=
+go.opentelemetry.io/contrib/instrumentation/runtime v0.14.0 h1:CN6KOuYF+Kdvfw7QxzGV7B1B19YgnNBdd8+hpPsz3TA=
+go.opentelemetry.io/contrib/instrumentation/runtime v0.14.0/go.mod h1:1Mdmr68bBZNMdEDM6VIst+QTD8YdKCvVGizkxf/93qw=
+go.opentelemetry.io/contrib/propagators v0.14.0 h1:Bk8l0d/OH1U2tTsKwuqG8aGcrLPRRE8IDRib/mxzgiM=
+go.opentelemetry.io/contrib/propagators v0.14.0/go.mod h1:/x+dKIF9X8rNbq/fVqMiq9aGvicGvXiJl4JEUqO9AaE=
+go.opentelemetry.io/otel v0.14.0 h1:YFBEfjCk9MTjaytCNSUkp9Q8lF7QJezA06T71FbQxLQ=
+go.opentelemetry.io/otel v0.14.0/go.mod h1:vH5xEuwy7Rts0GNtsCW3HYQoZDY+OmBJ6t1bFGGlxgw=
+go.opentelemetry.io/otel/exporters/otlp v0.14.0 h1:B5uCGwaThlJMVpCeOxRkiVeOhT2t0GcZp8G+x219W5k=
+go.opentelemetry.io/otel/exporters/otlp v0.14.0/go.mod h1:DmFebmd697PT2nIQ6t6p1tx9KQFu+R2PGd+3W62OkAE=
+go.opentelemetry.io/otel/sdk v0.14.0 h1:Pqgd85y5XhyvHQlOxkKW+FD4DAX7AoeaNIDKC2VhfHQ=
+go.opentelemetry.io/otel/sdk v0.14.0/go.mod h1:kGO5pEMSNqSJppHAm8b73zztLxB5fgDQnD56/dl5xqE=
 go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
 go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
 go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
diff --git a/launcher/config.go b/launcher/config.go
index b87c119..c86cc6b 100644
--- a/launcher/config.go
+++ b/launcher/config.go
@@ -29,10 +29,9 @@ import (
 	runtimeMetrics "go.opentelemetry.io/contrib/instrumentation/runtime"
 	"go.opentelemetry.io/contrib/propagators/b3"
 	"go.opentelemetry.io/otel"
-	"go.opentelemetry.io/otel/api/global"
 	"go.opentelemetry.io/otel/exporters/otlp"
 	"go.opentelemetry.io/otel/label"
-	"go.opentelemetry.io/otel/propagators"
+	"go.opentelemetry.io/otel/propagation"
 	controller "go.opentelemetry.io/otel/sdk/metric/controller/push"
 	processor "go.opentelemetry.io/otel/sdk/metric/processor/basic"
 	selector "go.opentelemetry.io/otel/sdk/metric/selector/simple"
@@ -116,7 +115,7 @@ func WithPropagators(propagators []string) Option {
 }
 
 // Configures a global error handler to be used throughout an OpenTelemetry instrumented project.
-// See "go.opentelemetry.io/otel/api/global"
+// See "go.opentelemetry.io/otel"
 func WithErrorHandler(handler otel.ErrorHandler) Option {
 	return func(c *Config) {
 		c.errorHandler = handler
@@ -257,12 +256,12 @@ type Launcher struct {
 
 // configurePropagators configures B3 propagation by default
 func configurePropagators(c *Config) error {
-	propagatorsMap := map[string]otel.TextMapPropagator{
+	propagatorsMap := map[string]propagation.TextMapPropagator{
 		"b3":           b3.B3{},
-		"baggage":      propagators.Baggage{},
-		"tracecontext": propagators.TraceContext{},
+		"baggage":      propagation.Baggage{},
+		"tracecontext": propagation.TraceContext{},
 	}
-	var props []otel.TextMapPropagator
+	var props []propagation.TextMapPropagator
 	for _, key := range c.Propagators {
 		prop := propagatorsMap[key]
 		if prop != nil {
@@ -272,7 +271,7 @@ func configurePropagators(c *Config) error {
 	if len(props) == 0 {
 		return fmt.Errorf("invalid configuration: unsupported propagators. Supported options: b3,cc")
 	}
-	global.SetTextMapPropagator(otel.NewCompositeTextMapPropagator(
+	otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(
 		props...,
 	))
 	return nil
@@ -333,7 +332,7 @@ func newResource(c *Config) *resource.Resource {
 	}
 
 	attributes = append(r.Attributes(), attributes...)
-	return resource.New(attributes...)
+	return resource.NewWithAttributes(attributes...)
 }
 
 func newExporter(accessToken, endpoint string, insecure bool) (*otlp.Exporter, error) {
@@ -373,10 +372,10 @@ func setupTracing(c Config) (func() error, error) {
 		return nil, err
 	}
 
-	global.SetTracerProvider(tp)
+	otel.SetTracerProvider(tp)
 
 	return func() error {
-		bsp.Shutdown()
+		_ = bsp.Shutdown(context.Background())
 		return spanExporter.Shutdown(context.Background())
 	}, nil
 }
@@ -426,7 +425,7 @@ func setupMetrics(c Config) (func() error, error) {
 		return nil, fmt.Errorf("failed to start host metrics: %v", err)
 	}
 
-	global.SetMeterProvider(provider)
+	otel.SetMeterProvider(provider)
 	return func() error {
 		pusher.Stop()
 		return metricExporter.Shutdown(context.Background())
@@ -449,7 +448,7 @@ func ConfigureOpentelemetry(opts ...Option) Launcher {
 	}
 
 	if c.errorHandler != nil {
-		global.SetErrorHandler(c.errorHandler)
+		otel.SetErrorHandler(c.errorHandler)
 	}
 
 	ls := Launcher{


Test patch:
diff --git a/launcher/config_test.go b/launcher/config_test.go
index 5109af7..766266e 100644
--- a/launcher/config_test.go
+++ b/launcher/config_test.go
@@ -24,7 +24,7 @@ import (
 
 	"github.com/stretchr/testify/assert"
 	"go.opentelemetry.io/otel"
-	"go.opentelemetry.io/otel/api/global"
+	"go.opentelemetry.io/otel/baggage"
 	"go.opentelemetry.io/otel/label"
 	"go.opentelemetry.io/otel/sdk/resource"
 )
@@ -315,7 +315,7 @@ func TestDefaultConfig(t *testing.T) {
 		AccessToken:                    "",
 		LogLevel:                       "info",
 		Propagators:                    []string{"b3"},
-		Resource:                       resource.New(attributes...),
+		Resource:                       resource.NewWithAttributes(attributes...),
 		logger:                         logger,
 		errorHandler:                   handler,
 	}
@@ -351,7 +351,7 @@ func TestEnvironmentVariables(t *testing.T) {
 		AccessToken:                    "token",
 		LogLevel:                       "debug",
 		Propagators:                    []string{"b3", "w3c"},
-		Resource:                       resource.New(attributes...),
+		Resource:                       resource.NewWithAttributes(attributes...),
 		logger:                         logger,
 		errorHandler:                   handler,
 	}
@@ -398,7 +398,7 @@ func TestConfigurationOverrides(t *testing.T) {
 		AccessToken:                    "override-access-token",
 		LogLevel:                       "info",
 		Propagators:                    []string{"b3"},
-		Resource:                       resource.New(attributes...),
+		Resource:                       resource.NewWithAttributes(attributes...),
 		logger:                         logger,
 		errorHandler:                   handler,
 	}
@@ -418,7 +418,7 @@ func (t TestCarrier) Set(key string, value string) {
 }
 
 func TestConfigurePropagators(t *testing.T) {
-	ctx := otel.ContextWithBaggageValues(context.Background(),
+	ctx := baggage.ContextWithValues(context.Background(),
 		label.String("keyone", "foo1"),
 		label.String("keytwo", "bar1"),
 	)
@@ -430,13 +430,13 @@ func TestConfigurePropagators(t *testing.T) {
 		WithSpanExporterEndpoint("localhost:443"),
 	)
 	defer lsOtel.Shutdown()
-	ctx, finish := global.Tracer("ex.com/basic").Start(ctx, "foo")
+	ctx, finish := otel.Tracer("ex.com/basic").Start(ctx, "foo")
 	defer finish.End()
 	carrier := TestCarrier{values: map[string]string{}}
-	prop := global.TextMapPropagator()
+	prop := otel.GetTextMapPropagator()
 	prop.Inject(ctx, carrier)
 	assert.Greater(t, len(carrier.Get("x-b3-traceid")), 0)
-	assert.Equal(t, "", carrier.Get("otcorrelations"))
+	assert.Equal(t, "", carrier.Get("baggage"))
 	assert.Equal(t, len(carrier.Get("traceparent")), 0)
 
 	lsOtel = ConfigureOpentelemetry(
@@ -447,11 +447,11 @@ func TestConfigurePropagators(t *testing.T) {
 	)
 	defer lsOtel.Shutdown()
 	carrier = TestCarrier{values: map[string]string{}}
-	prop = global.TextMapPropagator()
+	prop = otel.GetTextMapPropagator()
 	prop.Inject(ctx, carrier)
 	assert.Greater(t, len(carrier.Get("x-b3-traceid")), 0)
-	assert.Contains(t, carrier.Get("otcorrelations"), "keytwo=bar1")
-	assert.Contains(t, carrier.Get("otcorrelations"), "keyone=foo1")
+	assert.Contains(t, carrier.Get("baggage"), "keytwo=bar1")
+	assert.Contains(t, carrier.Get("baggage"), "keyone=foo1")
 	assert.Greater(t, len(carrier.Get("traceparent")), 0)
 
 	logger = &testLogger{}