Git Product home page Git Product logo

petabridge.tracing.zipkin's Introduction

Petabridge.Tracing.Zipkin

UPDATE: January, 2023 - the OpenTracing project has now been superseded by OpenTelemetry. You should use the OTEL Exporter for Zipkin instead going forward.

YAZDC - Yet Another Zipkin Driver for C#.

Petabridge develops highly tested, open source infrastructure software for .NET developers professionally.

We built this driver in order to provide a commercially supported, production-grade Zipkin driver for our customers but it's also available for users at large under the terms of the Apache 2 License. We did not feel like the other drivers out there for Zipkin were particularly well-suited for the types of things our customers do (i.e. large scale IOT, finance, etc...) thus this project now exists and will be supported on behalf of our customers and users.

It's also worth noting that Petabridge.Tracing.Zipkin supports the OpenTracing standards natively. No special adapters on top of the library or anything like that. We support them out of the box. Petabridge.Tracing.Zipkin targets .NET Standard 2.0.

This driver is built to be extremely memory-efficient, thread-safe, and highly concurrent - it's powered by Akka.NET actors under the hood.

Quickstart

To get started with Petabridge.Tracing.Zipkin, install the NuGet package:

PS> Install-Package Petabridge.Tracing.Zipkin

And then instantiate an instance of the ZipkinTracer class, like so:

	var url = "http://localhost:9411";
	var tracer = new ZipkinTracer(new ZipkinTracerOptions(url, "AaronsApp", debug:true));
	Console.WriteLine("Connected to Zipkin at {0}", url);
	Console.WriteLine("Type some gibberish and press enter to create a trace!");
	Console.WriteLine("Type '/exit to quit.");
	var line = Console.ReadLine();
	Span current = null;
	while (string.IsNullOrEmpty(line) || !line.Equals("/exit"))
	{
	    IZipkinSpanBuilder sb = null;
	    if (string.IsNullOrEmpty(line))
	    {
	        sb = tracer.BuildSpan("no-op").WithTag("empty", true);
	        if (current != null)
	        {
	            current.Finish();
	        }
	    }
	    else
	    {
	        sb = tracer.BuildSpan("actual-op").WithTag("empty", false);
	        if (current != null)
	        {
	            current.Finish();
	            sb = sb.AsChildOf(current);
	        }
	    }

	    current = sb.Start();

	    if (!string.IsNullOrEmpty(line))
	    {
	        current.Log(line);
	    }

	    line = Console.ReadLine();
	}

	current?.Finish();

	tracer.Dispose(); // call dispose when you're done, please.
}

That's actually our entire demo application and it works nicely:

Petabridge.Tracing.Zipkin.SimpleDemo output results

Firing Up Zipkin

Need help setting up your own Zipkin instance? If you have Docker installed on your system, then the fastest way to get up and running is using one of the Docker templates for Zipkin defined here: https://github.com/openzipkin/docker-zipkin

Clone that repository and then try the following (from the root directory of your local clone):

PS> docker-compose -f docker-compose.yml -f docker-compose-cassandra.yml up

Docker will be running at http://localhost:9411 by default, usually.

Building this solution

To run the build script associated with this solution, execute the following:

Windows

c:\> build.cmd all

Linux / OS X

c:\> build.sh all

If you need any information on the supported commands, please execute the build.[cmd|sh] help command.

This build script is powered by FAKE; please see their API documentation should you need to make any changes to the build.fsx file.

Previewing Documentation

To preview the documentation for this project, execute the following command at the root of this folder:

C:\> serve-docs.cmd

This will use the built-in docfx.console binary that is installed as part of the NuGet restore process from executing any of the usual build.cmd or build.sh steps to preview the fully-rendered documentation. For best results, do this immediately after calling build.cmd buildRelease.

Release Notes, Version Numbers, Etc

This project will automatically populate its release notes in all of its modules via the entries written inside RELEASE_NOTES.md and will automatically update the versions of all assemblies and NuGet packages via the metadata included inside common.props.

If you add any new projects to the solution created with this template, be sure to add the following line to each one of them in order to ensure that you can take advantage of common.props for standardization purposes:

<Import Project="..\common.props" />

petabridge.tracing.zipkin's People

Contributors

aaronontheweb avatar arkatufus avatar dependabot-preview[bot] avatar dependabot[bot] avatar igorfedchenko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

petabridge.tracing.zipkin's Issues

Documentation website

Should add a documentation website that explains some of the finer points of using the driver and expands on the concepts and examples included herein.

Traces not visible in Zipkin UI, when open tracing is used

Hi,

