Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure batch span processors are shutdown in examples #1199

Merged
merged 2 commits into from
Sep 24, 2020

Conversation

dashpole
Copy link
Contributor

@dashpole dashpole commented Sep 23, 2020

Issue #1197.

Spans in examples are not printed out because the program finishes before spans are handled in the batch processor. Based on the API, this should be properly solved by calling Shutdown() on the batch span processor before the program terminates. I limited this change to only fixing the examples, although I think some follow-up changes are probably warranted, which I have documented in the issue.

@codecov
Copy link

codecov bot commented Sep 23, 2020

Codecov Report

Merging #1199 into master will decrease coverage by 0.0%.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #1199     +/-   ##
========================================
- Coverage    76.4%   76.3%   -0.1%     
========================================
  Files         134     134             
  Lines        5732    5720     -12     
========================================
- Hits         4382    4370     -12     
  Misses       1106    1106             
  Partials      244     244             
Impacted Files Coverage Δ
sdk/trace/provider.go 92.9% <0.0%> (-3.5%) ⬇️
sdk/trace/batch_span_processor.go 80.6% <0.0%> (+2.1%) ⬆️

@Aneurysm9 Aneurysm9 linked an issue Sep 23, 2020 that may be closed by this pull request
@Aneurysm9
Copy link
Member

diff --git a/example/basic/main.go b/example/basic/main.go
index 21a8fa6..ab831f9 100644
--- a/example/basic/main.go
+++ b/example/basic/main.go
@@ -48,7 +48,7 @@ func main() {
 
        bsp := sdktrace.NewBatchSpanProcessor(exporter)
        defer bsp.Shutdown()
-       tp := sdktrace.NewProvider(sdktrace.WithSpanProcessor(bsp))
+       tp := sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(bsp))
        pusher := push.New(
                basic.New(
                        simple.NewWithExactDistribution(),
@@ -59,7 +59,7 @@ func main() {
        pusher.Start()
        defer pusher.Stop()
        global.SetTracerProvider(tp)
-       global.SetMeterProvider(pusher.Provider())
+       global.SetMeterProvider(pusher.MeterProvider())
 
        tracer := global.Tracer("ex.com/basic")
        meter := global.Meter("ex.com/basic")

@Aneurysm9 Aneurysm9 merged commit 304d4cd into open-telemetry:master Sep 24, 2020
@pellared pellared added this to the untracked milestone Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Basic and namedtracer examples do not print traces
3 participants