Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid calling obsolete methods #746

Merged
merged 3 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions src/cartservice/src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
if (string.IsNullOrEmpty(redisAddress))
{
Console.WriteLine("REDIS_ADDR environment variable is required.");
System.Environment.Exit(1);
Environment.Exit(1);
}
cartStore = new RedisCartStore(redisAddress);

Expand All @@ -42,29 +42,29 @@

builder.Services.AddSingleton<ICartStore>(cartStore);

builder.Services.AddOpenTelemetryTracing((builder) => builder
.ConfigureResource(r => r
.AddTelemetrySdk()
.AddEnvironmentVariableDetector()
.AddDetector(new DockerResourceDetector())
)
.AddRedisInstrumentation(
cartStore.GetConnection(),
options => options.SetVerboseDatabaseStatements = true)
.AddAspNetCoreInstrumentation()
.AddGrpcClientInstrumentation()
.AddHttpClientInstrumentation()
.AddOtlpExporter());
// see https://opentelemetry.io/docs/instrumentation/net/getting-started/

builder.Services.AddOpenTelemetryMetrics(builder => builder
.ConfigureResource(r => r
.AddTelemetrySdk()
.AddEnvironmentVariableDetector()
.AddDetector(new DockerResourceDetector())
)
.AddRuntimeInstrumentation()
.AddAspNetCoreInstrumentation()
.AddOtlpExporter());
var appResourceBuilder = ResourceBuilder
.CreateDefault()
.AddTelemetrySdk()
.AddEnvironmentVariableDetector()
.AddDetector(new DockerResourceDetector());

builder.Services.AddOpenTelemetry()
sungam3r marked this conversation as resolved.
Show resolved Hide resolved
.WithTracing(builder => builder
.SetResourceBuilder(appResourceBuilder)
.AddRedisInstrumentation(
cartStore.GetConnection(),
options => options.SetVerboseDatabaseStatements = true)
.AddAspNetCoreInstrumentation()
.AddGrpcClientInstrumentation()
.AddHttpClientInstrumentation()
.AddOtlpExporter())
.WithMetrics(builder => builder
.SetResourceBuilder(appResourceBuilder)
.AddRuntimeInstrumentation()
.AddAspNetCoreInstrumentation()
.AddOtlpExporter());

builder.Services.AddGrpc();
builder.Services.AddGrpcHealthChecks()
Expand All @@ -73,9 +73,9 @@
var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
{
app.UseDeveloperExceptionPage();
}

app.UseRouting();

Expand Down
22 changes: 11 additions & 11 deletions src/cartservice/src/cartservice.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.44.0" />
<PackageReference Include="Grpc.AspNetCore.HealthChecks" Version="2.46.0" />
<PackageReference Include="OpenTelemetry.Extensions.Docker" Version="1.0.0-beta.1" />
<PackageReference Include="StackExchange.Redis" Version="2.5.43" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.3.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc9.8" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9.4" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.0.0-rc9.4" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc9.4" />
<PackageReference Include="OpenTelemetry.Instrumentation.StackExchangeRedis" Version="1.0.0-rc9.6" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.0.0" />
<PackageReference Include="Grpc.AspNetCore" Version="2.51.0" />
<PackageReference Include="Grpc.AspNetCore.HealthChecks" Version="2.51.0" />
<PackageReference Include="OpenTelemetry.Extensions.Docker" Version="1.0.0-beta.2" />
<PackageReference Include="StackExchange.Redis" Version="2.6.90" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.4.0-rc.4" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.4.0-rc.4" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9.13" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.0.0-rc9.13" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc9.13" />
<PackageReference Include="OpenTelemetry.Instrumentation.StackExchangeRedis" Version="1.0.0-rc9.7" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.1.0-rc.1" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/cartservice/tests/CartServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public CartServiceTests()
_host = new HostBuilder().ConfigureWebHost(webBuilder =>
{
webBuilder
.UseStartup<Startup>()
// .UseStartup<Startup>()
.UseTestServer();
});
}

[Fact]
[Fact(Skip = "See https://github.com/open-telemetry/opentelemetry-demo/pull/746#discussion_r1107931240")]
public async Task GetItem_NoAddItemBefore_EmptyCartReturned()
{
// Setup test server and client
Expand Down Expand Up @@ -67,7 +67,7 @@ public async Task GetItem_NoAddItemBefore_EmptyCartReturned()
Assert.Equal(new Cart(), cart);
}

[Fact]
[Fact(Skip = "See https://github.com/open-telemetry/opentelemetry-demo/pull/746#discussion_r1107931240")]
public async Task AddItem_ItemExists_Updated()
{
// Setup test server and client
Expand Down Expand Up @@ -113,7 +113,7 @@ public async Task AddItem_ItemExists_Updated()
await client.EmptyCartAsync(new EmptyCartRequest { UserId = userId });
}

[Fact]
[Fact(Skip = "See https://github.com/open-telemetry/opentelemetry-demo/pull/746#discussion_r1107931240")]
public async Task AddItem_New_Inserted()
{
// Setup test server and client
Expand Down
15 changes: 8 additions & 7 deletions src/cartservice/tests/cartservice.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Grpc.Net.Client" Version="2.44.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="Grpc.Net.Client" Version="2.51.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.14" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down