Skip to content

Commit

Permalink
Create README.md for the ot bridge (open-telemetry#2896)
Browse files Browse the repository at this point in the history
* Create README.md

Some very bare-bones introductory documentation on how to use the ot bridge

* Update README.md

linting

* Update README.md

more linting

* Update bridge/opentracing/README.md

Co-authored-by: Tyler Yahn <[email protected]>

* Update bridge/opentracing/README.md

Co-authored-by: Tyler Yahn <[email protected]>

* Update bridge/opentracing/README.md

Co-authored-by: Tyler Yahn <[email protected]>

* Update bridge/opentracing/README.md

Co-authored-by: Tyler Yahn <[email protected]>

* Update bridge/opentracing/README.md

Co-authored-by: Tyler Yahn <[email protected]>

* Update bridge/opentracing/README.md

Co-authored-by: Tyler Yahn <[email protected]>

Co-authored-by: Tyler Yahn <[email protected]>
  • Loading branch information
jkwatson and MrAlias authored May 17, 2022
1 parent 2a02a55 commit 4475aaa
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions bridge/opentracing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# OpenTelemetry/OpenTracing Bridge

## Getting started

`go get go.opentelemetry.io/otel/bridge/opentracing`

Assuming you have configured an OpenTelemetry `TracerProvider`, these will be the steps to follow to wire up the bridge:

```go
import (
"go.opentelemetry.io/otel"
otelBridge "go.opentelemetry.io/otel/bridge/opentracing"
)

func main() {
/* Create tracerProvider and configure OpenTelemetry ... */

otelTracer := tracerProvider.Tracer("tracer_name")
// Use the bridgeTracer as your OpenTracing tracer.
bridgeTracer, wrapperTracerProvider := otelBridge.NewTracerPair(otelTracer)
// Set the wrapperTracerProvider as the global OpenTelemetry
// TracerProvider so instrumentation will use it by default.
otel.SetTracerProvider(wrapperTracerProvider)

/* ... */
}
```

## Interop from trace context from OpenTracing to OpenTelemetry

In order to get OpenTracing spans properly into the OpenTelemetry context, so they can be propagated (both internally, and externally), you will need to explicitly use the `BridgeTracer` for creating your OpenTracing spans, rather than a bare OpenTracing `Tracer` instance.

When you have started an OpenTracing Span, make sure the OpenTelemetry knows about it like this:

```go
ctxWithOTSpan := opentracing.ContextWithSpan(ctx, otSpan)
ctxWithOTAndOTelSpan := bridgeTracer.ContextWithSpanHook(ctxWithOTSpan, otSpan)
// Propagate the otSpan to both OpenTracing and OpenTelemetry
// instrumentation by using the ctxWithOTAndOTelSpan context.
```

0 comments on commit 4475aaa

Please sign in to comment.