Giter VIP home page Giter VIP logo

wavefront-opentracing-sdk-csharp's Introduction

wavefront-opentracing-sdk-csharp

OpenTracing Badge travis build status NuGet

We are deprecating the OpenTracing repositories, and they are no longer supported. To migrate from OpenTracing to OpenTelemetry, see the migration steps in our documentation

Contact our support team if you have any questions ([email protected]). Thank you!

Table of Content

Welcome to Wavefront's OpenTracing C# SDK

This is the Wavefront by VMware OpenTracing SDK for C# that provides distributed tracing support for Wavefront.

Before you start implementing, let us make sure you are using the correct SDK!

CSharp Tracing SDK Decision Tree

Note:

Wavefront SDKs

SDK Type SDK Description Supported Languages
OpenTracing SDK Implements the OpenTracing specification. Lets you define, collect, and report custom trace data from any part of your application code.
Automatically derives RED metrics from the reported spans.
Metrics SDK Implements a standard metrics library. Lets you define, collect, and report custom business metrics and histograms from any part of your application code.
Framework SDK Reports predefined traces, metrics, and histograms from the APIs of a supported app framework. Lets you get started quickly with minimal code changes.
Sender SDK Lets you send raw values to Wavefront for storage as metrics, histograms, or traces, e.g., to import CSV data into Wavefront.

Requirements and Installation

  • Supported Frameworks

    • .NET Framework (>= 4.5.2)
    • .NET Standard (>= 2.0)
  • Installation
    Install the NuGet package.

    • Package Manager Console
      PM> Install-Package Wavefront.OpenTracing.SDK.CSharp
      
    • .NET CLI Console
      > dotnet add package Wavefront.OpenTracing.SDK.CSharp
      

Usage

Tracer is an OpenTracing interface for creating spans and propagating them across arbitrary transports.

This SDK provides a WavefrontTracer that:

  • Creates spans and sends them to Wavefront.
  • Automatically generates and reports RED metrics from your spans.

The steps for creating a WavefrontTracer are:

  1. Create an ApplicationTags instance to specify metadata about your application.
  2. Create an IWavefrontSender instance to send trace data to Wavefront.
  3. Create a WavefrontSpanReporter instance to report trace data to Wavefront.
  4. Create a WavefrontTracer instance.

The following code sample creates a Tracer. For details of each step, see the sections below.

Tracer CreateWavefrontTracer(string application, string service) {
  // Step 1. Create ApplicationTags.
  ApplicationTags applicationTags = new ApplicationTags.Builder(application, service).Build();
  
  // Step 2. Create an IWavefrontSender instance for sending trace data via a Wavefront proxy.
  //         Assume you have installed and started the proxy on <proxyHostname>.
  IWavefrontSender wavefrontSender = new WavefrontProxyClient.Builder(<proxyHostname>)
    .MetricsPort(2878).TracingPort(30000).DistributionPort(40000).Build();
        
  // Step 3. Create a WavefrontSpanReporter for reporting trace data that originates on <sourceName>.
  IReporter wfSpanReporter = new WavefrontSpanReporter.Builder()
    .WithSource(<sourceName>).Build(wavefrontSender);
        
  // Step 4. Create the WavefrontTracer.
  return new WavefrontTracer.Builder(wfSpanReporter, applicationTags).Build();
}

1. Set Up Application Tags

Application tags determine the metadata (span tags) that are included with every span reported to Wavefront. These tags enable you to filter and query trace data in Wavefront.

You encapsulate application tags in an ApplicationTags object. See Instantiating ApplicationTags for details.

2. Set Up an IWavefrontSender

An IWavefrontSender object implements the low-level interface for sending data to Wavefront. You can choose to send data to Wavefront using the Wavefront proxy or direct ingestion.

3. Set Up a Reporter

You must create a WavefrontSpanReporter to report trace data to Wavefront. Optionally, you can create a CompositeReporter to send data to Wavefront and print it to the console.

Create a WavefrontSpanReporter

