TelemetrySrcGen 1.1.4

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

// Install TelemetrySrcGen as a Cake Tool
#tool nuget:?package=TelemetrySrcGen&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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.4 108 6/7/2024
1.1.2 96 6/7/2024

just ironing out the initial setup of the nuget package