No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/OpenTracing.Contrib.Decorators
test/OpenTracing.Contrib.Decorators.Tests
.editorconfig
.gitignore
Directory.Build.props
LICENSE
OpenTracing.Contrib.sln
README.md
appveyor.yml
build.cake
build.cmd
build.ps1

README.md

OpenTrancing 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
*/