Coder Social home page Coder Social logo

petabridge / petabridge.tracing.applicationinsights Goto Github PK

View Code? Open in Web Editor NEW
28.0 7.0 2.0 214 KB

OpenTracing adapter for Microsoft Application Insights

License: Apache License 2.0

Batchfile 0.10% F# 11.47% PowerShell 17.76% Shell 4.13% C# 66.53%
opentracing distributed-tracing application-insights azure zipkin-instrumentation jaegertracing

petabridge.tracing.applicationinsights's Introduction

Petabridge.Tracing.ApplicationInsights

This project is an OpenTracing distributed tracing driver built on top of Microsoft's Application Insights telemetry SDK. It is designed to allow developers consuming libraries and frameworks that expose the OpenTracing ITracer to be able to seamlessly swap in our ApplicationInsightsTracer as a vendor implementation if they so desire.

This driver follows the Application Insights to OpenTracing conventions outlined by the Application Insights team.

Petabridge.Tracing.ApplicationInsights is professionally maintained and tested by Petabridge and is used inside some of our commercial products, such as Phobos: Enterprise Akka.NET DevOps.

Quickstart

To get started with Petabridge.Tracing.ApplicationInsights, install the NuGet package:

PS> Install-Package Petabridge.Tracing.ApplicationInsights

And then instantiate an instance of the ApplicationInsightsTracer class, like so:

// use the active TelemetryConfiguration, if available
var tracer = new ApplicationInsightsTracer(TelemetryConfiguration.Active);

// record some new spans
using (var current = tracer.BuildSpan(Context.Self.Path.ToString()).StartActive())
{
    _loggingAdapter.Info(str);
    current.Span.Log(str);
    current.Span.SetTag("strLen", str.Length);

    using (var subOp = _tracer.BuildSpan(Context.Self.Path.ToString() + ".subOp").StartActive())
    {
        subOp.Span.Log("Do nested operations work?");
        subOp.Span.SetTag("nested", true);
    }
}

The output from this activity will show up as "Server Requests" in Application Insights:

Petabridge.Tracing.ApplicationInsights spans showing up as server requests

When using ApplicationInsightsTracer, if you want to record an operation as a "dependency" request, for instance if it's coming from a client app or driver, then make sure you call ApplicationInsightsTracer.BuildSpan("operationName").WithSpanKind(SpanKind.CLIENT). This will change how the ISpan is recorded in Application Insights.

Each distributed trace, even across multiple services and devices, is correlated automatically in Application Insights:

Petabridge.Tracing.ApplicationInsights trace shown inside end-to-end transaction details inside Application Insights

From a correlation standpoint:

  1. Each ISpan is recorded as either Request or Dependency telemetry inside Application Insights, depending upon which SpanKind was specified. By default it's SpanKind.SERVER, which correlates to Request telemetry.
  2. Each ISpan.Log call in OpenTracing is recorded as a Trace event inside Application Insights.
  3. OpenTracing IScopeManager and IScope still works as expected.
  4. All ISpan.SetTag calls append tags to the current Request or Dependency telemetry.

Building this solution

To run the build script associated with this solution, execute the following:

Windows

c:\> build.cmd all

Linux / OS X

c:\> build.sh all

If you need any information on the supported commands, please execute the build.[cmd|sh] help command.

This build script is powered by FAKE; please see their API documentation should you need to make any changes to the build.fsx file.

Conventions

The attached build script will automatically do the following based on the conventions of the project names added to this project:

  • Any project name ending with .Tests will automatically be treated as a XUnit2 project and will be included during the test stages of this build script;
  • Any project name ending with .Tests will automatically be treated as a NBench project and will be included during the test stages of this build script; and
  • Any project meeting neither of these conventions will be treated as a NuGet packaging target and its .nupkg file will automatically be placed in the bin\nuget folder upon running the build.[cmd|sh] all command.

DocFx for Documentation

This solution also supports DocFx for generating both API documentation and articles to describe the behavior, output, and usages of your project.

All of the relevant articles you wish to write should be added to the /docs/articles/ folder and any API documentation you might need will also appear there.

All of the documentation will be statically generated and the output will be placed in the /docs/_site/ folder.

Previewing Documentation

To preview the documentation for this project, execute the following command at the root of this folder:

C:\> serve-docs.cmd

This will use the built-in docfx.console binary that is installed as part of the NuGet restore process from executing any of the usual build.cmd or build.sh steps to preview the fully-rendered documentation. For best results, do this immediately after calling build.cmd buildRelease.

Release Notes, Version Numbers, Etc

This project will automatically populate its release notes in all of its modules via the entries written inside RELEASE_NOTES.md and will automatically update the versions of all assemblies and NuGet packages via the metadata included inside common.props.

If you add any new projects to the solution created with this template, be sure to add the following line to each one of them in order to ensure that you can take advantage of common.props for standardization purposes:

<Import Project="..\common.props" />

petabridge.tracing.applicationinsights's People

Contributors

aaronontheweb avatar dependabot-preview[bot] avatar dependabot[bot] avatar

Stargazers

 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

petabridge.tracing.applicationinsights's Issues

Could not load file or assembly 'Petabridge.Tracing.ApplicationInsights' Strong name signature could not be verified

Petabridge.Tracing.ApplicationInsights, Version=0.2.1.0
Dotnetframework v4.7.2 MVC project

Could not load file or assembly 'Petabridge.Tracing.ApplicationInsights' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)

incase sensitive http headers

Hello,

When receiving B3 propagation http headers they can be lowercase like "x-b3-traceid" but petabridge check this key as case sensitive uppercase . (linkerd can changes these headers to lowercase which http headers are lowercase by default)

 internal const string B3TraceId = "X-B3-TraceId";
 internal const string B3SpanId = "X-B3-SpanId";
 internal const string B3ParentId = "X-B3-ParentSpanId";

......


 public ApplicationInsightsSpanContext Extract(ITextMap carrier)
        {
            string traceId = null;
            string spanId = null;
            string parentId = null;
            foreach (var entry in carrier)
                switch (entry.Key)
                {
                    case B3TraceId:
                        traceId = entry.Value;
                        break;
                    case B3SpanId:
                        spanId = entry.Value;
                        break;
                    case B3ParentId:
                        parentId = entry.Value;
                        break;
                }

            if (traceId != null && spanId != null) // don't care of ParentId is null or not
                return new ApplicationInsightsSpanContext(traceId, spanId, parentId);
            return null;
        }

ApplicationInsights Sampling

ApplicationInsights provides Adaptive and Fixed-rate sampling methods to reduce the telemetry volume. How does Petabridge.Tracing.ApplicationInsights expose these? For example the Jaeger C# SDK allows Samplers to be specified at configuration.

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.