From d471839e4da34691cd0896819def1007acc4b215 Mon Sep 17 00:00:00 2001 From: Kieron Date: Sun, 7 Apr 2024 00:06:15 +0100 Subject: [PATCH] docs: added sample project --- Makefile | 2 +- README.md | 4 +- .../SampleApp/SampleApp.AppHost/Program.cs | 5 + .../Properties/launchSettings.json | 16 +++ .../SampleApp.AppHost.csproj | 19 +++ .../appsettings.Development.json | 8 ++ .../SampleApp.AppHost/appsettings.json | 9 ++ .../Controllers/WeatherForecastController.cs | 17 +++ .../Interfaces/Services/IWeatherService.cs | 5 + .../Services/IWeatherServiceTelemetry.cs | 30 +++++ samples/SampleApp/SampleApp.Host/Program.cs | 39 ++++++ .../SampleApp.Host/Properties/AssemblyInfo.cs | 3 + .../Properties/launchSettings.json | 41 +++++++ .../SampleApp.Host/SampleApp.Host.csproj | 19 +++ .../SampleApp.Host/SampleApp.Host.http | 6 + .../SampleApp.Host/Services/WeatherService.cs | 47 ++++++++ .../SampleApp.Host/WeatherForecast.cs | 9 ++ .../appsettings.Development.json | 8 ++ .../SampleApp/SampleApp.Host/appsettings.json | 9 ++ .../SampleApp.ServiceDefaults/Extensions.cs | 112 ++++++++++++++++++ .../SampleApp.ServiceDefaults.csproj | 24 ++++ samples/SampleApp/SampleApp.sln | 37 ++++++ ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ...sting.TestMetricsCore.Metric.g.verified.cs | 6 +- ..._0#MeterTelemetryCore.Metric.g.verified.cs | 6 +- ...#ServiceTelemetryCore.Metric.g.verified.cs | 6 +- ...ing.TestTelemetryCore.Metric.g.verified.cs | 6 +- ...ing.TestTelemetryCore.Metric.g.verified.cs | 6 +- ...ing.TestTelemetryCore.Metric.g.verified.cs | 6 +- ...8_0#TestTelemetryCore.Metric.g.verified.cs | 6 +- src/Purview.Telemetry.SourceGenerator.sln | 6 - .../Constants.Metrics.cs | 4 + .../Emitters/ConstructorEmitter.cs | 4 +- .../MeterTargetClassEmitter.Methods.cs | 2 +- .../Helpers/PipelineHelpers.Metrics.cs | 22 ++-- .../Helpers/SharedHelpers.Metrics.cs | 10 +- .../Records/GenericRecords.cs | 6 +- weatherforecast | 1 + 62 files changed, 588 insertions(+), 128 deletions(-) create mode 100644 samples/SampleApp/SampleApp.AppHost/Program.cs create mode 100644 samples/SampleApp/SampleApp.AppHost/Properties/launchSettings.json create mode 100644 samples/SampleApp/SampleApp.AppHost/SampleApp.AppHost.csproj create mode 100644 samples/SampleApp/SampleApp.AppHost/appsettings.Development.json create mode 100644 samples/SampleApp/SampleApp.AppHost/appsettings.json create mode 100644 samples/SampleApp/SampleApp.Host/Controllers/WeatherForecastController.cs create mode 100644 samples/SampleApp/SampleApp.Host/Interfaces/Services/IWeatherService.cs create mode 100644 samples/SampleApp/SampleApp.Host/Interfaces/Services/IWeatherServiceTelemetry.cs create mode 100644 samples/SampleApp/SampleApp.Host/Program.cs create mode 100644 samples/SampleApp/SampleApp.Host/Properties/AssemblyInfo.cs create mode 100644 samples/SampleApp/SampleApp.Host/Properties/launchSettings.json create mode 100644 samples/SampleApp/SampleApp.Host/SampleApp.Host.csproj create mode 100644 samples/SampleApp/SampleApp.Host/SampleApp.Host.http create mode 100644 samples/SampleApp/SampleApp.Host/Services/WeatherService.cs create mode 100644 samples/SampleApp/SampleApp.Host/WeatherForecast.cs create mode 100644 samples/SampleApp/SampleApp.Host/appsettings.Development.json create mode 100644 samples/SampleApp/SampleApp.Host/appsettings.json create mode 100644 samples/SampleApp/SampleApp.ServiceDefaults/Extensions.cs create mode 100644 samples/SampleApp/SampleApp.ServiceDefaults/SampleApp.ServiceDefaults.csproj create mode 100644 samples/SampleApp/SampleApp.sln create mode 100644 weatherforecast diff --git a/Makefile b/Makefile index ea2fd08..5d7223f 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 = 0.0.11-prerelease +PACK_VERSION = 0.0.12-prerelease ARTIFACT_FOLDER = p:/sync-projects/.local-nuget/ # Targets diff --git a/README.md b/README.md index b60d759..ef2f5f7 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ The following examples all contain explicit definitions, by that I mean that we Each generation target ([activity](./docs/ACTIVITIES.md), [logging](./docs/LOGGING.md) and [metrics](./docs/METRICS.md)) documentation contains information on what can be inferred. -> You can mix-and-match generation targets within a single interface but, however the inferring functionality is more limited. This is called [multi-targetting](./docs/MULTITARGETTING.md). +> You can mix-and-match generation targets within a single interface, however the ability to infer is more limited. This is called [multi-targetting](./docs/MULTITARGETTING.md). -> In .NET, Activities, Events and Metrics refer to additional properties captured at creation or recording time as **tags**. However, in Open Telemetry these are referred to as **attributes**. As this source generator makes extensive use of marker attributes to control source code generation we will use the term tags to mean this properties, and attributes as the .NET [Attribute](https://learn.microsoft.com/en-us/dotnet/api/system.attribute) type. +> In .NET, Activities, Events and Metrics refer to additional properties captured at creation, recording or observing as **tags**. However, in Open Telemetry these are referred to as **attributes**. As this source generator makes extensive use of marker attributes to control source code generation we will use the term tags to mean these properties, and attributes as the .NET [Attribute](https://learn.microsoft.com/en-us/dotnet/api/system.attribute) type. ### Activities diff --git a/samples/SampleApp/SampleApp.AppHost/Program.cs b/samples/SampleApp/SampleApp.AppHost/Program.cs new file mode 100644 index 0000000..b5f3ab8 --- /dev/null +++ b/samples/SampleApp/SampleApp.AppHost/Program.cs @@ -0,0 +1,5 @@ +var builder = DistributedApplication.CreateBuilder(args); + +builder.AddProject("sampleapp-host"); + +builder.Build().Run(); diff --git a/samples/SampleApp/SampleApp.AppHost/Properties/launchSettings.json b/samples/SampleApp/SampleApp.AppHost/Properties/launchSettings.json new file mode 100644 index 0000000..e181a21 --- /dev/null +++ b/samples/SampleApp/SampleApp.AppHost/Properties/launchSettings.json @@ -0,0 +1,16 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:15289", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16263" + } + } + } +} diff --git a/samples/SampleApp/SampleApp.AppHost/SampleApp.AppHost.csproj b/samples/SampleApp/SampleApp.AppHost/SampleApp.AppHost.csproj new file mode 100644 index 0000000..295ca8b --- /dev/null +++ b/samples/SampleApp/SampleApp.AppHost/SampleApp.AppHost.csproj @@ -0,0 +1,19 @@ + + + + Exe + net8.0 + enable + enable + true + + + + + + + + + + + diff --git a/samples/SampleApp/SampleApp.AppHost/appsettings.Development.json b/samples/SampleApp/SampleApp.AppHost/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/samples/SampleApp/SampleApp.AppHost/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/samples/SampleApp/SampleApp.AppHost/appsettings.json b/samples/SampleApp/SampleApp.AppHost/appsettings.json new file mode 100644 index 0000000..31c092a --- /dev/null +++ b/samples/SampleApp/SampleApp.AppHost/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Aspire.Hosting.Dcp": "Warning" + } + } +} diff --git a/samples/SampleApp/SampleApp.Host/Controllers/WeatherForecastController.cs b/samples/SampleApp/SampleApp.Host/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..f3e413b --- /dev/null +++ b/samples/SampleApp/SampleApp.Host/Controllers/WeatherForecastController.cs @@ -0,0 +1,17 @@ +using Microsoft.AspNetCore.Mvc; +using SampleApp.Host.Interfaces.Services; + +namespace SampleApp.Host.Controllers; + +[ApiController] +[Route("[controller]")] +public class WeatherForecastController(IWeatherService service) : ControllerBase +{ + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + => service.GetWeatherForecastsAsync(5); + + [HttpGet("{requestCount}", Name = "GetWeatherForecastWithRequest")] + public IEnumerable Get(int requestCount) + => service.GetWeatherForecastsAsync(requestCount); +} diff --git a/samples/SampleApp/SampleApp.Host/Interfaces/Services/IWeatherService.cs b/samples/SampleApp/SampleApp.Host/Interfaces/Services/IWeatherService.cs new file mode 100644 index 0000000..2801494 --- /dev/null +++ b/samples/SampleApp/SampleApp.Host/Interfaces/Services/IWeatherService.cs @@ -0,0 +1,5 @@ +namespace SampleApp.Host.Interfaces.Services; + +public interface IWeatherService { + IEnumerable GetWeatherForecastsAsync(int requestCount, CancellationToken cancellationToken = default); +} diff --git a/samples/SampleApp/SampleApp.Host/Interfaces/Services/IWeatherServiceTelemetry.cs b/samples/SampleApp/SampleApp.Host/Interfaces/Services/IWeatherServiceTelemetry.cs new file mode 100644 index 0000000..f2e4641 --- /dev/null +++ b/samples/SampleApp/SampleApp.Host/Interfaces/Services/IWeatherServiceTelemetry.cs @@ -0,0 +1,30 @@ +using System.Diagnostics; +using Purview.Telemetry; +using Purview.Telemetry.Activities; +using Purview.Telemetry.Logging; +using Purview.Telemetry.Metrics; + +namespace SampleApp.Host.Interfaces.Services; + +[ActivitySource] +[Logger] +[Meter] +public interface IWeatherServiceTelemetry { + [Activity(ActivityKind.Client)] + Activity? GettingWeatherForecastFromUpstreamService(string someRandomInfo, int requestedCount, [Baggage]int validatedRequestedCount); + + [Event] + void MinAndMaxReceived(Activity? activity, int minTempInC, int maxTempInC); + + [Log(LogLevel.Warning)] + void ThatsTooCold(int minTempInC); + + [Log] + void RequestedCountIsTooSmall(int requestCount, int validatedRequestedCount); + + [Counter(AutoIncrement = true)] + void WeatherForecastRequested(); + + [Counter(AutoIncrement = true)] + void ItsTooCold([Tag]int tooColdCount); +} diff --git a/samples/SampleApp/SampleApp.Host/Program.cs b/samples/SampleApp/SampleApp.Host/Program.cs new file mode 100644 index 0000000..11edf61 --- /dev/null +++ b/samples/SampleApp/SampleApp.Host/Program.cs @@ -0,0 +1,39 @@ +using SampleApp.Host.Interfaces.Services; +using SampleApp.Host.Services; + +namespace SampleApp.Host; + +public class Program { + public static void Main(string[] args) { + var builder = WebApplication.CreateBuilder(args); + builder.AddServiceDefaults(); + builder.Services.AddMetrics(); + + // Add services to the container. + builder.Services.AddIWeatherServiceTelemetry(); + builder.Services.AddTransient(); + + builder.Services.AddControllers(); + // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle + builder.Services.AddEndpointsApiExplorer(); + builder.Services.AddSwaggerGen(); + + var app = builder.Build(); + + app.MapDefaultEndpoints(); + + // Configure the HTTP request pipeline. + if (app.Environment.IsDevelopment()) { + app.UseSwagger(); + app.UseSwaggerUI(); + } + + app.UseHttpsRedirection(); + + app.UseAuthorization(); + + app.MapControllers(); + + app.Run(); + } +} diff --git a/samples/SampleApp/SampleApp.Host/Properties/AssemblyInfo.cs b/samples/SampleApp/SampleApp.Host/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..018403a --- /dev/null +++ b/samples/SampleApp/SampleApp.Host/Properties/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using Purview.Telemetry.Activities; + +[assembly: ActivitySourceGeneration("sample-weather-app")] diff --git a/samples/SampleApp/SampleApp.Host/Properties/launchSettings.json b/samples/SampleApp/SampleApp.Host/Properties/launchSettings.json new file mode 100644 index 0000000..e943679 --- /dev/null +++ b/samples/SampleApp/SampleApp.Host/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:58142", + "sslPort": 44302 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5275", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7015;http://localhost:5275", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/samples/SampleApp/SampleApp.Host/SampleApp.Host.csproj b/samples/SampleApp/SampleApp.Host/SampleApp.Host.csproj new file mode 100644 index 0000000..10d02a2 --- /dev/null +++ b/samples/SampleApp/SampleApp.Host/SampleApp.Host.csproj @@ -0,0 +1,19 @@ + + + + net8.0 + enable + enable + true + + + + + + + + + + + + diff --git a/samples/SampleApp/SampleApp.Host/SampleApp.Host.http b/samples/SampleApp/SampleApp.Host/SampleApp.Host.http new file mode 100644 index 0000000..5b96882 --- /dev/null +++ b/samples/SampleApp/SampleApp.Host/SampleApp.Host.http @@ -0,0 +1,6 @@ +@SampleApp.Host_HostAddress = http://localhost:5275 + +GET {{SampleApp.Host_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/samples/SampleApp/SampleApp.Host/Services/WeatherService.cs b/samples/SampleApp/SampleApp.Host/Services/WeatherService.cs new file mode 100644 index 0000000..0ade102 --- /dev/null +++ b/samples/SampleApp/SampleApp.Host/Services/WeatherService.cs @@ -0,0 +1,47 @@ +using SampleApp.Host.Interfaces.Services; + +namespace SampleApp.Host.Services; + +sealed class WeatherService(IWeatherServiceTelemetry telemetry) : IWeatherService { + const int _tooColdTempInC = -10; + + static readonly string[] _summaries = + [ + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + ]; + + public IEnumerable GetWeatherForecastsAsync(int requestCount, CancellationToken cancellationToken = default) { + var validatedRequestedCount = requestCount; + if (validatedRequestedCount < 5) { + validatedRequestedCount = 5; + + telemetry.RequestedCountIsTooSmall(requestCount, validatedRequestedCount); + } + + using var activity = telemetry.GettingWeatherForecastFromUpstreamService($"{Guid.NewGuid()}", requestCount, validatedRequestedCount); + + telemetry.WeatherForecastRequested(); + + // This would usually be async of course... + cancellationToken.ThrowIfCancellationRequested(); + + var results = Enumerable.Range(1, validatedRequestedCount).Select(index => new WeatherForecast { + Date = DateOnly.FromDateTime(DateTime.UtcNow.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = _summaries[Random.Shared.Next(_summaries.Length)] + }).ToArray(); + + var minTempInC = results.Min(m => m.TemperatureC); + telemetry.MinAndMaxReceived(activity, + minTempInC, + results.Max(wf => wf.TemperatureC) + ); + + if (minTempInC < _tooColdTempInC) { + telemetry.ThatsTooCold(minTempInC); + telemetry.ItsTooCold(results.Count(wf => wf.TemperatureC < _tooColdTempInC)); + } + + return results; + } +} diff --git a/samples/SampleApp/SampleApp.Host/WeatherForecast.cs b/samples/SampleApp/SampleApp.Host/WeatherForecast.cs new file mode 100644 index 0000000..598c543 --- /dev/null +++ b/samples/SampleApp/SampleApp.Host/WeatherForecast.cs @@ -0,0 +1,9 @@ +namespace SampleApp.Host; + +readonly public record struct WeatherForecast( + DateOnly Date, + int TemperatureC, + string? Summary) { + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); +} diff --git a/samples/SampleApp/SampleApp.Host/appsettings.Development.json b/samples/SampleApp/SampleApp.Host/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/samples/SampleApp/SampleApp.Host/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/samples/SampleApp/SampleApp.Host/appsettings.json b/samples/SampleApp/SampleApp.Host/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/samples/SampleApp/SampleApp.Host/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/SampleApp/SampleApp.ServiceDefaults/Extensions.cs b/samples/SampleApp/SampleApp.ServiceDefaults/Extensions.cs new file mode 100644 index 0000000..d70df36 --- /dev/null +++ b/samples/SampleApp/SampleApp.ServiceDefaults/Extensions.cs @@ -0,0 +1,112 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Diagnostics.HealthChecks; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Diagnostics.HealthChecks; +using Microsoft.Extensions.Logging; +using OpenTelemetry.Logs; +using OpenTelemetry.Metrics; +using OpenTelemetry.Trace; + +namespace Microsoft.Extensions.Hosting; + +public static class Extensions { + public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBuilder builder) { + builder.ConfigureOpenTelemetry(); + + builder.AddDefaultHealthChecks(); + + builder.Services.AddServiceDiscovery(); + + builder.Services.ConfigureHttpClientDefaults(http => { + // Turn on resilience by default + http.AddStandardResilienceHandler(); + + // Turn on service discovery by default + http.UseServiceDiscovery(); + }); + + return builder; + } + + public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicationBuilder builder) { + builder.Logging.AddOpenTelemetry(logging => { + logging.IncludeFormattedMessage = true; + logging.IncludeScopes = true; + }); + + builder.Services.AddOpenTelemetry() + .WithMetrics(metrics => { + metrics.AddAspNetCoreInstrumentation() + .AddHttpClientInstrumentation() + .AddProcessInstrumentation() + .AddRuntimeInstrumentation() + .AddMeter([ + "WeatherServiceTelemetry" + ]); + }) + .WithTracing(tracing => { + if (builder.Environment.IsDevelopment()) { + // We want to view all traces in development + tracing.SetSampler(new AlwaysOnSampler()); + } + + tracing.AddAspNetCoreInstrumentation() + .AddGrpcClientInstrumentation() + .AddHttpClientInstrumentation() + .AddSource([ + "sample-weather-app" + ]) + ; + }); + + builder.AddOpenTelemetryExporters(); + + return builder; + } + + private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostApplicationBuilder builder) { + var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]); + + if (useOtlpExporter) { + builder.Services.Configure(logging => logging.AddOtlpExporter()); + builder.Services.ConfigureOpenTelemetryMeterProvider(metrics => metrics.AddOtlpExporter()); + builder.Services.ConfigureOpenTelemetryTracerProvider(tracing => tracing.AddOtlpExporter()); + } + + // Uncomment the following lines to enable the Prometheus exporter (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package) + // builder.Services.AddOpenTelemetry() + // .WithMetrics(metrics => metrics.AddPrometheusExporter()); + + // Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package) + //if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"])) + //{ + // builder.Services.AddOpenTelemetry() + // .UseAzureMonitor(); + //} + + return builder; + } + + public static IHostApplicationBuilder AddDefaultHealthChecks(this IHostApplicationBuilder builder) { + builder.Services.AddHealthChecks() + // Add a default liveness check to ensure app is responsive + .AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]); + + return builder; + } + + public static WebApplication MapDefaultEndpoints(this WebApplication app) { + // Uncomment the following line to enable the Prometheus endpoint (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package) + // app.MapPrometheusScrapingEndpoint(); + + // All health checks must pass for app to be considered ready to accept traffic after starting + app.MapHealthChecks("/health"); + + // Only health checks tagged with the "live" tag must pass for app to be considered alive + app.MapHealthChecks("/alive", new HealthCheckOptions { + Predicate = r => r.Tags.Contains("live") + }); + + return app; + } +} diff --git a/samples/SampleApp/SampleApp.ServiceDefaults/SampleApp.ServiceDefaults.csproj b/samples/SampleApp/SampleApp.ServiceDefaults/SampleApp.ServiceDefaults.csproj new file mode 100644 index 0000000..69f196c --- /dev/null +++ b/samples/SampleApp/SampleApp.ServiceDefaults/SampleApp.ServiceDefaults.csproj @@ -0,0 +1,24 @@ + + + + net8.0 + enable + enable + true + + + + + + + + + + + + + + + + + diff --git a/samples/SampleApp/SampleApp.sln b/samples/SampleApp/SampleApp.sln new file mode 100644 index 0000000..e08af27 --- /dev/null +++ b/samples/SampleApp/SampleApp.sln @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.34707.107 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp.Host", "SampleApp.Host\SampleApp.Host.csproj", "{E3B94B39-B8DB-430C-9D66-D9331764056E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleApp.AppHost", "SampleApp.AppHost\SampleApp.AppHost.csproj", "{E4F0CA18-A3E6-4471-BB68-C1DC4FE71AE9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp.ServiceDefaults", "SampleApp.ServiceDefaults\SampleApp.ServiceDefaults.csproj", "{2B32200F-74F9-4C86-9BAC-9BE12A7752D5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E3B94B39-B8DB-430C-9D66-D9331764056E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E3B94B39-B8DB-430C-9D66-D9331764056E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E3B94B39-B8DB-430C-9D66-D9331764056E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E3B94B39-B8DB-430C-9D66-D9331764056E}.Release|Any CPU.Build.0 = Release|Any CPU + {E4F0CA18-A3E6-4471-BB68-C1DC4FE71AE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E4F0CA18-A3E6-4471-BB68-C1DC4FE71AE9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E4F0CA18-A3E6-4471-BB68-C1DC4FE71AE9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E4F0CA18-A3E6-4471-BB68-C1DC4FE71AE9}.Release|Any CPU.Build.0 = Release|Any CPU + {2B32200F-74F9-4C86-9BAC-9BE12A7752D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2B32200F-74F9-4C86-9BAC-9BE12A7752D5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2B32200F-74F9-4C86-9BAC-9BE12A7752D5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2B32200F-74F9-4C86-9BAC-9BE12A7752D5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8BB815FA-C86A-45B9-ABB7-228C5304C722} + EndGlobalSection +EndGlobal diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenAssemblyEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenAssemblyEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index d55ea82..e22d458 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenAssemblyEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenAssemblyEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -22,13 +22,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.Counter? _counterInstrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -78,7 +78,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicCountersWithAutoIncrement_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicCountersWithAutoIncrement_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index 1493e16..fcf2d6f 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicCountersWithAutoIncrement_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicCountersWithAutoIncrement_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -24,13 +24,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.Counter? _counter3Instrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -108,7 +108,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicCounters_GeneratesMetrics.DotNet7_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicCounters_GeneratesMetrics.DotNet7_0#Testing.TestMetricsCore.Metric.g.verified.cs index aaaf869..25c8ae6 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicCounters_GeneratesMetrics.DotNet7_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicCounters_GeneratesMetrics.DotNet7_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -28,13 +28,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.Counter? _counter7Instrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -105,7 +105,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); #endif diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicCounters_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicCounters_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index c8cf425..b5eb56d 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicCounters_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicCounters_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -28,13 +28,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.Counter? _counter7Instrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -168,7 +168,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicHistogram_GeneratesMetrics.DotNet7_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicHistogram_GeneratesMetrics.DotNet7_0#Testing.TestMetricsCore.Metric.g.verified.cs index f91fc90..50ed40b 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicHistogram_GeneratesMetrics.DotNet7_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicHistogram_GeneratesMetrics.DotNet7_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -23,13 +23,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.Histogram? _histogram1Instrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -75,7 +75,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); #endif diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicHistogram_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicHistogram_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index 6f835d4..466ec72 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicHistogram_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicHistogram_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -23,13 +23,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.Histogram? _histogram1Instrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -93,7 +93,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicObservableCounters_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicObservableCounters_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index da92522..78db0e2 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicObservableCounters_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicObservableCounters_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -24,13 +24,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.ObservableCounter? _observableCounter3Instrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -66,7 +66,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory #endif } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicObservableGauge_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicObservableGauge_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index 1fa10ad..92ba09a 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicObservableGauge_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicObservableGauge_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -24,13 +24,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.ObservableGauge? _observableGauge3Instrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -66,7 +66,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory #endif } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicObservableUpDown_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicObservableUpDown_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index edb5bf8..78cadc3 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicObservableUpDown_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicObservableUpDown_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -24,13 +24,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.ObservableUpDownCounter? _observableUpDown3Instrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -66,7 +66,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory #endif } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicUpDown_GeneratesMetrics.DotNet7_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicUpDown_GeneratesMetrics.DotNet7_0#Testing.TestMetricsCore.Metric.g.verified.cs index 31af04a..e6eee80 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicUpDown_GeneratesMetrics.DotNet7_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicUpDown_GeneratesMetrics.DotNet7_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -23,13 +23,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.UpDownCounter? _upDown2Instrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -75,7 +75,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); #endif diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicUpDown_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicUpDown_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index dab0700..6b81bb6 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicUpDown_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenBasicUpDown_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -23,13 +23,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.UpDownCounter? _upDown2Instrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -93,7 +93,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index d55ea82..e22d458 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenDIDisabledAtAssemblyAndInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -22,13 +22,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.Counter? _counterInstrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -78,7 +78,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenDIEnabledAtAssemblyAndInterfaceDisabledDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenDIEnabledAtAssemblyAndInterfaceDisabledDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index d55ea82..e22d458 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenDIEnabledAtAssemblyAndInterfaceDisabledDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenDIEnabledAtAssemblyAndInterfaceDisabledDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -22,13 +22,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.Counter? _counterInstrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -78,7 +78,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index d55ea82..e22d458 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenInterfaceEnableDI_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -22,13 +22,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.Counter? _counterInstrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -78,7 +78,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_1728b4e25d608bbb.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_1728b4e25d608bbb.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index 31fe025..5be098a 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_1728b4e25d608bbb.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_1728b4e25d608bbb.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -22,13 +22,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.ObservableGauge? _metricInstrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -64,7 +64,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory #endif } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_376f9653222cb1c7.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_376f9653222cb1c7.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index 987b4af..633df6b 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_376f9653222cb1c7.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_376f9653222cb1c7.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -22,13 +22,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.UpDownCounter? _metricInstrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -78,7 +78,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_41984246985a9105.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_41984246985a9105.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index b47dbcc..f57a577 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_41984246985a9105.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_41984246985a9105.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -22,13 +22,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.ObservableUpDownCounter? _metricInstrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -64,7 +64,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory #endif } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_5b7f36e655b24551.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_5b7f36e655b24551.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index 27e4576..674765f 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_5b7f36e655b24551.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_5b7f36e655b24551.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -22,13 +22,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.ObservableGauge? _metricInstrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -64,7 +64,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory #endif } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_64e6fdbd07b755c2.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_64e6fdbd07b755c2.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index 6680afe..922097d 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_64e6fdbd07b755c2.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_64e6fdbd07b755c2.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -22,13 +22,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.UpDownCounter? _metricInstrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -78,7 +78,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_8e053d60a620f445.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_8e053d60a620f445.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index 88045e6..20cc197 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_8e053d60a620f445.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_8e053d60a620f445.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -22,13 +22,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.ObservableCounter? _metricInstrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -64,7 +64,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory #endif } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_94506ee3e326406c.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_94506ee3e326406c.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index 321c1ac..58dc2bc 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_94506ee3e326406c.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_94506ee3e326406c.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -22,13 +22,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.ObservableUpDownCounter? _metricInstrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -64,7 +64,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory #endif } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_b148694d2a7ef9c9.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_b148694d2a7ef9c9.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index 6b5af27..1fbb6a0 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_b148694d2a7ef9c9.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_b148694d2a7ef9c9.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -22,13 +22,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.ObservableCounter? _metricInstrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -64,7 +64,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory #endif } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_d9579a1740cc550f.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_d9579a1740cc550f.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index 5bbb00c..304471f 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_d9579a1740cc550f.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_d9579a1740cc550f.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -22,13 +22,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.Counter? _metricInstrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -78,7 +78,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_e6f282f2934e384c.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_e6f282f2934e384c.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index b31a8ce..03a7460 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_e6f282f2934e384c.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenNameUnitsDescription_GeneratesMetrics_e6f282f2934e384c.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -22,13 +22,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.Counter? _metricInstrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -78,7 +78,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenObservablesReturnBoolAndThrowsOnAlreadyInitialized_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenObservablesReturnBoolAndThrowsOnAlreadyInitialized_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index af904b9..8fde576 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenObservablesReturnBoolAndThrowsOnAlreadyInitialized_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenObservablesReturnBoolAndThrowsOnAlreadyInitialized_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -24,13 +24,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.ObservableUpDownCounter? _upDownInstrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -66,7 +66,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory #endif } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenObservablesReturnBool_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenObservablesReturnBool_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs index 9fdc0ee..04e707c 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenObservablesReturnBool_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorMetricsTests.Generate_GivenObservablesReturnBool_GeneratesMetrics.DotNet8_0#Testing.TestMetricsCore.Metric.g.verified.cs @@ -24,13 +24,13 @@ sealed partial class TestMetricsCore : Testing.ITestMetrics System.Diagnostics.Metrics.ObservableUpDownCounter? _upDownInstrument = null; public TestMetricsCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -66,7 +66,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory #endif } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromREADMEMetricsSection_GeneratesTelemetry.DotNet8_0#MeterTelemetryCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromREADMEMetricsSection_GeneratesTelemetry.DotNet8_0#MeterTelemetryCore.Metric.g.verified.cs index 1b64ad1..f2cb30f 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromREADMEMetricsSection_GeneratesTelemetry.DotNet8_0#MeterTelemetryCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromREADMEMetricsSection_GeneratesTelemetry.DotNet8_0#MeterTelemetryCore.Metric.g.verified.cs @@ -26,13 +26,13 @@ sealed partial class MeterTelemetryCore : IMeterTelemetry System.Diagnostics.Metrics.UpDownCounter? _upDownCounterMeterInstrument = null; public MeterTelemetryCore( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -124,7 +124,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromREADMEMultiTargetingSection_GeneratesTelemetry.DotNet8_0#ServiceTelemetryCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromREADMEMultiTargetingSection_GeneratesTelemetry.DotNet8_0#ServiceTelemetryCore.Metric.g.verified.cs index e19d755..628739a 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromREADMEMultiTargetingSection_GeneratesTelemetry.DotNet8_0#ServiceTelemetryCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_FromREADMEMultiTargetingSection_GeneratesTelemetry.DotNet8_0#ServiceTelemetryCore.Metric.g.verified.cs @@ -20,14 +20,14 @@ sealed partial class ServiceTelemetryCore : IServiceTelemetry System.Diagnostics.Metrics.Counter? _anAutoIncrementInstrument = null; public ServiceTelemetryCore(Microsoft.Extensions.Logging.ILogger logger -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER , System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { _logger = logger; InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -77,7 +77,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenBasicTelemetryGen_GeneratesTelemetry.DotNet7_0#Testing.TestTelemetryCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenBasicTelemetryGen_GeneratesTelemetry.DotNet7_0#Testing.TestTelemetryCore.Metric.g.verified.cs index bdbe265..7764348 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenBasicTelemetryGen_GeneratesTelemetry.DotNet7_0#Testing.TestTelemetryCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenBasicTelemetryGen_GeneratesTelemetry.DotNet7_0#Testing.TestTelemetryCore.Metric.g.verified.cs @@ -22,14 +22,14 @@ sealed partial class TestTelemetryCore : Testing.ITestTelemetry System.Diagnostics.Metrics.Counter? _counterInstrument = null; public TestTelemetryCore(Microsoft.Extensions.Logging.ILogger logger -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER , System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { _logger = logger; InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -79,7 +79,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenBasicTelemetryGen_GeneratesTelemetry.DotNet8_0#Testing.TestTelemetryCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenBasicTelemetryGen_GeneratesTelemetry.DotNet8_0#Testing.TestTelemetryCore.Metric.g.verified.cs index bdbe265..7764348 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenBasicTelemetryGen_GeneratesTelemetry.DotNet8_0#Testing.TestTelemetryCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenBasicTelemetryGen_GeneratesTelemetry.DotNet8_0#Testing.TestTelemetryCore.Metric.g.verified.cs @@ -22,14 +22,14 @@ sealed partial class TestTelemetryCore : Testing.ITestTelemetry System.Diagnostics.Metrics.Counter? _counterInstrument = null; public TestTelemetryCore(Microsoft.Extensions.Logging.ILogger logger -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER , System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { _logger = logger; InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -79,7 +79,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenDuplicateTelemetryGen_GeneratesDiagnostics.DotNet8_0#Testing.TestTelemetryCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenDuplicateTelemetryGen_GeneratesDiagnostics.DotNet8_0#Testing.TestTelemetryCore.Metric.g.verified.cs index 7f37ffe..d084f3c 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenDuplicateTelemetryGen_GeneratesDiagnostics.DotNet8_0#Testing.TestTelemetryCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenDuplicateTelemetryGen_GeneratesDiagnostics.DotNet8_0#Testing.TestTelemetryCore.Metric.g.verified.cs @@ -21,14 +21,14 @@ sealed partial class TestTelemetryCore : Testing.ITestTelemetry public TestTelemetryCore(Microsoft.Extensions.Logging.ILogger logger -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER , System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { _logger = logger; InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -64,7 +64,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory #endif } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenNoNamespace_GeneratesTelemetry.DotNet8_0#TestTelemetryCore.Metric.g.verified.cs b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenNoNamespace_GeneratesTelemetry.DotNet8_0#TestTelemetryCore.Metric.g.verified.cs index c496b40..1a97bb0 100644 --- a/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenNoNamespace_GeneratesTelemetry.DotNet8_0#TestTelemetryCore.Metric.g.verified.cs +++ b/src/Purview.Telemetry.SourceGenerator.IntegrationTests/Snapshots/TelemetrySourceGeneratorTests.Generate_GivenNoNamespace_GeneratesTelemetry.DotNet8_0#TestTelemetryCore.Metric.g.verified.cs @@ -20,14 +20,14 @@ sealed partial class TestTelemetryCore : ITestTelemetry System.Diagnostics.Metrics.Counter? _counterInstrument = null; public TestTelemetryCore(Microsoft.Extensions.Logging.ILogger logger -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER , System.Diagnostics.Metrics.IMeterFactory meterFactory #endif ) { _logger = logger; InitializeMeters( -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER meterFactory #endif ); @@ -77,7 +77,7 @@ System.Diagnostics.Metrics.IMeterFactory meterFactory ); } -#if NET8_OR_GREATER +#if NET8_0_OR_GREATER partial void PopulateMeterTags(System.Collections.Generic.Dictionary meterTags); diff --git a/src/Purview.Telemetry.SourceGenerator.sln b/src/Purview.Telemetry.SourceGenerator.sln index b09222b..17fd48d 100644 --- a/src/Purview.Telemetry.SourceGenerator.sln +++ b/src/Purview.Telemetry.SourceGenerator.sln @@ -22,8 +22,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".build-system", ".build-sys EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Purview.Telemetry.SourceGenerator.IntegrationTests", "Purview.Telemetry.SourceGenerator.IntegrationTests\Purview.Telemetry.SourceGenerator.IntegrationTests.csproj", "{3572DA61-9CAA-4936-917B-B032E0863AD0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TelemetryRoslynTestHarness", "TelemetryRoslynTestHarness\TelemetryRoslynTestHarness.csproj", "{A8B4B72D-D23A-4A2C-B26C-477D62342737}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{6590A7CF-EA90-49DD-AA46-F46634ED2391}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{7DCDD99F-4EC4-4920-8A1E-7C32023E8C7B}" @@ -45,10 +43,6 @@ Global {3572DA61-9CAA-4936-917B-B032E0863AD0}.Debug|Any CPU.Build.0 = Debug|Any CPU {3572DA61-9CAA-4936-917B-B032E0863AD0}.Release|Any CPU.ActiveCfg = Release|Any CPU {3572DA61-9CAA-4936-917B-B032E0863AD0}.Release|Any CPU.Build.0 = Release|Any CPU - {A8B4B72D-D23A-4A2C-B26C-477D62342737}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A8B4B72D-D23A-4A2C-B26C-477D62342737}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A8B4B72D-D23A-4A2C-B26C-477D62342737}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A8B4B72D-D23A-4A2C-B26C-477D62342737}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Purview.Telemetry.SourceGenerator/Constants.Metrics.cs b/src/Purview.Telemetry.SourceGenerator/Constants.Metrics.cs index b3736a1..f0c201a 100644 --- a/src/Purview.Telemetry.SourceGenerator/Constants.Metrics.cs +++ b/src/Purview.Telemetry.SourceGenerator/Constants.Metrics.cs @@ -9,6 +9,10 @@ static public class Metrics { public const string MeterInitializationMethod = "InitializeMeters"; public const string MeterFactoryParameterName = "meterFactory"; + public const string InstrumentSeparatorDefault = "."; + public const bool LowercaseInstrumentNameDefault = true; + public const bool LowercaseTagKeysDefault = true; + readonly static public TemplateInfo MeterGenerationAttribute = TemplateInfo.Create("Purview.Telemetry.Metrics.MeterGenerationAttribute"); readonly static public TemplateInfo MeterAttribute = TemplateInfo.Create("Purview.Telemetry.Metrics.MeterAttribute"); diff --git a/src/Purview.Telemetry.SourceGenerator/Emitters/ConstructorEmitter.cs b/src/Purview.Telemetry.SourceGenerator/Emitters/ConstructorEmitter.cs index 1b54348..707986e 100644 --- a/src/Purview.Telemetry.SourceGenerator/Emitters/ConstructorEmitter.cs +++ b/src/Purview.Telemetry.SourceGenerator/Emitters/ConstructorEmitter.cs @@ -65,7 +65,7 @@ static void EmitParameters(GenerationType generationType, string? loggerFullyQua if (generationType.HasFlag(GenerationType.Metrics)) { builder .AppendLine() - .AppendLine("#if NET8_OR_GREATER") + .AppendLine("#if NET8_0_OR_GREATER") ; if (generationType.HasFlag(GenerationType.Logging)) { @@ -104,7 +104,7 @@ static void EmitBody(GenerationType generationType, int indent, StringBuilder bu ; builder - .AppendLine("#if NET8_OR_GREATER") + .AppendLine("#if NET8_0_OR_GREATER") .Append(indent + 2, Constants.Metrics.MeterFactoryParameterName) .AppendLine("#endif") ; diff --git a/src/Purview.Telemetry.SourceGenerator/Emitters/MeterTargetClassEmitter.Methods.cs b/src/Purview.Telemetry.SourceGenerator/Emitters/MeterTargetClassEmitter.Methods.cs index 09e7fd2..be29b5a 100644 --- a/src/Purview.Telemetry.SourceGenerator/Emitters/MeterTargetClassEmitter.Methods.cs +++ b/src/Purview.Telemetry.SourceGenerator/Emitters/MeterTargetClassEmitter.Methods.cs @@ -32,7 +32,7 @@ static void EmitPartialMethods(StringBuilder builder, int indent, MeterTarget ta builder .AppendLine() - .AppendLine("#if NET8_OR_GREATER") + .AppendLine("#if NET8_0_OR_GREATER") .AppendLine() ; diff --git a/src/Purview.Telemetry.SourceGenerator/Helpers/PipelineHelpers.Metrics.cs b/src/Purview.Telemetry.SourceGenerator/Helpers/PipelineHelpers.Metrics.cs index 6af5b66..e06a015 100644 --- a/src/Purview.Telemetry.SourceGenerator/Helpers/PipelineHelpers.Metrics.cs +++ b/src/Purview.Telemetry.SourceGenerator/Helpers/PipelineHelpers.Metrics.cs @@ -345,20 +345,18 @@ static ImmutableArray GetInstrumentParameters( token.ThrowIfCancellationRequested(); string? prefix = null; - var separator = meterGenerationAttribute?.InstrumentSeparator.IsSet == true - ? meterGenerationAttribute.InstrumentSeparator.Value - : "."; - - if (meterGenerationAttribute?.InstrumentPrefix.IsSet == true) { - prefix = meterGenerationAttribute.InstrumentPrefix.Value; - if (meterGenerationAttribute?.InstrumentSeparator.IsSet == true) { - prefix += separator; - } + var separator = meterGenerationAttribute? + .InstrumentSeparator.Or(Constants.Metrics.InstrumentSeparatorDefault); + + if (meterGenerationAttribute?.InstrumentPrefix.IsSet == true + && !string.IsNullOrWhiteSpace(meterGenerationAttribute?.InstrumentPrefix.Value)) { + prefix = meterGenerationAttribute!.InstrumentPrefix.Value! + separator; } - if (meterAttribute.InstrumentPrefix.IsSet) { - if (meterAttribute.IncludeAssemblyInstrumentPrefix.Value == true) { - prefix += meterAttribute.InstrumentPrefix.Value + separator; + if (meterAttribute.InstrumentPrefix.IsSet && !string.IsNullOrWhiteSpace(meterAttribute.InstrumentPrefix.Value)) { + if (meterAttribute.IncludeAssemblyInstrumentPrefix.Value == true + && !string.IsNullOrWhiteSpace(meterGenerationAttribute?.InstrumentPrefix.Value)) { + prefix += meterGenerationAttribute!.InstrumentPrefix.Value + separator; } else { prefix = meterAttribute.InstrumentPrefix.Value + separator; diff --git a/src/Purview.Telemetry.SourceGenerator/Helpers/SharedHelpers.Metrics.cs b/src/Purview.Telemetry.SourceGenerator/Helpers/SharedHelpers.Metrics.cs index 2bfc089..f874cb3 100644 --- a/src/Purview.Telemetry.SourceGenerator/Helpers/SharedHelpers.Metrics.cs +++ b/src/Purview.Telemetry.SourceGenerator/Helpers/SharedHelpers.Metrics.cs @@ -51,8 +51,8 @@ partial class SharedHelpers { Name: nameValue ?? new(), InstrumentPrefix: instrumentPrefix ?? new(), IncludeAssemblyInstrumentPrefix: includeAssemblyInstrumentPrefix ?? new(true), - LowercaseInstrumentName: lowercaseInstrumentName ?? new(true), - LowercaseTagKeys: lowercaseTagKeys ?? new(true) + LowercaseInstrumentName: lowercaseInstrumentName ?? new(Constants.Metrics.LowercaseInstrumentNameDefault), + LowercaseTagKeys: lowercaseTagKeys ?? new(Constants.Metrics.LowercaseTagKeysDefault) ); } @@ -88,9 +88,9 @@ partial class SharedHelpers { return new( InstrumentPrefix: instrumentPrefix ?? new(), - InstrumentSeparator: instrumentSeparator ?? new(), - LowercaseInstrumentName: lowercaseInstrumentName ?? new(), - LowercaseTagKeys: lowercaseTagKeys ?? new() + InstrumentSeparator: instrumentSeparator ?? new(Constants.Metrics.InstrumentSeparatorDefault), + LowercaseInstrumentName: lowercaseInstrumentName ?? new(Constants.Metrics.LowercaseInstrumentNameDefault), + LowercaseTagKeys: lowercaseTagKeys ?? new(Constants.Metrics.LowercaseTagKeysDefault) ); } diff --git a/src/Purview.Telemetry.SourceGenerator/Records/GenericRecords.cs b/src/Purview.Telemetry.SourceGenerator/Records/GenericRecords.cs index fb94c69..36d80d1 100644 --- a/src/Purview.Telemetry.SourceGenerator/Records/GenericRecords.cs +++ b/src/Purview.Telemetry.SourceGenerator/Records/GenericRecords.cs @@ -54,9 +54,9 @@ public AttributeStringValue() { IsSet = false; } - public string? Or(string value) { - if (IsSet) { - return Value; + public string Or(string value) { + if (IsSet && !string.IsNullOrWhiteSpace(Value)) { + return Value!; } return value; diff --git a/weatherforecast b/weatherforecast new file mode 100644 index 0000000..fa3ee93 --- /dev/null +++ b/weatherforecast @@ -0,0 +1 @@ +[{"date":"2024-04-07","temperatureC":-9,"summary":"Chilly","temperatureF":16},{"date":"2024-04-08","temperatureC":4,"summary":"Warm","temperatureF":39},{"date":"2024-04-09","temperatureC":31,"summary":"Freezing","temperatureF":87},{"date":"2024-04-10","temperatureC":54,"summary":"Warm","temperatureF":129},{"date":"2024-04-11","temperatureC":33,"summary":"Mild","temperatureF":91}] \ No newline at end of file