#opentracing #tracing

opentracingrust

opentracing.io library for rust

10 releases

0.4.0 Apr 29, 2020
0.3.4 Jun 29, 2019
0.3.3 May 19, 2019
0.3.1 Feb 26, 2018
0.1.1 Jan 16, 2018

#5 in #opentracing

Download history 7/week @ 2021-05-25 2/week @ 2021-06-01 13/week @ 2021-06-08 3/week @ 2021-06-15 4/week @ 2021-06-22 13/week @ 2021-06-29 8/week @ 2021-07-06 5/week @ 2021-07-13 15/week @ 2021-07-20 25/week @ 2021-07-27 17/week @ 2021-08-03 6/week @ 2021-08-10 13/week @ 2021-08-17 4/week @ 2021-08-24 6/week @ 2021-09-07

67 downloads per month
Used in 5 crates

MIT license

115KB
2K SLoC

OpenTracing Rust

A rust crate implementing the OpenTracing API.

This crate must be complemented by a tracer implementation to send information to a supported distributed tracer.

Alpha notice

This library is in alpha state!

Feature completeness

The library is almost feature-complete with OpenTracing v1.1

Stability

Most features are just out the door and not extensively tested in production environments.

Why OpenTracing?

If you are not yet convinced that distributed tracing is a useful tool see: http://opentracing.io/documentation/

OpenTracing is a language and tracer independent specification, different libraries exist for many languages to integrate any software in the ecosystem.

The OpenTracing specification also allows library users to pick whichever distributed tracer they want (and is supported by the language ecosystem).

Why not rustracing?

Rust has already an opentracing implementation called rustracing so why create another one?

The main difference is that opentracingrust uses traits and trait objects to abstract tracer specific details. These abstractions are then wrapped by structs and functions that implement the common logic shared by all tracer implementations.

This means that:

  • Changing the distributed tracer means changing the tracer initialisation.
  • The distributed tracer can be configured at run time by library users.
  • Supporting an new distributed tracer requires implementing a handfull of traits.

References

Quickstart

To use opentracingrust add a dependency to this crate.

For development and testing the core library provides two tracers:

  • The NoopTracer is a tracer that drops all received information. This tracer is a useful default for unit tests and project bootstapping.
  • The FileTracer is a test only tracer that writes span information to a rust Write stream (usually stdout/stderr). This tracer is useful to test that all desired information is collected and experiment with opentracingrust.

For production use you will need to add a dependency on all tracers you would like to support:

# These crates may not exist yet but tracer crates will look like this
opentracingrust_appdash = "^0.1.0"
opentracingrust_zipkin = "^0.1.0"

Usage examples with step by step explainations can be found in the examples/ directory and you should start with examples/0-quickstart.rs. Regardless of the tracer though there are four steps to using opentracingrust:

  1. Set up a tracer (there should only be one tracer instance: pass it around as needed).
  2. Create spans to represent operations.
  3. Pass span contexts around to link spans across the system.
  4. Once the operation is complete send each span to the tracing system.

Dependencies

~750KB
~12K SLoC