Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Commit

Permalink
Update otel
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyzimarev committed Mar 16, 2023
1 parent 496bc87 commit 5f5cdb0
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 57 deletions.
6 changes: 3 additions & 3 deletions Bookings.Payments/Bookings.Payments.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<PackageReference Include="Eventuous.Projections.MongoDB" Version="$(EventuousVersion)" />
<PackageReference Include="MongoDB.Driver.Core.Extensions.OpenTelemetry" Version="1.0.0" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.4.0-alpha.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="1.3.1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.3.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9.6" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.0.0-rc9.6" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9.14" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.0.0-rc9.14" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Bookings.Payments/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
builder.Services.AddSwaggerGen();

// OpenTelemetry instrumentation must be added before adding Eventuous services
builder.Services.AddOpenTelemetry();
builder.Services.AddTelemetry();

builder.Services.AddServices(builder.Configuration);
builder.Host.UseSerilog();
Expand Down
36 changes: 19 additions & 17 deletions Bookings.Payments/Registrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,25 @@ public static void AddServices(this IServiceCollection services, IConfiguration
);
}

public static void AddOpenTelemetry(this IServiceCollection services) {
services.AddOpenTelemetryMetrics(
builder => builder
.AddAspNetCoreInstrumentation()
.AddEventuous()
.AddEventuousSubscriptions()
.AddPrometheusExporter()
);
public static void AddTelemetry(this IServiceCollection services) {
services.AddOpenTelemetry()
.WithMetrics(
builder => builder
.AddAspNetCoreInstrumentation()
.AddEventuous()
.AddEventuousSubscriptions()
.AddPrometheusExporter()
);

services.AddOpenTelemetryTracing(
builder => builder
.AddAspNetCoreInstrumentation()
.AddGrpcClientInstrumentation()
.AddEventuousTracing()
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("payments"))
.SetSampler(new AlwaysOnSampler())
.AddZipkinExporter()
);
services.AddOpenTelemetry()
.WithTracing(
builder => builder
.AddAspNetCoreInstrumentation()
.AddGrpcClientInstrumentation()
.AddEventuousTracing()
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("payments"))
.SetSampler(new AlwaysOnSampler())
.AddZipkinExporter()
);
}
}
14 changes: 7 additions & 7 deletions Bookings/Bookings.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
<PackageReference Include="MongoDb.Bson.NodaTime" Version="3.0.0" />
<PackageReference Include="MongoDB.Driver.Core.Extensions.OpenTelemetry" Version="1.0.0" />
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.0.0" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.4.0-alpha.2" />
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="1.3.1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.3.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9.6" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.0.0-rc9.6" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.4.0-rc.4" />
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="1.4.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.4.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9.14" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.0.0-rc9.14" />
<PackageReference Include="Serilog.AspNetCore" Version="6.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.1.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.2.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Bookings.Domain\Bookings.Domain.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion Bookings/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
.AddJsonOptions(cfg => cfg.JsonSerializerOptions.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb));
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddOpenTelemetry();
builder.Services.AddTelemetry();
builder.Services.AddEventuous(builder.Configuration);
builder.Services.AddEventuousSpyglass();

Expand Down
56 changes: 29 additions & 27 deletions Bookings/Registrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,36 +59,38 @@ public static void AddEventuous(this IServiceCollection services, IConfiguration
);
}

public static void AddOpenTelemetry(this IServiceCollection services) {
public static void AddTelemetry(this IServiceCollection services) {
var otelEnabled = Environment.GetEnvironmentVariable("OTEL_EXPORTER_OTLP_ENDPOINT") != null;

services.AddOpenTelemetryMetrics(
builder => {
builder
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("bookings"))
.AddAspNetCoreInstrumentation()
.AddEventuous()
.AddEventuousSubscriptions()
.AddPrometheusExporter();
if (otelEnabled) builder.AddOtlpExporter();
}
);
services.AddOpenTelemetry()
.WithMetrics(
builder => {
builder
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("bookings"))
.AddAspNetCoreInstrumentation()
.AddEventuous()
.AddEventuousSubscriptions()
.AddPrometheusExporter();
if (otelEnabled) builder.AddOtlpExporter();
}
);

services.AddOpenTelemetryTracing(
builder => {
builder
.AddAspNetCoreInstrumentation()
.AddGrpcClientInstrumentation()
.AddEventuousTracing()
.AddMongoDBInstrumentation()
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("bookings"))
.SetSampler(new AlwaysOnSampler());
services.AddOpenTelemetry()
.WithTracing(
builder => {
builder
.AddAspNetCoreInstrumentation()
.AddGrpcClientInstrumentation()
.AddEventuousTracing()
.AddMongoDBInstrumentation()
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("bookings"))
.SetSampler(new AlwaysOnSampler());

if (otelEnabled)
builder.AddOtlpExporter();
else
builder.AddZipkinExporter();
}
);
if (otelEnabled)
builder.AddOtlpExporter();
else
builder.AddZipkinExporter();
}
);
}
}
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EventuousVersion>0.13.4-alpha.0.1</EventuousVersion>
<EventuousVersion>0.14.1-alpha.0.7</EventuousVersion>
</PropertyGroup>
</Project>

0 comments on commit 5f5cdb0

Please sign in to comment.