6402598a1f
* add optional server url arg to http client example Signed-off-by: Andrew Hsu <xuzuan@gmail.com> * add Dockerfile to build example http images Multi-stage Dockerfile with targets for building example http server and client. $ docker build --tag the-server --target example-http-server . $ docker build --tag the-client --target example-http-client . Signed-off-by: Andrew Hsu <xuzuan@gmail.com> * add docker-compose.yml file for running examples This docker compose configuration file will help a new user to compile and run the example code quickly. Uses the Dockerfile to build images with compiled examples. $ docker-compose build http-server http-client $ docker-compose up http-server http-client Signed-off-by: Andrew Hsu <xuzuan@gmail.com> * add newline to last message of example http client Signed-off-by: Andrew Hsu <xuzuan@gmail.com> * add optional collector url arg to zipkin client example Signed-off-by: Andrew Hsu <xuzuan@gmail.com> * add Dockerfile target to build zipkin client For building the example zipkin client: $ docker build --tag zipkin-client --target example-zipkin-client . Signed-off-by: Andrew Hsu <xuzuan@gmail.com> * add docker compose service to run zipkin examples Services to run the zipkin client along with a zipkin collector: $ docker-compose build zipkin-client $ docker-compose up zipkin-collector zipkin-client Since the zipkin collector takes a few seconds before it is ready to receive traces, I added a simple retry loop to the client command. The collector service exposes port 9411 so user can visit http//localhost:9411/ to see the trace sent to the collector. Be sure to search by the trace id logged by the client. Signed-off-by: Andrew Hsu <xuzuan@gmail.com> * Update Dockerfile with AL2 declaration As described in https://www.apache.org/licenses/LICENSE-2.0#apply Co-Authored-By: Tyler Yahn <MrAlias@users.noreply.github.com> * Update docker-compose.yml with AL2 declaration As described in https://www.apache.org/licenses/LICENSE-2.0#apply Co-Authored-By: Tyler Yahn <MrAlias@users.noreply.github.com> * pass server url as flag in example http client $ ./client -h Usage of ./client: -server string server url (default "http://localhost:7777/hello") Signed-off-by: Andrew Hsu <xuzuan@gmail.com> * pass zipkin url as flag in example zipkin client $ ./zipkin -h Usage of ./zipkin: -zipkin string zipkin url (default "http://localhost:9411/api/v2/spans") Signed-off-by: Andrew Hsu <xuzuan@gmail.com> * move Dockerfile and docker-compose.yml into example dir Signed-off-by: Andrew Hsu <xuzuan@gmail.com> * add Dockerfile and docker-compose.yml for zipkin example Signed-off-by: Andrew Hsu <xuzuan@gmail.com> * update zipkin example README.md With instructions on how to use docker-compose to run the example. Signed-off-by: Andrew Hsu <xuzuan@gmail.com> * add http example README.md With instructions on how to use docker-compose to run the example. Signed-off-by: Andrew Hsu <xuzuan@gmail.com> * Update example/http/Dockerfile WORKDIR Co-Authored-By: Krzesimir Nowak <qdlacz@gmail.com> * Update example/http/Dockerfile RUN go install Co-Authored-By: Krzesimir Nowak <qdlacz@gmail.com> * Update example/http/Dockerfile RUN go install Co-Authored-By: Krzesimir Nowak <qdlacz@gmail.com> * Update example/zipkin/Dockerfile WORKDIR Co-Authored-By: Krzesimir Nowak <qdlacz@gmail.com> * Update example/zipkin/Dockerfile RUN go install Co-Authored-By: Krzesimir Nowak <qdlacz@gmail.com> Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com> Co-authored-by: Krzesimir Nowak <qdlacz@gmail.com> Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com> |
||
---|---|---|
.circleci | ||
api | ||
bridge/opentracing | ||
example | ||
exporters | ||
internal | ||
plugin | ||
sdk | ||
tools | ||
.gitignore | ||
.golangci.yml | ||
CODEOWNERS | ||
CONTRIBUTING.md | ||
get_main_pkgs.sh | ||
go.mod | ||
go.sum | ||
LICENSE | ||
Makefile | ||
pre_release.sh | ||
README.md | ||
RELEASING.md | ||
tag.sh | ||
verify_examples.sh |
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.
All packages are published to go.opentelemetry.io/otel and is the preferred location to import from.
Additional resources:
Quick Start
Below is a brief example of importing OpenTelemetry, initializing a tracer and creating some simple spans.
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.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.
Compatible Libraries
See the opentelemetry-go-contrib repo for packages that facilitates instrumenting other useful Go libraries with opentelemetry-go for distributed tracing and monitoring.
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 | Release Date |
---|---|---|
Tracing API | Alpha v0.1.0 | November 05 2019 |
Tracing SDK | Alpha v0.1.0 | November 05 2019 |
Jaeger Trace Exporter | Alpha v0.1.0 | November 05 2019 |
Trace Context Propagation | Alpha v0.1.0 | November 05 2019 |
OpenTracing Bridge | Alpha v0.1.0 | November 05 2019 |
Metrics API | Alpha v0.2.0 | December 03 2019 |
Metrics SDK | Alpha v0.2.0 | December 03 2019 |
Prometheus Metrics Exporter | Alpha v0.2.0 | December 03 2019 |
Context Prop. rename/Baggage | Beta v0.4.0 | March 30 2020 |
OpenTelemetry Collector Exporter | Beta v0.4.0 | March 30 2020 |
Zipkin Trace Exporter | Beta v0.4.0 | March 30 2020 |
OTLP Trace & Metrics Exporter | Beta v0.4.0 | March 30 2020 |