PW.OpenTelemetry.StaticProxy 3.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package PW.OpenTelemetry.StaticProxy --version 3.1.0                
NuGet\Install-Package PW.OpenTelemetry.StaticProxy -Version 3.1.0                
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="PW.OpenTelemetry.StaticProxy" Version="3.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PW.OpenTelemetry.StaticProxy --version 3.1.0                
#r "nuget: PW.OpenTelemetry.StaticProxy, 3.1.0"                
#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 PW.OpenTelemetry.StaticProxy as a Cake Addin
#addin nuget:?package=PW.OpenTelemetry.StaticProxy&version=3.1.0

// Install PW.OpenTelemetry.StaticProxy as a Cake Tool
#tool nuget:?package=PW.OpenTelemetry.StaticProxy&version=3.1.0                

OpenTelemetry.Proxy

Generate an activity to wrap the method, modify name of the inner activity or discard inner activity.

Attribute

[ActivitySource]

DynamicProxy

[ActivitySource] all methods defined in the interface or virtual methods defined in the class will automatically generate activity, unless defined [NonActivity] on method.

IncludeNonAsyncStateMachineMethod: default include all async methods of defined in an interface, or all [AsyncStateMachine] public or protected virtual method of class (except for async void method). If true, all methods defined in the interface will be included and all public or protected virtual methods of the class.

StaticProxy

[ActivitySource] all methods will automatically generate activity, except for those that are defined [NonActivity] on method.

IncludeNonAsyncStateMachineMethod: public methods defined in the class that are marked with the [AsyncStateMachine] attribute (except for async void method). If true, will include all methods of class.

Needs to be installed in each working project, and install Metalama.Compiler or Fody (Fody need some additional file), recommend Metalama.Compiler.

[Activity]

[Activity] can be defined on method only.

[NonActivity]

If defined [NonActivity] on method, call method will not generate an activity. if SuppressInstrumentation is true, the inner activity will be discarded.

[ActivityName]

To modify the DisplayName of an inner activity, you must invoke TracerProviderBuilder.AddActivityNameProcessor(). If a type is defined with the [ActivitySource] attribute or a method is defined with the [Activity] or [NonActivity] attribute, the [ActivityName] attribute will not take effect.

Priority: [NonActivity] > [Activity] > [ActivityName] (method) > [ActivitySource] > [ActivityName] (class)

[ActivityTag]

To add tag to activity, it defined on parameter or return value.

[ActivityTags]

To add tags to activity, it defined on type or method.

About DynamicProxy and StaticProxy

DynamicProxy StaticProxy
AOT ✔️
Work in Runtime Compiling
Support scenario interface or virtual method Any method with a body of type.
Work order (ASC) 2 1
Performance ⭐⭐⭐ ⭐⭐⭐⭐⭐
Expression Default: public property, field or parameterless method.<br />DynamicExpressionParser: see DynamicExpresso.Core Any valid code.

Tag expression

Must start with $ on [ActivityTag]

DynamicProxy

Parse expression on runtime.

Default

Public property, field or parameterless method only.

DynamicExpressionParser

See DynamicExpresso.Core

StaticProxy

Parse expression on compiling.

Any valid code.

QA

How to get ActivitySource name?

ActivitySourceAttribute.GetActivitySourceName(typeof(YourType))

See demo

How to generate proxy class?

ProxyGenerator generator = ...
IActivityInvokerFactory invokerFactory = ...

var proxyType = generator.CreateClassProxy<YourType>(new ActivityInterceptor(invokerFactory));

See demo.

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. 
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.1.2 142 10/21/2024
3.1.1.1 141 10/9/2024
3.1.1 100 9/30/2024
3.1.0 192 9/13/2024
3.0.4 117 7/24/2024
2.4.1 132 7/7/2024
2.4.0 132 7/3/2024
2.3.5.1 142 3/8/2024
2.3.5 142 1/26/2024
2.3.4.3 108 1/25/2024
2.2.6 475 5/16/2023