* Propagate context changes in mix tests We will need this for testing the correlation context and baggage items propagation between the APIs. * Add baggage interoperation tests The test adds a baggage item to active OT span and some correlation key value to current Otel span. Then makes sure that the OT span contains both the baggage item and some translated version of the correlation key value its Otel sibling got, and that the Otel span contains both the correlation key value and the baggage item its OT sibling got. * Add hooks functionality to baggage propagation This introduces two kinds of hooks into the correlation context code. The set hook gets called every time we set a Map in the context. The hook receives a context with the Map and returns a new context. The get hook gets called every time we get a Map from the context. The hook receives the context and the map, and returns a new Map. These hooks will be used for correlation context and baggage items propagation between the Otel and OT APIs. * Warn on foreign opentracing span * fixup for using otel propagators * Add utility function for setting up bridge and context This prepares the context by installing the hooks, so the correlation context and baggage items can be propagated between the APIs. * Add bridge span constructor So I do not need to remember about initializing a newly added member in several places now. * Propagate baggage across otel and OT APIs This uses the set hook functionality to propagate correlation context changes from Otel to OT spans by inserting keys and values into the baggage items. The get hook functionality is used to propagate baggage items from active OT span into the otel correlation context. * Use correlation Map for baggage items We will put this map into the context with correlation context functions, and that is easier if we have correlation.Map, not map[string]string. * Use otel propagators in bridge The otel propagators are now kinda sorta usable for opentracing bridge. Some more work is needed to make it fully work, though - correlation context set with the otel API is not propagated to OT spans as baggage items yet. Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
OpenTelemetry-Go
The Go OpenTelemetry client.
Installation
This repository includes multiple packages. The api
package contains core data types, interfaces and no-op implementations that comprise the OpenTelemetry API following
the
specification.
The sdk package is the reference implementation of the API.
Libraries that produce telemetry data should only depend on api
and defer the choice of the SDK to the application developer. Applications may
depend on sdk or another package that implements the API.
To install the API and SDK packages,
$ go get -u go.opentelemetry.io/otel
Quick Start
package main
import (
"context"
"log"
"go.opentelemetry.io/otel/api/global"
"go.opentelemetry.io/otel/exporters/trace/stdout"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)
func initTracer() {
exporter, err := stdout.NewExporter(stdout.Options{PrettyPrint: true})
if err != nil {
log.Fatal(err)
}
tp, err := sdktrace.NewProvider(sdktrace.WithConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}),
sdktrace.WithSyncer(exporter))
if err != nil {
log.Fatal(err)
}
global.SetTraceProvider(tp)
}
func main() {
initTracer()
tracer := global.TraceProvider().Tracer("ex.com/basic")
tracer.WithSpan(context.Background(), "foo",
func(ctx context.Context) error {
tracer.WithSpan(ctx, "bar",
func(ctx context.Context) error {
tracer.WithSpan(ctx, "baz",
func(ctx context.Context) error {
return nil
},
)
return nil
},
)
return nil
},
)
}
See the API documentation for more detail, and the opentelemetry-example-app for a complete example.
Compatible Exporters
See the Go packages depending upon sdk/export/trace and sdk/export/metric for a list of all exporters compatible with OpenTelemetry's Go SDK.
Contributing
See the contributing file.
Release Schedule
OpenTelemetry Go is under active development. Below is the release schedule for the Go library. The first version of the release isn't guaranteed to conform to a specific version of the specification, and future releases will not attempt to maintain backward compatibility with the alpha release.
| Component | Version | Target Date | Release Date |
|---|---|---|---|
| Tracing API | Alpha v0.1.0 | October 28 2019 | November 05 2019 |
| Tracing SDK | Alpha v0.1.0 | October 28 2019 | November 05 2019 |
| Jaeger Trace Exporter | Alpha v0.1.0 | October 28 2019 | November 05 2019 |
| Trace Context Propagation | Alpha v0.1.0 | Unknown | November 05 2019 |
| OpenTracing Bridge | Alpha v0.1.0 | October | November 05 2019 |
| Metrics API | Alpha v0.2.0 | October 28 2019 | December 03 2019 |
| Metrics SDK | Alpha v0.2.0 | October 28 2019 | December 03 2019 |
| Prometheus Metrics Exporter | Alpha v0.2.0 | October 28 2019 | December 03 2019 |
| Context Prop. rename/Baggage | Alpha v0.3.0 | December 23 2019 | - |
| OpenTelemetry Collector Exporter | Alpha v0.4.0 | January 15 2020 | - |
| Zipkin Trace Exporter | Alpha | Unknown | - |
| OpenCensus Bridge | Alpha | Unknown | - |