Skip to content

Commit

Permalink
update template to .NET 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RassK committed Dec 1, 2023
1 parent 827aca1 commit 7d728a3
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 47 deletions.
17 changes: 10 additions & 7 deletions integration-examples/splunk-otel-dotnet-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 80
EXPOSE 8080

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["MultiStageDocker/MultiStageDocker.csproj", "MultiStageDocker/"]
RUN dotnet restore "MultiStageDocker/MultiStageDocker.csproj"
RUN dotnet restore "./MultiStageDocker/./MultiStageDocker.csproj"
COPY . .
WORKDIR "/src/MultiStageDocker"
RUN dotnet build "MultiStageDocker.csproj" -c Release -o /app/build
RUN dotnet build "./MultiStageDocker.csproj" -c $BUILD_CONFIGURATION -o /app/build

# Add dependencies for splunk-otel-dotnet-install.sh
RUN apt-get update && \
Expand All @@ -23,12 +25,13 @@ RUN curl -sSfL https://github.com/signalfx/splunk-otel-dotnet/releases/latest/do
RUN sh ./splunk-otel-dotnet-install.sh

FROM build AS publish
RUN dotnet publish "MultiStageDocker.csproj" -c Release -o /app/publish /p:UseAppHost=false
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./MultiStageDocker.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final

# Copy instrumentation file tree
WORKDIR "/root/.splunk-otel-dotnet"
WORKDIR "//home/app/.splunk-otel-dotnet"
COPY --from=build /root/.splunk-otel-dotnet/ .

WORKDIR /app
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
</ItemGroup>

</Project>
76 changes: 38 additions & 38 deletions integration-examples/splunk-otel-dotnet-docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,50 @@ The `entrypoint.sh` is essential for sourcing environment variables from the `in

1. Set `ENV OTEL_DOTNET_AUTO_TRACES_CONSOLE_EXPORTER_ENABLED=true` in the Dockerfile for verification purposes.
1. Build the Docker image.
1. Map a random host port (e.g.: 8181) to the container port (80).
1. Map a random host port (e.g.: 8181) to the container port (8080).
1. Open your browser and navigate to `http://localhost:8181`.
1. Verify the execution of instrumentation by examining the container logs, which should now include Activity information. (Refer to the sample output below.)

Sample log output:

