Distributed tracing and stats collecting framework
Clone or download
simonz130 and SergeyKanzhelev Fixing stackdriver export interval propagation (#66)
* Introducing Stackdriver Exporter for Opencensus C# library

- Current implementation can only store string values
- Added the exporter and trace handler only
- The exporter relies on newest Trace API from Stackdriver.

* Updating translation from ISpan to Stackdriver's Span to cover more fields

* Fixing the issue that prevented Stackdriver API call to succeed:
now construction of Span resource is taken care of by SpanName class that
is part of Stackdriver Trace V2 API.

* - Added support for capturing all types of trace spans (long/bool/string)
- Fixed csproj, so it produces both .NET Core and .NET versions. It also means signing the assembly using the same mechanism as other assemblies in the solution

* - Added support for storing links
- Minor fixes to proto<->opencensus translation methods

* Fixing merge issue

* Added command line support for the Samples project.
This will make it easier to script testing multiple exporters as
well as prevent commenting and uncommenting different test procedures
for different exporters. Finally, it will making test code cleaner for
showing samples embedded in documentation website.

In order to test the exporter, you can either execute it from the command line:
samples.dll prometheus
or to debug using Visual Studio:
Debug => Sample Properties => Debug.
Now create a profile for your testing execution and fill application arguments
if needed.
Now choose your profile in running configuration of Visual Studio.
Running settings are local to the machine and are ignored in PRs.

* Adding sceleton of metrics support in Stackdriver Exporter.

Currently we can't detect all types of monitoring resources but we
can ship the batches of metrics with time series to Stackdriver.
Thorough testing TBD

* Fixing a few bugs in Stackdriver metrics exporter

- Small refactoring
- Assinging default values for time intervals

* - Fixing a few bugs around metric creation and labels
- Refactoring MetricsConversions
- Fixing stackdriver stats configuration - population of default resource and projects

* First working version of Stackdriver Stats Exporter.

1) Fixed bugs related to Stackdriver Metrics Descriptor creation
2) Renamed Metrics Exporter to Stats Exporter to follow Opencensus terminology
3) Cache Stackdriver Metrics Descriptors locally so it's easy which descriptor holds the time series to upload
4) Fixed test code that was producing the metrics using Opencensus and uploading it to Stackdriver
5) Minor refactoring

Current limitations:

1) Supporting only string labels
2) We support only "Global" monitored resource. We need to detect dynamically where the code is running and attach
corresponding labels to the monitored resource, so metrics are stored correctly
3) More Tests

* Removing commented lines

* Fixed Stackdriver export interval propagation
Added Opencensus headers into every call into Stackdriver APIs
Added consts for resources that Stackdriver Exporter should auto-detect when running on GCP

* - Added test project for Stackdriver Exporter
- Added tests for StackdriverStatsConfiguration

* Trying to fix the tests that fail on CI as a result of wrong signing key for InternalVisibleTo

* Updating Travis build definition to latest .netcore sdk and running all tests

* Adding an option to set google cloud projectId in environment variable for testing purposes(Stackdriver exporter).

* Temporarily commenting out lines that read from a friend assembly as it doesn't work on a build server

* Added AssemblyInfo.cs into Stackdriver Exporter, so it's visible to tests on both signed and unsigned builds
Latest commit 38976dd Dec 4, 2018

README.md

OpenCensus .NET SDK - distributed tracing and stats collection framework

Gitter chat Build Status

Source OpenCensus Zipkin Exporter Application Insights exporter
MyGet MyGet Nightly MyGet Nightly MyGet Nightly

OpenCensus is a toolkit for collecting application performance and behavior data. It currently includes 3 APIs: stats, tracing and tags.

The library is in Beta stage and APIs are expected to be mostly stable. The library is expected to move to GA stage after v1.0.0 major release.

Please join gitter for help or feedback on this project.

We encourage contributions. Use tags up-for-grabs and good first issue to get started with the project. Follow CONTRIBUTING guide to report issues or submit a proposal.

OpenCensus Quickstart

Using Zipkin exporter

Configure Zipkin exporter to see traces in Zipkin UI.

  1. Get Zipkin using getting started guide.
  2. Start ZipkinTraceExporter as below:
  3. See sample for example use.
var exporter = new ZipkinTraceExporter(
  new ZipkinTraceExporterOptions() {
    Endpoint = new Uri("https://<zipkin-server:9411>/api/v2/spans"),
    ServiceName = typeof(Program).Assembly.GetName().Name,
  },
  Tracing.ExportComponent);
exporter.Start();

var span = tracer
            .SpanBuilder("incoming request")
            .SetSampler(Samplers.AlwaysSample)
            .StartSpan();

Thread.Sleep(TimeSpan.FromSeconds(1));
span.End();

Using Prometheus exporter

Configure Prometheus exporter to have stats collected by Prometheus.

  1. Get Prometheus using getting started guide.
  2. Start PrometheusExporter as below.
  3. See sample for example use.
var exporter = new PrometheusExporter(
    new PrometheusExporterOptions()
    {
        Url = new Uri("http://localhost:9184/metrics/")
    },
    Stats.ViewManager);

exporter.Start();

try
{
    // record metrics
    statsRecorder.NewMeasureMap().Put(VideoSize, values[0] * MiB).Record();
}
finally
{
    exporter.Stop();
}

Using Stackdriver Exporter

  1. Enable Stackdriver Trace resource.
  2. Instantiate a new instance of StackdriverExporter with your Google Cloud's ProjectId
  3. See sample for example use.
var exporter = new StackdriverExporter("YOUR-GOOGLE-PROJECT-ID", Tracing.ExportComponent);
exporter.Start();

Using Application Insights exporter

  1. Create Application Insights resource.
  2. Set instrumentation key via telemetry configuration object (new TelemetryConfiguration("iKey")). This object may be injected via dependency injection as well.
  3. Instantiate a new instance of ApplicationInsightsExporter.
  4. See sample for example use.
var config = new TelemetryConfiguration("iKey")
var exporter = new ApplicationInsightsExporter(
    Tracing.ExportComponent,
    Stats.ViewManager,
    config); // either global or local config can be used
exporter.Start();

Versioning

This library follows Semantic Versioning.

GA: Libraries defined at a GA quality level are stable, and will not introduce backwards-incompatible changes in any minor or patch releases. We will address issues and requests with the highest priority. If we were to make a backwards-incompatible changes on an API, we will first mark the existing API as deprecated and keep it for 18 months before removing it.

Beta: Libraries defined at a Beta quality level are expected to be mostly stable and we're working towards their release candidate. We will address issues and requests with a higher priority. There may be backwards incompatible changes in a minor version release, though not in a patch release. If an element is part of an API that is only meant to be used by exporters or other opencensus libraries, then there is no deprecation period. Otherwise, we will deprecate it for 18 months before removing it, if possible.