Crates.io | opentracingrust_zipkin |
lib.rs | opentracingrust_zipkin |
version | 0.3.1 |
source | src |
created_at | 2018-02-24 10:41:51.87955 |
updated_at | 2020-05-05 21:49:14.978268 |
description | Zipkin tracer for OpenTracingRust |
homepage | https://github.com/stefano-pogliani/opentracingrust_zipkin |
repository | https://github.com/stefano-pogliani/opentracingrust-zipkin |
max_upload_size | |
id | 52625 |
size | 174,259 |
Zipkin tracer for OpenTracingRust.
Once your Cargo.toml
includes a dependency on opentracingrust_zipkin
create a tracer and a collector and initialise the system:
extern crate opentracingrust;
extern crate opentracingrust_zipkin;
use opentracingrust::utils::GlobalTracer;
use opentracingrust::utils::ReporterThread;
use opentracingrust_zipkin::ZipkinTracer;
use opentracingrust_zipkin::ZipkinEndpoint;
use opentracingrust_zipkin::KafkaCollector;
fn main() {
let (tracer, receiver) = ZipkinTracer::new();
GlobalTracer::init(tracer);
let mut collector = KafkaCollector::new(
ZipkinEndpoint::new(None, None, Some(String::from("zipkin-example")), None),
String::from("zipkin"), // Kafka topic
vec![String::from("127.0.0.1:9092")] // Kafka seed
);
let reporter = ReporterThread::new(receiver, move |span| {
match collector.collect(span) {
Err(err) => println!("Failed to report span: {:?}", err),
_ => (),
}
});
}
This crate uses thrift to send messages to Zipkin and for the bynary encoding.
The thift-generated rust modules are checked into source control so that the crate can be compiled without having to install a rust-enabled thrift compiler.
This crate comes with a Dockerfile that installs and configures thrift with rust support. The commands below can be used to re-generate the rust code from thrift definitions:
cd thrift/
docker build --rm --tag thrift-compiler .
docker run --rm -it -v $PWD:/thrift/models -v $PWD/../src:/thrift/src thrift-compiler bash
thrift -r --out /thrift/src/thrift_gen --gen rs /thrift/models/binary_format.thrift
thrift -r --out /thrift/src/thrift_gen --gen rs /thrift/models/zipkinCore.thrift
To play around with the tracer and aid development you can run a zipkin-in-a-box with docker and docker-compose.
The following steps are for use with the provided docker scripts:
git clone https://github.com/openzipkin/docker-zipkin.git
KAFKA_ADVERTISED_HOST_NAME
:
1. Set it to kafka-zookeeper
to make all containers properly work with each other.
2. Edit docker-zipkin/docker-compose-kafka10.yml
at line 15.
3. New line should be KAFKA_ADVERTISED_HOST_NAME=kafka-zookeeper
.kafka-zookeeper
container.
2. Edit /etc/hosts
.
3. Add <IP> kafka-zookeeper
.docker-compose -f docker-compose.yml -f docker-compose-kafka10.yml -f docker-compose-ui.yml up