PW.OpenTelemetry.Proxy 3.1.3

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

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

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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 is compatible.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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 (2)

Showing the top 2 NuGet packages that depend on PW.OpenTelemetry.Proxy:

Package Downloads
PW.OpenTelemetry.DynamicProxy

Automatically generate activity by defined [Activity] on runtime.

PW.OpenTelemetry.StaticProxy

Automatically generate activity by defined [Activity] on compile. Install `Metalama.Compiler` to emit code.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.2.0 51 11/25/2024
3.1.3 228 10/21/2024
3.1.2 271 9/30/2024
3.1.1 202 9/14/2024
3.0.0 375 7/22/2024
2.4.0 266 7/3/2024
2.3.4 151 6/24/2024
2.3.3 266 2/19/2024
2.3.2 334 1/23/2024
2.2.2 1,198 5/16/2023