All Projects → openzipkin → Zipkin4net

openzipkin / Zipkin4net

Licence: apache-2.0
A .NET client library for Zipkin

Labels

Projects that are alternatives of or similar to Zipkin4net

e-shop
Sample Spring Cloud microservices e-shop.
Stars: ✭ 48 (-82.92%)
Mutual labels:  zipkin
zipkin-view
An alternative UI for Zipkin
Stars: ✭ 28 (-90.04%)
Mutual labels:  zipkin
vertx-tracing
Vertx integration with tracing libraries
Stars: ✭ 21 (-92.53%)
Mutual labels:  zipkin
kong-plugin-zipkin
A Kong plugin for propogating zipkin spans and reporting spans to a zipkin server - this plugin has been moved into https://github.com/Kong/kong, please open issues and PRs in that repo
Stars: ✭ 60 (-78.65%)
Mutual labels:  zipkin
easeagent
An agent component for the Java system
Stars: ✭ 437 (+55.52%)
Mutual labels:  zipkin
zipkin-cpp-opentracing
OpenTracing Tracer implementation for Zipkin in C++
Stars: ✭ 46 (-83.63%)
Mutual labels:  zipkin
zipkin-php-example
See how much time php services spend on an http request
Stars: ✭ 52 (-81.49%)
Mutual labels:  zipkin
Fw Spring Cloud
SpringCloud构建实战、从入门到高级,包含eureka、zuul、gateway、feign、ribbon、hystrix、mq、turbine、nacos、elk、consul、zookeeper、rocketmq、kafka、分布式事务(RocketMq、LCN、Seata)、分库分表(Sharding-JDBC)、分布式锁(Redis、Guava)、jwt、SkyWalking、Zipkin、bootadmin等使用案例
Stars: ✭ 276 (-1.78%)
Mutual labels:  zipkin
zipkin-ruby-opentracing
OpenTracing Tracer implementation for Zipkin in Ruby
Stars: ✭ 15 (-94.66%)
Mutual labels:  zipkin
pitchfork
Convert tracing data between Zipkin and Haystack formats
Stars: ✭ 40 (-85.77%)
Mutual labels:  zipkin
my-demo
Demo Application for Dubbo, Mycat, Sharding-Proxy, Seata, SkyWalking, PinPoint, ZipKin, Docker, Kubernetes, Istio, Postman/Newman, FitNesse
Stars: ✭ 37 (-86.83%)
Mutual labels:  zipkin
nginx-opentracing
Instrument nginx for OpenTracing.
Stars: ✭ 21 (-92.53%)
Mutual labels:  zipkin
gateway
A proxy to buffer and forward metrics, events, and traces.
Stars: ✭ 94 (-66.55%)
Mutual labels:  zipkin
loopback-example-polyglot
Example LoopBack application with polyglot runtimes
Stars: ✭ 14 (-95.02%)
Mutual labels:  zipkin
zipkin-javascript-opentracing
Opentracing implementation for Zipkin in Javascript
Stars: ✭ 19 (-93.24%)
Mutual labels:  zipkin
brave-kafka-interceptor
Kafka Interceptor for Zipkin
Stars: ✭ 30 (-89.32%)
Mutual labels:  zipkin
cloud-native-workshop
1 day workshop to learn Spring Boot + Spring Cloud + Pivotal Cloud Foundry
Stars: ✭ 37 (-86.83%)
Mutual labels:  zipkin
Opentelemetry Rust
OpenTelemetry API and SDK for Rust
Stars: ✭ 280 (-0.36%)
Mutual labels:  zipkin
Microservices Traffic Management Using Istio
Istio is an open platform that provides a uniform way to connect, manage, and secure microservices. In this code we show how we can enable your microservices with advanced traffic management, routing and tracing capabilities leveraging Istio
Stars: ✭ 257 (-8.54%)
Mutual labels:  zipkin
go-zipkin-demo
Laravel + go-micro + grpc + Zipkin
Stars: ✭ 65 (-76.87%)
Mutual labels:  zipkin

Gitter chat

Zipkin4net

A .NET client library for Zipkin.

Build status

Linux Windows

What it provides

It provides you with:

  • Zipkin primitives (spans, annotations, binary annotations, ...)
  • Asynchronous trace sending
  • Trace transport abstraction

Basic usage

Bootstrap

The easiest way to use the library is the following

var logger = CreateLogger(); //It should implement ILogger
var sender = CreateYourTransport(); // It should implement IZipkinSender

TraceManager.SamplingRate = 1.0f; //full tracing

var tracer = new ZipkinTracer(sender);
TraceManager.RegisterTracer(tracer);
TraceManager.Start(logger);