To build a WavefrontSpanReporter, you must specify an IWavefrontSender. Optionally, you can specify a string that represents the source for the reported spans. If you omit the source, the host name is automatically used.

Example: Create a WavefrontSpanReporter:

// Create a WavefrontProxyClient or WavefrontDirectIngestionClient
IWavefrontSender sender = BuildWavefrontSender(); // pseudocode; see above

IReporter wfSpanReporter = new WavefrontSpanReporter.Builder()
  .WithSource("wavefront-tracing-example") // optional nondefault source name
  .Build(sender);

//  To get the number of failures observed while reporting
int totalFailures = wfSpanReporter.GetFailureCount();

Note: After you initialize the WavefrontTracer with the WavefrontSpanReporter (below), completed spans will automatically be reported to Wavefront. You do not need to start the reporter explicitly.

Create a CompositeReporter (Optional)

A CompositeReporter enables you to chain a WavefrontSpanReporter to another reporter, such as a ConsoleReporter. A console reporter is useful for debugging.

Example:

// Create a console reporter that reports span to console
IReporter consoleReporter = new ConsoleReporter("wavefront-tracing-example"); // Specify the same source you used for the WavefrontSpanReporter

// Instantiate a composite reporter composed of a console reporter and a WavefrontSpanReporter
IReporter compositeReporter = new CompositeReporter(wfSpanReporter, consoleReporter);

4. Create a WavefrontTracer

To create a WavefrontTracer, you pass the ApplicationTags and Reporter instances you created above to a Builder:

Example:

ApplicationTags appTags = BuildTags(); // pseudocode; see above
IReporter wfSpanReporter = BuildReporter();  // pseudocode; see above
WavefrontTracer.Builder wfTracerBuilder = new WavefrontTracer.Builder(wfSpanReporter, appTags);
// Optionally, configure sampling and add multi-valued span tags before building
ITracer tracer = wfTracerBuilder.Build();

Sampling (Optional)

Optionally, you can apply one or multiple sampling strategies to the WavefrontTracer. See the sampling documentation for details.

Multi-valued Span Tags (Optional)

Optionally, you can add metadata to OpenTracing spans in the form of multi-valued tags. The WavefrontTracer Builder supports different methods to add those tags.

Example:

// Construct WavefrontTracer.Builder instance
WavefrontTracer.Builder wfTracerBuilder = new WavefrontTracer.Builder(...);

// Add individual tag key value
wfTracerBuilder.WithGlobalTag("env", "Staging");

// Add a dictionary of tags
wfTracerBuilder.WithGlobalTags(new Dictionary<string, string>{ { "severity", "sev-1" } });

// Add a dictionary of multivalued tags since Wavefront supports repeated tags
wfTracerBuilder.WithGlobalMultiValuedTags(new Dictionary<string, IEnumerable<string>>
{
    { "location", new string[]{ "SF", "NY", "LA" } }
});

// Construct Wavefront OpenTracing Tracer
ITracer tracer = wfTracerBuilder.Build();

Add Custom Span-Level RED metrics

Optionally, you can add custom span-level tags to propagate RED metrics. See Custom Span-Level Tags for RED Metrics for details.

wfTracerBuilder.RedMetricsCustomTagKeys(new HashSet<string>{ "env", "location" });

Close the Tracer

Always close the tracer before exiting your application to flush all buffered spans to Wavefront.

tracer.Close();

Span Logs

Note: Span logs are disabled by default and require Wavefront proxy version 5.0 or later. Contact [email protected] to enable the feature.

You can instrument your application to emit logs or events with spans, and examine them from the Wavefront Tracing UI.

Use the OpenTracing Span object’s log() method in your application.

Cross Process Context Propagation

See the context propagation documentation for details on propagating span contexts across process boundaries.

RED Metrics

See the RED metrics documentation for details on the out-of-the-box metrics and histograms that are provided.

License

Apache 2.0 License.

How to Contribute

  • Reach out to us on our public Slack channel.
  • If you run into any issues, let us know by creating a GitHub issue.

