1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-29 23:07:45 +02:00

Add options to opencensus bridge, and install tracer instead of returning (#4567)

* Add options to opencensus bridge, and install tracer instead of returning

* add unit test

* update unit tests

* fix example

* import ordering

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
David Ashpole
2023-09-29 11:07:06 -04:00
committed by GitHub
parent 0022098fd2
commit 0f09b9b2d8
7 changed files with 149 additions and 12 deletions

View File

@@ -78,8 +78,7 @@ func tracing(otExporter sdktrace.SpanExporter) {
otel.SetTracerProvider(tp)
log.Println("Installing the OpenCensus bridge to make OpenCensus libraries write spans using OpenTelemetry.")
tracer := tp.Tracer("simple")
octrace.DefaultTracer = opencensus.NewTracer(tracer)
opencensus.InstallTraceBridge()
tp.ForceFlush(ctx)
log.Println("Creating OpenCensus span, which should be printed out using the OpenTelemetry stdouttrace exporter.\n-- It should have no parent, since it is the first span.")
@@ -88,7 +87,7 @@ func tracing(otExporter sdktrace.SpanExporter) {
tp.ForceFlush(ctx)
log.Println("Creating OpenTelemetry span\n-- It should have the OpenCensus span as a parent, since the OpenCensus span was written with using OpenTelemetry APIs.")
ctx, otspan := tracer.Start(ctx, "OpenTelemetrySpan")
ctx, otspan := tp.Tracer("simple").Start(ctx, "OpenTelemetrySpan")
otspan.End()
tp.ForceFlush(ctx)