Closed arun0009 closed 3 years ago
Hi this change is not needed. If you close the reporter on exit it will send completed spans that are still in the reporter queue.
Per your example:
package main
import (
"context"
"fmt"
"github.com/openzipkin/zipkin-go"
zipkinHttpReporter "github.com/openzipkin/zipkin-go/reporter/http"
)
const ZipkinHttpEndpoint = "http://localhost:9411/api/v2/spans"
func main() {
reporter := zipkinHttpReporter.NewReporter(ZipkinHttpEndpoint)
defer reporter.Close() // this will make sure the spans are reported to the collector on exit.
endpoint, err := zipkin.NewEndpoint("myService", "")
if err != nil {
fmt.Println("error creating endpoint", err)
}
tracer, err := zipkin.NewTracer(reporter, zipkin.WithLocalEndpoint(endpoint))
if err != nil {
fmt.Println("error creating tracer", err)
}
span, _ := tracer.StartSpanFromContext(context.Background(), "test")
span.Finish()
}
closing this issue as reporter.Close()
will send spans over before lambda terminates
We aren't getting tracing when using zipkin-go in lambda function unless we add some kind of sleep so that tracing data gets a chance to be sent to reporter (default time is 1 second).
Here's an example, if you run this code on a local Zipkin docker, it won't show any trace unless we uncomment the last sleep statement.
Allowing to set an asynchronous option (defaulting to true, to maintain current behavior), if set to false will send reporting data in sync. Added tests to show async vs sync behavior.