Skip to content

Commit

Permalink
Cleanup names.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarciarubio committed Nov 6, 2024
1 parent 5e0054d commit 0703a0d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -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 =>
{
Expand All @@ -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 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

namespace AspNetCore.Examples.OpenTelemetry.Api.WeatherForecast.Services;

internal interface IWeatherForecastTelemetry : ITelemetry<WeatherForecast>
internal interface ITelemetry : ITelemetry<WeatherForecast>
{
Histogram<int> TemperatureC { get; }
}

internal class WeatherForecastTelemetry : Telemetry<WeatherForecast>, IWeatherForecastTelemetry
internal class Telemetry : Telemetry<WeatherForecast>, ITelemetry
{
public WeatherForecastTelemetry(ILoggerFactory loggerFactory, IMeterFactory meterFactory)
public Telemetry(ILoggerFactory loggerFactory, IMeterFactory meterFactory)
: base(loggerFactory, meterFactory)
{
TemperatureC = Meter.CreateHistogram<int>("weather_forecast.temperature", unit: "ºC");
Expand All @@ -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<IWeatherForecastTelemetry, WeatherForecastTelemetry>()
.ConfigureOpenTelemetryTracerProvider(t => t.AddSource(WeatherForecastTelemetry.Name))
.ConfigureOpenTelemetryMeterProvider(m => m.AddMeter(WeatherForecastTelemetry.Name));
.AddSingleton<ITelemetry, Telemetry>()
.ConfigureOpenTelemetryTracerProvider(t => t.AddSource(Telemetry.Name))
.ConfigureOpenTelemetryMeterProvider(m => m.AddMeter(Telemetry.Name));
}
}

0 comments on commit 0703a0d

Please sign in to comment.