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.
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:
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 callApplicationInsightsTracer.BuildSpan("operationName").WithSpanKind(SpanKind.CLIENT)
. This will change how theISpan
is recorded in Application Insights.
Each distributed trace, even across multiple services and devices, is correlated automatically in Application Insights:
From a correlation standpoint:
- Each
ISpan
is recorded as eitherRequest
orDependency
telemetry inside Application Insights, depending upon whichSpanKind
was specified. By default it'sSpanKind.SERVER
, which correlates toRequest
telemetry. - Each
ISpan.Log
call in OpenTracing is recorded as aTrace
event inside Application Insights. - OpenTracing
IScopeManager
andIScope
still works as expected. - All
ISpan.SetTag
calls append tags to the currentRequest
orDependency
telemetry.
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.
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 thebin\nuget
folder upon running thebuild.[cmd|sh] all
command.
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.
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
.
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" />