Skip to content

Commit

Permalink
Update to OTel-Go 1.0.0-RC1 (draft)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua MacDonald committed Jun 21, 2021
1 parent 4686d49 commit 09257e8
Show file tree
Hide file tree
Showing 6 changed files with 373 additions and 60 deletions.
19 changes: 8 additions & 11 deletions examples/tracing/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (
"github.com/lightstep/otel-launcher-go/launcher"
"go.opentelemetry.io/collector/translator/conventions"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/baggage"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/trace"
Expand All @@ -44,7 +44,7 @@ func main() {
ctx2, finish2 := tracer.Start(ctx1, "bar")
defer finish2.End()

ctx3, finish3 := tracer.Start(ctx2, "baz")
ctx3, finish3 := tracer.Start(setBaggage(ctx2), "baz")
defer finish3.End()

ctx := ctx3
Expand All @@ -54,7 +54,6 @@ func main() {
recordException(ctx)
createChild(ctx, tracer)
setResourceAttributes()
setBaggage()

fmt.Println("OpenTelemetry example")
}
Expand Down Expand Up @@ -103,18 +102,16 @@ func setResourceAttributes() {
attribute.String(conventions.AttributeHostName, host),
}
tp := sdktrace.NewTracerProvider(
sdktrace.WithResource(resource.NewWithAttributes(attributes...)),
sdktrace.WithResource(resource.NewWithAttributes("schema", attributes...)),
)
otel.SetTracerProvider(tp)
}

// example of setting baggage
func setBaggage() {
ctx := baggage.ContextWithValues(context.Background(),
attribute.String("keyone", "foo1"),
attribute.String("keytwo", "bar1"),
)
func setBaggage(ctx context.Context) context.Context {
mem1, _ := baggage.NewMember("keyone", "foo1")
mem2, _ := baggage.NewMember("keytwo", "bar1")
bag, _ := baggage.New(mem1, mem2)

fmt.Printf("key keyone: %v\n", baggage.Value(ctx, "keyone"))
fmt.Printf("key keytwo: %v\n", baggage.Value(ctx, "keytwo"))
return baggage.ContextWithBaggage(context.Background(), bag)
}
29 changes: 14 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@ go 1.14
require (
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/sethvargo/go-envconfig v0.3.2
github.com/shirou/gopsutil v3.20.12+incompatible // indirect
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/collector v0.20.0
go.opentelemetry.io/contrib/instrumentation/host v0.20.0
go.opentelemetry.io/contrib/instrumentation/runtime v0.20.0
go.opentelemetry.io/contrib/propagators v0.20.0
go.opentelemetry.io/otel v0.20.0
go.opentelemetry.io/otel/exporters/otlp v0.20.0
go.opentelemetry.io/otel/metric v0.20.0
go.opentelemetry.io/otel/sdk v0.20.0
go.opentelemetry.io/otel/sdk/metric v0.20.0
go.opentelemetry.io/otel/trace v0.20.0
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect
golang.org/x/sys v0.0.0-20210123111255-9b0068b26619 // indirect
google.golang.org/genproto v0.0.0-20210122163508-8081c04a3579 // indirect
google.golang.org/grpc v1.37.0
go.opentelemetry.io/collector v0.28.0
go.opentelemetry.io/contrib/instrumentation/host v0.21.0
go.opentelemetry.io/contrib/instrumentation/runtime v0.21.0
go.opentelemetry.io/contrib/propagators v0.21.0
go.opentelemetry.io/otel v1.0.0-RC1
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.21.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.21.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0-RC1
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0-RC1
go.opentelemetry.io/otel/metric v0.21.0
go.opentelemetry.io/otel/sdk v1.0.0-RC1
go.opentelemetry.io/otel/sdk/metric v0.21.0
go.opentelemetry.io/otel/trace v1.0.0-RC1
google.golang.org/grpc v1.38.0
)
Loading

0 comments on commit 09257e8

Please sign in to comment.