//Run your application

//On shutdown
TraceManager.Stop();

Your zipkin client is now ready!

Play with traces

To create a new trace, simply call

var trace = Trace.Create();

Then, you can record annotations

trace.Record(Annotations.ServerRecv());
trace.Record(Annotations.ServiceName(serviceName));
trace.Record(Annotations.Rpc("GET"));
trace.Record(Annotations.ServerSend());
trace.Record(Annotations.Tag("http.url", "<url>")); //adds binary annotation

Transport

The transport is responsible to send traces to a zipkin collector.

HTTP transport

We provide you with an HTTP transport. Just create it with the zipkin collector url (i.e. if you test locally, you'll probably end up with something like 'http://localhost:9411') and pass it to the creation of the ZipkinTracer and you're set.

Custom transport implementation

The implementation is really easy to do. All you have to do is to implement a Send(byte[]) method. For example, if you want to send traces through Kafka and assuming you have a kafka producer, you should write

class KafkaZipkinSender : IZipkinSender
{
  private readonly IKafkaProducer _producer;
  private const string Topic = "zipkin";

  public KafkaZipkinSender(IKafkaProducer producer)
  {
    _producer = producer;
  }

  public void Send(byte[] data)
  {
    _producer.produce(Topic, data);
  }
}

We internally use Kafka-sharp.

Span creation

Zipkin is designed to handle complete spans. However, an incorrect usage of the library can lead to incomplete span creation. To create a complete span, you need a pair of matching annotations in the following list:

  • ServerRecv and ServerSend annotations
  • ClientSend and ClientRecv annotations
  • LocalOperationStart and LocalOperationStop annotations
  • ProducerStart and ProducerStop annotations
  • ConsumerStart and ConsumerStop annotations

When are my traces/spans sent?

A span is sent asynchronously to the zipkin collector when one of the following annotation is recorded:

  • ServerSend
  • ClientRecv
  • LocalOperationStop
  • ProducerStop
  • ConsumerStop

with the matching opening annotation specified above (matching means same (traceId, spanId, parentSpanId)).

A flushing mechanism regurlarly checks for incomplete spans waiting in the memory to be sent.

Advanced usage

Monitor the tracer itself

The library comes with few handy tricks to help you monitor tracers

Metrics

ZipkinTracer can be created with an implementation of IStatistics interface. This is useful if you want to send various metrics to graphite. We update four metrics:

Metric Description
RecordProcessed The number of annotation, binaryAnnotations, ... recorded by the tracer
SpanSent The number of span successfully sent
SpanSentBytes What went on the network
SpanFlushed The number of span flushed

Since the library is meant to have almost no dependency, you'll have to write the implementation that sends these metrics to graphite for example.

Tracers for testing and debugging purposes

When integrating this kind of library, it can be useful to know that we called it correctly.

Debugging

ConsoleTracer writes every record it gets on the console (annotations, service names, ...).

Unit/Integration test
  • InMemoryTracer keeps every record in a queue. It is useful when a mock tracer is not enough.
  • VoidTracer drops records. It is useful when you don't need tracing in tests.

Please also note that the default sampling is 0 meaning that by default, tracing is disabled. You should either set the sampling to 1.0 (to be deterministic) or force the trace to be sampled.

B3 Headers propagation

If your services communicate through HTTP, we provide you with headers injection and extraction (ZipkinHttpTraceInjector and ZipkinHttpTraceExtractor). It will allow you to add headers in HTTP requests between your services. The headers are zipkin standard headers but you can also implement yours with interfaces ITraceInjector and ITraceExtractor.

Flush mechanism

We implemented a safety mechanism in the library in order to avoid any memory footprint explosion. Spans can remain in memory if the user doesn't record the matching annotation to complete the span, leading to a memory leak. To avoid it, we added a safety that removes these spans after 60 seconds.

Force sampling

You can force a trace to bypass sampling. It is useful for tests but can also be useful if you want to trace specific requests depending on the context.

Trace.ForceSampled();

If you want to do that in production, we highly recommend too wrap your IZipkinSender implementation with the RateLimiterZipkinSender. It will throttle traces based on a time-window pattern.

Trace context

Passing the trace context accross every API can be very cumbersome and doesn't bring any real added value. It's also a bit painful to implement a working solution if you have async code. That's why we implemented TraceContext which relies on .Net CallContext to carry traces over the execution path.

By setting

Trace.Current = myTrace;

You will be able to retrieve it, even if you have async code in between. It means that it will follow the sync/async path of your request. Since it can be a bit tricky, please use it with caution and if you know what you're doing.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].