Skip to content

Commit

Permalink
Fix .NET instrumentation for .NET 6.0 (odigos-io#2056)
Browse files Browse the repository at this point in the history
  • Loading branch information
edeNFed committed Dec 25, 2024
1 parent d333d50 commit c5de09e
Show file tree
Hide file tree
Showing 26 changed files with 678 additions and 69 deletions.
11 changes: 11 additions & 0 deletions docs/instrumentations/dotnet/dotnet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,14 @@ The following .NET modules will be auto instrumented by Odigos:
| [Kafka](https://www.nuget.org/packages/Confluent.Kafka) | | | |
| [NServiceBus](https://docs.particular.net/nservicebus/) | Yes | Yes | |
| [MassTransit](https://masstransit-project.com/) | Yes | | |

## Automatic Testing

The following scenarios are automatically tested with every release:

| .NET Version | LibC type | CPU |
|--------------|-----------|-------|
| 6.0 | glibc | amd64 |
| 6.0 | musl | amd64 |
| 8.0 | glibc | amd64 |
| 8.0 | musl | amd64 |
16 changes: 12 additions & 4 deletions odiglet/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

######### python Native Community Agent #########

FROM python:3.11 AS python-builder
FROM python:3.11.9 AS python-builder
ARG ODIGOS_VERSION
WORKDIR /python-instrumentation
COPY ../agents/python ./agents/configurator
Expand Down Expand Up @@ -61,7 +61,7 @@ RUN yarn --cwd ./odigos/agents/nodejs-native-community --production --frozen-loc

FROM --platform=$BUILDPLATFORM busybox:1.36.1 AS dotnet-builder
WORKDIR /dotnet-instrumentation
ARG DOTNET_OTEL_VERSION=v1.8.0
ARG DOTNET_OTEL_VERSION=v1.9.0
ARG TARGETARCH
RUN if [ "$TARGETARCH" = "arm64" ]; then \
echo "arm64" > /tmp/arch_suffix; \
Expand All @@ -78,14 +78,22 @@ RUN ARCH_SUFFIX=$(cat /tmp/arch_suffix) && \
unzip opentelemetry-dotnet-instrumentation-linux-musl-${ARCH_SUFFIX}.zip "linux-musl-$ARCH_SUFFIX/*" -d . && \
rm opentelemetry-dotnet-instrumentation-linux-musl-${ARCH_SUFFIX}.zip

FROM --platform=$BUILDPLATFORM keyval/odiglet-base:v1.5 AS builder
# TODO(edenfed): Currently .NET Automatic instrumentation does not work on dotnet 6.0 with glibc,
# This is due to compilation of the .so file on a newer version of glibc than the one used by the dotnet runtime.
# The following override the .so file with our own which is compiled on the same glibc version as the dotnet runtime.
RUN ARCH_SUFFIX=$(cat /tmp/arch_suffix) && \
wget https://github.com/odigos-io/opentelemetry-dotnet-instrumentation/releases/download/${DOTNET_OTEL_VERSION}/OpenTelemetry.AutoInstrumentation.Native-${ARCH_SUFFIX}.so && \
mv OpenTelemetry.AutoInstrumentation.Native-${ARCH_SUFFIX}.so linux-glibc-${ARCH_SUFFIX}/OpenTelemetry.AutoInstrumentation.Native.so

FROM --platform=$BUILDPLATFORM keyval/odiglet-base:v1.7 AS builder
WORKDIR /go/src/github.com/odigos-io/odigos
# Copy local modules required by the build
COPY api/ api/
COPY common/ common/
COPY k8sutils/ k8sutils/
COPY procdiscovery/ procdiscovery/
COPY opampserver/ opampserver/
COPY instrumentation/ instrumentation/
WORKDIR /go/src/github.com/odigos-io/odigos/odiglet
COPY odiglet/ .

Expand All @@ -97,7 +105,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
WORKDIR /instrumentations

# Java
ARG JAVA_OTEL_VERSION=v2.8.0
ARG JAVA_OTEL_VERSION=v2.10.0
ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/$JAVA_OTEL_VERSION/opentelemetry-javaagent.jar /instrumentations/java/javaagent.jar
RUN chmod 644 /instrumentations/java/javaagent.jar

Expand Down
13 changes: 12 additions & 1 deletion odiglet/debug.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,18 @@ RUN if [ "$TARGETARCH" = "arm64" ]; then \
RUN ARCH_SUFFIX=$(cat /tmp/arch_suffix) && \
wget https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/download/${DOTNET_OTEL_VERSION}/opentelemetry-dotnet-instrumentation-linux-glibc-${ARCH_SUFFIX}.zip && \
unzip opentelemetry-dotnet-instrumentation-linux-glibc-${ARCH_SUFFIX}.zip && \
rm opentelemetry-dotnet-instrumentation-linux-glibc-${ARCH_SUFFIX}.zip
rm opentelemetry-dotnet-instrumentation-linux-glibc-${ARCH_SUFFIX}.zip && \
mv linux-$ARCH_SUFFIX linux-glibc-$ARCH_SUFFIX && \
wget https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/download/${DOTNET_OTEL_VERSION}/opentelemetry-dotnet-instrumentation-linux-musl-${ARCH_SUFFIX}.zip && \
unzip opentelemetry-dotnet-instrumentation-linux-musl-${ARCH_SUFFIX}.zip "linux-musl-$ARCH_SUFFIX/*" -d . && \
rm opentelemetry-dotnet-instrumentation-linux-musl-${ARCH_SUFFIX}.zip

# TODO(edenfed): Currently .NET Automatic instrumentation does not work on dotnet 6.0 with glibc,
# This is due to compilation of the .so file on a newer version of glibc than the one used by the dotnet runtime.
# The following override the .so file with our own which is compiled on the same glibc version as the dotnet runtime.
RUN ARCH_SUFFIX=$(cat /tmp/arch_suffix) && \
wget https://github.com/odigos-io/opentelemetry-dotnet-instrumentation/releases/download/${DOTNET_OTEL_VERSION}/OpenTelemetry.AutoInstrumentation.Native-${ARCH_SUFFIX}.so && \
mv OpenTelemetry.AutoInstrumentation.Native-${ARCH_SUFFIX}.so linux-glibc-${ARCH_SUFFIX}/OpenTelemetry.AutoInstrumentation.Native.so

FROM --platform=$BUILDPLATFORM keyval/odiglet-base:v1.5 AS builder
WORKDIR /go/src/github.com/odigos-io/odigos
Expand Down
46 changes: 44 additions & 2 deletions tests/e2e/workload-lifecycle/01-assert-apps-installed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,53 @@ apiVersion: v1
kind: Pod
metadata:
labels:
app: dotnet-musl
app: dotnet8-musl
namespace: default
status:
containerStatuses:
- name: dotnet-musl
- name: dotnet8-musl
ready: true
restartCount: 0
started: true
phase: Running
---
apiVersion: v1
kind: Pod
metadata:
labels:
app: dotnet6-musl
namespace: default
status:
containerStatuses:
- name: dotnet6-musl
ready: true
restartCount: 0
started: true
phase: Running
---
apiVersion: v1
kind: Pod
metadata:
labels:
app: dotnet6-glibc
namespace: default
status:
containerStatuses:
- name: dotnet6-glibc
ready: true
restartCount: 0
started: true
phase: Running
---
apiVersion: v1
kind: Pod
metadata:
labels:
app: dotnet8-glibc
namespace: default
status:
containerStatuses:
- name: dotnet8-glibc
ready: true
restartCount: 0
started: true
Expand Down
59 changes: 55 additions & 4 deletions tests/e2e/workload-lifecycle/01-assert-runtime-detected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -324,16 +324,67 @@ spec:
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
name: deployment-dotnet-musl
name: deployment-dotnet8-musl
namespace: default
ownerReferences:
- apiVersion: apps/v1
blockOwnerDeletion: true
controller: true
kind: Deployment
name: dotnet-musl
name: dotnet8-musl
spec:
runtimeDetails:
- containerName: dotnet-musl
- containerName: dotnet8-musl
language: dotnet
libCType: musl
libCType: musl
---
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
name: deployment-dotnet6-musl
namespace: default
ownerReferences:
- apiVersion: apps/v1
blockOwnerDeletion: true
controller: true
kind: Deployment
name: dotnet6-musl
spec:
runtimeDetails:
- containerName: dotnet6-musl
language: dotnet
libCType: musl
---
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
name: deployment-dotnet8-glibc
namespace: default
ownerReferences:
- apiVersion: apps/v1
blockOwnerDeletion: true
controller: true
kind: Deployment
name: dotnet8-glibc
spec:
runtimeDetails:
- containerName: dotnet8-glibc
language: dotnet
libCType: glibc
---
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
name: deployment-dotnet6-glibc
namespace: default
ownerReferences:
- apiVersion: apps/v1
blockOwnerDeletion: true
controller: true
kind: Deployment
name: dotnet6-glibc
spec:
runtimeDetails:
- containerName: dotnet6-glibc
language: dotnet
libCType: glibc
97 changes: 92 additions & 5 deletions tests/e2e/workload-lifecycle/01-assert-workloads.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -555,21 +555,108 @@ metadata:
deployment.kubernetes.io/revision: "2" # the deployment spec changed when odigos resource was added
generation: 2 # the deployment spec changed when odigos resource was added
labels:
app: dotnet-musl
name: dotnet-musl
app: dotnet8-musl
name: dotnet8-musl
namespace: default
spec:
selector:
matchLabels:
app: dotnet-musl
app: dotnet8-musl
template:
spec:
containers:
- image: dotnet-musl:v0.0.1
name: dotnet-musl
- image: dotnet8-musl:v0.0.1
name: dotnet8-musl
resources:
limits:
instrumentation.odigos.io/musl-dotnet-native-community: "1"
status:
availableReplicas: 1
observedGeneration: 2 # the deployment spec changed when odigos resource was added
readyReplicas: 1
replicas: 1
updatedReplicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "2" # the deployment spec changed when odigos resource was added
generation: 2 # the deployment spec changed when odigos resource was added
labels:
app: dotnet6-musl
name: dotnet6-musl
namespace: default
spec:
selector:
matchLabels:
app: dotnet6-musl
template:
spec:
containers:
- image: dotnet6-musl:v0.0.1
name: dotnet6-musl
resources:
limits:
instrumentation.odigos.io/musl-dotnet-native-community: "1"
status:
availableReplicas: 1
observedGeneration: 2 # the deployment spec changed when odigos resource was added
readyReplicas: 1
replicas: 1
updatedReplicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "2" # the deployment spec changed when odigos resource was added
generation: 2 # the deployment spec changed when odigos resource was added
labels:
app: dotnet8-glibc
name: dotnet8-glibc
namespace: default
spec:
selector:
matchLabels:
app: dotnet8-glibc
template:
spec:
containers:
- image: dotnet8-glibc:v0.0.1
name: dotnet8-glibc
resources:
limits:
instrumentation.odigos.io/dotnet-native-community: "1"
status:
availableReplicas: 1
observedGeneration: 2 # the deployment spec changed when odigos resource was added
readyReplicas: 1
replicas: 1
updatedReplicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "2" # the deployment spec changed when odigos resource was added
generation: 2 # the deployment spec changed when odigos resource was added
labels:
app: dotnet6-glibc
name: dotnet6-glibc
namespace: default
spec:
selector:
matchLabels:
app: dotnet6-glibc
template:
spec:
containers:
- image: dotnet6-glibc:v0.0.1
name: dotnet6-glibc
resources:
limits:
instrumentation.odigos.io/dotnet-native-community: "1"
status:
availableReplicas: 1
observedGeneration: 2 # the deployment spec changed when odigos resource was added
Expand Down
5 changes: 4 additions & 1 deletion tests/e2e/workload-lifecycle/01-generate-traffic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ spec:
curl -s --fail http://python-min-version:3000/insert-random/
curl -s --fail http://python-not-supported:3000/insert-random/
curl -s --fail http://dotnet-musl:8080
curl -s --fail http://dotnet8-musl:8080
curl -s --fail http://dotnet6-musl:8080
curl -s --fail http://dotnet8-glibc:8080
curl -s --fail http://dotnet6-glibc:8080
Loading

0 comments on commit c5de09e

Please sign in to comment.