Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.

OpenTracing decorators

Provide a way to plug extentions to opentracing instrumentation

Build status License Nuget

Installing

Using NuGet Package Manager Console: PM> OpenTracing.Contrib.Decorators

Usage

In order to decorate some behavior to an existing ITracer implementation, you'll have to encapsulate this one in an other ITracer implementation of your own. This project provide some simple way to do that by using a TracerDecoratorBuilder and then add behaviors throught predefined hooks.

using OpenTracing.Contrib.Decorators;

Build some additional behavior using method hooks

var builder = new TracerDecoratorBuilder(_tracer)
    .OnSpanStarted((span, operationName) => WriteLine($"Span started: {operationName}"))
    .OnSpanActivated((span, operationName) => WriteLine($"Span activated: {operationName}"))
    .OnSpanFinished((span, operationName) => WriteLine($"Span finished: {operationName}"))
    ;

var decoratedTracer = builder.Build();

Then use the resulting decorated tracer as expected previously

using (var scope = decoratedTracer.BuildSpan("main").StartActive())
{
    WriteLine("--> Doing something");
}

The output should be like this one :

/*
    Span started: main
    Span activated: main
    --> Doing something 1
    Span finished: main
*/

About

No description, website, or topics provided.

Resources

License

Releases

No releases published

Packages

No packages published