Skip to content

Commit ff00914

Browse files
[Example/WorkerService] enable analysis (#6220)
Co-authored-by: Rajkumar Rangaraj <[email protected]>
1 parent aa73ce3 commit ff00914

File tree

9 files changed

+11
-29
lines changed

9 files changed

+11
-29
lines changed

examples/MicroserviceExample/Utils/Messaging/MessageReceiver.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ public void StartConsumer()
4040

4141
public void ReceiveMessage(BasicDeliverEventArgs ea)
4242
{
43-
if (ea == null)
44-
{
45-
throw new ArgumentNullException(nameof(ea));
46-
}
43+
ArgumentNullException.ThrowIfNull(ea);
4744

4845
// Extract the PropagationContext of the upstream parent from the message headers.
4946
var parentContext = Propagator.Extract(default, ea.BasicProperties, this.ExtractTraceContextFromBasicProperties);

examples/MicroserviceExample/Utils/Messaging/RabbitMqHelper.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ public static IConnection CreateConnection()
2828

2929
public static IModel CreateModelAndDeclareTestQueue(IConnection connection)
3030
{
31-
if (connection == null)
32-
{
33-
throw new ArgumentNullException(nameof(connection));
34-
}
31+
ArgumentNullException.ThrowIfNull(connection);
3532

3633
var channel = connection.CreateModel();
3734

examples/MicroserviceExample/Utils/Utils.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netstandard2.0</TargetFramework>
3+
<TargetFramework>$(DefaultTargetFrameworkForExampleApps)</TargetFramework>
44
<AnalysisLevel>latest-all</AnalysisLevel>
55
</PropertyGroup>
66

examples/MicroserviceExample/WebApi/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
ARG SDK_VERSION=8.0
2-
1+
ARG SDK_VERSION=9.0
32
FROM mcr.microsoft.com/dotnet/sdk:8.0.407@sha256:2d7f935b8c7fe032cd3d36b5ce9c82c24413881e6dad1b4fbdf36cf369e4244f AS dotnet-sdk-8.0
43
FROM mcr.microsoft.com/dotnet/sdk:9.0.202@sha256:d7f4691d11f610d9b94bb75517c9e78ac5799447b5b3e82af9e4625d8c8d1d53 AS dotnet-sdk-9.0
54

65
FROM dotnet-sdk-${SDK_VERSION} AS build
76
ARG PUBLISH_CONFIGURATION=Release
8-
ARG PUBLISH_FRAMEWORK=net8.0
7+
ARG PUBLISH_FRAMEWORK=net9.0
98
WORKDIR /app
109
COPY . ./
1110
RUN dotnet publish ./examples/MicroserviceExample/WebApi -c "${PUBLISH_CONFIGURATION}" -f "${PUBLISH_FRAMEWORK}" -o /out -p:IntegrationBuild=true

examples/MicroserviceExample/WebApi/WebApi.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
<ItemGroup>
99
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
10-
<PackageReference Include="RabbitMQ.Client" />
1110
</ItemGroup>
1211

1312
<ItemGroup>

examples/MicroserviceExample/WorkerService/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
ARG SDK_VERSION=8.0
1+
ARG SDK_VERSION=9.0
22

33
FROM mcr.microsoft.com/dotnet/sdk:8.0.407@sha256:2d7f935b8c7fe032cd3d36b5ce9c82c24413881e6dad1b4fbdf36cf369e4244f AS dotnet-sdk-8.0
44
FROM mcr.microsoft.com/dotnet/sdk:9.0.202@sha256:d7f4691d11f610d9b94bb75517c9e78ac5799447b5b3e82af9e4625d8c8d1d53 AS dotnet-sdk-9.0
55

66
FROM dotnet-sdk-${SDK_VERSION} AS build
77
ARG PUBLISH_CONFIGURATION=Release
8-
ARG PUBLISH_FRAMEWORK=net8.0
8+
ARG PUBLISH_FRAMEWORK=net9.0
99
WORKDIR /app
1010
COPY . ./
1111
RUN dotnet publish ./examples/MicroserviceExample/WorkerService -c "${PUBLISH_CONFIGURATION}" -f "${PUBLISH_FRAMEWORK}" -o /out -p:IntegrationBuild=true

examples/MicroserviceExample/WorkerService/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace WorkerService;
88

9-
public class Program
9+
internal static class Program
1010
{
1111
public static void Main(string[] args)
1212
{

examples/MicroserviceExample/WorkerService/Worker.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace WorkerService;
77

8-
public partial class Worker : BackgroundService
8+
internal sealed class Worker : BackgroundService
99
{
1010
private readonly MessageReceiver messageReceiver;
1111

@@ -14,16 +14,6 @@ public Worker(MessageReceiver messageReceiver)
1414
this.messageReceiver = messageReceiver;
1515
}
1616

17-
public override Task StartAsync(CancellationToken cancellationToken)
18-
{
19-
return base.StartAsync(cancellationToken);
20-
}
21-
22-
public override async Task StopAsync(CancellationToken cancellationToken)
23-
{
24-
await base.StopAsync(cancellationToken).ConfigureAwait(false);
25-
}
26-
2717
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
2818
{
2919
stoppingToken.ThrowIfCancellationRequested();

examples/MicroserviceExample/WorkerService/WorkerService.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk.Worker">
22
<PropertyGroup>
33
<TargetFramework>$(DefaultTargetFrameworkForExampleApps)</TargetFramework>
4+
<AnalysisLevel>latest-all</AnalysisLevel>
5+
<NoWarn>$(NoWarn);CA1812</NoWarn>
46
</PropertyGroup>
57

68
<ItemGroup>
79
<PackageReference Include="Microsoft.Extensions.Hosting" />
8-
<PackageReference Include="RabbitMQ.Client" />
910
</ItemGroup>
1011

1112
<ItemGroup>
12-
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
1313
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Zipkin\OpenTelemetry.Exporter.Zipkin.csproj" />
1414
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Extensions.Hosting\OpenTelemetry.Extensions.Hosting.csproj" />
1515
</ItemGroup>

0 commit comments

Comments
 (0)