From 4e0239850937fa46698820724d00291ec7ce0b5b Mon Sep 17 00:00:00 2001 From: Kieron Date: Mon, 6 May 2024 09:52:34 +0100 Subject: [PATCH 1/2] fix: fixed diagnostic id duplication --- Makefile | 2 +- .../TelemetryDiagnostics.Activities.cs | 26 +++++++++---------- .../TelemetryDiagnostics.General.cs | 6 ++--- .../TelemetryDiagnostics.Metrics.cs | 14 +++++----- version.json | 2 +- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 29440fc8..8342f270 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ SOLUTION_FILE = $(ROOT_FOLDER)Purview.Telemetry.SourceGenerator.sln TEST_PROJECT = $(ROOT_FOLDER)Purview.Telemetry.SourceGenerator.sln CONFIGURATION = Release -PACK_VERSION = 1.0.4 +PACK_VERSION = 1.0.5 ARTIFACT_FOLDER = p:/sync-projects/.local-nuget/ # Targets diff --git a/src/Purview.Telemetry.SourceGenerator/TelemetryDiagnostics.Activities.cs b/src/Purview.Telemetry.SourceGenerator/TelemetryDiagnostics.Activities.cs index 5acfd320..eb2a9636 100644 --- a/src/Purview.Telemetry.SourceGenerator/TelemetryDiagnostics.Activities.cs +++ b/src/Purview.Telemetry.SourceGenerator/TelemetryDiagnostics.Activities.cs @@ -10,7 +10,7 @@ public static class Activities { public static readonly TelemetryDiagnosticDescriptor BaggageParameterShouldBeString = new( Id: "TSG3000", - Title: "Baggage parameter types only accept strings.", + Title: "Baggage parameter types only accept strings", Description: "Baggage parameter types only accept strings, be aware this parameter will have ToString() called.", Category: Constants.Diagnostics.Activity.Usage, Severity: DiagnosticSeverity.Warning @@ -18,7 +18,7 @@ public static class Activities public static readonly TelemetryDiagnosticDescriptor NoActivitySourceSpecified = new( Id: "TSG3001", - Title: "No activity source specified.", + Title: "No activity source specified", Description: $"An activity source helps to identify your application and it's telemetry. Defaulting to '{Constants.Activities.DefaultActivitySourceName}'.", Category: Constants.Diagnostics.Activity.Usage, Severity: DiagnosticSeverity.Warning @@ -26,7 +26,7 @@ public static class Activities public static readonly TelemetryDiagnosticDescriptor InvalidReturnType = new( Id: "TSG3002", - Title: "Invalid return type.", + Title: "Invalid return type", Description: $"An activity or event must return either void or an {Constants.Activities.SystemDiagnostics.Activity}.", Category: Constants.Diagnostics.Activity.Usage, Severity: DiagnosticSeverity.Error @@ -34,7 +34,7 @@ public static class Activities public static readonly TelemetryDiagnosticDescriptor DuplicateParameterTypes = new( Id: "TSG3003", - Title: "Duplicate special parameters defined.", + Title: "Duplicate reserved parameters defined", Description: "{0} are all the same type of parameter ({1}), a maximum or one is allowed. Explicitly define them as either a Tag or Baggage.", Category: Constants.Diagnostics.Activity.Usage, Severity: DiagnosticSeverity.Error @@ -42,7 +42,7 @@ public static class Activities public static readonly TelemetryDiagnosticDescriptor ActivityParameterNotAllowed = new( Id: "TSG3004", - Title: "Activity parameter is not valid.", + Title: "Activity parameter is not valid", Description: "The {0} parameter is not allowed when defining an activity, only an event.", Category: Constants.Diagnostics.Activity.Usage, Severity: DiagnosticSeverity.Error @@ -50,7 +50,7 @@ public static class Activities public static readonly TelemetryDiagnosticDescriptor TimestampParameterNotAllowed = new( Id: "TSG3005", - Title: "Timestamp parameter is not valid.", + Title: "Timestamp parameter is not valid", Description: "The {0} parameter is not allowed when defining an activity, only an event. You can specify this as a Tag or as Baggage to stop the inference.", Category: Constants.Diagnostics.Activity.Usage, Severity: DiagnosticSeverity.Error @@ -58,7 +58,7 @@ public static class Activities public static readonly TelemetryDiagnosticDescriptor StartTimeParameterNotAllowed = new( Id: "TSG3006", - Title: "Start time parameter is not valid on Create activity or Event method.", + Title: "Start time parameter is not valid on Create activity or Event method", Description: "The {0} parameter is not allowed when defining an activity create or activity event method, only when starting an activity.", Category: Constants.Diagnostics.Activity.Usage, Severity: DiagnosticSeverity.Error @@ -66,7 +66,7 @@ public static class Activities public static readonly TelemetryDiagnosticDescriptor ParentContextOrIdParameterNotAllowed = new( Id: "TSG3007", - Title: "Parent context or Parent Id parameter is not valid on event.", + Title: "Parent context or Parent Id parameter is not valid on event", Description: "The {0} parameter is not allowed when defining an activity event, only on the activity start/ create method.", Category: Constants.Diagnostics.Activity.Usage, Severity: DiagnosticSeverity.Error @@ -74,7 +74,7 @@ public static class Activities public static readonly TelemetryDiagnosticDescriptor LinksParameterNotAllowed = new( Id: "TSG3008", - Title: "Activity links parameters are not valid on events or context methods.", + Title: "Activity links parameters are not valid on events or context methods", Description: "The {0} parameter is not allowed when defining an activity event or context, only on the activity start/ create method.", Category: Constants.Diagnostics.Activity.Usage, Severity: DiagnosticSeverity.Error @@ -82,7 +82,7 @@ public static class Activities public static readonly TelemetryDiagnosticDescriptor TagsParameterNotAllowed = new( Id: "TSG3009", - Title: "Activity tags parameter are not valid on context methods.", + Title: "Activity tags parameter are not valid on context methods", Description: "The {0} parameter is not allowed when defining an activity context, only on the activity start/ create methods or events.", Category: Constants.Diagnostics.Activity.Usage, Severity: DiagnosticSeverity.Error @@ -90,15 +90,15 @@ public static class Activities public static readonly TelemetryDiagnosticDescriptor EscapedParameterInvalidType = new( Id: "TSG3010", - Title: "Escaped parameters must be a boolean.", + Title: "Escaped parameters must be a boolean", Description: "Only boolean parameter types are valid for the escape parameter.", Category: Constants.Diagnostics.Activity.Usage, Severity: DiagnosticSeverity.Error ); public static readonly TelemetryDiagnosticDescriptor EscapedParameterIsOnlyValidOnEvent = new( - Id: "TSG3010", - Title: "Escaped parameters are only valid on Events, not Activity or Context methods.", + Id: "TSG3011", + Title: "Escaped parameters are only valid on Events, not Activity or Context methods", Description: "The parameters {0} is not valid on Activity or Context methods, only on Events.", Category: Constants.Diagnostics.Activity.Usage, Severity: DiagnosticSeverity.Error diff --git a/src/Purview.Telemetry.SourceGenerator/TelemetryDiagnostics.General.cs b/src/Purview.Telemetry.SourceGenerator/TelemetryDiagnostics.General.cs index f7e9f6d6..5c2a4ff6 100644 --- a/src/Purview.Telemetry.SourceGenerator/TelemetryDiagnostics.General.cs +++ b/src/Purview.Telemetry.SourceGenerator/TelemetryDiagnostics.General.cs @@ -17,7 +17,7 @@ public static class General public static readonly TelemetryDiagnosticDescriptor InferenceNotSupportedWithMultiTargeting = new( Id: "TSG1001", - Title: "Inferring generation targets is not supported when using multi-target generation.", + Title: "Inferring generation targets is not supported when using multi-target generation", Description: $"When using multiple generation targets - Activities, Logs or Metrics, each method must be either excluded or have an explicit generation target: " + $"{Constants.Activities.ActivityAttribute.Name}, {Constants.Activities.EventAttribute.Name}, {Constants.Activities.ContextAttribute.Name}, {Constants.Logging.LogAttribute.Name}, " + $"{Constants.Metrics.CounterAttribute.Name}, {Constants.Metrics.HistogramAttribute.Name}, {Constants.Metrics.UpDownCounterAttribute.Name}, " + @@ -28,8 +28,8 @@ public static class General public static readonly TelemetryDiagnosticDescriptor MultiGenerationTargetsNotSupported = new( Id: "TSG1002", - Title: "Only single generation types are supported.", - Description: $"Only a single generation target types (Activities, Logs or Metrics) is supported on methods. Use one of the following: " + + Title: "Multiple generation types are not supported", + Description: $"Only a single generation target types (Activities, Logs or Metrics) are supported. Use one of the following: " + $"{Constants.Activities.ActivityAttribute.Name}, {Constants.Activities.EventAttribute.Name}, {Constants.Activities.ContextAttribute.Name}, {Constants.Logging.LogAttribute.Name}, " + $"{Constants.Metrics.CounterAttribute.Name}, {Constants.Metrics.HistogramAttribute.Name}, {Constants.Metrics.UpDownCounterAttribute.Name}, " + $"{Constants.Metrics.ObservableCounterAttribute.Name}, {Constants.Metrics.ObservableGaugeAttribute.Name} or {Constants.Metrics.ObservableUpDownCounterAttribute.Name}.", diff --git a/src/Purview.Telemetry.SourceGenerator/TelemetryDiagnostics.Metrics.cs b/src/Purview.Telemetry.SourceGenerator/TelemetryDiagnostics.Metrics.cs index 66b4e121..523ec9cc 100644 --- a/src/Purview.Telemetry.SourceGenerator/TelemetryDiagnostics.Metrics.cs +++ b/src/Purview.Telemetry.SourceGenerator/TelemetryDiagnostics.Metrics.cs @@ -10,7 +10,7 @@ public static class Metrics { public static readonly TelemetryDiagnosticDescriptor NoInstrumentDefined = new( Id: "TSG4000", - Title: "No instrument defined.", + Title: "No instrument defined", Description: "Either exclude this method, or define an instrument.", Category: Constants.Diagnostics.Metrics.Usage, Severity: DiagnosticSeverity.Error @@ -18,7 +18,7 @@ public static class Metrics public static readonly TelemetryDiagnosticDescriptor DoesNotReturnVoid = new( Id: "TSG4001", - Title: "Must return void or bool.", + Title: "Must return void or bool", Description: "Instrument methods can only return void or bool.", Category: Constants.Diagnostics.Metrics.Usage, Severity: DiagnosticSeverity.Error @@ -26,7 +26,7 @@ public static class Metrics public static readonly TelemetryDiagnosticDescriptor AutoIncrementCountAndMeasurementParam = new( Id: "TSG4002", - Title: "Auto increment counter and measurement defined.", + Title: "Auto increment counter and measurement defined", Description: "Auto increment counter and a measurement parameter are defined, either remove the parameter or disable auto increment.", Category: Constants.Diagnostics.Metrics.Usage, Severity: DiagnosticSeverity.Error @@ -34,7 +34,7 @@ public static class Metrics public static readonly TelemetryDiagnosticDescriptor MoreThanOneMeasurementValueDefined = new( Id: "TSG4003", - Title: "Multiple measurement values defined.", + Title: "Multiple measurement values defined", Description: "More than one measurement parameters are defined.", Category: Constants.Diagnostics.Metrics.Usage, Severity: DiagnosticSeverity.Error @@ -42,7 +42,7 @@ public static class Metrics public static readonly TelemetryDiagnosticDescriptor NoMeasurementValueDefined = new( Id: "TSG4004", - Title: "No measurement value defined.", + Title: "No measurement value defined", Description: "Either define a measurement parameter, or provide a supported type parameter that is not a tag to enable inferring.", Category: Constants.Diagnostics.Metrics.Usage, Severity: DiagnosticSeverity.Error @@ -50,7 +50,7 @@ public static class Metrics public static readonly TelemetryDiagnosticDescriptor ObservableRequiredFunc = new( Id: "TSG4005", - Title: "Observable instrument requires func.", + Title: "Observable instrument requires Func", Description: "Observable instruments require a Func where T is a supported instrument result type.", Category: Constants.Diagnostics.Metrics.Usage, Severity: DiagnosticSeverity.Error @@ -58,7 +58,7 @@ public static class Metrics public static readonly TelemetryDiagnosticDescriptor InvalidMeasurementType = new( Id: "TSG4006", - Title: "Invalid measurement type.", + Title: "Invalid measurement type", Description: $"Invalid measurement type used, valid types are {string.Join(", ", Constants.Metrics.ValidMeasurementKeywordTypes)}, Measurement or IEnumerable>.", Category: Constants.Diagnostics.Metrics.Usage, Severity: DiagnosticSeverity.Error diff --git a/version.json b/version.json index 4e7a9856..c48de278 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.0.4", + "version": "1.0.5", "cloudBuild": { "buildNumber": { "enabled": true, From e2a4bc39555769ecf5f329291c2aaae89e45801c Mon Sep 17 00:00:00 2001 From: Kieron Date: Mon, 6 May 2024 10:06:20 +0100 Subject: [PATCH 2/2] docs: updated the README.md --- README.md | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 42aa06a2..71d7c962 100644 --- a/README.md +++ b/README.md @@ -13,22 +13,37 @@ The latest version is available on [NuGet](https://www.nuget.org/packages/Purvie [ActivitySource] [Logger] [Meter] -interface IServiceTelemetry +interface IEntityStoreTelemetry { + /// + /// Creates and starts an Activity and adds the parameters as Tags and Baggage. + /// [Activity] - Activity? StartsAnActivity(string tagStringParam, [Baggage]int entityId); + void GettingEntityFromStore(int entityId, [Baggage]string serviceUrl); + /// + /// Adds an ActivityEvent to the Activity with the parameters as Tags. + /// [Event] - void AnInterestingEvent(Activity? activity, float aTagValue); + void GetDuration(int durationInMS); + /// + /// Adds the parameters as Baggage to the Activity. + /// [Context] - void InterestingInfo(Activity? activity, float anotherTagValue, int intTagValue); + void RetrievedEntity(float totalValue, int lastUpdatedByUserId); + /// + /// Generates a structured log message using an ILogger. + /// [Log] - void ProcessingEntity(int entityId, string property); + void ProcessingEntity(int entityId, string updateState); + /// + /// Adds 1 to a Counter with the entityId as a Tag. + /// [AutoCounter] - void AnAutoIncrementCounter([Tag]int entityId); + void RetrievingEntity(int entityId); } ```