I have written below code, to see if the opentracing api can be used with this driver. It does not seem to work as I don't see anything in the Zipkin UI. However, the sample code shown in the Readme works perfectly fine.

Am I missing anything?

using OpenTracing;
using OpenTracing.Tag;
using Petabridge.Tracing.Zipkin;
using System;

namespace Zipkin.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var url = "http://localhost:9411";
            var tracer = new ZipkinTracer(new ZipkinTracerOptions(url, "ZipkinTest", debug: true));

            Console.WriteLine("Connected to Zipkin at {0}", url);
 
            using (IScope scope = tracer.BuildSpan("someWork").StartActive(finishSpanOnDispose: true))
            {
                try
                {
                    scope.Span.Log("some work");
                }
                catch (Exception ex)
                {
                    Tags.Error.Set(scope.Span, true);
                }
            }

            System.Threading.Thread.Sleep(TimeSpan.FromSeconds(3));
        }
    }
}

Update the screenshot?

Maybe update the screenshot with the lens ui (packaged in all recent versions of zipkin)? looks a lot nicer

Sampling isn't being propagated correctly

Symptom

The application receives a request with a header of X-B3-Sampled: 1, indicating that the trace is including in sampling. The B3Propagator should pass this value on to downstream requests. However, downstream requests appear to be made with a header value of X-B3-Sampled: 10.

Root Cause

Doing some digging, the B3Propagator is assigning this value based on the SpanContext.Sampled value.

Looking at the implementation of SpanBuilder, it appears this value is influenced not by if the span is spampled, but by the Sampling value of the ITraceSampler in use. I don't feel this is the correct given my understanding of Zipkin.

B3Propagator.Extract always returns a span context even when one isn't present

When attempting to extract B3 headers from a request using the B3Propagator, Extract() will returns a SpanContext with a trace ID of 0 when the headers are missing. As a reference, the Jaeger client returns null when these headers are missing. I didn't see anything immediately in the OT spec with how to handle this, so it's possible the current behaviour is correct (but it just feels weird).

Support for "true" value on sampling state

From the B3 Specification.

Note: Before this specification was written, some tracers propagated X-B3-Sampled as true or false as opposed to 1 or 0. While you shouldn't encode X-B3-Sampled as true or false, a lenient implementation may accept them.

zipkin-ruby is still currently transmitting a sampled value using true or false, can support for this be added?

Throttle rate of Zipkin error messages

Happens after generating a couple hundred spans per second for 10-15 minutes at a time while running Zipkin locally in a stand-alone Docker for Windows container with no backing store, but eventually we can tip the system over without a huge amount of effort.

In those cases, we should probably limit the number of log messages we display when connectivity to Zipkin starts to backfire.

Related to #27

Open Kafka Producer for Reporting

The options to define a Kafka connection to send reports via Kafka are not sufficient. We are using SASL_SSL and I'm missing a lot of options you need to set to configure a e.g. secured Kafka connection.
Would be nice to have an option to directly set an Producer so you keep this API independent from new Kafka features that need configuration on instantiation.

Perf: limit degree of concurrency on ZipkinHttpReporter

Kind of need #4 to do this properly. Some of our applications using Petabridge.Tracing.Zipkin are capable of toppling over a smaller Zipkin instance with little effort (although to be fair, the environment where this has occurred is Docker for Windows which isn't particularly robust.)

However, this will be an issue in sufficiently busy systems. I think we should consider using some type of exponential back-off-type mechanism or rate-limiting to help protect Zipkin endpoints from being overwhelmed by busy transports.

Honestly though, in a busy enough system HTTP ain't going to cut it. Might be better off just implementing gRPC #17 or Azure Event Hubs #18

implement "b3 single" header format

As discussed on openzipkin/b3-propagation#21 and first implemented here: https://github.com/openzipkin/brave/blob/master/brave/src/main/java/brave/propagation/B3SingleFormat.java https://github.com/openzipkin/brave/blob/master/brave/src/test/java/brave/propagation/B3SingleFormatTest.java

Let's support at least reading "b3" header from a single string, most commonly traceid-spanid-1
It would also be nice to support optionally writing this, especially in message providers or others with constrained environments.

Brave currently has a property like this, but its name could change with feedback:

    /**
     * When true, only writes a single {@link B3SingleFormat b3 header} for outbound propagation.
     *
     * <p>Use this to reduce overhead. Note: normal {@link Tracing#propagation()} is used to parse
     * incoming headers. The implementation must be able to read "b3" headers.
     */
    public Builder b3SingleFormat(boolean b3SingleFormat) {
      this.b3SingleFormat = b3SingleFormat;
      return this;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.