PaTh.AzureFunctions.Tracing 1.1.0-beta

This is a prerelease version of PaTh.AzureFunctions.Tracing.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package PaTh.AzureFunctions.Tracing --version 1.1.0-beta                
NuGet\Install-Package PaTh.AzureFunctions.Tracing -Version 1.1.0-beta                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PaTh.AzureFunctions.Tracing" Version="1.1.0-beta" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PaTh.AzureFunctions.Tracing --version 1.1.0-beta                
#r "nuget: PaTh.AzureFunctions.Tracing, 1.1.0-beta"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PaTh.AzureFunctions.Tracing as a Cake Addin
#addin nuget:?package=PaTh.AzureFunctions.Tracing&version=1.1.0-beta&prerelease

// Install PaTh.AzureFunctions.Tracing as a Cake Tool
#tool nuget:?package=PaTh.AzureFunctions.Tracing&version=1.1.0-beta&prerelease                

Azure Functions Tracing

Distributed tracing enhancements for Azure Functions using OpenTelemetry and Dynatrace. This package makes use of Castle Dynamic Proxy to intercept function invocations, adding distributed tracing via Dynatrace OpenTeleetry extension.

Read more about tracing Azure Functions

Features

The package provides a IFunctionHostBuilder extension to register all necessary components in your functions startup class.

It allows you to add tracing if you already use a startup class or want to customize the TraceProvider configuration.

By default the instrumentation adds automatic function tracing for any function trigger type and enables automatic distributed tracing for following triggers:

  • HttpTrigger using a HttpRequest binding
  • ServiceBusTrigger using a ServiceBusReceivedMessage binding

You can enable .NET Framworks additional instrumentation such as outgoing http or SQLclient calls.

Since October 2021, .NET Azure SDK comes with experimental OpenTelemetry support which gives additional trace details. While you can capture these spans span as described here, the Azure.Function.Tracing library adds selected and validated instrumentation filters via simple TraceProviderBuilder extension methods:

  • AddServiceBusInstrumentation adds spans for Azure.Messaging.ServiceBus Client

ChangeLog

  • v1.0.0 - Removed dependency on AutoFac. Removed parameter RegisterBuilder from configuration method AddFunctionTracing as it is no longer necessary to pass the services when using dependency injection in Azure Functions.
  • v1.1.0 - Adding support for ServiceBus message tracing

Contribute

This is an open source project, and we gladly accept new contributions and contributors.

Enhancing the instrumentation to support other triggers

Enhacing the instrumentation is easy, as you only have to advance the interceptor logic in class FunctionInvocationInterceptor.

...
    public void Intercept(IInvocation invocation)
    {
        var attr = invocation.Method.GetCustomAttributes(typeof(FunctionNameAttribute), true);

        if (attr != null)
        {
            //check for incoming htttprequest
            var httpReq = invocation.Arguments.Where(a => a.GetType().IsSubclassOf(typeof(HttpRequest))).SingleOrDefault() as HttpRequest;
            ActivityContext parentContext = httpReq != null ? ExtractParentContext(httpReq) : default;

            AzureFunctionsCoreInstrumentation.TraceAsync(tracerProvider, ((FunctionNameAttribute)attr[0]).Name, () =>
            {
                invocation.Proceed();

                return Task.FromResult(invocation.ReturnValue);
            }, parentContext);
        }

    }

Support

This project is not an offical release of Dynatrace. If you have questions or any problems, open a github issue.

License

Licensed under Apache 2.0 license. See LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on PaTh.AzureFunctions.Tracing:

Package Downloads
PaTh.AzureFunctions.Tracing.Extra

An Azure Function startup class leveraging PaTh.AzureFunctions.Tracing to enable tracing with OpenTelemetry and Dynatrace.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.1-beta 202 4/6/2023
1.1.0-beta 2,296 11/14/2022
1.0.0-beta 524 9/22/2022
0.10.0-beta 119 9/6/2022
0.9.2-beta 133 5/24/2022
0.9.1-beta 144 5/17/2022

Fixing exception with non-task function return values.