Skip to content

Commit

Permalink
feat: adding more instruments
Browse files Browse the repository at this point in the history
  • Loading branch information
hez2010 committed Apr 8, 2024
1 parent f06a090 commit 91691e0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
<PackageVersion Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.8.0-rc.1" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.8.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.EntityFrameworkCore" Version="1.0.0-beta.11" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.8.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Process" Version="0.5.0-beta.5" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.8.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.StackExchangeRedis" Version="1.0.0-rc9.14" />
<PackageVersion Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageVersion Include="Serilog.Expressions" Version="4.0.0" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="8.0.0" />
Expand All @@ -45,9 +49,9 @@
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="8.0.3" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="xunit" Version="2.7.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.7"/>
<PackageVersion Include="xunit.runner.console" Version="2.7.0"/>
<PackageVersion Include="coverlet.collector" Version="6.0.2"/>
<PackageVersion Include="coverlet.msbuild" Version="6.0.2"/>
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.7" />
<PackageVersion Include="xunit.runner.console" Version="2.7.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.2" />
</ItemGroup>
</Project>
15 changes: 14 additions & 1 deletion src/GZCTF/Extensions/TelemetryExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,29 @@ public static void AddTelemetry(this IServiceCollection services, TelemetryConfi
{
metrics.AddAspNetCoreInstrumentation();
metrics.AddHttpClientInstrumentation();
metrics.AddRuntimeInstrumentation();
metrics.AddProcessInstrumentation();

if (config.Prometheus.Enable)
{
metrics.AddPrometheusExporter();
metrics.AddPrometheusExporter(options =>
{
options.DisableTotalNameSuffixForCounters = true;
});
}

if (config.Console.Enable)
{
metrics.AddConsoleExporter();
}
});

otel.WithTracing(tracing =>
{
tracing.AddAspNetCoreInstrumentation();
tracing.AddHttpClientInstrumentation();
tracing.AddEntityFrameworkCoreInstrumentation();
tracing.AddRedisInstrumentation();
tracing.AddNpgsql();
if (config.Console.Enable)
{
Expand Down
6 changes: 5 additions & 1 deletion src/GZCTF/GZCTF.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
Expand Down Expand Up @@ -52,7 +52,11 @@
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
<PackageReference Include="OpenTelemetry.Instrumentation.EntityFrameworkCore" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" />
<PackageReference Include="OpenTelemetry.Instrumentation.Process" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" />
<PackageReference Include="OpenTelemetry.Instrumentation.StackExchangeRedis" />
<PackageReference Include="Serilog.AspNetCore" />
<PackageReference Include="Serilog.Expressions" />
<PackageReference Include="Serilog.Extensions.Logging" />
Expand Down

0 comments on commit 91691e0

Please sign in to comment.