wavefront-opentracing-sdk-csharp's People

Contributors

akodali18 avatar hanwavefront avatar jmoravec avatar joannatk avatar michael132 avatar roflores21 avatar shavidissa avatar susanjlindner avatar sushantdewan123 avatar thepeterstone avatar vikramraman avatar xshipeng avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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

wavefront-opentracing-sdk-csharp's Issues

System.TypeLoadException: Method 'IsBucketHistogramMatch' in type 'App.Metrics.Internal.NoOp.NullMetricsFilter' does not have an implementation.

I am getting the following exception:

Failed to initialize application. Exception: System.TypeLoadException: Method 'IsBucketHistogramMatch' in type 'App.Metrics.Internal.NoOp.NullMetricsFilter' from assembly 'App.Metrics.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0d5193a913d1b812' does not have an implementation.
at App.Metrics.MetricsBuilder..ctor()
at Wavefront.OpenTracing.SDK.CSharp.WavefrontTracer.InitMetricsHistogramsReporting(WavefrontSpanReporter wfSpanReporter, ApplicationTags applicationTags, TimeSpan reportFrequency, ILoggerFactory loggerFactory, IMetricsRoot& metricsRoot, AppMetricsTaskScheduler& metricsScheduler, HeartbeaterService& heartbeaterService, WavefrontSdkMetricsRegistry& sdkMetricsRegistry)
at Wavefront.OpenTracing.SDK.CSharp.WavefrontTracer..ctor(IReporter reporter, IList1 tags, IList1 samplers, ApplicationTags applicationTags, ISet`1 redMetricsCustomTagKeys, TimeSpan reportFrequency, PropagatorRegistry registry, ILoggerFactory loggerFactory)
at Wavefront.OpenTracing.SDK.CSharp.WavefrontTracer.Builder.Build()
at CyraCom_CCSCallFlowEngine.CfeService.CreateWavefrontTracer(String application, String service, Settings settings) in C:\Source\cfe\3x\CyraCom_CCSCallFlowEngine\CfeService.cs:line 150
at CyraCom_CCSCallFlowEngine.CfeService.InitializeOT(Settings settings) in C:\Source\cfe\3x\CyraCom_CCSCallFlowEngine\CfeService.cs:line 121
at CyraCom_CCSCallFlowEngine.CfeService.OnInitializeApplication() in C:\Source\cfe\3x\CyraCom_CCSCallFlowEngine\CfeService.cs:line 108

Here is my packages.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="App.Metrics" version="4.0.0" targetFramework="net461" />
  <package id="App.Metrics.Abstractions" version="4.3.0" targetFramework="net461" />
  <package id="App.Metrics.Concurrency" version="2.0.1" targetFramework="net452" />
  <package id="App.Metrics.Core" version="4.0.0" targetFramework="net461" />
  <package id="App.Metrics.Formatters.Ascii" version="4.0.0" targetFramework="net461" />
  <package id="App.Metrics.Formatters.Json" version="4.0.0" targetFramework="net461" />
  <package id="C5" version="2.3.0.1" targetFramework="net452" />
  <package id="CyraCom.CCS.CMI" version="3.4.10.204" targetFramework="net452" />
  <package id="Microsoft.Bcl.AsyncInterfaces" version="1.0.0" targetFramework="net461" />
  <package id="System.Runtime.CompilerServices.Unsafe" version="4.6.0" targetFramework="net461" />
  <package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net461" />
  <package id="Wavefront.AppMetrics.SDK.CSharp" version="3.1.0" targetFramework="net461" />
  <package id="Wavefront.OpenTracing.SDK.CSharp" version="2.1.0" targetFramework="net461" />
  <package id="Wavefront.SDK.CSharp" version="1.7.0" targetFramework="net461" />
</packages>

README update request

  • Need to specify the required tags ("application", "service"). These 2 tags are required in order for users to use span-search qb in Wavefront
  • If we can include the instruction about span extract/inject in the README, that will be great. Or the other way is to provide a URL link to the opentracing-sdk doc?!

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.