From 0703a0df6e540d99c18135130beea3fcf9a26a48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Rubio?= Date: Wed, 6 Nov 2024 17:14:42 +0100 Subject: [PATCH] Cleanup names. --- .../Endpoints/{GetWeatherForecast.cs => Get.cs} | 12 ++++++------ ...{WeatherForecastExtensions.cs => Extensions.cs} | 8 ++++---- .../{WeatherForecastTelemetry.cs => Telemetry.cs} | 14 +++++++------- 3 files changed, 17 insertions(+), 17 deletions(-) rename AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Endpoints/{GetWeatherForecast.cs => Get.cs} (77%) rename AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/{WeatherForecastExtensions.cs => Extensions.cs} (61%) rename AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Services/{WeatherForecastTelemetry.cs => Telemetry.cs} (56%) diff --git a/AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Endpoints/GetWeatherForecast.cs b/AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Endpoints/Get.cs similarity index 77% rename from AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Endpoints/GetWeatherForecast.cs rename to AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Endpoints/Get.cs index 30323f9..bf7ff43 100644 --- a/AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Endpoints/GetWeatherForecast.cs +++ b/AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Endpoints/Get.cs @@ -1,15 +1,15 @@ using AspNetCore.Examples.OpenTelemetry.Api.WeatherForecast.Services; -using System.Diagnostics; +//using System.Diagnostics; namespace AspNetCore.Examples.OpenTelemetry.Api.WeatherForecast.Endpoints; -internal static class GetWeatherForecast +internal static class Get { - public static IEndpointRouteBuilder MapGetWeatherForecast(this IEndpointRouteBuilder endpoints) + public static IEndpointRouteBuilder MapGet(this IEndpointRouteBuilder endpoints) { - endpoints.MapGet("/weather-forecast", (IWeatherForecastTelemetry telemetry) => + endpoints.MapGet("/weather-forecast", (ITelemetry telemetry) => { - using var activity = telemetry.ActivitySource.StartActivity(name: "weather_forecast.request", kind: ActivityKind.Internal); + using var activity = telemetry.ActivitySource.StartActivity(name: "weather_forecast.request", kind: System.Diagnostics.ActivityKind.Internal); return Enumerable.Range(1, 5).Select(index => { @@ -24,7 +24,7 @@ public static IEndpointRouteBuilder MapGetWeatherForecast(this IEndpointRouteBui item.TemperatureC, item.TemperatureF ); - telemetry.TemperatureC.Record(item.TemperatureC, new TagList + telemetry.TemperatureC.Record(item.TemperatureC, new System.Diagnostics.TagList { { "Date", item.Date.ToString("yyyy-MM-dd") }, { "Summary", item.Summary } diff --git a/AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/WeatherForecastExtensions.cs b/AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Extensions.cs similarity index 61% rename from AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/WeatherForecastExtensions.cs rename to AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Extensions.cs index 9d99e83..3614fb5 100644 --- a/AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/WeatherForecastExtensions.cs +++ b/AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Extensions.cs @@ -3,17 +3,17 @@ namespace AspNetCore.Examples.OpenTelemetry.Api.WeatherForecast; -internal static class WeatherForecastExtensions +internal static class Extensions { public static IServiceCollection AddWeatherForecast(this IServiceCollection services) { - services.AddWeatherForecastTelemetry(); + services.AddTelemetry(); return services; } - public static IEndpointRouteBuilder MapWeatherForecast(this IEndpointRouteBuilder endpoints) + public static IEndpointRouteBuilder MapWeatherForecastEndpoints(this IEndpointRouteBuilder endpoints) { - endpoints.MapGetWeatherForecast(); + endpoints.MapGet(); return endpoints; } } diff --git a/AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Services/WeatherForecastTelemetry.cs b/AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Services/Telemetry.cs similarity index 56% rename from AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Services/WeatherForecastTelemetry.cs rename to AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Services/Telemetry.cs index e426377..436faa8 100644 --- a/AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Services/WeatherForecastTelemetry.cs +++ b/AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Services/Telemetry.cs @@ -5,14 +5,14 @@ namespace AspNetCore.Examples.OpenTelemetry.Api.WeatherForecast.Services; -internal interface IWeatherForecastTelemetry : ITelemetry +internal interface ITelemetry : ITelemetry { Histogram TemperatureC { get; } } -internal class WeatherForecastTelemetry : Telemetry, IWeatherForecastTelemetry +internal class Telemetry : Telemetry, ITelemetry { - public WeatherForecastTelemetry(ILoggerFactory loggerFactory, IMeterFactory meterFactory) + public Telemetry(ILoggerFactory loggerFactory, IMeterFactory meterFactory) : base(loggerFactory, meterFactory) { TemperatureC = Meter.CreateHistogram("weather_forecast.temperature", unit: "ºC"); @@ -23,11 +23,11 @@ public WeatherForecastTelemetry(ILoggerFactory loggerFactory, IMeterFactory mete internal static class WeatherForecastTelemetryExtensions { - public static IServiceCollection AddWeatherForecastTelemetry(this IServiceCollection services) + public static IServiceCollection AddTelemetry(this IServiceCollection services) { return services - .AddSingleton() - .ConfigureOpenTelemetryTracerProvider(t => t.AddSource(WeatherForecastTelemetry.Name)) - .ConfigureOpenTelemetryMeterProvider(m => m.AddMeter(WeatherForecastTelemetry.Name)); + .AddSingleton() + .ConfigureOpenTelemetryTracerProvider(t => t.AddSource(Telemetry.Name)) + .ConfigureOpenTelemetryMeterProvider(m => m.AddMeter(Telemetry.Name)); } }