```txt
2023-11-30 13:16:56 info: Microsoft.Hosting.Lifetime[14]
2023-11-30 13:16:56 Now listening on: http://[::]:80
2023-11-30 13:16:56 info: Microsoft.Hosting.Lifetime[0]
2023-11-30 13:16:56 Application started. Press Ctrl+C to shut down.
2023-11-30 13:16:56 info: Microsoft.Hosting.Lifetime[0]
2023-11-30 13:16:56 Hosting environment: Production
2023-11-30 13:16:56 info: Microsoft.Hosting.Lifetime[0]
2023-11-30 13:16:56 Content root path: /app/
2023-11-30 13:17:02 Activity.TraceId: 31f535f9515f017c72f030c17823651d
2023-11-30 13:17:02 Activity.SpanId: fb15fa8d223d9f6c
2023-11-30 13:17:02 Activity.TraceFlags: Recorded
2023-11-30 13:17:02 Activity.ActivitySourceName: OpenTelemetry.Instrumentation.AspNetCore
2023-11-30 13:17:02 Activity.DisplayName: GET /
2023-11-30 13:17:02 Activity.Kind: Server
2023-11-30 13:17:02 Activity.StartTime: 2023-11-30T11:17:02.1819362Z
2023-11-30 13:17:02 Activity.Duration: 00:00:00.0766474
2023-11-30 13:17:02 Activity.Tags:
2023-11-30 13:17:02 net.host.name: localhost
2023-11-30 13:17:02 net.host.port: 8181
2023-11-30 13:17:02 http.method: GET
2023-11-30 13:17:02 http.scheme: http
2023-11-30 13:17:02 http.target: /
2023-11-30 13:17:02 http.url: http://localhost:8181/
2023-11-30 13:17:02 http.flavor: 1.1
2023-11-30 13:17:02 http.user_agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0
2023-11-30 13:17:02 http.route: /
2023-11-30 13:17:02 http.status_code: 200
2023-11-30 13:17:02 Resource associated with Activity:
2023-11-30 13:17:02 service.name: MultiStageDocker
2023-11-30 13:17:02 splunk.distro.version: 1.2.0
2023-11-30 13:17:02 telemetry.distro.name: splunk-otel-dotnet
2023-11-30 13:17:02 telemetry.distro.version: 1.2.0
2023-11-30 13:17:02 container.id: 78f56ae03c320713dd0af833f1ab3a844ac5b5f6440ccd4d1716cfe9d73180e4
2023-11-30 13:17:02 telemetry.sdk.name: opentelemetry
2023-11-30 13:17:02 telemetry.sdk.language: dotnet
2023-11-30 13:17:02 telemetry.sdk.version: 1.6.0
2023-11-30 13:17:02
2023-12-01 15:34:28 info: Microsoft.Hosting.Lifetime[14]
2023-12-01 15:34:28 Now listening on: http://[::]:8080
2023-12-01 15:34:28 info: Microsoft.Hosting.Lifetime[0]
2023-12-01 15:34:28 Application started. Press Ctrl+C to shut down.
2023-12-01 15:34:28 info: Microsoft.Hosting.Lifetime[0]
2023-12-01 15:34:28 Hosting environment: Production
2023-12-01 15:34:28 info: Microsoft.Hosting.Lifetime[0]
2023-12-01 15:34:28 Content root path: /app
2023-12-01 15:34:32 Activity.TraceId: 7f34db4b569f6b6dd6c77c1a5d5164e2
2023-12-01 15:34:32 Activity.SpanId: 87c76863b1d6b603
2023-12-01 15:34:32 Activity.TraceFlags: Recorded
2023-12-01 15:34:32 Activity.ActivitySourceName: OpenTelemetry.Instrumentation.AspNetCore
2023-12-01 15:34:32 Activity.DisplayName: GET /
2023-12-01 15:34:32 Activity.Kind: Server
2023-12-01 15:34:32 Activity.StartTime: 2023-12-01T13:34:32.4239711Z
2023-12-01 15:34:32 Activity.Duration: 00:00:00.0958729
2023-12-01 15:34:32 Activity.Tags:
2023-12-01 15:34:32 net.host.name: localhost
2023-12-01 15:34:32 net.host.port: 8181
2023-12-01 15:34:32 http.method: GET
2023-12-01 15:34:32 http.scheme: http
2023-12-01 15:34:32 http.target: /
2023-12-01 15:34:32 http.url: http://localhost:8181/
2023-12-01 15:34:32 http.flavor: 1.1
2023-12-01 15:34:32 http.user_agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0
2023-12-01 15:34:32 http.route: /
2023-12-01 15:34:32 http.status_code: 200
2023-12-01 15:34:32 Resource associated with Activity:
2023-12-01 15:34:32 service.name: MultiStageDocker
2023-12-01 15:34:32 splunk.distro.version: 1.2.0
2023-12-01 15:34:32 telemetry.distro.name: splunk-otel-dotnet
2023-12-01 15:34:32 telemetry.distro.version: 1.2.0
2023-12-01 15:34:32 container.id: 9cc3abcf5e01dd5276768fe5e008ffc0a83cb57073d8dd98dc2e2c79f5620100
2023-12-01 15:34:32 telemetry.sdk.name: opentelemetry
2023-12-01 15:34:32 telemetry.sdk.language: dotnet
2023-12-01 15:34:32 telemetry.sdk.version: 1.6.0
2023-12-01 15:34:32
```

## Common known issues
Expand Down

0 comments on commit 7d728a3

Please sign in to comment.