TelemetrySrcGen.Abstractions 1.1.4

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

// Install TelemetrySrcGen.Abstractions as a Cake Tool
#tool nuget:?package=TelemetrySrcGen.Abstractions&version=1.1.4

TelemetrySrcGen

A simple source generator to create the boilerplate code needed to report performance metrics via App Insights.

TelemetrySrcGen lets you define telemetry metrics in the form of simple fields and the source generator creates the methods to send metrics to app insights for you.

Usage

using Microsoft.ApplicationInsights;

[TelemetrySource]
public partial class MyIngestionTelemetry
{
    private TelemetryClient telemetryClient;
    public MyIngestionTelemetry(TelemetryClient telemetryClient)
    {
        this.telemetryClient = telemetryClient;
    }

    [Measurement(MetricKind.Duration)]
    public bool IngestionProcess ;

    [Measurement(MetricKind.Duration)]
    public bool DeliveryTime;

    [Measurement(MetricKind.Counter)]
    public double DataPointsReceived;

    [Measurement(MetricKind.Operation)]
    public bool CallAPI;
    
    [Measurement(MetricKind.Event)]
    public partial void OnPollingSucceeded(IDictionary<string, string> properties = null, IDictionary<string, double> metrics = null); 
}

Will Augment your class with some extra methods to drive App Insights.

// Generated on 2024-06-07
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
#pragma warning disable CS0108 // hides inherited member.

using Microsoft.ApplicationInsights;
namespace TelemetrySrcGen.Playground;

using Microsoft.ApplicationInsights.DataContracts;
public partial class MyIngestionTelemetry
{
    public void AddDataPointsReceived(Double value) => telemetryClient.TrackMetric("DataPointsReceived.Counter", value);
    public void StartCallAPI() 
      => telemetryClient.StartOperation<RequestTelemetry>("CallAPI");
    public IDisposable RecordIngestionProcessDuration(IDictionary<string, string> properties = null)
    {
        return new TelemetrySrcGen.Abstractions.StopwatchDisposable(this.telemetryClient, "IngestionProcess.Duration", properties);
    }
    public IDisposable RecordDeliveryTimeDuration(IDictionary<string, string> properties = null)
    {
        return new TelemetrySrcGen.Abstractions.StopwatchDisposable(this.telemetryClient, "DeliveryTime.Duration", properties);
    }
}
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on TelemetrySrcGen.Abstractions:

Package Downloads
TelemetrySrcGen

A simple source generator to create the boilerplate code needed to report performance metrics via App Insights.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.4 79 6/7/2024
1.1.2 79 6/7/2024