Git Product home page Git Product logo

lightstep-tracer-csharp's Introduction

lightstep-tracer-csharp

The LightStep distributed tracing library for C#

NuGet CircleCI codecov

Installation

Install the package via NuGet into your solution, or use Install-Package LightStep / dotnet add package LightStep.

Basic Usage

It's recommended to initialize the tracer once at the beginning of your application and assign it as the global tracer, as follows:

var tracerOptions = new Options();
var tracer = new Tracer(tracerOptions);
GlobalTracer.Register(tracer);

Once you've initialized a tracer, you can begin to create and emit spans.

Please refer to the OpenTracing C# documentation for information on how to create spans.

You can also refer to the examples folder for sample code and projects.

Advanced Usage

There's several options that can be adjusted when instantiating a LightStepTracer.

Options

Method Description
WithTags(IDictionary<string, object>) Default tags to apply to all spans created by the tracer.
WithReportPeriod(TimeSpan) How frequently the Tracer should batch and send Spans to LightStep (5s default)
WithReportTimeout(TimeSpan) Timeout for sending spans to the Satellite (30s default)
WithToken(string) The LightStep Project Access Token
WithSatellite(SatelliteOptions) A SatelliteOptions object that specifies the host, port, and if we should use HTTPS
WithHttp2(bool) If this is true, we use HTTP/2 to communicate with the Satellite. We reccomend you enable this option if you're on a modern version of .NET (4.6.1+ or .NET Core)
WithAutomaticReporting(bool) If false, disables the automatic flushing of buffered spans.
WithMaxBufferedSpans(int) The maximum amount of spans to record in a single buffer.
WithTransport(enum) Which transport to use when sending spans to the Satellite.

SatelliteOptions

Property Description
SatelliteHost The hostname of a Satelite (i.e., collector.lightstep.com)
SatellitePort The port number where the Satellite is listening for HTTP traffic (defaults to 443)
UsePlaintext Should we use HTTP or HTTPS traffic? (Defaults to HTTPS)

The C# Tracer will prefer TLS 1.2 when available on all .NET Runtime versions, but should fall back to TLS 1.1 or 1.0 in that order.

The following is an example of overriding the LightStep Component Name and adding a new custom tag for all spans -

var satelliteOptions = new SatelliteOptions("satellite.mydomain.com");
var overrideTags = new Dictionary<string, object> 
{
    {LightStepConstants.ComponentNameKey, "test_component"},
    {"my_tag", "foobar"}
};
var tracerOptions = new Options("TEST_TOKEN").WithSatellite(satelliteOptions).WithTags(overrideTags);
var tracer = new Tracer(tracerOptions);

Logging

This tracer uses LibLog, a transparent logging abstraction that provides built-in support for NLog, Log4Net, Serilog, and Loupe. If you use a logging provider that isn't identified by LibLog, see this gist on how to implement a custom logging provider.

lightstep-tracer-csharp's People

Contributors

austinlparker avatar isaaczinda avatar matthewdolan avatar

Watchers

 avatar

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.