The OpenTelemetry .NET Client
Go to file
PS-EGHornbostel 8e1d8fa47e Jaeger exporter implementation (#132)
* Fix visual studio dotnet core build task

* Added CNCF Jaeger exporter support

https://github.com/open-telemetry/opentelemetry-dotnet/issues/77

* possible fix for win32 build issue.

* Fix windows build by adding Thrift source

* Fix yet more windows build issues.

* fix another style issue.

* fix reference to System.Net.Http

* remove unnecessary conditional framework reference.

* Update lib/Thrift/Transports/Client/TStreamClientTransport.cs

Co-Authored-By: Bruno Garcia <github@brunogarcia.com>

* Update lib/Thrift/Transports/Client/TStreamClientTransport.cs

Co-Authored-By: Bruno Garcia <github@brunogarcia.com>

* Added the conditional for netstandard2.0

* remove IDisposable TODO comments.

* Update src/OpenTelemetry.Exporter.Jaeger/Implimentation/EmitBatchArgs.cs

Co-Authored-By: Bruno Garcia <github@brunogarcia.com>

* Add readme with thrift fork info.

* cleanup after merge.

* WIP remove thrift code

* Use prepackaged Apache Thrift assembly

* wrap EmitBatch

* Revert "wrap EmitBatch "

This reverts commit 9aaa1388ba.

* Revert "Use prepackaged Apache Thrift assembly"

This reverts commit fa5fbd8e6c.

* Revert "Use prepackaged Apache Thrift assembly"

This reverts commit fa5fbd8e6c.

* Revert "WIP remove thrift code"

This reverts commit bbbcf470e8.

* Add missing ConfigureAwait(false) to Thrift async calls.

* Added Thrift fork differences to README.md

* WIP Jaeger Unit tests

* Fix build after merge.

* WIP Jaeger Unit tests - Span conversion to Jaeger Thrift format

* WIP Jaeger Unit tests - Span conversion to Jaeger Thrift format - cleanup

* Clean up merge issues

* WIP

* WIP cleanup

* more testing WIP

* use pattern matching for attribute conversion

* WIP cleanup after timestamp removal.

* WIP

* WIP UDP integration test

* Update src/OpenTelemetry.Exporter.Jaeger/Implimentation/Batch.cs

Co-Authored-By: Bruno Garcia <github@brunogarcia.com>

* remove solution-explorer

* add to gitignore

* refactored List<T> to IEnumerable<T>

* Fix unit test bug

* Add integration test

* cleanup

* fix unix epoch conversion

* Update Thrift expected payload in unit test.

* fix build issues

* fix typo

* fix solution
2019-07-23 19:47:52 -07:00
.vscode Jaeger exporter implementation (#132) 2019-07-23 19:47:52 -07:00
.vsts fix few warnings (#39) 2019-05-22 13:50:52 -07:00
build Disable code coverage in CI: reportgenerator does not work (#159) 2019-07-23 19:13:26 -07:00
docs find and replace OpenCensus -> OpenTelemetry 2019-05-10 10:30:04 -07:00
lib Jaeger exporter implementation (#132) 2019-07-23 19:47:52 -07:00
samples Jaeger exporter implementation (#132) 2019-07-23 19:47:52 -07:00
src Jaeger exporter implementation (#132) 2019-07-23 19:47:52 -07:00
test Jaeger exporter implementation (#132) 2019-07-23 19:47:52 -07:00
.editorconfig add editorconfig with the defaults that Visual Studio 2019 created for .NET (#50) 2019-05-31 08:39:42 -07:00
.gitignore Jaeger exporter implementation (#132) 2019-07-23 19:47:52 -07:00
CHANGELOG.md Jaeger exporter implementation (#132) 2019-07-23 19:47:52 -07:00
CODEOWNERS Update CODEOWNERS (#43) 2019-05-22 13:51:08 -07:00
CONTRIBUTING.md Add prerequisites to CONTRIBUTING (#141) 2019-07-10 00:11:06 -07:00
Directory.Build.props Use ActivityTraceId and ActivitySpanId (#136) 2019-07-11 12:10:38 -07:00
Directory.Build.targets Jaeger exporter implementation (#132) 2019-07-23 19:47:52 -07:00
LICENSE copy of OpenCensus at 0474607a16282252697f989113d68bdf71959070 2019-05-08 12:32:06 -07:00
NuGet.config copy of OpenCensus at 0474607a16282252697f989113d68bdf71959070 2019-05-08 12:32:06 -07:00
OpenTelemetry.proj Code Cleanups (#131) 2019-07-08 22:32:22 -07:00
OpenTelemetry.sln Jaeger exporter implementation (#132) 2019-07-23 19:47:52 -07:00
README.md Jaeger exporter implementation (#132) 2019-07-23 19:47:52 -07:00

README.md

OpenTelemetry .NET SDK - distributed tracing and stats collection framework

.NET Channel: Gitter chat

Community Channel: Gitter chat

We hold regular meetings. See details at community page.

BuildStatus

OpenTelemetry is a toolkit for collecting application performance and behavior data.

The library is in Alpha stage. 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.

Packages

API and implementation

Package MyGet (CI) NuGet (releases)
OpenTelemetry MyGet Nightly NuGet Release
OpenTelemetry.Abstractions MyGet Nightly NuGet Release

Data Collectors

Package MyGet (CI) NuGet (releases)
Asp.Net Core MyGet Nightly NuGet Release
.Net Core HttpClient MyGet Nightly NuGet Release
StackExchange.Redis MyGet Nightly NuGet Release

Exporters Packages

Package MyGet (CI) NuGet (releases)
Zipkin MyGet Nightly NuGet release
Prometheus MyGet Nightly NuGet release
Application Insights MyGet Nightly NuGet release
Stackdriver MyGet Nightly NuGet release

OpenTelemetry QuickStart: collecting data

You can use OpenTelemetry API to instrument code and report data. Or use one of automatic data collection modules.

Using ASP.NET Core incoming requests collector

Incoming requests of ASP.NET Core app can be automatically tracked.

  1. Install packages to your project: OpenTelemetry OpenTelemetry.Collector.AspNetCore

  2. Make sure ITracer, ISampler, and IPropagationComponent registered in DI.

    services.AddSingleton<ITracer>(Tracing.Tracer);
    services.AddSingleton<ISampler>(Samplers.AlwaysSample);
    services.AddSingleton<IPropagationComponent>(new DefaultPropagationComponent());
    
  3. Configure data collection singletons in ConfigureServices method:

    public void ConfigureServices(IServiceCollection services)
    {
        // ...
        services.AddSingleton<RequestsCollectorOptions>(new RequestsCollectorOptions());
        services.AddSingleton<RequestsCollector>();
    
  4. Initialize data collection by instantiating singleton in Configure method

    public void Configure(IApplicationBuilder app, /*... other arguments*/ )
    {
        // ...
        var collector = app.ApplicationServices.GetService<RequestsCollector>();
    

Using Dependencies collector

Outgoing http calls made by .NET Core HttpClient can be automatically tracked.

  1. Install package to your project: OpenTelemetry.Collector.Dependencies

  2. Make sure ITracer, ISampler, and IPropagationComponent registered in DI.

    services.AddSingleton<ITracer>(Tracing.Tracer);
    services.AddSingleton<ISampler>(Samplers.AlwaysSample);
    services.AddSingleton<IPropagationComponent>(new DefaultPropagationComponent());
    
  3. Configure data collection singletons in ConfigureServices method:

    public void ConfigureServices(IServiceCollection services)
    {
        // ...
        services.AddSingleton<DependenciesCollectorOptions>(new DependenciesCollectorOptions());
        services.AddSingleton<DependenciesCollector>();
    
  4. Initiate data collection by instantiating singleton in Configure method

    public void Configure(IApplicationBuilder app, /*... other arguments*/ )
    {
        // ...
        var depCollector = app.ApplicationServices.GetService<DependenciesCollector>();
    

Using StackExchange.Redis collector

Outgoing http calls to Redis made usign StackExchange.Redis library can be automatically tracked.

  1. Install package to your project: OpenTelemetry.Collector.StackExchangeRedis

  2. Make sure ITracer, ISampler, and IExportComponent registered in DI.

    services.AddSingleton<ITracer>(Tracing.Tracer);
    services.AddSingleton<ISampler>(Samplers.AlwaysSample);
    services.AddSingleton<IExportComponent>(Tracing.ExportComponent);
    
  3. Configure data collection singletons in ConfigureServices method:

    public void ConfigureServices(IServiceCollection services)
    {
        // ...
        services.AddSingleton<StackExchangeRedisCallsCollectorOptions>(new StackExchangeRedisCallsCollectorOptions());
        services.AddSingleton<StackExchangeRedisCallsCollector>();
    
  4. Initiate data collection by instantiating singleton in Configure method

    public void Configure(IApplicationBuilder app, /*... other arguments*/ )
    {
        // ...
        var redisCollector = app.ApplicationServices.GetService<StackExchangeRedisCallsCollector>();
    
        // use collector to configure the profiler
        ConnectionMultiplexer connection = ConnectionMultiplexer.Connect("localhost:6379");
        connection.RegisterProfiler(redisCollector.GetProfilerSessionsFactory());
    

OpenTelemetry QuickStart: exporting data

Using the Jaeger exporter

The Jaeger exporter communicates to a Jaeger Agent through the compact thrift protocol on the Compact Thrift API port. You can configure the Jaeger exporter by following the directions below:

  1. Get Jaeger.
  2. Configure the JaegerExporter
    • ServiceName: The name of your application or service.
    • AgengHost: Usually localhost since an agent should usually be running on the same machine as your application or service.
    • AgentPort: The compact thrift protocol port of the Jaeger Agent (default 6831)
    • MaxPacketSize: The maximum size of each UDP packet that gets sent to the agent. (default 65000)
  3. See the sample for an example of how to use the exporter.
var exporter = new JaegerExporter(
    new JaegerExporterOptions
    {
        ServiceName = "tracing-to-jaeger-service",
        AgentHost = host,
        AgentPort = port,
    },
    Tracing.ExportComponent);

exporter.Start();

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

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

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 = "http://+:9184/metrics/"
    },
    Stats.ViewManager);

exporter.Start();

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

Using Stackdriver Exporter

This sample assumes your code authenticates to Stackdriver APIs using service account with credentials stored in environment variable GOOGLE_APPLICATION_CREDENTIALS. When you run on GAE, GKE or locally with gcloud sdk installed - this is typically the case. There is also a constructor for specifying path to the service account credential. See sample for details.

  1. Add Stackdriver Exporter package reference.
  2. Enable Stackdriver Trace API.
  3. Enable Stackdriver Monitoring API.
  4. Instantiate a new instance of StackdriverExporter with your Google Cloud's ProjectId
  5. See sample for example use.
    var exporter = new StackdriverExporter(
        "YOUR-GOOGLE-PROJECT-ID",
        Tracing.ExportComponent,
        Stats.ViewManager);
    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 OpenTelemetry libraries, then there is no deprecation period. Otherwise, we will deprecate it for 18 months before removing it, if possible.