PW.OpenTelemetry.DynamicProxy 3.2.0

dotnet add package PW.OpenTelemetry.DynamicProxy --version 3.2.0                
NuGet\Install-Package PW.OpenTelemetry.DynamicProxy -Version 3.2.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.DynamicProxy" Version="3.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PW.OpenTelemetry.DynamicProxy --version 3.2.0                
#r "nuget: PW.OpenTelemetry.DynamicProxy, 3.2.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.DynamicProxy as a Cake Addin
#addin nuget:?package=PW.OpenTelemetry.DynamicProxy&version=3.2.0

// Install PW.OpenTelemetry.DynamicProxy as a Cake Tool
#tool nuget:?package=PW.OpenTelemetry.DynamicProxy&version=3.2.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 net6.0 is compatible.  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 is compatible.  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 Framework net472 is compatible.  net48 was computed.  net481 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 PW.OpenTelemetry.DynamicProxy:

Package Downloads
PW.OpenTelemetry.DynamicProxy.ExpressionParser

Automatically generate activity by defined [Activity] on runtime.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.2.0 279 11/25/2024
3.1.0 429 9/13/2024
3.0.1 165 7/23/2024
2.4.0 157 7/3/2024
2.3.4 119 6/24/2024
2.3.3 170 4/17/2024
2.3.2 156 1/23/2024
2.2.2 1,244 4/3/2023