Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/purview-dev/purview-telemetry-sourcegenerator

.NET Source Generator for interface-based telemetry building activities, activity events, logs and metrics.
https://github.com/purview-dev/purview-telemetry-sourcegenerator

activity distributed-tracing dotnet events logging metrics open-telemetry open-telemetry-csharp source-generator spans

Last synced: 14 days ago
JSON representation

.NET Source Generator for interface-based telemetry building activities, activity events, logs and metrics.

Awesome Lists containing this project

README

        

# Purview Telemetry Source Generator

Generates [ActivitySource](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.activitysource), [High-performance logging](https://learn.microsoft.com/en-us/dotnet/core/extensions/high-performance-logging) and [Metrics](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics) based on methods on an interface, enabling fast iteration cycles, dependency injection and substitutes for testing.

The latest version is available on [NuGet](https://www.nuget.org/packages/Purview.Telemetry.SourceGenerator/), and supports generating for the following frameworks:

* .NET Framework 4.7.2
* .NET Framework 4.8
* .NET 7
* .NET 8
* .NET 9

```csharp
[ActivitySource]
[Logger]
[Meter]
interface IEntityStoreTelemetry
{
///
/// Creates and starts an Activity and adds the parameters as Tags and Baggage.
///
[Activity]
Activity? GettingEntityFromStore(int entityId, [Baggage]string serviceUrl);

///
/// Adds an ActivityEvent to the Activity with the parameters as Tags.
///
[Event]
void GetDuration(Activity? activity, int durationInMS);

///
/// Adds the parameters as Baggage to the Activity.
///
[Context]
void RetrievedEntity(Activity? activity, float totalValue, int lastUpdatedByUserId);

///
/// Generates a structured log message using an ILogger.
///
[Log]
void ProcessingEntity(int entityId, string updateState);

///
/// Adds 1 to a Counter with the entityId as a Tag.
///
[AutoCounter]
void RetrievingEntity(int entityId);
}
```

For more information see the [wiki](https://github.com/purview-dev/purview-telemetry-sourcegenerator/wiki).