Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Standards in Distributed Tracing

Standards in Distributed Tracing

An introduction to the standards used in Distributed Tracing, specifically OpenTracing, OpenCensus, and W3C TraceContext.

Thomas Watson

March 07, 2019
Tweet

More Decks by Thomas Watson

Other Decks in Programming

Transcript

  1. @wa7son Date: Mon, 29 Oct 2018 16:11:05 GMT Connection: keep-alive

    Content-Length: 0 GET /products HTTP/1.1 Host: www.example.com <magic header>
  2. @wa7son Date: Mon, 29 Oct 2018 16:11:05 GMT Connection: keep-alive

    Content-Length: 0 GET /products HTTP/1.1 Host: www.example.com <magic header>
  3. @wa7son GET /products HTTP/1.1 Host: www.example.com : - - -

    Date: Mon, 29 Oct 2018 16:11:05 GMT Connection: keep-alive Content-Length: 0 00 82c5500f40667e5500e9ae8e9711553c 992631f881f78c3b 01 traceparent
  4. @wa7son GET /products HTTP/1.1 Host: www.example.com : - - -

    Date: Mon, 29 Oct 2018 16:11:05 GMT Connection: keep-alive Content-Length: 0 00 82c5500f40667e5500e9ae8e9711553c 992631f881f78c3b 01 traceparent GET /products HTTP/1.1 Host: www.example.com traceparent: 00-82c5500f40667e5500e9ae8e9711553c-992631f881f78c3b-01 Date: Mon, 29 Oct 2018 16:11:05 GMT Connection: keep-alive Content-Length: 0 Trace Context Working Group DRAFT
  5. @wa7son GET /products HTTP/1.1 Host: www.example.com : - - -

    Date: Mon, 29 Oct 2018 16:11:05 GMT Connection: keep-alive Content-Length: 0 00 82c5500f40667e5500e9ae8e9711553c 992631f881f78c3b 01 traceparent
  6. @wa7son 00 82c5500f40667e5500e9ae8e9711553c 992631f881f78c3b 01 Version Trace ID 1 byte

    8 bits 128 bit random number 64 bit random number Parent Span ID Trace Flags traceparent
  7. @wa7son 00 82c5500f40667e5500e9ae8e9711553c 992631f881f78c3b 01 Version Trace ID Parent Span

    ID Trace Flags 1 byte 8 bits 128 bit random number 64 bit random number Trace Flags Recorded — 0b00000001 traceparent
  8. @wa7son GET /products HTTP/1.1 Host: www.example.com traceparent: 00-82c5500f40667e5500e9ae8e9711553c-992631f881f78c3b-01 Date: Mon,

    29 Oct 2018 16:11:05 GMT Connection: keep-alive Content-Length: 0 : <vendorname1=opaqueValue1>,<vendorname2=opaqueValue2>,… tracestate DRAFT
  9. @wa7son Programmatic API Integrations (frameworks, db’s, etc) Context Propagation (in

    process) Context Propagation (cross service) Data format Backend transport protocol Backend / UI
  10. @wa7son TraceContext Programmatic API Integrations (frameworks, db’s, etc) Context Propagation

    (in process) Context Propagation (cross service) ✅ Data format Backend transport protocol Backend / UI
  11. @wa7son const opentracing = require('opentracing') const tracer = new opentracing.Tracer()

    const span = tracer.startSpan('some work') // Do some work span.finish()
  12. @wa7son // Start a new (parentless) root Span: const parent

    = Tracer.startSpan('DoWork') // Start a new (child) Span: const child = Tracer.startSpan('load-from-db', { childOf: parent.context() }) // Start a new async (FollowsFrom) Span: const child = Tracer.startSpan('async-cache-write', { references: [ opentracing.followsFrom(parent.context()) ] })
  13. @wa7son const headersCarrier = {} // "Serialize" Span Context into

    headersCarrier tracer.inject( clientSpan.context(), Tracer.FORMAT_HTTP_HEADERS, headersCarrier ) // Add tracing headers to headers of outgoing request Object.assign(outboundHTTPReq.headers, headersCarrier)
  14. @wa7son // "De-serialize" Span Context from inbound HTTP request headers

    const headersCarrier = inboundHTTPReq.headers const wireCtx = tracer.extract( Tracer.FORMAT_HTTP_HEADERS, headersCarrier ) const serverSpan = tracer.startSpan('...', { childOf: wireCtx })
  15. @wa7son const { Tracer } = require('my-custom-tracer') const tracer =

    new Tracer() const opentracing = require('opentracing') opentracing.initGlobalTracer(tracer) // then later... const tracer = opentracing.globalTracer()
  16. @wa7son const { Tracer } = require('my-custom-tracer') const tracer =

    new Tracer() const express = require('express') const expressOpenTracing = require('express-opentracing') const app = express() app.use(expressOpenTracing({ tracer })) // ...
  17. @wa7son Contributions per language at github.com/opentracing-contrib • Java: 50 •

    Python: 11 • Go: 9 • C#: 3 • Scala: 3 • JavaScript: 2 • Ruby: 2 • C++: 1 • Erlang: 1 • nginx: 1
  18. @wa7son TraceContext Programmatic API Integrations (frameworks, db’s, etc) Context Propagation

    (in process) Context Propagation (cross service) ✅ Data format Backend transport protocol Backend / UI
  19. @wa7son TraceContext OpenTracing Programmatic API ✅ Integrations (frameworks, db’s, etc)

    (✅) Context Propagation (in process) ((✅)) Context Propagation (cross service) ✅ Data format Backend transport protocol Backend / UI
  20. @wa7son Implementation Details • continuation-local-storage + async_hooks • require-in-the-middle •

    shimmer • @opencensus/instrumentation-all • @opencensus/instrumentation-grpc • @opencensus/instrumentation-http • @opencensus/instrumentation-https • @opencensus/instrumentation-http2 • @opencensus/instrumentation-mongodb • (@opencensus/instrumentation-redis)
  21. @wa7son TraceContext OpenTracing Programmatic API ✅ Integrations (frameworks, db’s, etc)

    (✅) Context Propagation (in process) ((✅)) Context Propagation (cross service) ✅ Data format Backend transport protocol Backend / UI
  22. @wa7son TraceContext OpenTracing OpenCensus Programmatic API ✅ ✅ Integrations (frameworks,

    db’s, etc) (✅) (✅) Context Propagation (in process) ((✅)) ✅ Context Propagation (cross service) ✅ ✅ Data format (✅) Backend transport protocol (✅) Backend / UI