Skip to content

Commit

Permalink
Change OTLP example to use syncer (#756)
Browse files Browse the repository at this point in the history
* change otlp-example to use syncer

* precommit

Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
  • Loading branch information
stefanprisca and jmacd authored May 21, 2020
1 parent 84a21fe commit 7329ccc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
13 changes: 5 additions & 8 deletions example/otel-collector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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`.
Expand Down
1 change: 0 additions & 1 deletion example/otel-collector/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
7 changes: 1 addition & 6 deletions example/otel-collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -75,6 +72,4 @@ func main() {
}

span.End()
// Wait 1 second before ending
<-time.After(time.Second)
}

0 comments on commit 7329ccc

Please sign in to comment.