-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor usage of telemetry classes.
- Loading branch information
1 parent
fb1a345
commit d0028d4
Showing
12 changed files
with
114 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 12 additions & 17 deletions
29
...therForecast/WeatherForecastExtensions.cs → ...etry.Api/WeatherForecast/Endpoints/Get.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Extensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using AspNetCore.Examples.OpenTelemetry.Api.WeatherForecast.Endpoints; | ||
using AspNetCore.Examples.OpenTelemetry.Api.WeatherForecast.Services; | ||
|
||
namespace AspNetCore.Examples.OpenTelemetry.Api.WeatherForecast; | ||
|
||
internal static class Extensions | ||
{ | ||
public static IServiceCollection AddWeatherForecast(this IServiceCollection services) | ||
{ | ||
services.AddTelemetry(); | ||
return services; | ||
} | ||
|
||
public static IEndpointRouteBuilder MapWeatherForecast(this IEndpointRouteBuilder endpoints) | ||
{ | ||
endpoints.MapGet(); | ||
return endpoints; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/Services/Telemetry.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Diagnostics; | ||
using System.Diagnostics.Metrics; | ||
|
||
namespace AspNetCore.Examples.OpenTelemetry.Api.WeatherForecast.Services; | ||
|
||
internal interface ITelemetry : ITelemetry<WeatherForecast> | ||
{ | ||
Histogram<int> TemperatureC { get; } | ||
} | ||
|
||
internal class Telemetry : Telemetry<WeatherForecast>, ITelemetry | ||
{ | ||
public Telemetry(ILoggerFactory loggerFactory, IMeterFactory meterFactory) | ||
: base(loggerFactory, meterFactory) | ||
{ | ||
TemperatureC = Meter.CreateHistogram<int>("temperature", unit: "ºC"); | ||
} | ||
|
||
public Histogram<int> TemperatureC { get; } | ||
} | ||
|
||
internal static class TelemetryExtensions | ||
{ | ||
public static IServiceCollection AddTelemetry(this IServiceCollection services) | ||
{ | ||
services.AddSingleton<ITelemetry, Telemetry>(); | ||
services.AddOpenTelemetry() | ||
.WithTracing(t => t.AddSource(Telemetry.CategoryName)) | ||
.WithMetrics(t => t.AddMeter(Telemetry.CategoryName)); | ||
return services; | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
AspNetCore.Examples.OpenTelemetry.Api/WeatherForecast/WeatherForecastTelemetry.cs
This file was deleted.
Oops, something went wrong.
9 changes: 5 additions & 4 deletions
9
...ore.Examples.OpenTelemetry.AspireHost/AspNetCore.Examples.OpenTelemetry.AspireHost.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 0 additions & 79 deletions
79
AspNetCore.Examples.OpenTelemetry.TelemetryExtensions/Extensions.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"sdk": { | ||
"version": "9.0.100-rc.2.24474.11" | ||
} | ||
} |