Rougamo.APM.Abstractions 4.0.0-priview-1723628750

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

// Install Rougamo.APM.Abstractions as a Cake Tool
#tool nuget:?package=Rougamo.APM.Abstractions&version=4.0.0-priview-1723628750&prerelease                

Rougamo.APM

APM stands for Application Performance Management. Some common APM tools include Pinpoint, Zipkin, SkyWalking, CAT, and Jaeger. These popular APM tools typically come with built-in IO-level agents, which allow us to quickly integrate and record IO performance. However, sometimes IO integration alone might not be sufficient for thorough analysis and problem-solving. In such cases, we might need to manually add some instrumentation, which can be intrusive and cumbersome. To avoid this, we can use AOP for instrumentation, and Rougamo, as a static AOP component, can effectively handle this task.

This project does not include any specific APM implementations but provides basic implementations and proxy weaving methods for projects using Rougamo for APM code weaving. For specific APM implementations, refer to Rougamo.OpenTelemetry (0.1.1 released) and Rougamo.SkyWalking (in development).

Rougamo.APM.Abstractions

Common Attributes

Rougamo.APM.Abstractions defines several common attributes to avoid redundant definitions across different APM implementations and provides implementations for retrieving these attributes.

Attribute Target Purpose
SpanAttribute Method Marker attribute for proxy weaving that indicates a Span will be recorded for the marked method. By default, it records method parameters and return values.
PureSpanAttribute Method Marker attribute for proxy weaving that indicates a Span will be recorded for the marked method but does <font color=red>not</font> record method parameters and return values by default.
ApmIgnoreAttribute Parameter, Return Value Used with SpanAttribute to ignore specified parameters and return values from being recorded.
ApmRecordAttribute Parameter, Return Value Used with PureSpanAttribute to record specified parameters and return values.
ApmExceptionAnnounceAttribute Method Ensures that exceptions are recorded even if they have been logged before. By default, exceptions are recorded only once, but all Spans with unhandled exceptions are marked as failed.
// Example of ApmExceptionAnnounceAttribute
// In the example below, since M3 has an unhandled exception, the Span on M3 will record the exception and mark its status as failed.
// M2, which calls M3 and does not catch the exception, will only mark its Span as failed without recording the exception because M3 has already recorded it.
// M1, which calls M2 and does not catch the exception, will also mark its Span as failed and will record the exception information due to the addition of ApmExceptionAnnounceAttribute.

[ApmExceptionAnnounce]
[Span]
void M1()
{
    M2();
}
[Span]
void M2()
{
    M3();
}
[Span]
void M3()
{
    throw new NotImplementedException();
}

Proxy Weaving

Rougamo.APM.Abstractions defines several attributes that are markers and do not directly use Rougamo for code weaving. To weave AOP based on these markers, we need to utilize Rougamo's proxy weaving functionality. For example, proxy weaving with Rougamo.OpenTelemetry can be done as follows; see the full example in the Rougamo.OpenTelemetry project:

[assembly: MoProxy(typeof(SpanAttribute), typeof(OtelAttribute))]
[assembly: MoProxy(typeof(PureSpanAttribute), typeof(PureOtelAttribute))]

// Implementation code weaving OtelAttribute
[Span]
void M1()
{
}
// Implementation code weaving PureOtelAttribute
[PureSpan]
void M2()
{
}

Rougamo.APM.JsonSerialization

When recording parameters and return values, they need to be serialized into strings. By default, ToStringSerializer is used, which directly calls the object's ToString method. You can implement your own ISerializer and replace the default ToStringSerializer as per the specific requirements of your APM implementation (usually by registering a singleton in IServiceCollection). The Rougamo.APM.JsonSerialization project provides a JSON serialization implementation using Newtonsoft.Json, and can be registered with services.AddRougamoJsonSerializer():

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        // ...

        services.AddRougamoJsonSerializer(); // Use default serialization configuration

        services.AddRougamoJsonSerializer(settings =>
        {
            // Modify Newtonsoft.Json serialization configuration
        });

        // ...
    }
}
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 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  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 Rougamo.APM.Abstractions:

Package Downloads
Rougamo.OpenTelemetry

Rougamo OpenTelemetry code weaver.

Rougamo.APM.JsonSerialization

json serializer of rougamo apm parameter and return value record

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.0.0 357 8/14/2024
4.0.0-priview-1723628750 211 8/14/2024
0.1.0 1,091 12/8/2021

**注意:`Rougamo.APM.Abstractions`和`Rougamo.APM.JsonSerialization`共享以下更新内容**

- 更新依赖的NuGet版本
 
 |包名|版本变化|
 |:-:|:-----:|
 | `Rougamo.Fody` | `1.0.1 -> 4.0.0` |
 | `Microsoft.SourceLink.GitHub` | `1.1.1 -> 8.0.0` |
 | `Newtonsoft.Json` | `9.0.1 -> 13.0.1` |
 | `Microsoft.Extensions.Options` | `3.0.0 -> 3.1.0+` |

- SDK版本新增net6.0, net7.0, net8.0,不同的SDK版本针对某些NuGet引用不同的版本

---