1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-01-07 23:02:15 +02:00
opentelemetry-go/example
Krzesimir Nowak 942713a02d
Replace span relationship with a potentially remote parent context (#451)
This PR removes the non-compliant ChildOf and FollowsFrom interfaces
and the Relation type, which were inherited from OpenTracing via the
initial prototype. Instead allow adding a span context to the go
context as a remote span context and use a simple algorithm for
figuring out an actual parent of the new span, which was proposed for
the OpenTelemetry specification.

Also add a way to ignore current span and remote span context in go
context, so we can force the tracer to create a new root span - a span
with a new trace ID.

That required some moderate changes in the opentracing bridge - first
reference with ChildOfRef reference type becomes a local parent, the
rest become links. This also fixes links handling in the meantime. The
downside of the approach proposed here is that we can only set the
remote parent when creating a span through the opentracing API.

Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
2020-02-04 08:55:03 -08:00
..
basic Reorganize propagation code (shrink PR 381) (#444) 2020-01-28 10:13:46 -08:00
grpc Replace span relationship with a potentially remote parent context (#451) 2020-02-04 08:55:03 -08:00
http Replace span relationship with a potentially remote parent context (#451) 2020-02-04 08:55:03 -08:00
http-stackdriver Replace span relationship with a potentially remote parent context (#451) 2020-02-04 08:55:03 -08:00
jaeger go module update for release v0.2.1 (#413) 2020-01-08 09:41:58 -05:00
namedtracer Reorganize propagation code (shrink PR 381) (#444) 2020-01-28 10:13:46 -08:00
prometheus go module update for release v0.2.1 (#413) 2020-01-08 09:41:58 -05:00
README.md Namespace import path under "/otel" (#274) 2019-11-01 11:40:29 -07:00

Example

HTTP

This is a simple example that demonstrates tracing http request from client to server. The example shows key aspects of tracing such as:

  • Root Span (on Client)
  • Child Span (on Client)
  • Child Span from a Remote Parent (on Server)
  • SpanContext Propagation (from Client to Server)
  • Span Events
  • Span Attributes

Example uses

  • open-telemetry SDK as trace instrumentation provider,
  • httptrace plugin to facilitate tracing http request on client and server
  • http trace_context propagation to propagate SpanContext on the wire.
  • stdout exporter to print information about spans in the terminal

How to run?

Prequisites

  • go 1.13 installed
  • GOPATH is configured.

1 Download git repo

GO111MODULE="" go get -d go.opentelemetry.io/otel

2 Start Server

cd $GOPATH/src/go.opentelemetry.io/otel/example/http/
go run ./server/server.go

3 Start Client

cd $GOPATH/src/go.opentelemetry.io/otel/example/http/
go run ./client/client.go

4 Check traces in stdout

The spans should be visible in stdout in the order that they were exported.