From 7329ccc8231bb8412dfe0508c0918e1a17c61ec0 Mon Sep 17 00:00:00 2001 From: Stefan Prisca Date: Thu, 21 May 2020 20:40:11 +0200 Subject: [PATCH] Change OTLP example to use syncer (#756) * change otlp-example to use syncer * precommit Co-authored-by: Joshua MacDonald --- example/otel-collector/README.md | 13 +++++-------- example/otel-collector/go.sum | 1 - example/otel-collector/main.go | 7 +------ 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/example/otel-collector/README.md b/example/otel-collector/README.md index 67c4857ce3f..382d41ae79b 100644 --- a/example/otel-collector/README.md +++ b/example/otel-collector/README.md @@ -156,14 +156,11 @@ The next step is to create the TraceProvider: ```go tp, err := sdktrace.NewProvider( sdktrace.WithConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}), - sdktrace.WithResourceAttributes( + sdktrace.WithResource(resource.New( // the service name used to display traces in Jaeger - core.Key(conventions.AttributeServiceName).String("test-service"), - ), - sdktrace.WithBatcher(exp, // add following two options to ensure flush - sdktrace.WithScheduleDelayMillis(5), - sdktrace.WithMaxExportBatchSize(2), - )) + kv.Key(conventions.AttributeServiceName).String("test-service"), + )), + sdktrace.WithSyncer(exp)) if err != nil { log.Fatalf("error creating trace provider: %v\n", err) } @@ -175,7 +172,7 @@ After this, you can simply start sending traces: ```go tracer := tp.Tracer("test-tracer") ctx, span := tracer.Start(context.Background(), "CollectorExporter-Example") - defer span.End() +defer span.End() ``` The traces should now be visible from the Jaeger UI (if you have it installed), or thorough the jaeger-query service, under the name `test-service`. diff --git a/example/otel-collector/go.sum b/example/otel-collector/go.sum index 683a554dfd8..7f08f906d70 100644 --- a/example/otel-collector/go.sum +++ b/example/otel-collector/go.sum @@ -414,7 +414,6 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.5 h1:F768QJ1E9tib+q5Sc8MkdJi1RxLTbRcTf8LJV56aRls= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= diff --git a/example/otel-collector/main.go b/example/otel-collector/main.go index c16002f7ef3..44625816216 100644 --- a/example/otel-collector/main.go +++ b/example/otel-collector/main.go @@ -55,10 +55,7 @@ func main() { // the service name used to display traces in Jaeger kv.Key(conventions.AttributeServiceName).String("test-service"), )), - sdktrace.WithBatcher(exp, // add following two options to ensure flush - sdktrace.WithBatchTimeout(5), - sdktrace.WithMaxExportBatchSize(2), - )) + sdktrace.WithSyncer(exp)) if err != nil { log.Fatalf("error creating trace provider: %v\n", err) } @@ -75,6 +72,4 @@ func main() { } span.End() - // Wait 1 second before ending - <-time.After(time.Second) }