From 04aaed8e6daa2b773b931545fd1ce3ee7ce3539e Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Tue, 12 Apr 2022 12:45:15 +0530 Subject: [PATCH 01/33] Adds support for dotnet auto-instrumentation --- .../publish-autoinstrumentation-dotnet.yaml | 48 +++ .../publish-autoinstrumentation-java.yaml | 22 +- .../publish-autoinstrumentation-nodejs.yaml | 22 +- .../publish-autoinstrumentation-python.yaml | 22 +- .github/workflows/publish-images.yaml | 12 +- .../workflows/publish-target-allocator.yaml | 14 +- .github/workflows/release.yaml | 4 +- Dockerfile | 3 +- Makefile | 3 +- apis/v1alpha1/instrumentation_types.go | 16 + apis/v1alpha1/instrumentation_webhook.go | 9 + apis/v1alpha1/zz_generated.deepcopy.go | 23 ++ autoinstrumentation/dotnet/Dockerfile | 15 + autoinstrumentation/dotnet/version.txt | 1 + ...emetry-operator.clusterserviceversion.yaml | 4 +- .../opentelemetry.io_instrumentations.yaml | 121 ++++++++ .../opentelemetry.io_instrumentations.yaml | 121 ++++++++ ...emetry-operator.clusterserviceversion.yaml | 2 +- docs/api.md | 287 ++++++++++++++++++ internal/config/main.go | 7 + internal/config/options.go | 7 + internal/version/main.go | 13 +- main.go | 6 + pkg/instrumentation/annotation.go | 1 + pkg/instrumentation/dotnet.go | 115 +++++++ pkg/instrumentation/dotnet_test.go | 274 +++++++++++++++++ pkg/instrumentation/podmutator.go | 10 +- pkg/instrumentation/podmutator_test.go | 165 ++++++++++ pkg/instrumentation/sdk.go | 7 + pkg/instrumentation/sdk_test.go | 106 +++++++ pkg/instrumentation/upgrade/upgrade.go | 9 + pkg/instrumentation/upgrade/upgrade_test.go | 5 + .../00-install-collector.yaml | 23 ++ .../00-install-instrumentation.yaml | 30 ++ .../e2e/instrumentation-dotnet/01-assert.yaml | 48 +++ .../01-install-app.yaml | 24 ++ versions.txt | 4 + 37 files changed, 1549 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/publish-autoinstrumentation-dotnet.yaml create mode 100644 autoinstrumentation/dotnet/Dockerfile create mode 100644 autoinstrumentation/dotnet/version.txt create mode 100644 pkg/instrumentation/dotnet.go create mode 100644 pkg/instrumentation/dotnet_test.go create mode 100644 tests/e2e/instrumentation-dotnet/00-install-collector.yaml create mode 100644 tests/e2e/instrumentation-dotnet/00-install-instrumentation.yaml create mode 100644 tests/e2e/instrumentation-dotnet/01-assert.yaml create mode 100644 tests/e2e/instrumentation-dotnet/01-install-app.yaml diff --git a/.github/workflows/publish-autoinstrumentation-dotnet.yaml b/.github/workflows/publish-autoinstrumentation-dotnet.yaml new file mode 100644 index 0000000000..e97f4043db --- /dev/null +++ b/.github/workflows/publish-autoinstrumentation-dotnet.yaml @@ -0,0 +1,48 @@ +name: "Publish DotNet Auto-Instrumentation" + +on: + # push: + # paths: + # - 'autoinstrumentation/dotnet/**' + # - '.github/workflows/publish-autoinstrumentation-dotnet.yaml' + # branches: + # - main + # pull_request: + # paths: + # - 'autoinstrumentation/dotnet/**' + # - '.github/workflows/publish-autoinstrumentation-dotnet.yaml' + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v3 + + - name: Read version + run: echo "VERSION=$(cat autoinstrumentation/dotnet/version.txt)" >> $GITHUB_ENV + + - name: Docker meta + id: meta + uses: docker/metadata-action@v3.7.0 + with: + images: ghcr.io/avadhut123pisal/opentelemetry-operator/autoinstrumentation-dotnet + tags: | + type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} + + - name: Login to GitHub Package Registry + uses: docker/login-action@v1.14.1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v2.10.0 + with: + context: autoinstrumentation/dotnet + push: ${{ github.event_name == 'push' }} + build-args: version=${{ env.VERSION }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/publish-autoinstrumentation-java.yaml b/.github/workflows/publish-autoinstrumentation-java.yaml index a7176fc191..84f9c04a44 100644 --- a/.github/workflows/publish-autoinstrumentation-java.yaml +++ b/.github/workflows/publish-autoinstrumentation-java.yaml @@ -1,16 +1,16 @@ name: "Publish Java Auto-Instrumentation" on: - push: - paths: - - 'autoinstrumentation/java/**' - - '.github/workflows/publish-autoinstrumentation-java.yaml' - branches: - - main - pull_request: - paths: - - 'autoinstrumentation/java/**' - - '.github/workflows/publish-autoinstrumentation-java.yaml' + # push: + # paths: + # - 'autoinstrumentation/java/**' + # - '.github/workflows/publish-autoinstrumentation-java.yaml' + # branches: + # - main + # pull_request: + # paths: + # - 'autoinstrumentation/java/**' + # - '.github/workflows/publish-autoinstrumentation-java.yaml' workflow_dispatch: jobs: @@ -27,7 +27,7 @@ jobs: id: meta uses: docker/metadata-action@v3.7.0 with: - images: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java + images: ghcr.io/avadhut123pisal/opentelemetry-operator/autoinstrumentation-java tags: | type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} diff --git a/.github/workflows/publish-autoinstrumentation-nodejs.yaml b/.github/workflows/publish-autoinstrumentation-nodejs.yaml index c900495914..65e987dc01 100644 --- a/.github/workflows/publish-autoinstrumentation-nodejs.yaml +++ b/.github/workflows/publish-autoinstrumentation-nodejs.yaml @@ -1,16 +1,16 @@ name: "Publish NodeJS Auto-Instrumentation" on: - push: - paths: - - 'autoinstrumentation/nodejs/**' - - '.github/workflows/publish-autoinstrumentation-nodejs.yaml' - branches: - - main - pull_request: - paths: - - 'autoinstrumentation/nodejs/**' - - '.github/workflows/publish-autoinstrumentation-nodejs.yaml' + # push: + # paths: + # - 'autoinstrumentation/nodejs/**' + # - '.github/workflows/publish-autoinstrumentation-nodejs.yaml' + # branches: + # - main + # pull_request: + # paths: + # - 'autoinstrumentation/nodejs/**' + # - '.github/workflows/publish-autoinstrumentation-nodejs.yaml' workflow_dispatch: jobs: @@ -27,7 +27,7 @@ jobs: id: meta uses: docker/metadata-action@v3.7.0 with: - images: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-nodejs + images: ghcr.io/avadhut123pisal/opentelemetry-operator/autoinstrumentation-nodejs tags: | type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} diff --git a/.github/workflows/publish-autoinstrumentation-python.yaml b/.github/workflows/publish-autoinstrumentation-python.yaml index 30c892683a..1cb8f40d3e 100644 --- a/.github/workflows/publish-autoinstrumentation-python.yaml +++ b/.github/workflows/publish-autoinstrumentation-python.yaml @@ -1,16 +1,16 @@ name: "Publish Python Auto-Instrumentation" on: - push: - paths: - - 'autoinstrumentation/python/**' - - '.github/workflows/publish-autoinstrumentation-python.yaml' - branches: - - main - pull_request: - paths: - - 'autoinstrumentation/python/**' - - '.github/workflows/publish-autoinstrumentation-python.yaml' + # push: + # paths: + # - 'autoinstrumentation/python/**' + # - '.github/workflows/publish-autoinstrumentation-python.yaml' + # branches: + # - main + # pull_request: + # paths: + # - 'autoinstrumentation/python/**' + # - '.github/workflows/publish-autoinstrumentation-python.yaml' workflow_dispatch: jobs: @@ -27,7 +27,7 @@ jobs: id: meta uses: docker/metadata-action@v3.7.0 with: - images: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-python + images: ghcr.io/avadhut123pisal/opentelemetry-operator/autoinstrumentation-python tags: | type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} diff --git a/.github/workflows/publish-images.yaml b/.github/workflows/publish-images.yaml index 897b0430d5..18657a78ea 100644 --- a/.github/workflows/publish-images.yaml +++ b/.github/workflows/publish-images.yaml @@ -1,9 +1,9 @@ name: "Publish operator" on: - push: - branches: [ main ] - tags: [ 'v*' ] + # push: + # branches: [ main ] + # tags: [ 'v*' ] workflow_dispatch: @@ -27,6 +27,7 @@ jobs: grep -v '\#' versions.txt | grep autoinstrumentation-java | awk -F= '{print "AUTO_INSTRUMENTATION_JAVA_VERSION="$2}' >> $GITHUB_ENV grep -v '\#' versions.txt | grep autoinstrumentation-nodejs | awk -F= '{print "AUTO_INSTRUMENTATION_NODEJS_VERSION="$2}' >> $GITHUB_ENV grep -v '\#' versions.txt | grep autoinstrumentation-python | awk -F= '{print "AUTO_INSTRUMENTATION_PYTHON_VERSION="$2}' >> $GITHUB_ENV + grep -v '\#' versions.txt | grep autoinstrumentation-dotnet | awk -F= '{print "AUTO_INSTRUMENTATION_DOTNET_VERSION="$2}' >> $GITHUB_ENV echo "VERSION_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV echo "VERSION=$(git describe --tags | sed 's/^v//')" >> $GITHUB_ENV @@ -34,7 +35,7 @@ jobs: id: docker_meta uses: docker/metadata-action@v3.7.0 with: - images: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator + images: ghcr.io/avadhut123pisal/opentelemetry-operator/opentelemetry-operator tags: | type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} @@ -79,6 +80,7 @@ jobs: TARGETALLOCATOR_VERSION=${{ env.TARGETALLOCATOR_VERSION }} AUTO_INSTRUMENTATION_JAVA_VERSION=${{ env.AUTO_INSTRUMENTATION_JAVA_VERSION }} AUTO_INSTRUMENTATION_NODEJS_VERSION=${{ env.AUTO_INSTRUMENTATION_NODEJS_VERSION }} - AUTO_INSTRUMENTATION_PYTHON_VERSION=${{ env. AUTO_INSTRUMENTATION_PYTHON_VERSION }} + AUTO_INSTRUMENTATION_PYTHON_VERSION=${{ env.AUTO_INSTRUMENTATION_PYTHON_VERSION }} + AUTO_INSTRUMENTATION_DOTNET_VERSION=${{ env.AUTO_INSTRUMENTATION_DOTNET_VERSION }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache diff --git a/.github/workflows/publish-target-allocator.yaml b/.github/workflows/publish-target-allocator.yaml index 2e476453af..c71bed7077 100644 --- a/.github/workflows/publish-target-allocator.yaml +++ b/.github/workflows/publish-target-allocator.yaml @@ -1,12 +1,12 @@ name: "Publish target allocator" on: - push: - paths: - - 'cmd/otel-allocator/**' - - '.github/workflows/publish-target-allocator.yaml' - branches: - - main + # push: + # paths: + # - 'cmd/otel-allocator/**' + # - '.github/workflows/publish-target-allocator.yaml' + # branches: + # - main workflow_dispatch: jobs: @@ -23,7 +23,7 @@ jobs: id: meta uses: docker/metadata-action@v3.7.0 with: - images: ghcr.io/open-telemetry/opentelemetry-operator/target-allocator + images: ghcr.io/avadhut123pisal/opentelemetry-operator/target-allocator tags: | type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d4c38ac47a..721c66e4b8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -21,7 +21,7 @@ jobs: run: ./hack/install-kustomize.sh - name: "generate release resources" - run: make release-artifacts IMG_PREFIX="ghcr.io/open-telemetry/opentelemetry-operator" + run: make release-artifacts IMG_PREFIX="ghcr.io/avadhut123pisal/opentelemetry-operator" - name: "create the release in GitHub" env: @@ -31,4 +31,4 @@ jobs: - name: "refresh go proxy module info on release" run: | OPERATOR_VERSION=$(git describe --tags) - curl https://proxy.golang.org/github.com/open-telemetry/opentelemetry-operator/@v/${OPERATOR_VERSION}.info + curl https://proxy.golang.org/github.com/avadhut123pisal/opentelemetry-operator/@v/${OPERATOR_VERSION}.info diff --git a/Dockerfile b/Dockerfile index a55a53c215..655c11c10a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,9 +25,10 @@ ARG TARGETALLOCATOR_VERSION ARG AUTO_INSTRUMENTATION_JAVA_VERSION ARG AUTO_INSTRUMENTATION_NODEJS_VERSION ARG AUTO_INSTRUMENTATION_PYTHON_VERSION +ARG AUTO_INSTRUMENTATION_DOTNET_VERSION # Build -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -ldflags="-X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.buildDate=${VERSION_DATE} -X ${VERSION_PKG}.otelCol=${OTELCOL_VERSION} -X ${VERSION_PKG}.targetAllocator=${TARGETALLOCATOR_VERSION} -X ${VERSION_PKG}.autoInstrumentationJava=${AUTO_INSTRUMENTATION_JAVA_VERSION} -X ${VERSION_PKG}.autoInstrumentationNodeJS=${AUTO_INSTRUMENTATION_NODEJS_VERSION} -X ${VERSION_PKG}.autoInstrumentationPython=${AUTO_INSTRUMENTATION_PYTHON_VERSION}" -a -o manager main.go +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -ldflags="-X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.buildDate=${VERSION_DATE} -X ${VERSION_PKG}.otelCol=${OTELCOL_VERSION} -X ${VERSION_PKG}.targetAllocator=${TARGETALLOCATOR_VERSION} -X ${VERSION_PKG}.autoInstrumentationJava=${AUTO_INSTRUMENTATION_JAVA_VERSION} -X ${VERSION_PKG}.autoInstrumentationNodeJS=${AUTO_INSTRUMENTATION_NODEJS_VERSION} -X ${VERSION_PKG}.autoInstrumentationPython=${AUTO_INSTRUMENTATION_PYTHON_VERSION} -X ${VERSION_PKG}.autoInstrumentationDotnet=${AUTO_INSTRUMENTATION_DOTNET_VERSION}" -a -o manager main.go # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/Makefile b/Makefile index 5c7069ff7f..b44082eacb 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ TARGETALLOCATOR_VERSION ?= "$(shell grep -v '\#' versions.txt | grep targetalloc AUTO_INSTRUMENTATION_JAVA_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-java | awk -F= '{print $$2}')" AUTO_INSTRUMENTATION_NODEJS_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-nodejs | awk -F= '{print $$2}')" AUTO_INSTRUMENTATION_PYTHON_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-python | awk -F= '{print $$2}')" +AUTO_INSTRUMENTATION_DOTNET_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-dotnet | awk -F= '{print $$2}')" LD_FLAGS ?= "-X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.buildDate=${VERSION_DATE} -X ${VERSION_PKG}.otelCol=${OTELCOL_VERSION} -X ${VERSION_PKG}.targetAllocator=${TARGETALLOCATOR_VERSION} -X ${VERSION_PKG}.autoInstrumentationJava=${AUTO_INSTRUMENTATION_JAVA_VERSION} -X ${VERSION_PKG}.autoInstrumentationNodeJS=${AUTO_INSTRUMENTATION_NODEJS_VERSION} -X ${VERSION_PKG}.autoInstrumentationPython=${AUTO_INSTRUMENTATION_PYTHON_VERSION}" # Image URL to use all building/pushing image targets @@ -165,7 +166,7 @@ set-test-image-vars: # Build the container image, used only for local dev purposes .PHONY: container container: - docker build -t ${IMG} --build-arg VERSION_PKG=${VERSION_PKG} --build-arg VERSION=${VERSION} --build-arg VERSION_DATE=${VERSION_DATE} --build-arg OTELCOL_VERSION=${OTELCOL_VERSION} --build-arg TARGETALLOCATOR_VERSION=${TARGETALLOCATOR_VERSION} --build-arg AUTO_INSTRUMENTATION_JAVA_VERSION=${AUTO_INSTRUMENTATION_JAVA_VERSION} --build-arg AUTO_INSTRUMENTATION_NODEJS_VERSION=${AUTO_INSTRUMENTATION_NODEJS_VERSION} --build-arg AUTO_INSTRUMENTATION_PYTHON_VERSION=${AUTO_INSTRUMENTATION_PYTHON_VERSION} . + docker build -t ${IMG} --build-arg VERSION_PKG=${VERSION_PKG} --build-arg VERSION=${VERSION} --build-arg VERSION_DATE=${VERSION_DATE} --build-arg OTELCOL_VERSION=${OTELCOL_VERSION} --build-arg TARGETALLOCATOR_VERSION=${TARGETALLOCATOR_VERSION} --build-arg AUTO_INSTRUMENTATION_JAVA_VERSION=${AUTO_INSTRUMENTATION_JAVA_VERSION} --build-arg AUTO_INSTRUMENTATION_NODEJS_VERSION=${AUTO_INSTRUMENTATION_NODEJS_VERSION} --build-arg AUTO_INSTRUMENTATION_PYTHON_VERSION=${AUTO_INSTRUMENTATION_PYTHON_VERSION} --build-arg AUTO_INSTRUMENTATION_DOTNET_VERSION=${AUTO_INSTRUMENTATION_DOTNET_VERSION} . # Push the container image, used only for local dev purposes .PHONY: container-push diff --git a/apis/v1alpha1/instrumentation_types.go b/apis/v1alpha1/instrumentation_types.go index 95a0a13e87..af6ef30a7c 100644 --- a/apis/v1alpha1/instrumentation_types.go +++ b/apis/v1alpha1/instrumentation_types.go @@ -54,6 +54,10 @@ type InstrumentationSpec struct { // Python defines configuration for python auto-instrumentation. // +optional Python Python `json:"python,omitempty"` + + // DotNet defines configuration for DotNet auto-instrumentation. + // +optional + DotNet DotNet `json:"dotnet,omitempty"` } // Resource defines the configuration for the resource attributes, as defined by the OpenTelemetry specification. @@ -129,6 +133,18 @@ type Python struct { Env []corev1.EnvVar `json:"env,omitempty"` } +type DotNet struct { + // Image is a container image with DotNet SDK and auto-instrumentation. + // +optional + Image string `json:"image,omitempty"` + + // Env defines DotNet specific env vars. There are four layers for env vars' definitions and + // the precedence order is: `original container env vars` > `language specific env vars` > `common env vars` > `instrument spec configs' vars`. + // If the former var had been defined, then the other vars would be ignored. + // +optional + Env []corev1.EnvVar `json:"env,omitempty"` +} + // InstrumentationStatus defines status of the instrumentation. type InstrumentationStatus struct { } diff --git a/apis/v1alpha1/instrumentation_webhook.go b/apis/v1alpha1/instrumentation_webhook.go index f2793a8640..0a19653ce8 100644 --- a/apis/v1alpha1/instrumentation_webhook.go +++ b/apis/v1alpha1/instrumentation_webhook.go @@ -30,6 +30,7 @@ const ( AnnotationDefaultAutoInstrumentationJava = "instrumentation.opentelemetry.io/default-auto-instrumentation-java-image" AnnotationDefaultAutoInstrumentationNodeJS = "instrumentation.opentelemetry.io/default-auto-instrumentation-nodejs-image" AnnotationDefaultAutoInstrumentationPython = "instrumentation.opentelemetry.io/default-auto-instrumentation-python-image" + AnnotationDefaultAutoInstrumentationDotNet = "instrumentation.opentelemetry.io/default-auto-instrumentation-dotnet-image" envPrefix = "OTEL_" envSplunkPrefix = "SPLUNK_" ) @@ -72,6 +73,11 @@ func (r *Instrumentation) Default() { r.Spec.Python.Image = val } } + if r.Spec.DotNet.Image == "" { + if val, ok := r.Annotations[AnnotationDefaultAutoInstrumentationDotNet]; ok { + r.Spec.DotNet.Image = val + } + } } // +kubebuilder:webhook:verbs=create;update,path=/validate-opentelemetry-io-v1alpha1-instrumentation,mutating=false,failurePolicy=fail,groups=opentelemetry.io,resources=instrumentations,versions=v1alpha1,name=vinstrumentationcreateupdate.kb.io,sideEffects=none,admissionReviewVersions=v1 @@ -125,6 +131,9 @@ func (in *Instrumentation) validate() error { if err := in.validateEnv(in.Spec.Python.Env); err != nil { return err } + if err := in.validateEnv(in.Spec.DotNet.Env); err != nil { + return err + } return nil } diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index e375a200c1..3bf0ef0f87 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -24,6 +24,28 @@ import ( "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DotNet) DeepCopyInto(out *DotNet) { + *out = *in + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]v1.EnvVar, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DotNet. +func (in *DotNet) DeepCopy() *DotNet { + if in == nil { + return nil + } + out := new(DotNet) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Exporter) DeepCopyInto(out *Exporter) { *out = *in @@ -119,6 +141,7 @@ func (in *InstrumentationSpec) DeepCopyInto(out *InstrumentationSpec) { in.Java.DeepCopyInto(&out.Java) in.NodeJS.DeepCopyInto(&out.NodeJS) in.Python.DeepCopyInto(&out.Python) + in.DotNet.DeepCopyInto(&out.DotNet) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstrumentationSpec. diff --git a/autoinstrumentation/dotnet/Dockerfile b/autoinstrumentation/dotnet/Dockerfile new file mode 100644 index 0000000000..56f7d0b6c0 --- /dev/null +++ b/autoinstrumentation/dotnet/Dockerfile @@ -0,0 +1,15 @@ +# To build one auto-instrumentation image for dotnet, please: +# - Download your dotnet auto-instrumentation artefacts to `/autoinstrumentation` directory. This is required as when instrumenting the pod, +# one init container will be created to copy the files to your app's container. +# - Grant the necessary access to the files in the `/autoinstrumentation` directory. +FROM busybox + +WORKDIR /autoinstrumentation + +ARG version + +ADD https://github.com/logicmonitor/lm-telemetry-sdk-dotnet/releases/download/$version/lm-telemetry-dotnet-instrumentation-$version.zip . + +RUN tar -xvf lm-telemetry-dotnet-instrumentation-$version.zip && rm lm-telemetry-dotnet-instrumentation-$version.zip + +RUN chmod -R go+r . \ No newline at end of file diff --git a/autoinstrumentation/dotnet/version.txt b/autoinstrumentation/dotnet/version.txt new file mode 100644 index 0000000000..8a9ecc2ea9 --- /dev/null +++ b/autoinstrumentation/dotnet/version.txt @@ -0,0 +1 @@ +0.0.1 \ No newline at end of file diff --git a/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml index 594d4c8c0f..b87809c9f7 100644 --- a/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -30,7 +30,7 @@ metadata: capabilities: Basic Install categories: Logging & Tracing certified: "false" - containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator + containerImage: ghcr.io/avadhut123pisal/opentelemetry-operator/opentelemetry-operator createdAt: "2020-12-16T13:37:00+00:00" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.16.0+git @@ -297,7 +297,7 @@ spec: - args: - --metrics-addr=127.0.0.1:8080 - --enable-leader-election - image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.48.0 + image: ghcr.io/avadhut123pisal/opentelemetry-operator/opentelemetry-operator:0.48.0 livenessProbe: httpGet: path: /healthz diff --git a/bundle/manifests/opentelemetry.io_instrumentations.yaml b/bundle/manifests/opentelemetry.io_instrumentations.yaml index d00551d3a7..832f9bf5d2 100644 --- a/bundle/manifests/opentelemetry.io_instrumentations.yaml +++ b/bundle/manifests/opentelemetry.io_instrumentations.yaml @@ -53,6 +53,127 @@ spec: description: InstrumentationSpec defines the desired state of OpenTelemetry SDK and instrumentation. properties: + dotnet: + description: DotNet defines configuration for DotNet auto-instrumentation. + properties: + env: + description: 'Env defines DotNet specific env vars. There are + four layers for env vars'' definitions and the precedence order + is: `original container env vars` > `language specific env vars` + > `common env vars` > `instrument spec configs'' vars`. If the + former var had been defined, then the other vars would be ignored.' + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: Name of the environment variable. Must be a + C_IDENTIFIER. + type: string + value: + description: 'Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in + the container and any service environment variables. If + a variable cannot be resolved, the reference in the input + string will be unchanged. Double $$ are reduced to a single + $, which allows for escaping the $(VAR_NAME) syntax: i.e. + "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". + Escaped references will never be expanded, regardless + of whether the variable exists or not. Defaults to "".' + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + fieldRef: + description: 'Selects a field of the pod: supports metadata.name, + metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.podIP, + status.podIPs.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + resourceFieldRef: + description: 'Selects a resource of the container: only + resources limits and requests (limits.cpu, limits.memory, + limits.ephemeral-storage, requests.cpu, requests.memory + and requests.ephemeral-storage) are currently supported.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + type: object + required: + - name + type: object + type: array + image: + description: Image is a container image with DotNet SDK and auto-instrumentation. + type: string + type: object env: description: 'Env defines common env vars. There are four layers for env vars'' definitions and the precedence order is: `original container diff --git a/config/crd/bases/opentelemetry.io_instrumentations.yaml b/config/crd/bases/opentelemetry.io_instrumentations.yaml index b31e5fedc1..c1354e589d 100644 --- a/config/crd/bases/opentelemetry.io_instrumentations.yaml +++ b/config/crd/bases/opentelemetry.io_instrumentations.yaml @@ -52,6 +52,127 @@ spec: description: InstrumentationSpec defines the desired state of OpenTelemetry SDK and instrumentation. properties: + dotnet: + description: DotNet defines configuration for DotNet auto-instrumentation. + properties: + env: + description: 'Env defines DotNet specific env vars. There are + four layers for env vars'' definitions and the precedence order + is: `original container env vars` > `language specific env vars` + > `common env vars` > `instrument spec configs'' vars`. If the + former var had been defined, then the other vars would be ignored.' + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: Name of the environment variable. Must be a + C_IDENTIFIER. + type: string + value: + description: 'Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in + the container and any service environment variables. If + a variable cannot be resolved, the reference in the input + string will be unchanged. Double $$ are reduced to a single + $, which allows for escaping the $(VAR_NAME) syntax: i.e. + "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". + Escaped references will never be expanded, regardless + of whether the variable exists or not. Defaults to "".' + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + fieldRef: + description: 'Selects a field of the pod: supports metadata.name, + metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.podIP, + status.podIPs.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + resourceFieldRef: + description: 'Selects a resource of the container: only + resources limits and requests (limits.cpu, limits.memory, + limits.ephemeral-storage, requests.cpu, requests.memory + and requests.ephemeral-storage) are currently supported.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + type: object + required: + - name + type: object + type: array + image: + description: Image is a container image with DotNet SDK and auto-instrumentation. + type: string + type: object env: description: 'Env defines common env vars. There are four layers for env vars'' definitions and the precedence order is: `original container diff --git a/config/manifests/bases/opentelemetry-operator.clusterserviceversion.yaml b/config/manifests/bases/opentelemetry-operator.clusterserviceversion.yaml index b36f42e8e6..2b3c8f042c 100644 --- a/config/manifests/bases/opentelemetry-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/opentelemetry-operator.clusterserviceversion.yaml @@ -6,7 +6,7 @@ metadata: capabilities: Basic Install categories: Logging & Tracing certified: "false" - containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator + containerImage: ghcr.io/avadhut123pisal/opentelemetry-operator/opentelemetry-operator createdAt: "2020-12-16T13:37:00+00:00" description: Provides the OpenTelemetry components, including the Collector repository: github.com/open-telemetry/opentelemetry-operator diff --git a/docs/api.md b/docs/api.md index 9e9e42de1f..8aa33068ff 100644 --- a/docs/api.md +++ b/docs/api.md @@ -86,6 +86,13 @@ InstrumentationSpec defines the desired state of OpenTelemetry SDK and instrumen + dotnet + object + + DotNet defines configuration for DotNet auto-instrumentation.
+ + false + env []object @@ -145,6 +152,286 @@ InstrumentationSpec defines the desired state of OpenTelemetry SDK and instrumen +### Instrumentation.spec.dotnet +[↩ Parent](#instrumentationspec) + + + +DotNet defines configuration for DotNet auto-instrumentation. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
env[]object + Env defines DotNet specific env vars. There are four layers for env vars' definitions and the precedence order is: `original container env vars` > `language specific env vars` > `common env vars` > `instrument spec configs' vars`. If the former var had been defined, then the other vars would be ignored.
+
false
imagestring + Image is a container image with DotNet SDK and auto-instrumentation.
+
false
+ + +### Instrumentation.spec.dotnet.env[index] +[↩ Parent](#instrumentationspecdotnet) + + + +EnvVar represents an environment variable present in a Container. + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
namestring + Name of the environment variable. Must be a C_IDENTIFIER.
+
true
valuestring + Variable references $(VAR_NAME) are expanded using the previously defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".
+
false
valueFromobject + Source for the environment variable's value. Cannot be used if value is not empty.
+
false
+ + +### Instrumentation.spec.dotnet.env[index].valueFrom +[↩ Parent](#instrumentationspecdotnetenvindex) + + + +Source for the environment variable's value. Cannot be used if value is not empty. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
configMapKeyRefobject + Selects a key of a ConfigMap.
+
false
fieldRefobject + Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs.
+
false
resourceFieldRefobject + Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported.
+
false
secretKeyRefobject + Selects a key of a secret in the pod's namespace
+
false
+ + +### Instrumentation.spec.dotnet.env[index].valueFrom.configMapKeyRef +[↩ Parent](#instrumentationspecdotnetenvindexvaluefrom) + + + +Selects a key of a ConfigMap. + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
keystring + The key to select.
+
true
namestring + Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?
+
false
optionalboolean + Specify whether the ConfigMap or its key must be defined
+
false
+ + +### Instrumentation.spec.dotnet.env[index].valueFrom.fieldRef +[↩ Parent](#instrumentationspecdotnetenvindexvaluefrom) + + + +Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
fieldPathstring + Path of the field to select in the specified API version.
+
true
apiVersionstring + Version of the schema the FieldPath is written in terms of, defaults to "v1".
+
false
+ + +### Instrumentation.spec.dotnet.env[index].valueFrom.resourceFieldRef +[↩ Parent](#instrumentationspecdotnetenvindexvaluefrom) + + + +Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported. + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
resourcestring + Required: resource to select
+
true
containerNamestring + Container name: required for volumes, optional for env vars
+
false
divisorint or string + Specifies the output format of the exposed resources, defaults to "1"
+
false
+ + +### Instrumentation.spec.dotnet.env[index].valueFrom.secretKeyRef +[↩ Parent](#instrumentationspecdotnetenvindexvaluefrom) + + + +Selects a key of a secret in the pod's namespace + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
keystring + The key of the secret to select from. Must be a valid secret key.
+
true
namestring + Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?
+
false
optionalboolean + Specify whether the Secret or its key must be defined
+
false
+ + ### Instrumentation.spec.env[index] [↩ Parent](#instrumentationspec) diff --git a/internal/config/main.go b/internal/config/main.go index bed73be4da..f2821e8838 100644 --- a/internal/config/main.go +++ b/internal/config/main.go @@ -51,6 +51,7 @@ type Config struct { autoInstrumentationJavaImage string autoInstrumentationNodeJSImage string autoInstrumentationPythonImage string + autoInstrumentationDotNetImage string labelsFilter []string } @@ -82,6 +83,7 @@ func New(opts ...Option) Config { autoInstrumentationJavaImage: o.autoInstrumentationJavaImage, autoInstrumentationNodeJSImage: o.autoInstrumentationNodeJSImage, autoInstrumentationPythonImage: o.autoInstrumentationPythonImage, + autoInstrumentationDotNetImage: o.autoInstrumentationDotNetImage, labelsFilter: o.labelsFilter, } } @@ -177,6 +179,11 @@ func (c *Config) AutoInstrumentationPythonImage() string { return c.autoInstrumentationPythonImage } +// AutoInstrumentationDotNetImage returns OpenTelemetry DotNet auto-instrumentation container image. +func (c *Config) AutoInstrumentationDotNetImage() string { + return c.autoInstrumentationDotNetImage +} + // Returns the filters converted to regex strings used to filter out unwanted labels from propagations. func (c *Config) LabelsFilter() []string { return c.labelsFilter diff --git a/internal/config/options.go b/internal/config/options.go index 37fe630a37..c71e2e27d5 100644 --- a/internal/config/options.go +++ b/internal/config/options.go @@ -37,6 +37,7 @@ type options struct { autoInstrumentationJavaImage string autoInstrumentationNodeJSImage string autoInstrumentationPythonImage string + autoInstrumentationDotNetImage string collectorConfigMapEntry string targetAllocatorConfigMapEntry string logger logr.Logger @@ -119,6 +120,12 @@ func WithAutoInstrumentationPythonImage(s string) Option { } } +func WithAutoInstrumentationDotNetImage(s string) Option { + return func(o *options) { + o.autoInstrumentationDotNetImage = s + } +} + func WithLabelFilters(labelFilters []string) Option { return func(o *options) { diff --git a/internal/version/main.go b/internal/version/main.go index 5b2dcc5397..d6e7cf1db6 100644 --- a/internal/version/main.go +++ b/internal/version/main.go @@ -28,6 +28,7 @@ var ( autoInstrumentationJava string autoInstrumentationNodeJS string autoInstrumentationPython string + autoInstrumentationDotNet string ) // Version holds this Operator's version as well as the version of some of the components it uses. @@ -40,6 +41,7 @@ type Version struct { AutoInstrumentationJava string `json:"auto-instrumentation-java"` AutoInstrumentationNodeJS string `json:"auto-instrumentation-nodejs"` AutoInstrumentationPython string `json:"auto-instrumentation-python"` + AutoInstrumentationDotNet string `json:"auto-instrumentation-dotnet"` } // Get returns the Version object with the relevant information. @@ -53,12 +55,13 @@ func Get() Version { AutoInstrumentationJava: AutoInstrumentationJava(), AutoInstrumentationNodeJS: AutoInstrumentationNodeJS(), AutoInstrumentationPython: AutoInstrumentationPython(), + AutoInstrumentationDotNet: AutoInstrumentationDotNet(), } } func (v Version) String() string { return fmt.Sprintf( - "Version(Operator='%v', BuildDate='%v', OpenTelemetryCollector='%v', Go='%v', TargetAllocator='%v', AutoInstrumentationJava='%v', AutoInstrumentationNodeJS='%v', AutoInstrumentationPython='%v')", + "Version(Operator='%v', BuildDate='%v', OpenTelemetryCollector='%v', Go='%v', TargetAllocator='%v', AutoInstrumentationJava='%v', AutoInstrumentationNodeJS='%v', AutoInstrumentationPython='%v', AutoInstrumentationDotNet='%v')", v.Operator, v.BuildDate, v.OpenTelemetryCollector, @@ -67,6 +70,7 @@ func (v Version) String() string { v.AutoInstrumentationJava, v.AutoInstrumentationNodeJS, v.AutoInstrumentationPython, + v.AutoInstrumentationDotNet, ) } @@ -112,3 +116,10 @@ func AutoInstrumentationPython() string { } return "0.0.0" } + +func AutoInstrumentationDotNet() string { + if len(autoInstrumentationDotNet) > 0 { + return autoInstrumentationDotNet + } + return "0.0.0" +} diff --git a/main.go b/main.go index 776438563e..adc988226b 100644 --- a/main.go +++ b/main.go @@ -80,6 +80,7 @@ func main() { autoInstrumentationJava string autoInstrumentationNodeJS string autoInstrumentationPython string + autoInstrumentationDotNet string labelsFilter []string ) @@ -93,6 +94,7 @@ func main() { pflag.StringVar(&autoInstrumentationJava, "auto-instrumentation-java-image", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java:%s", v.AutoInstrumentationJava), "The default OpenTelemetry Java instrumentation image. This image is used when no image is specified in the CustomResource.") pflag.StringVar(&autoInstrumentationNodeJS, "auto-instrumentation-nodejs-image", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-nodejs:%s", v.AutoInstrumentationNodeJS), "The default OpenTelemetry NodeJS instrumentation image. This image is used when no image is specified in the CustomResource.") pflag.StringVar(&autoInstrumentationPython, "auto-instrumentation-python-image", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-python:%s", v.AutoInstrumentationPython), "The default OpenTelemetry Python instrumentation image. This image is used when no image is specified in the CustomResource.") + pflag.StringVar(&autoInstrumentationDotNet, "auto-instrumentation-dot-net", fmt.Sprintf("ghcr.io/logicmonitor/opentelemetry-operator/autoinstrumentation-dotnet:%s", v.AutoInstrumentationDotNet), "The default OpenTelemetry DotNet instrumentation image. This image is used when no image is specified in the CustomResource.") pflag.StringArrayVar(&labelsFilter, "labels", []string{}, "Labels to filter away from propagating onto deploys") pflag.Parse() @@ -106,6 +108,7 @@ func main() { "auto-instrumentation-java", autoInstrumentationJava, "auto-instrumentation-nodejs", autoInstrumentationNodeJS, "auto-instrumentation-python", autoInstrumentationPython, + "auto-instrumentation-dotnet", autoInstrumentationDotNet, "build-date", v.BuildDate, "go-version", v.Go, "go-arch", runtime.GOARCH, @@ -130,6 +133,7 @@ func main() { config.WithAutoInstrumentationJavaImage(autoInstrumentationJava), config.WithAutoInstrumentationNodeJSImage(autoInstrumentationNodeJS), config.WithAutoInstrumentationPythonImage(autoInstrumentationPython), + config.WithAutoInstrumentationDotNetImage(autoInstrumentationDotNet), config.WithAutoDetect(ad), config.WithLabelFilters(labelsFilter), ) @@ -198,6 +202,7 @@ func main() { otelv1alpha1.AnnotationDefaultAutoInstrumentationJava: autoInstrumentationJava, otelv1alpha1.AnnotationDefaultAutoInstrumentationNodeJS: autoInstrumentationNodeJS, otelv1alpha1.AnnotationDefaultAutoInstrumentationPython: autoInstrumentationPython, + otelv1alpha1.AnnotationDefaultAutoInstrumentationDotNet: autoInstrumentationDotNet, }, }, }).SetupWebhookWithManager(mgr); err != nil { @@ -259,6 +264,7 @@ func addDependencies(_ context.Context, mgr ctrl.Manager, cfg config.Config, v v Logger: ctrl.Log.WithName("instrumentation-upgrade"), DefaultAutoInstJava: cfg.AutoInstrumentationJavaImage(), DefaultAutoInstNodeJS: cfg.AutoInstrumentationJavaImage(), + DefaultAutoInstDotNet: cfg.AutoInstrumentationDotNetImage(), Client: mgr.GetClient(), } return u.ManagedInstances(c) diff --git a/pkg/instrumentation/annotation.go b/pkg/instrumentation/annotation.go index 8ce17a7c6f..e389806e32 100644 --- a/pkg/instrumentation/annotation.go +++ b/pkg/instrumentation/annotation.go @@ -26,6 +26,7 @@ const ( annotationInjectJava = "instrumentation.opentelemetry.io/inject-java" annotationInjectNodeJS = "instrumentation.opentelemetry.io/inject-nodejs" annotationInjectPython = "instrumentation.opentelemetry.io/inject-python" + annotationInjectDotNet = "instrumentation.opentelemetry.io/inject-dotnet" ) // annotationValue returns the effective annotationInjectJava value, based on the annotations from the pod and namespace. diff --git a/pkg/instrumentation/dotnet.go b/pkg/instrumentation/dotnet.go new file mode 100644 index 0000000000..5061a3a9d7 --- /dev/null +++ b/pkg/instrumentation/dotnet.go @@ -0,0 +1,115 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package instrumentation + +import ( + "fmt" + + "github.com/go-logr/logr" + corev1 "k8s.io/api/core/v1" + + "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" +) + +const ( + envDotNetAdditionalDeps = "DOTNET_ADDITIONAL_DEPS" + envDotNetSharedStore = "DOTNET_SHARED_STORE" + envDotNetStartupHook = "DOTNET_STARTUP_HOOKS" + dotNetAdditionalDepsPath = "./otel-auto-instrumentation/bin/tracer-home/AdditionalDeps" + dotNetSharedStorePath = "/otel-auto-instrumentation/bin/tracer-home/store" + dotNetStartupHookPath = "/otel-auto-instrumentation/bin/tracer-home/netcoreapp3.1/LMStartupHook.dll" +) + +func injectDotNetSDK(logger logr.Logger, dotNetSpec v1alpha1.DotNet, pod corev1.Pod) corev1.Pod { + // caller checks if there is at least one container + container := pod.Spec.Containers[0] + + // inject env vars + for _, env := range dotNetSpec.Env { + idx := getIndexOfEnv(container.Env, env.Name) + if idx == -1 { + container.Env = append(container.Env, env) + } + } + + idx := getIndexOfEnv(container.Env, envDotNetStartupHook) + if idx == -1 { + container.Env = append(container.Env, corev1.EnvVar{ + Name: envDotNetStartupHook, + Value: dotNetStartupHookPath, + }) + } else if idx > -1 { + if container.Env[idx].ValueFrom != nil { + // TODO add to status object or submit it as an event + logger.Info("Skipping DotNet SDK injection, the container defines DOTNET_STARTUP_HOOKS env var value via ValueFrom", "container", container.Name) + return pod + } + container.Env[idx].Value = fmt.Sprintf("%s:%s", container.Env[idx].Value, dotNetStartupHookPath) + } + + idx = getIndexOfEnv(container.Env, envDotNetAdditionalDeps) + if idx == -1 { + container.Env = append(container.Env, corev1.EnvVar{ + Name: envDotNetAdditionalDeps, + Value: dotNetAdditionalDepsPath, + }) + } else if idx > -1 { + if container.Env[idx].ValueFrom != nil { + // TODO add to status object or submit it as an event + logger.Info("Skipping DotNet SDK injection, the container defines DOTNET_ADDITIONAL_DEPS env var value via ValueFrom", "container", container.Name) + return pod + } + container.Env[idx].Value = fmt.Sprintf("%s:%s", container.Env[idx].Value, dotNetAdditionalDepsPath) + } + + idx = getIndexOfEnv(container.Env, envDotNetSharedStore) + if idx == -1 { + container.Env = append(container.Env, corev1.EnvVar{ + Name: envDotNetSharedStore, + Value: dotNetSharedStorePath, + }) + } else if idx > -1 { + if container.Env[idx].ValueFrom != nil { + // TODO add to status object or submit it as an event + logger.Info("Skipping DotNet SDK injection, the container defines DOTNET_SHARED_STORE env var value via ValueFrom", "container", container.Name) + return pod + } + container.Env[idx].Value = fmt.Sprintf("%s:%s", container.Env[idx].Value, dotNetSharedStorePath) + } + + container.VolumeMounts = append(container.VolumeMounts, corev1.VolumeMount{ + Name: volumeName, + MountPath: "/otel-auto-instrumentation", + }) + + pod.Spec.Volumes = append(pod.Spec.Volumes, corev1.Volume{ + Name: volumeName, + VolumeSource: corev1.VolumeSource{ + EmptyDir: &corev1.EmptyDirVolumeSource{}, + }}) + + pod.Spec.InitContainers = append(pod.Spec.InitContainers, corev1.Container{ + Name: initContainerName, + Image: dotNetSpec.Image, + Command: []string{"cp", "-a", "/autoinstrumentation/.", "/otel-auto-instrumentation/"}, + VolumeMounts: []corev1.VolumeMount{{ + Name: volumeName, + MountPath: "/otel-auto-instrumentation", + }}, + }) + + pod.Spec.Containers[0] = container + return pod +} diff --git a/pkg/instrumentation/dotnet_test.go b/pkg/instrumentation/dotnet_test.go new file mode 100644 index 0000000000..13f3c4680d --- /dev/null +++ b/pkg/instrumentation/dotnet_test.go @@ -0,0 +1,274 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package instrumentation + +import ( + "fmt" + "testing" + + "github.com/go-logr/logr" + "github.com/stretchr/testify/assert" + corev1 "k8s.io/api/core/v1" + + "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" +) + +func TestInjectDotNetSDK(t *testing.T) { + tests := []struct { + name string + v1alpha1.DotNet + pod corev1.Pod + expected corev1.Pod + }{ + { + name: "DOTNET_STARTUP_HOOKS, DOTNET_SHARED_STORE, DOTNET_ADDITIONAL_DEPS not defined", + DotNet: v1alpha1.DotNet{Image: "foo/bar:1", Env: []corev1.EnvVar{{Name: "OTEL_DOTNET_TRACER_INSTRUMENTATIONS", Value: "AspNet,HttpClient,SqlClient"}}}, + pod: corev1.Pod{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + {}, + }, + }, + }, + expected: corev1.Pod{ + Spec: corev1.PodSpec{ + Volumes: []corev1.Volume{ + { + Name: volumeName, + VolumeSource: corev1.VolumeSource{ + EmptyDir: &corev1.EmptyDirVolumeSource{}, + }, + }, + }, + InitContainers: []corev1.Container{ + { + Name: initContainerName, + Image: "foo/bar:1", + Command: []string{"cp", "-a", "/autoinstrumentation/.", "/otel-auto-instrumentation/"}, + VolumeMounts: []corev1.VolumeMount{{ + Name: volumeName, + MountPath: "/otel-auto-instrumentation", + }}, + }, + }, + Containers: []corev1.Container{ + { + VolumeMounts: []corev1.VolumeMount{ + { + Name: volumeName, + MountPath: "/otel-auto-instrumentation", + }, + }, + Env: []corev1.EnvVar{ + { + Name: "OTEL_DOTNET_TRACER_INSTRUMENTATIONS", + Value: "AspNet,HttpClient,SqlClient", + }, + { + Name: envDotNetStartupHook, + Value: dotNetStartupHookPath, + }, + { + Name: envDotNetAdditionalDeps, + Value: dotNetAdditionalDepsPath, + }, + { + Name: envDotNetSharedStore, + Value: dotNetSharedStorePath, + }, + }, + }, + }, + }, + }, + }, + { + name: "DOTNET_STARTUP_HOOKS, DOTNET_ADDITIONAL_DEPS, DOTNET_SHARED_STORE defined", + DotNet: v1alpha1.DotNet{Image: "foo/bar:1"}, + pod: corev1.Pod{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Env: []corev1.EnvVar{ + { + Name: envDotNetStartupHook, + Value: "/foo:/bar", + }, + { + Name: envDotNetAdditionalDeps, + Value: "/foo:/bar", + }, + { + Name: envDotNetSharedStore, + Value: "/foo:/bar", + }, + }, + }, + }, + }, + }, + expected: corev1.Pod{ + Spec: corev1.PodSpec{ + Volumes: []corev1.Volume{ + { + Name: volumeName, + VolumeSource: corev1.VolumeSource{ + EmptyDir: &corev1.EmptyDirVolumeSource{}, + }, + }, + }, + InitContainers: []corev1.Container{ + { + Name: initContainerName, + Image: "foo/bar:1", + Command: []string{"cp", "-a", "/autoinstrumentation/.", "/otel-auto-instrumentation/"}, + VolumeMounts: []corev1.VolumeMount{{ + Name: volumeName, + MountPath: "/otel-auto-instrumentation", + }}, + }, + }, + Containers: []corev1.Container{ + { + VolumeMounts: []corev1.VolumeMount{ + { + Name: volumeName, + MountPath: "/otel-auto-instrumentation", + }, + }, + Env: []corev1.EnvVar{ + { + Name: envDotNetStartupHook, + Value: fmt.Sprintf("%s:%s", "/foo:/bar", dotNetStartupHookPath), + }, + { + Name: envDotNetAdditionalDeps, + Value: fmt.Sprintf("%s:%s", "/foo:/bar", dotNetAdditionalDepsPath), + }, + { + Name: envDotNetSharedStore, + Value: fmt.Sprintf("%s:%s", "/foo:/bar", dotNetSharedStorePath), + }, + }, + }, + }, + }, + }, + }, + { + name: "DOTNET_STARTUP_HOOKS defined as ValueFrom", + DotNet: v1alpha1.DotNet{Image: "foo/bar:1"}, + pod: corev1.Pod{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Env: []corev1.EnvVar{ + { + Name: envDotNetStartupHook, + ValueFrom: &corev1.EnvVarSource{}, + }, + }, + }, + }, + }, + }, + expected: corev1.Pod{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Env: []corev1.EnvVar{ + { + Name: envDotNetStartupHook, + ValueFrom: &corev1.EnvVarSource{}, + }, + }, + }, + }, + }, + }, + }, + { + name: "DOTNET_ADDITIONAL_DEPS defined as ValueFrom", + DotNet: v1alpha1.DotNet{Image: "foo/bar:1"}, + pod: corev1.Pod{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Env: []corev1.EnvVar{ + { + Name: envDotNetAdditionalDeps, + ValueFrom: &corev1.EnvVarSource{}, + }, + }, + }, + }, + }, + }, + expected: corev1.Pod{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Env: []corev1.EnvVar{ + { + Name: envDotNetAdditionalDeps, + ValueFrom: &corev1.EnvVarSource{}, + }, + }, + }, + }, + }, + }, + }, + { + name: "DOTNET_SHARED_STORE defined as ValueFrom", + DotNet: v1alpha1.DotNet{Image: "foo/bar:1"}, + pod: corev1.Pod{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Env: []corev1.EnvVar{ + { + Name: envDotNetSharedStore, + ValueFrom: &corev1.EnvVarSource{}, + }, + }, + }, + }, + }, + }, + expected: corev1.Pod{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Env: []corev1.EnvVar{ + { + Name: envDotNetSharedStore, + ValueFrom: &corev1.EnvVarSource{}, + }, + }, + }, + }, + }, + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + pod := injectDotNetSDK(logr.Discard(), test.DotNet, test.pod) + assert.Equal(t, test.expected, pod) + }) + } +} diff --git a/pkg/instrumentation/podmutator.go b/pkg/instrumentation/podmutator.go index ba40d73b51..420951e57a 100644 --- a/pkg/instrumentation/podmutator.go +++ b/pkg/instrumentation/podmutator.go @@ -43,6 +43,7 @@ type languageInstrumentations struct { Java *v1alpha1.Instrumentation NodeJS *v1alpha1.Instrumentation Python *v1alpha1.Instrumentation + DotNet *v1alpha1.Instrumentation } var _ webhookhandler.PodMutator = (*instPodMutator)(nil) @@ -89,7 +90,14 @@ func (pm *instPodMutator) Mutate(ctx context.Context, ns corev1.Namespace, pod c } insts.Python = inst - if insts.Java == nil && insts.NodeJS == nil && insts.Python == nil { + if inst, err = pm.getInstrumentationInstance(ctx, ns, pod, annotationInjectDotNet); err != nil { + // we still allow the pod to be created, but we log a message to the operator's logs + logger.Error(err, "failed to select an OpenTelemetry Instrumentation instance for this pod") + return pod, err + } + insts.DotNet = inst + + if insts.Java == nil && insts.NodeJS == nil && insts.Python == nil && insts.DotNet == nil { logger.V(1).Info("annotation not present in deployment, skipping instrumentation injection") return pod, nil } diff --git a/pkg/instrumentation/podmutator_test.go b/pkg/instrumentation/podmutator_test.go index 00aa549c1b..92aa9945d2 100644 --- a/pkg/instrumentation/podmutator_test.go +++ b/pkg/instrumentation/podmutator_test.go @@ -549,6 +549,171 @@ func TestMutatePod(t *testing.T) { }, }, }, + { + name: "dotnet injection, true", + ns: corev1.Namespace{ + ObjectMeta: metav1.ObjectMeta{ + Name: "dotnet", + }, + }, + inst: v1alpha1.Instrumentation{ + ObjectMeta: metav1.ObjectMeta{ + Name: "example-inst", + Namespace: "dotnet", + }, + Spec: v1alpha1.InstrumentationSpec{ + DotNet: v1alpha1.DotNet{ + Image: "otel/dotnet:1", + Env: []corev1.EnvVar{ + { + Name: "OTEL_LOG_LEVEL", + Value: "debug", + }, + { + Name: "OTEL_EXPORTER_OTLP_ENDPOINT", + Value: "http://localhost:4317", + }, + }, + }, + Exporter: v1alpha1.Exporter{ + Endpoint: "http://collector:12345", + }, + Env: []corev1.EnvVar{ + { + Name: "OTEL_EXPORTER_OTLP_TIMEOUT", + Value: "20", + }, + { + Name: "OTEL_TRACES_SAMPLER", + Value: "parentbased_traceidratio", + }, + { + Name: "OTEL_TRACES_SAMPLER_ARG", + Value: "0.85", + }, + { + Name: "SPLUNK_TRACE_RESPONSE_HEADER_ENABLED", + Value: "true", + }, + }, + }, + }, + pod: corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{ + annotationInjectDotNet: "true", + }, + }, + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Name: "app", + }, + }, + }, + }, + expected: corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{ + annotationInjectDotNet: "true", + }, + }, + Spec: corev1.PodSpec{ + Volumes: []corev1.Volume{ + { + Name: "opentelemetry-auto-instrumentation", + VolumeSource: corev1.VolumeSource{ + EmptyDir: &corev1.EmptyDirVolumeSource{}, + }, + }, + }, + InitContainers: []corev1.Container{ + { + Name: initContainerName, + Image: "otel/dotnet:1", + Command: []string{"cp", "-a", "/autoinstrumentation/.", "/otel-auto-instrumentation/"}, + VolumeMounts: []corev1.VolumeMount{{ + Name: volumeName, + MountPath: "/otel-auto-instrumentation", + }}, + }, + }, + Containers: []corev1.Container{ + { + Name: "app", + Env: []corev1.EnvVar{ + { + Name: "OTEL_LOG_LEVEL", + Value: "debug", + }, + { + Name: "OTEL_EXPORTER_OTLP_ENDPOINT", + Value: "http://localhost:4317", + }, + { + Name: envDotNetStartupHook, + Value: dotNetStartupHookPath, + }, + { + Name: envDotNetAdditionalDeps, + Value: dotNetAdditionalDepsPath, + }, + { + Name: envDotNetSharedStore, + Value: dotNetSharedStorePath, + }, + { + Name: "OTEL_EXPORTER_OTLP_TIMEOUT", + Value: "20", + }, + { + Name: "OTEL_TRACES_SAMPLER", + Value: "parentbased_traceidratio", + }, + { + Name: "OTEL_TRACES_SAMPLER_ARG", + Value: "0.85", + }, + { + Name: "SPLUNK_TRACE_RESPONSE_HEADER_ENABLED", + Value: "true", + }, + { + Name: "OTEL_SERVICE_NAME", + Value: "app", + }, + { + Name: "OTEL_RESOURCE_ATTRIBUTES_POD_NAME", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "metadata.name", + }, + }, + }, + { + Name: "OTEL_RESOURCE_ATTRIBUTES_NODE_NAME", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "spec.nodeName", + }, + }, + }, + { + Name: "OTEL_RESOURCE_ATTRIBUTES", + Value: "k8s.container.name=app,k8s.namespace.name=dotnet,k8s.node.name=$(OTEL_RESOURCE_ATTRIBUTES_NODE_NAME),k8s.pod.name=$(OTEL_RESOURCE_ATTRIBUTES_POD_NAME)", + }, + }, + VolumeMounts: []corev1.VolumeMount{ + { + Name: "opentelemetry-auto-instrumentation", + MountPath: "/otel-auto-instrumentation", + }, + }, + }, + }, + }, + }, + }, { name: "missing annotation", ns: corev1.Namespace{ diff --git a/pkg/instrumentation/sdk.go b/pkg/instrumentation/sdk.go index 161e08ad29..14fe57b316 100644 --- a/pkg/instrumentation/sdk.go +++ b/pkg/instrumentation/sdk.go @@ -84,6 +84,13 @@ func (i *sdkInjector) inject(ctx context.Context, insts languageInstrumentations pod = i.injectCommonEnvVar(otelinst, pod) pod = i.injectCommonSDKConfig(ctx, otelinst, ns, pod) } + if insts.DotNet != nil { + otelinst := *insts.DotNet + i.logger.V(1).Info("injecting dotnet instrumentation into pod", "otelinst-namespace", otelinst.Namespace, "otelinst-name", otelinst.Name) + pod = injectDotNetSDK(i.logger, otelinst.Spec.DotNet, pod) + pod = i.injectCommonEnvVar(otelinst, pod) + pod = i.injectCommonSDKConfig(ctx, otelinst, ns, pod) + } return pod } diff --git a/pkg/instrumentation/sdk_test.go b/pkg/instrumentation/sdk_test.go index 4ee0e63c0f..7a78f6a0cc 100644 --- a/pkg/instrumentation/sdk_test.go +++ b/pkg/instrumentation/sdk_test.go @@ -670,3 +670,109 @@ func TestInjectPython(t *testing.T) { }, }, pod) } + +func TestInjectDotNet(t *testing.T) { + inst := v1alpha1.Instrumentation{ + Spec: v1alpha1.InstrumentationSpec{ + DotNet: v1alpha1.DotNet{ + Image: "img:1", + }, + Exporter: v1alpha1.Exporter{ + Endpoint: "https://collector:4318", + }, + }, + } + insts := languageInstrumentations{ + DotNet: &inst, + } + inj := sdkInjector{ + logger: logr.Discard(), + } + pod := inj.inject(context.Background(), insts, + corev1.Namespace{}, + corev1.Pod{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Name: "app", + }, + }, + }, + }) + assert.Equal(t, corev1.Pod{ + Spec: corev1.PodSpec{ + Volumes: []corev1.Volume{ + { + Name: volumeName, + VolumeSource: corev1.VolumeSource{ + EmptyDir: &corev1.EmptyDirVolumeSource{}, + }, + }, + }, + InitContainers: []corev1.Container{ + { + Name: initContainerName, + Image: "img:1", + Command: []string{"cp", "-a", "/autoinstrumentation/.", "/otel-auto-instrumentation/"}, + VolumeMounts: []corev1.VolumeMount{{ + Name: volumeName, + MountPath: "/otel-auto-instrumentation", + }}, + }, + }, + Containers: []corev1.Container{ + { + Name: "app", + VolumeMounts: []corev1.VolumeMount{ + { + Name: volumeName, + MountPath: "/otel-auto-instrumentation", + }, + }, + Env: []corev1.EnvVar{ + { + Name: envDotNetStartupHook, + Value: dotNetStartupHookPath, + }, + { + Name: envDotNetAdditionalDeps, + Value: dotNetAdditionalDepsPath, + }, + { + Name: envDotNetSharedStore, + Value: dotNetSharedStorePath, + }, + { + Name: "OTEL_SERVICE_NAME", + Value: "app", + }, + { + Name: "OTEL_EXPORTER_OTLP_ENDPOINT", + Value: "https://collector:4318", + }, + { + Name: "OTEL_RESOURCE_ATTRIBUTES_POD_NAME", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "metadata.name", + }, + }, + }, + { + Name: "OTEL_RESOURCE_ATTRIBUTES_NODE_NAME", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "spec.nodeName", + }, + }, + }, + { + Name: "OTEL_RESOURCE_ATTRIBUTES", + Value: "k8s.container.name=app,k8s.node.name=$(OTEL_RESOURCE_ATTRIBUTES_NODE_NAME),k8s.pod.name=$(OTEL_RESOURCE_ATTRIBUTES_POD_NAME)", + }, + }, + }, + }, + }, + }, pod) +} diff --git a/pkg/instrumentation/upgrade/upgrade.go b/pkg/instrumentation/upgrade/upgrade.go index 9a702cbf3f..65e7b6f774 100644 --- a/pkg/instrumentation/upgrade/upgrade.go +++ b/pkg/instrumentation/upgrade/upgrade.go @@ -30,6 +30,7 @@ type InstrumentationUpgrade struct { DefaultAutoInstJava string DefaultAutoInstNodeJS string DefaultAutoInstPython string + DefaultAutoInstDotNet string Client client.Client } @@ -92,5 +93,13 @@ func (u *InstrumentationUpgrade) upgrade(_ context.Context, inst v1alpha1.Instru inst.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationPython] = u.DefaultAutoInstPython } } + autoInstDotnet := inst.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationDotNet] + if autoInstDotnet != "" { + // upgrade the image only if the image matches the annotation + if inst.Spec.DotNet.Image == autoInstDotnet { + inst.Spec.DotNet.Image = u.DefaultAutoInstDotNet + inst.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationDotNet] = u.DefaultAutoInstDotNet + } + } return inst } diff --git a/pkg/instrumentation/upgrade/upgrade_test.go b/pkg/instrumentation/upgrade/upgrade_test.go index 07eb0a9332..89a1c251d5 100644 --- a/pkg/instrumentation/upgrade/upgrade_test.go +++ b/pkg/instrumentation/upgrade/upgrade_test.go @@ -46,6 +46,7 @@ func TestUpgrade(t *testing.T) { v1alpha1.AnnotationDefaultAutoInstrumentationJava: "java:1", v1alpha1.AnnotationDefaultAutoInstrumentationNodeJS: "nodejs:1", v1alpha1.AnnotationDefaultAutoInstrumentationPython: "python:1", + v1alpha1.AnnotationDefaultAutoInstrumentationDotNet: "dotnet:1", }, }, Spec: v1alpha1.InstrumentationSpec{ @@ -58,6 +59,7 @@ func TestUpgrade(t *testing.T) { assert.Equal(t, "java:1", inst.Spec.Java.Image) assert.Equal(t, "nodejs:1", inst.Spec.NodeJS.Image) assert.Equal(t, "python:1", inst.Spec.Python.Image) + assert.Equal(t, "dotnet:1", inst.Spec.DotNet.Image) err = k8sClient.Create(context.Background(), inst) require.NoError(t, err) @@ -66,6 +68,7 @@ func TestUpgrade(t *testing.T) { DefaultAutoInstJava: "java:2", DefaultAutoInstNodeJS: "nodejs:2", DefaultAutoInstPython: "python:2", + DefaultAutoInstDotNet: "dotnet:2", Client: k8sClient, } err = up.ManagedInstances(context.Background()) @@ -83,4 +86,6 @@ func TestUpgrade(t *testing.T) { assert.Equal(t, "nodejs:2", updated.Spec.NodeJS.Image) assert.Equal(t, "python:2", updated.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationPython]) assert.Equal(t, "python:2", updated.Spec.Python.Image) + assert.Equal(t, "dotnet:2", updated.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationDotNet]) + assert.Equal(t, "dotnet:2", updated.Spec.DotNet.Image) } diff --git a/tests/e2e/instrumentation-dotnet/00-install-collector.yaml b/tests/e2e/instrumentation-dotnet/00-install-collector.yaml new file mode 100644 index 0000000000..f8e1e98e07 --- /dev/null +++ b/tests/e2e/instrumentation-dotnet/00-install-collector.yaml @@ -0,0 +1,23 @@ +apiVersion: opentelemetry.io/v1alpha1 +kind: OpenTelemetryCollector +metadata: + name: sidecar +spec: + mode: sidecar + config: | + receivers: + otlp: + protocols: + grpc: + http: + processors: + + exporters: + logging: + + service: + pipelines: + traces: + receivers: [otlp] + processors: [] + exporters: [logging] diff --git a/tests/e2e/instrumentation-dotnet/00-install-instrumentation.yaml b/tests/e2e/instrumentation-dotnet/00-install-instrumentation.yaml new file mode 100644 index 0000000000..a2c1dd3f79 --- /dev/null +++ b/tests/e2e/instrumentation-dotnet/00-install-instrumentation.yaml @@ -0,0 +1,30 @@ +apiVersion: opentelemetry.io/v1alpha1 +kind: Instrumentation +metadata: + name: dotnet +spec: + env: + - name: OTEL_TRACES_EXPORTER + value: otlp + - name: OTEL_EXPORTER_OTLP_ENDPOINT + value: http://localhost:4317 + - name: OTEL_EXPORTER_OTLP_TIMEOUT + value: "20" + - name: OTEL_TRACES_SAMPLER + value: parentbased_traceidratio + - name: OTEL_TRACES_SAMPLER_ARG + value: "0.85" + - name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED + value: "true" + exporter: + endpoint: http://localhost:4317 + propagators: + - jaeger + - b3 + sampler: + type: parentbased_traceidratio + argument: "0.25" + dotnet: + env: + - name: OTEL_DOTNET_TRACER_INSTRUMENTATIONS + value: AspNet,HttpClient,SqlClient diff --git a/tests/e2e/instrumentation-dotnet/01-assert.yaml b/tests/e2e/instrumentation-dotnet/01-assert.yaml new file mode 100644 index 0000000000..2f81e05b82 --- /dev/null +++ b/tests/e2e/instrumentation-dotnet/01-assert.yaml @@ -0,0 +1,48 @@ +apiVersion: v1 +kind: Pod +metadata: + annotations: + sidecar.opentelemetry.io/inject: "true" + instrumentation.opentelemetry.io/inject-java: "true" + labels: + app: my-pod-with-sidecar +spec: + containers: + - name: myapp + env: + - name: OTEL_DOTNET_TRACER_INSTRUMENTATIONS + value: AspNet,HttpClient,SqlClient + - name: DOTNET_STARTUP_HOOKS + value: "/otel-auto-instrumentation/bin/tracer-home/netcoreapp3.1/LMStartupHook.dll" + - name: DOTNET_ADDITIONAL_DEPS + value: ./otel-auto-instrumentation/bin/tracer-home/AdditionalDeps + - name: DOTNET_SHARED_STORE + value: /otel-auto-instrumentation/bin/tracer-home/store + - name: OTEL_TRACES_EXPORTER + value: otlp + - name: OTEL_EXPORTER_OTLP_ENDPOINT + value: http://localhost:4317 + - name: OTEL_EXPORTER_OTLP_TIMEOUT + value: "20" + - name: OTEL_TRACES_SAMPLER + value: parentbased_traceidratio + - name: OTEL_TRACES_SAMPLER_ARG + value: "0.85" + - name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED + value: "true" + - name: OTEL_SERVICE_NAME + value: my-deployment-with-sidecar + - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME + - name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME + - name: OTEL_RESOURCE_ATTRIBUTES + - name: OTEL_PROPAGATORS + value: jaeger,b3 + volumeMounts: + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - mountPath: /otel-auto-instrumentation + name: opentelemetry-auto-instrumentation + - name: otc-container + initContainers: + - name: opentelemetry-auto-instrumentation +status: + phase: Running diff --git a/tests/e2e/instrumentation-dotnet/01-install-app.yaml b/tests/e2e/instrumentation-dotnet/01-install-app.yaml new file mode 100644 index 0000000000..f259251d41 --- /dev/null +++ b/tests/e2e/instrumentation-dotnet/01-install-app.yaml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: my-deployment-with-sidecar +spec: + selector: + matchLabels: + app: my-pod-with-sidecar + replicas: 1 + template: + metadata: + labels: + app: my-pod-with-sidecar + annotations: + sidecar.opentelemetry.io/inject: "true" + instrumentation.opentelemetry.io/inject-dotnet: "true" + spec: + securityContext: + runAsUser: 1000 + runAsGroup: 3000 + fsGroup: 2000 + containers: + - name: myapp + image: ghcr.io/pavolloffay/spring-petclinic:latest diff --git a/versions.txt b/versions.txt index c5d17b581c..e5a1bdb9c0 100644 --- a/versions.txt +++ b/versions.txt @@ -21,3 +21,7 @@ autoinstrumentation-nodejs=0.27.0 # Represents the current release of Python instrumentation. # Should match value in autoinstrumentation/python/requirements.txt autoinstrumentation-python=0.28b1 + +# Represents the current release of DotNet instrumentation. +# Should match autoinstrumentation/dotnet/version.txt +autoinstrumentation-dotnet=0.0.1 From 713a17eb2c484f1a6445658d113512d2061f97da Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Tue, 12 Apr 2022 14:46:26 +0530 Subject: [PATCH 02/33] changes default image for testing --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index adc988226b..c3eedb6db3 100644 --- a/main.go +++ b/main.go @@ -94,7 +94,7 @@ func main() { pflag.StringVar(&autoInstrumentationJava, "auto-instrumentation-java-image", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java:%s", v.AutoInstrumentationJava), "The default OpenTelemetry Java instrumentation image. This image is used when no image is specified in the CustomResource.") pflag.StringVar(&autoInstrumentationNodeJS, "auto-instrumentation-nodejs-image", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-nodejs:%s", v.AutoInstrumentationNodeJS), "The default OpenTelemetry NodeJS instrumentation image. This image is used when no image is specified in the CustomResource.") pflag.StringVar(&autoInstrumentationPython, "auto-instrumentation-python-image", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-python:%s", v.AutoInstrumentationPython), "The default OpenTelemetry Python instrumentation image. This image is used when no image is specified in the CustomResource.") - pflag.StringVar(&autoInstrumentationDotNet, "auto-instrumentation-dot-net", fmt.Sprintf("ghcr.io/logicmonitor/opentelemetry-operator/autoinstrumentation-dotnet:%s", v.AutoInstrumentationDotNet), "The default OpenTelemetry DotNet instrumentation image. This image is used when no image is specified in the CustomResource.") + pflag.StringVar(&autoInstrumentationDotNet, "auto-instrumentation-dot-net", fmt.Sprintf("ghcr.io/avadhut123pisal/opentelemetry-operator/autoinstrumentation-dotnet:%s", v.AutoInstrumentationDotNet), "The default OpenTelemetry DotNet instrumentation image. This image is used when no image is specified in the CustomResource.") pflag.StringArrayVar(&labelsFilter, "labels", []string{}, "Labels to filter away from propagating onto deploys") pflag.Parse() From 16d05aed8651f1fe98523a7e562fb27554bf4430 Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Tue, 12 Apr 2022 15:12:23 +0530 Subject: [PATCH 03/33] adds dotnet auto-instrumentation to the ldflags in makefile --- Makefile | 2 +- config/manager/kustomization.yaml | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b44082eacb..9c79b06097 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ AUTO_INSTRUMENTATION_JAVA_VERSION ?= "$(shell grep -v '\#' versions.txt | grep a AUTO_INSTRUMENTATION_NODEJS_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-nodejs | awk -F= '{print $$2}')" AUTO_INSTRUMENTATION_PYTHON_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-python | awk -F= '{print $$2}')" AUTO_INSTRUMENTATION_DOTNET_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-dotnet | awk -F= '{print $$2}')" -LD_FLAGS ?= "-X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.buildDate=${VERSION_DATE} -X ${VERSION_PKG}.otelCol=${OTELCOL_VERSION} -X ${VERSION_PKG}.targetAllocator=${TARGETALLOCATOR_VERSION} -X ${VERSION_PKG}.autoInstrumentationJava=${AUTO_INSTRUMENTATION_JAVA_VERSION} -X ${VERSION_PKG}.autoInstrumentationNodeJS=${AUTO_INSTRUMENTATION_NODEJS_VERSION} -X ${VERSION_PKG}.autoInstrumentationPython=${AUTO_INSTRUMENTATION_PYTHON_VERSION}" +LD_FLAGS ?= "-X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.buildDate=${VERSION_DATE} -X ${VERSION_PKG}.otelCol=${OTELCOL_VERSION} -X ${VERSION_PKG}.targetAllocator=${TARGETALLOCATOR_VERSION} -X ${VERSION_PKG}.autoInstrumentationJava=${AUTO_INSTRUMENTATION_JAVA_VERSION} -X ${VERSION_PKG}.autoInstrumentationNodeJS=${AUTO_INSTRUMENTATION_NODEJS_VERSION} -X ${VERSION_PKG}.autoInstrumentationPython=${AUTO_INSTRUMENTATION_PYTHON_VERSION} -X ${VERSION_PKG}.autoInstrumentationDotnet=${AUTO_INSTRUMENTATION_DOTNET_VERSION}" # Image URL to use all building/pushing image targets IMG_PREFIX ?= ghcr.io/${USER}/opentelemetry-operator diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 7394a6d059..8b32672890 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -1,2 +1,8 @@ resources: - - manager.yaml +- manager.yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +images: +- name: controller + newName: ghcr.io/avadhut123pisal/opentelemetry-operator/opentelemetry-operator + newTag: 0.48.0 From 89295de4912ea30b4e19d38bfa785bef16bf9369 Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Tue, 12 Apr 2022 15:24:11 +0530 Subject: [PATCH 04/33] changes in Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9c79b06097..a2436ed5e2 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,7 @@ endif .PHONY: ensure-generate-is-noop ensure-generate-is-noop: VERSION=$(OPERATOR_VERSION) -ensure-generate-is-noop: USER=open-telemetry +ensure-generate-is-noop: USER=avadhut123pisal ensure-generate-is-noop: set-image-controller generate bundle @# on make bundle config/manager/kustomization.yaml includes changes, which should be ignored for the below check @git restore config/manager/kustomization.yaml From ac57c4a35f90eae59dc5ea2a0a17bf77b224bdb2 Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Tue, 12 Apr 2022 17:39:31 +0530 Subject: [PATCH 05/33] fixes issue in makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a2436ed5e2..d1cf064c02 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ AUTO_INSTRUMENTATION_JAVA_VERSION ?= "$(shell grep -v '\#' versions.txt | grep a AUTO_INSTRUMENTATION_NODEJS_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-nodejs | awk -F= '{print $$2}')" AUTO_INSTRUMENTATION_PYTHON_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-python | awk -F= '{print $$2}')" AUTO_INSTRUMENTATION_DOTNET_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-dotnet | awk -F= '{print $$2}')" -LD_FLAGS ?= "-X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.buildDate=${VERSION_DATE} -X ${VERSION_PKG}.otelCol=${OTELCOL_VERSION} -X ${VERSION_PKG}.targetAllocator=${TARGETALLOCATOR_VERSION} -X ${VERSION_PKG}.autoInstrumentationJava=${AUTO_INSTRUMENTATION_JAVA_VERSION} -X ${VERSION_PKG}.autoInstrumentationNodeJS=${AUTO_INSTRUMENTATION_NODEJS_VERSION} -X ${VERSION_PKG}.autoInstrumentationPython=${AUTO_INSTRUMENTATION_PYTHON_VERSION} -X ${VERSION_PKG}.autoInstrumentationDotnet=${AUTO_INSTRUMENTATION_DOTNET_VERSION}" +LD_FLAGS ?= "-X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.buildDate=${VERSION_DATE} -X ${VERSION_PKG}.otelCol=${OTELCOL_VERSION} -X ${VERSION_PKG}.targetAllocator=${TARGETALLOCATOR_VERSION} -X ${VERSION_PKG}.autoInstrumentationJava=${AUTO_INSTRUMENTATION_JAVA_VERSION} -X ${VERSION_PKG}.autoInstrumentationNodeJS=${AUTO_INSTRUMENTATION_NODEJS_VERSION} -X ${VERSION_PKG}.autoInstrumentationPython=${AUTO_INSTRUMENTATION_PYTHON_VERSION} -X ${VERSION_PKG}.autoInstrumentationDotNet=${AUTO_INSTRUMENTATION_DOTNET_VERSION}" # Image URL to use all building/pushing image targets IMG_PREFIX ?= ghcr.io/${USER}/opentelemetry-operator From c07be13979953654c990bcf3a2c4351422f136f3 Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Tue, 12 Apr 2022 17:55:39 +0530 Subject: [PATCH 06/33] fixes issue in dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 655c11c10a..4c7d8f34e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,7 @@ ARG AUTO_INSTRUMENTATION_PYTHON_VERSION ARG AUTO_INSTRUMENTATION_DOTNET_VERSION # Build -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -ldflags="-X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.buildDate=${VERSION_DATE} -X ${VERSION_PKG}.otelCol=${OTELCOL_VERSION} -X ${VERSION_PKG}.targetAllocator=${TARGETALLOCATOR_VERSION} -X ${VERSION_PKG}.autoInstrumentationJava=${AUTO_INSTRUMENTATION_JAVA_VERSION} -X ${VERSION_PKG}.autoInstrumentationNodeJS=${AUTO_INSTRUMENTATION_NODEJS_VERSION} -X ${VERSION_PKG}.autoInstrumentationPython=${AUTO_INSTRUMENTATION_PYTHON_VERSION} -X ${VERSION_PKG}.autoInstrumentationDotnet=${AUTO_INSTRUMENTATION_DOTNET_VERSION}" -a -o manager main.go +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -ldflags="-X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.buildDate=${VERSION_DATE} -X ${VERSION_PKG}.otelCol=${OTELCOL_VERSION} -X ${VERSION_PKG}.targetAllocator=${TARGETALLOCATOR_VERSION} -X ${VERSION_PKG}.autoInstrumentationJava=${AUTO_INSTRUMENTATION_JAVA_VERSION} -X ${VERSION_PKG}.autoInstrumentationNodeJS=${AUTO_INSTRUMENTATION_NODEJS_VERSION} -X ${VERSION_PKG}.autoInstrumentationPython=${AUTO_INSTRUMENTATION_PYTHON_VERSION} -X ${VERSION_PKG}.autoInstrumentationDotNet=${AUTO_INSTRUMENTATION_DOTNET_VERSION}" -a -o manager main.go # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details From e75108b9cbc2c4f8335b27c9b764e197c3cc6ed8 Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Tue, 12 Apr 2022 18:24:09 +0530 Subject: [PATCH 07/33] passes dotnet sample app image to e2e test --- tests/e2e/instrumentation-dotnet/01-install-app.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/instrumentation-dotnet/01-install-app.yaml b/tests/e2e/instrumentation-dotnet/01-install-app.yaml index f259251d41..15c652bac4 100644 --- a/tests/e2e/instrumentation-dotnet/01-install-app.yaml +++ b/tests/e2e/instrumentation-dotnet/01-install-app.yaml @@ -21,4 +21,4 @@ spec: fsGroup: 2000 containers: - name: myapp - image: ghcr.io/pavolloffay/spring-petclinic:latest + image: docker.io/adib070/mvc From cd917687ab920ffb3b0df4e3762a1fe8c8178ce0 Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Wed, 13 Apr 2022 10:45:54 +0530 Subject: [PATCH 08/33] fixes version in the dot net autoinstrumentation version file --- autoinstrumentation/dotnet/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoinstrumentation/dotnet/version.txt b/autoinstrumentation/dotnet/version.txt index 8a9ecc2ea9..93a33ab427 100644 --- a/autoinstrumentation/dotnet/version.txt +++ b/autoinstrumentation/dotnet/version.txt @@ -1 +1 @@ -0.0.1 \ No newline at end of file +0.0.1-alpha \ No newline at end of file From 96c4ed6b50629a4f976ba6819d8f98ffb62fcb8c Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Thu, 21 Apr 2022 19:01:23 +0530 Subject: [PATCH 09/33] adds testing changes for dot-net-autoinstrumentation --- autoinstrumentation/dotnet/Dockerfile | 10 ++++++---- versions.txt | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/autoinstrumentation/dotnet/Dockerfile b/autoinstrumentation/dotnet/Dockerfile index 56f7d0b6c0..ef5e02c6e4 100644 --- a/autoinstrumentation/dotnet/Dockerfile +++ b/autoinstrumentation/dotnet/Dockerfile @@ -4,12 +4,14 @@ # - Grant the necessary access to the files in the `/autoinstrumentation` directory. FROM busybox +ARG version + WORKDIR /autoinstrumentation -ARG version +# ADD https://github.com/logicmonitor/lm-telemetry-sdk-dotnet/releases/download/$version/lm-telemetry-dotnet-instrumentation-$version.zip lm-telemetry-dotnet-instrumentation-$version.zip -ADD https://github.com/logicmonitor/lm-telemetry-sdk-dotnet/releases/download/$version/lm-telemetry-dotnet-instrumentation-$version.zip . +COPY tracer-home_all-signed.tar.gz . -RUN tar -xvf lm-telemetry-dotnet-instrumentation-$version.zip && rm lm-telemetry-dotnet-instrumentation-$version.zip +RUN tar -xvf tracer-home_all-signed.tar.gz -RUN chmod -R go+r . \ No newline at end of file +RUN chmod -R go+r bin/ \ No newline at end of file diff --git a/versions.txt b/versions.txt index e5a1bdb9c0..43e1ebd5ed 100644 --- a/versions.txt +++ b/versions.txt @@ -24,4 +24,4 @@ autoinstrumentation-python=0.28b1 # Represents the current release of DotNet instrumentation. # Should match autoinstrumentation/dotnet/version.txt -autoinstrumentation-dotnet=0.0.1 +autoinstrumentation-dotnet=0.0.1-alpha From 0204ae02b45b4725f4769cd809f65a8498e14ade Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Fri, 22 Apr 2022 12:19:56 +0530 Subject: [PATCH 10/33] fixes annotation --- tests/e2e/instrumentation-dotnet/01-assert.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/instrumentation-dotnet/01-assert.yaml b/tests/e2e/instrumentation-dotnet/01-assert.yaml index 2f81e05b82..eef6a93573 100644 --- a/tests/e2e/instrumentation-dotnet/01-assert.yaml +++ b/tests/e2e/instrumentation-dotnet/01-assert.yaml @@ -3,7 +3,7 @@ kind: Pod metadata: annotations: sidecar.opentelemetry.io/inject: "true" - instrumentation.opentelemetry.io/inject-java: "true" + instrumentation.opentelemetry.io/inject-dotnet: "true" labels: app: my-pod-with-sidecar spec: From b010bda82136b9ef23d429149bc5d17fea001a15 Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Fri, 22 Apr 2022 14:10:06 +0530 Subject: [PATCH 11/33] downloads dot-net release from github --- autoinstrumentation/dotnet/Dockerfile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/autoinstrumentation/dotnet/Dockerfile b/autoinstrumentation/dotnet/Dockerfile index ef5e02c6e4..9a15a272e4 100644 --- a/autoinstrumentation/dotnet/Dockerfile +++ b/autoinstrumentation/dotnet/Dockerfile @@ -8,10 +8,8 @@ ARG version WORKDIR /autoinstrumentation -# ADD https://github.com/logicmonitor/lm-telemetry-sdk-dotnet/releases/download/$version/lm-telemetry-dotnet-instrumentation-$version.zip lm-telemetry-dotnet-instrumentation-$version.zip +ADD https://github.com/logicmonitor/lm-telemetry-sdk-dotnet/releases/download/$version/lm-telemetry-dotnet-instrumentation-$version.zip . -COPY tracer-home_all-signed.tar.gz . +RUN tar -xvf lm-telemetry-dotnet-instrumentation-$version.zip -RUN tar -xvf tracer-home_all-signed.tar.gz - -RUN chmod -R go+r bin/ \ No newline at end of file +RUN chmod -R go+r . \ No newline at end of file From d34e3bd23e79df7a3de0afb6c0ff0f9f7c3a7831 Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Fri, 22 Apr 2022 14:49:21 +0530 Subject: [PATCH 12/33] removes git push condition check --- .github/workflows/publish-autoinstrumentation-dotnet.yaml | 2 +- .github/workflows/publish-images.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-autoinstrumentation-dotnet.yaml b/.github/workflows/publish-autoinstrumentation-dotnet.yaml index e97f4043db..56b803179c 100644 --- a/.github/workflows/publish-autoinstrumentation-dotnet.yaml +++ b/.github/workflows/publish-autoinstrumentation-dotnet.yaml @@ -42,7 +42,7 @@ jobs: uses: docker/build-push-action@v2.10.0 with: context: autoinstrumentation/dotnet - push: ${{ github.event_name == 'push' }} + # push: ${{ github.event_name == 'push' }} build-args: version=${{ env.VERSION }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/publish-images.yaml b/.github/workflows/publish-images.yaml index 6b8628fe0f..f779f61eae 100644 --- a/.github/workflows/publish-images.yaml +++ b/.github/workflows/publish-images.yaml @@ -69,7 +69,7 @@ jobs: context: . file: ./Dockerfile platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} + # push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.docker_meta.outputs.tags }} labels: ${{ steps.docker_meta.outputs.labels }} build-args: | From de99d8d33e82de204a85985172c387f7262e4668 Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Fri, 22 Apr 2022 14:53:50 +0530 Subject: [PATCH 13/33] removes git push condition check --- .github/workflows/publish-autoinstrumentation-dotnet.yaml | 1 + .github/workflows/publish-images.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/publish-autoinstrumentation-dotnet.yaml b/.github/workflows/publish-autoinstrumentation-dotnet.yaml index 56b803179c..48f192fe03 100644 --- a/.github/workflows/publish-autoinstrumentation-dotnet.yaml +++ b/.github/workflows/publish-autoinstrumentation-dotnet.yaml @@ -43,6 +43,7 @@ jobs: with: context: autoinstrumentation/dotnet # push: ${{ github.event_name == 'push' }} + push: true build-args: version=${{ env.VERSION }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/publish-images.yaml b/.github/workflows/publish-images.yaml index f779f61eae..d828da8ac6 100644 --- a/.github/workflows/publish-images.yaml +++ b/.github/workflows/publish-images.yaml @@ -70,6 +70,7 @@ jobs: file: ./Dockerfile platforms: linux/amd64,linux/arm64 # push: ${{ github.event_name != 'pull_request' }} + push: true tags: ${{ steps.docker_meta.outputs.tags }} labels: ${{ steps.docker_meta.outputs.labels }} build-args: | From 554296f50d15597217eb9e5b9ee9865534864754 Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Fri, 22 Apr 2022 17:29:28 +0530 Subject: [PATCH 14/33] changes repo to logicmonitor --- .github/workflows/publish-autoinstrumentation-dotnet.yaml | 2 +- .github/workflows/publish-autoinstrumentation-java.yaml | 2 +- .github/workflows/publish-autoinstrumentation-nodejs.yaml | 2 +- .github/workflows/publish-autoinstrumentation-python.yaml | 2 +- .github/workflows/publish-images.yaml | 2 +- .github/workflows/publish-target-allocator.yaml | 2 +- .github/workflows/release.yaml | 4 ++-- Makefile | 2 +- .../opentelemetry-operator.clusterserviceversion.yaml | 4 ++-- config/manager/kustomization.yaml | 2 +- .../bases/opentelemetry-operator.clusterserviceversion.yaml | 2 +- main.go | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/publish-autoinstrumentation-dotnet.yaml b/.github/workflows/publish-autoinstrumentation-dotnet.yaml index 48f192fe03..8890f8030a 100644 --- a/.github/workflows/publish-autoinstrumentation-dotnet.yaml +++ b/.github/workflows/publish-autoinstrumentation-dotnet.yaml @@ -27,7 +27,7 @@ jobs: id: meta uses: docker/metadata-action@v3.7.0 with: - images: ghcr.io/avadhut123pisal/opentelemetry-operator/autoinstrumentation-dotnet + images: ghcr.io/logicmonitor/opentelemetry-operator/autoinstrumentation-dotnet tags: | type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} diff --git a/.github/workflows/publish-autoinstrumentation-java.yaml b/.github/workflows/publish-autoinstrumentation-java.yaml index 62d09c97fe..e5329afbcc 100644 --- a/.github/workflows/publish-autoinstrumentation-java.yaml +++ b/.github/workflows/publish-autoinstrumentation-java.yaml @@ -27,7 +27,7 @@ jobs: id: meta uses: docker/metadata-action@v3.7.0 with: - images: ghcr.io/avadhut123pisal/opentelemetry-operator/autoinstrumentation-java + images: ghcr.io/logicmonitor/opentelemetry-operator/autoinstrumentation-java tags: | type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} diff --git a/.github/workflows/publish-autoinstrumentation-nodejs.yaml b/.github/workflows/publish-autoinstrumentation-nodejs.yaml index 542bcffcc1..c3024263c9 100644 --- a/.github/workflows/publish-autoinstrumentation-nodejs.yaml +++ b/.github/workflows/publish-autoinstrumentation-nodejs.yaml @@ -27,7 +27,7 @@ jobs: id: meta uses: docker/metadata-action@v3.7.0 with: - images: ghcr.io/avadhut123pisal/opentelemetry-operator/autoinstrumentation-nodejs + images: ghcr.io/logicmonitor/opentelemetry-operator/autoinstrumentation-nodejs tags: | type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} diff --git a/.github/workflows/publish-autoinstrumentation-python.yaml b/.github/workflows/publish-autoinstrumentation-python.yaml index 9235589b66..29d576b249 100644 --- a/.github/workflows/publish-autoinstrumentation-python.yaml +++ b/.github/workflows/publish-autoinstrumentation-python.yaml @@ -27,7 +27,7 @@ jobs: id: meta uses: docker/metadata-action@v3.7.0 with: - images: ghcr.io/avadhut123pisal/opentelemetry-operator/autoinstrumentation-python + images: ghcr.io/logicmonitor/opentelemetry-operator/autoinstrumentation-python tags: | type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} diff --git a/.github/workflows/publish-images.yaml b/.github/workflows/publish-images.yaml index d828da8ac6..f55e108ba6 100644 --- a/.github/workflows/publish-images.yaml +++ b/.github/workflows/publish-images.yaml @@ -35,7 +35,7 @@ jobs: id: docker_meta uses: docker/metadata-action@v3.7.0 with: - images: ghcr.io/avadhut123pisal/opentelemetry-operator/opentelemetry-operator + images: ghcr.io/logicmonitor/opentelemetry-operator/opentelemetry-operator tags: | type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} diff --git a/.github/workflows/publish-target-allocator.yaml b/.github/workflows/publish-target-allocator.yaml index b072e59fad..f5f7be9029 100644 --- a/.github/workflows/publish-target-allocator.yaml +++ b/.github/workflows/publish-target-allocator.yaml @@ -23,7 +23,7 @@ jobs: id: meta uses: docker/metadata-action@v3.7.0 with: - images: ghcr.io/avadhut123pisal/opentelemetry-operator/target-allocator + images: ghcr.io/logicmonitor/opentelemetry-operator/target-allocator tags: | type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 640163ae90..c9a4cd5623 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -21,7 +21,7 @@ jobs: run: ./hack/install-kustomize.sh - name: "generate release resources" - run: make release-artifacts IMG_PREFIX="ghcr.io/avadhut123pisal/opentelemetry-operator" + run: make release-artifacts IMG_PREFIX="ghcr.io/logicmonitor/opentelemetry-operator" - name: "create the release in GitHub" env: @@ -31,4 +31,4 @@ jobs: - name: "refresh go proxy module info on release" run: | OPERATOR_VERSION=$(git describe --tags) - curl https://proxy.golang.org/github.com/avadhut123pisal/opentelemetry-operator/@v/${OPERATOR_VERSION}.info + curl https://proxy.golang.org/github.com/logicmonitor/opentelemetry-operator/@v/${OPERATOR_VERSION}.info diff --git a/Makefile b/Makefile index d1cf064c02..0083b94b00 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,7 @@ endif .PHONY: ensure-generate-is-noop ensure-generate-is-noop: VERSION=$(OPERATOR_VERSION) -ensure-generate-is-noop: USER=avadhut123pisal +ensure-generate-is-noop: USER=logicmonitor ensure-generate-is-noop: set-image-controller generate bundle @# on make bundle config/manager/kustomization.yaml includes changes, which should be ignored for the below check @git restore config/manager/kustomization.yaml diff --git a/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml index b87809c9f7..036d7bd43f 100644 --- a/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -30,7 +30,7 @@ metadata: capabilities: Basic Install categories: Logging & Tracing certified: "false" - containerImage: ghcr.io/avadhut123pisal/opentelemetry-operator/opentelemetry-operator + containerImage: ghcr.io/logicmonitor/opentelemetry-operator/opentelemetry-operator createdAt: "2020-12-16T13:37:00+00:00" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.16.0+git @@ -297,7 +297,7 @@ spec: - args: - --metrics-addr=127.0.0.1:8080 - --enable-leader-election - image: ghcr.io/avadhut123pisal/opentelemetry-operator/opentelemetry-operator:0.48.0 + image: ghcr.io/logicmonitor/opentelemetry-operator/opentelemetry-operator:0.48.0 livenessProbe: httpGet: path: /healthz diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 8b32672890..718f081c19 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: - name: controller - newName: ghcr.io/avadhut123pisal/opentelemetry-operator/opentelemetry-operator + newName: ghcr.io/logicmonitor/opentelemetry-operator/opentelemetry-operator newTag: 0.48.0 diff --git a/config/manifests/bases/opentelemetry-operator.clusterserviceversion.yaml b/config/manifests/bases/opentelemetry-operator.clusterserviceversion.yaml index 2b3c8f042c..3d33ef4350 100644 --- a/config/manifests/bases/opentelemetry-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/opentelemetry-operator.clusterserviceversion.yaml @@ -6,7 +6,7 @@ metadata: capabilities: Basic Install categories: Logging & Tracing certified: "false" - containerImage: ghcr.io/avadhut123pisal/opentelemetry-operator/opentelemetry-operator + containerImage: ghcr.io/logicmonitor/opentelemetry-operator/opentelemetry-operator createdAt: "2020-12-16T13:37:00+00:00" description: Provides the OpenTelemetry components, including the Collector repository: github.com/open-telemetry/opentelemetry-operator diff --git a/main.go b/main.go index c3eedb6db3..adc988226b 100644 --- a/main.go +++ b/main.go @@ -94,7 +94,7 @@ func main() { pflag.StringVar(&autoInstrumentationJava, "auto-instrumentation-java-image", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java:%s", v.AutoInstrumentationJava), "The default OpenTelemetry Java instrumentation image. This image is used when no image is specified in the CustomResource.") pflag.StringVar(&autoInstrumentationNodeJS, "auto-instrumentation-nodejs-image", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-nodejs:%s", v.AutoInstrumentationNodeJS), "The default OpenTelemetry NodeJS instrumentation image. This image is used when no image is specified in the CustomResource.") pflag.StringVar(&autoInstrumentationPython, "auto-instrumentation-python-image", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-python:%s", v.AutoInstrumentationPython), "The default OpenTelemetry Python instrumentation image. This image is used when no image is specified in the CustomResource.") - pflag.StringVar(&autoInstrumentationDotNet, "auto-instrumentation-dot-net", fmt.Sprintf("ghcr.io/avadhut123pisal/opentelemetry-operator/autoinstrumentation-dotnet:%s", v.AutoInstrumentationDotNet), "The default OpenTelemetry DotNet instrumentation image. This image is used when no image is specified in the CustomResource.") + pflag.StringVar(&autoInstrumentationDotNet, "auto-instrumentation-dot-net", fmt.Sprintf("ghcr.io/logicmonitor/opentelemetry-operator/autoinstrumentation-dotnet:%s", v.AutoInstrumentationDotNet), "The default OpenTelemetry DotNet instrumentation image. This image is used when no image is specified in the CustomResource.") pflag.StringArrayVar(&labelsFilter, "labels", []string{}, "Labels to filter away from propagating onto deploys") pflag.Parse() From 9d3caae8a4801a480c4fb8370697d2c66c6f833e Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Mon, 25 Apr 2022 15:26:08 +0530 Subject: [PATCH 15/33] adds dontnet auto-instrumentation related details in readme --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 95adad872a..411fa217ee 100644 --- a/README.md +++ b/README.md @@ -210,6 +210,11 @@ Python: instrumentation.opentelemetry.io/inject-python: "true" ``` +DotNet: +```bash +instrumentation.opentelemetry.io/inject-dotnet: "true" +``` + The possible values for the annotation can be * `"true"` - inject and `Instrumentation` resource from the namespace. * `"my-instrumentation"` - name of `Instrumentation` CR instance. @@ -232,6 +237,8 @@ spec: image: your-customized-auto-instrumentation-image:nodejs python: image: your-customized-auto-instrumentation-image:python + dotnet: + image: your-customized-auto-instrumentation-image:dotnet ``` The Dockerfiles for auto-instrumentation can be found in [autoinstrumentation directory](./autoinstrumentation). From d29eddb2043553f65a6f70952d4cf97afbe705c5 Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Tue, 26 Apr 2022 11:08:38 +0530 Subject: [PATCH 16/33] adds docker image layer caching in github action --- .../publish-autoinstrumentation-dotnet.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/publish-autoinstrumentation-dotnet.yaml b/.github/workflows/publish-autoinstrumentation-dotnet.yaml index 8890f8030a..078a36216e 100644 --- a/.github/workflows/publish-autoinstrumentation-dotnet.yaml +++ b/.github/workflows/publish-autoinstrumentation-dotnet.yaml @@ -30,6 +30,20 @@ jobs: images: ghcr.io/logicmonitor/opentelemetry-operator/autoinstrumentation-dotnet tags: | type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1.2.0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1.6.0 + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- - name: Login to GitHub Package Registry uses: docker/login-action@v1.14.1 @@ -42,8 +56,11 @@ jobs: uses: docker/build-push-action@v2.10.0 with: context: autoinstrumentation/dotnet + platforms: linux/amd64,linux/arm64 # push: ${{ github.event_name == 'push' }} push: true build-args: version=${{ env.VERSION }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache From 6c2113cf2737adc04da1ece71e6b3a4f1ae8e01d Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Tue, 26 Apr 2022 11:41:19 +0530 Subject: [PATCH 17/33] triggers action on pull request --- .github/workflows/publish-autoinstrumentation-dotnet.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-autoinstrumentation-dotnet.yaml b/.github/workflows/publish-autoinstrumentation-dotnet.yaml index 078a36216e..456916b594 100644 --- a/.github/workflows/publish-autoinstrumentation-dotnet.yaml +++ b/.github/workflows/publish-autoinstrumentation-dotnet.yaml @@ -7,10 +7,10 @@ on: # - '.github/workflows/publish-autoinstrumentation-dotnet.yaml' # branches: # - main - # pull_request: - # paths: - # - 'autoinstrumentation/dotnet/**' - # - '.github/workflows/publish-autoinstrumentation-dotnet.yaml' + pull_request: + paths: + - 'autoinstrumentation/dotnet/**' + - '.github/workflows/publish-autoinstrumentation-dotnet.yaml' workflow_dispatch: jobs: From 7c7d4fb133be8130aa57209cb2f257c5e3535b26 Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Wed, 13 Jul 2022 14:29:17 +0530 Subject: [PATCH 18/33] adds e2e test cases for dotnet instrumentation --- .../publish-autoinstrumentation-dotnet.yaml | 37 +++++++++--------- .../publish-autoinstrumentation-java.yaml | 22 +++++------ .../publish-autoinstrumentation-nodejs.yaml | 22 +++++------ .../publish-autoinstrumentation-python.yaml | 22 +++++------ .github/workflows/publish-images.yaml | 15 +++----- .../workflows/publish-target-allocator.yaml | 14 +++---- .github/workflows/release.yaml | 4 +- Makefile | 12 ++---- autoinstrumentation/dotnet/Dockerfile | 4 +- ...emetry-operator.clusterserviceversion.yaml | 38 +++++++++---------- config/manager/kustomization.yaml | 8 +++- ...emetry-operator.clusterserviceversion.yaml | 2 +- main.go | 2 +- pkg/instrumentation/dotnet.go | 6 +-- .../e2e/instrumentation-dotnet/01-assert.yaml | 6 +-- 15 files changed, 105 insertions(+), 109 deletions(-) diff --git a/.github/workflows/publish-autoinstrumentation-dotnet.yaml b/.github/workflows/publish-autoinstrumentation-dotnet.yaml index 078a36216e..967c5f5a13 100644 --- a/.github/workflows/publish-autoinstrumentation-dotnet.yaml +++ b/.github/workflows/publish-autoinstrumentation-dotnet.yaml @@ -1,16 +1,16 @@ name: "Publish DotNet Auto-Instrumentation" on: - # push: - # paths: - # - 'autoinstrumentation/dotnet/**' - # - '.github/workflows/publish-autoinstrumentation-dotnet.yaml' - # branches: - # - main - # pull_request: - # paths: - # - 'autoinstrumentation/dotnet/**' - # - '.github/workflows/publish-autoinstrumentation-dotnet.yaml' + push: + paths: + - 'autoinstrumentation/dotnet/**' + - '.github/workflows/publish-autoinstrumentation-dotnet.yaml' + branches: + - main + pull_request: + paths: + - 'autoinstrumentation/dotnet/**' + - '.github/workflows/publish-autoinstrumentation-dotnet.yaml' workflow_dispatch: jobs: @@ -25,17 +25,17 @@ jobs: - name: Docker meta id: meta - uses: docker/metadata-action@v3.7.0 + uses: docker/metadata-action@v4.0.1 with: - images: ghcr.io/logicmonitor/opentelemetry-operator/autoinstrumentation-dotnet + images: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-dotnet tags: | type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} - + - name: Set up QEMU - uses: docker/setup-qemu-action@v1.2.0 + uses: docker/setup-qemu-action@v2.0.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1.6.0 + uses: docker/setup-buildx-action@v2.0.0 - name: Cache Docker layers uses: actions/cache@v3 @@ -46,19 +46,18 @@ jobs: ${{ runner.os }}-buildx- - name: Login to GitHub Package Registry - uses: docker/login-action@v1.14.1 + uses: docker/login-action@v2.0.0 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v2.10.0 + uses: docker/build-push-action@v3.0.0 with: context: autoinstrumentation/dotnet platforms: linux/amd64,linux/arm64 - # push: ${{ github.event_name == 'push' }} - push: true + push: ${{ github.event_name == 'push' }} build-args: version=${{ env.VERSION }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/publish-autoinstrumentation-java.yaml b/.github/workflows/publish-autoinstrumentation-java.yaml index 3a641259fd..0232c8320a 100644 --- a/.github/workflows/publish-autoinstrumentation-java.yaml +++ b/.github/workflows/publish-autoinstrumentation-java.yaml @@ -1,16 +1,16 @@ name: "Publish Java Auto-Instrumentation" on: - # push: - # paths: - # - 'autoinstrumentation/java/**' - # - '.github/workflows/publish-autoinstrumentation-java.yaml' - # branches: - # - main - # pull_request: - # paths: - # - 'autoinstrumentation/java/**' - # - '.github/workflows/publish-autoinstrumentation-java.yaml' + push: + paths: + - 'autoinstrumentation/java/**' + - '.github/workflows/publish-autoinstrumentation-java.yaml' + branches: + - main + pull_request: + paths: + - 'autoinstrumentation/java/**' + - '.github/workflows/publish-autoinstrumentation-java.yaml' workflow_dispatch: jobs: @@ -27,7 +27,7 @@ jobs: id: meta uses: docker/metadata-action@v4.0.1 with: - images: ghcr.io/logicmonitor/opentelemetry-operator/autoinstrumentation-java + images: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java tags: | type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} diff --git a/.github/workflows/publish-autoinstrumentation-nodejs.yaml b/.github/workflows/publish-autoinstrumentation-nodejs.yaml index ebd51d9753..18f1dc23ae 100644 --- a/.github/workflows/publish-autoinstrumentation-nodejs.yaml +++ b/.github/workflows/publish-autoinstrumentation-nodejs.yaml @@ -1,16 +1,16 @@ name: "Publish NodeJS Auto-Instrumentation" on: - # push: - # paths: - # - 'autoinstrumentation/nodejs/**' - # - '.github/workflows/publish-autoinstrumentation-nodejs.yaml' - # branches: - # - main - # pull_request: - # paths: - # - 'autoinstrumentation/nodejs/**' - # - '.github/workflows/publish-autoinstrumentation-nodejs.yaml' + push: + paths: + - 'autoinstrumentation/nodejs/**' + - '.github/workflows/publish-autoinstrumentation-nodejs.yaml' + branches: + - main + pull_request: + paths: + - 'autoinstrumentation/nodejs/**' + - '.github/workflows/publish-autoinstrumentation-nodejs.yaml' workflow_dispatch: jobs: @@ -27,7 +27,7 @@ jobs: id: meta uses: docker/metadata-action@v4.0.1 with: - images: ghcr.io/logicmonitor/opentelemetry-operator/autoinstrumentation-nodejs + images: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-nodejs tags: | type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} diff --git a/.github/workflows/publish-autoinstrumentation-python.yaml b/.github/workflows/publish-autoinstrumentation-python.yaml index 9fc6ab4801..aaab2af838 100644 --- a/.github/workflows/publish-autoinstrumentation-python.yaml +++ b/.github/workflows/publish-autoinstrumentation-python.yaml @@ -1,16 +1,16 @@ name: "Publish Python Auto-Instrumentation" on: - # push: - # paths: - # - 'autoinstrumentation/python/**' - # - '.github/workflows/publish-autoinstrumentation-python.yaml' - # branches: - # - main - # pull_request: - # paths: - # - 'autoinstrumentation/python/**' - # - '.github/workflows/publish-autoinstrumentation-python.yaml' + push: + paths: + - 'autoinstrumentation/python/**' + - '.github/workflows/publish-autoinstrumentation-python.yaml' + branches: + - main + pull_request: + paths: + - 'autoinstrumentation/python/**' + - '.github/workflows/publish-autoinstrumentation-python.yaml' workflow_dispatch: jobs: @@ -27,7 +27,7 @@ jobs: id: meta uses: docker/metadata-action@v4.0.1 with: - images: ghcr.io/logicmonitor/opentelemetry-operator/autoinstrumentation-python + images: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-python tags: | type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} diff --git a/.github/workflows/publish-images.yaml b/.github/workflows/publish-images.yaml index 258c3eae55..e93ab18545 100644 --- a/.github/workflows/publish-images.yaml +++ b/.github/workflows/publish-images.yaml @@ -1,9 +1,9 @@ name: "Publish operator" on: - # push: - # branches: [ main ] - # tags: [ 'v*' ] + push: + branches: [ main ] + tags: [ 'v*' ] workflow_dispatch: @@ -27,7 +27,6 @@ jobs: grep -v '\#' versions.txt | grep autoinstrumentation-java | awk -F= '{print "AUTO_INSTRUMENTATION_JAVA_VERSION="$2}' >> $GITHUB_ENV grep -v '\#' versions.txt | grep autoinstrumentation-nodejs | awk -F= '{print "AUTO_INSTRUMENTATION_NODEJS_VERSION="$2}' >> $GITHUB_ENV grep -v '\#' versions.txt | grep autoinstrumentation-python | awk -F= '{print "AUTO_INSTRUMENTATION_PYTHON_VERSION="$2}' >> $GITHUB_ENV - grep -v '\#' versions.txt | grep autoinstrumentation-dotnet | awk -F= '{print "AUTO_INSTRUMENTATION_DOTNET_VERSION="$2}' >> $GITHUB_ENV echo "VERSION_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV echo "VERSION=$(git describe --tags | sed 's/^v//')" >> $GITHUB_ENV @@ -35,7 +34,7 @@ jobs: id: docker_meta uses: docker/metadata-action@v4.0.1 with: - images: ghcr.io/logicmonitor/opentelemetry-operator/opentelemetry-operator + images: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator tags: | type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} @@ -69,8 +68,7 @@ jobs: context: . file: ./Dockerfile platforms: linux/amd64,linux/arm64 - # push: ${{ github.event_name != 'pull_request' }} - push: true + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.docker_meta.outputs.tags }} labels: ${{ steps.docker_meta.outputs.labels }} build-args: | @@ -81,7 +79,6 @@ jobs: TARGETALLOCATOR_VERSION=${{ env.TARGETALLOCATOR_VERSION }} AUTO_INSTRUMENTATION_JAVA_VERSION=${{ env.AUTO_INSTRUMENTATION_JAVA_VERSION }} AUTO_INSTRUMENTATION_NODEJS_VERSION=${{ env.AUTO_INSTRUMENTATION_NODEJS_VERSION }} - AUTO_INSTRUMENTATION_PYTHON_VERSION=${{ env.AUTO_INSTRUMENTATION_PYTHON_VERSION }} - AUTO_INSTRUMENTATION_DOTNET_VERSION=${{ env.AUTO_INSTRUMENTATION_DOTNET_VERSION }} + AUTO_INSTRUMENTATION_PYTHON_VERSION=${{ env. AUTO_INSTRUMENTATION_PYTHON_VERSION }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache diff --git a/.github/workflows/publish-target-allocator.yaml b/.github/workflows/publish-target-allocator.yaml index d9302e6732..50038713ae 100644 --- a/.github/workflows/publish-target-allocator.yaml +++ b/.github/workflows/publish-target-allocator.yaml @@ -1,12 +1,12 @@ name: "Publish target allocator" on: - # push: - # paths: - # - 'cmd/otel-allocator/**' - # - '.github/workflows/publish-target-allocator.yaml' - # branches: - # - main + push: + paths: + - 'cmd/otel-allocator/**' + - '.github/workflows/publish-target-allocator.yaml' + branches: + - main workflow_dispatch: jobs: @@ -23,7 +23,7 @@ jobs: id: meta uses: docker/metadata-action@v4.0.1 with: - images: ghcr.io/logicmonitor/opentelemetry-operator/target-allocator + images: ghcr.io/open-telemetry/opentelemetry-operator/target-allocator tags: | type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c9a4cd5623..ceed9ccc45 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -21,7 +21,7 @@ jobs: run: ./hack/install-kustomize.sh - name: "generate release resources" - run: make release-artifacts IMG_PREFIX="ghcr.io/logicmonitor/opentelemetry-operator" + run: make release-artifacts IMG_PREFIX="ghcr.io/open-telemetry/opentelemetry-operator" - name: "create the release in GitHub" env: @@ -31,4 +31,4 @@ jobs: - name: "refresh go proxy module info on release" run: | OPERATOR_VERSION=$(git describe --tags) - curl https://proxy.golang.org/github.com/logicmonitor/opentelemetry-operator/@v/${OPERATOR_VERSION}.info + curl https://proxy.golang.org/github.com/open-telemetry/opentelemetry-operator/@v/${OPERATOR_VERSION}.info diff --git a/Makefile b/Makefile index ef1cc5a590..96a6206a4d 100644 --- a/Makefile +++ b/Makefile @@ -48,12 +48,12 @@ else GOTEST_OPTS=-race -v endif -KUBE_VERSION ?= 1.24 +KUBE_VERSION ?= 1.21 KIND_CONFIG ?= kind-$(KUBE_VERSION).yaml OPERATOR_SDK_VERSION ?= 1.17.0 -CERTMANAGER_VERSION ?= 1.8.0 +CERTMANAGER_VERSION ?= 1.6.1 ifndef ignore-not-found ignore-not-found = false @@ -61,7 +61,7 @@ endif .PHONY: ensure-generate-is-noop ensure-generate-is-noop: VERSION=$(OPERATOR_VERSION) -ensure-generate-is-noop: USER=logicmonitor +ensure-generate-is-noop: USER=open-telemetry ensure-generate-is-noop: set-image-controller generate bundle @# on make bundle config/manager/kustomization.yaml includes changes, which should be ignored for the below check @git restore config/manager/kustomization.yaml @@ -208,9 +208,6 @@ CMCTL = $(shell pwd)/bin/cmctl cmctl: @{ \ set -e ;\ - if (`pwd`/bin/cmctl version | grep ${CERTMANAGER_VERSION}) > /dev/null 2>&1 ; then \ - exit 0; \ - fi ;\ TMP_DIR=$$(mktemp -d) ;\ curl -L -o $$TMP_DIR/cmctl.tar.gz https://github.com/jetstack/cert-manager/releases/download/v$(CERTMANAGER_VERSION)/cmctl-`go env GOOS`-`go env GOARCH`.tar.gz ;\ tar xzf $$TMP_DIR/cmctl.tar.gz -C $$TMP_DIR ;\ @@ -293,9 +290,6 @@ OPERATOR_SDK = $(shell pwd)/bin/operator-sdk operator-sdk: @{ \ set -e ;\ - if (`pwd`/bin/operator-sdk version | grep ${OPERATOR_SDK_VERSION}) > /dev/null 2>&1 ; then \ - exit 0; \ - fi ;\ [ -d bin ] || mkdir bin ;\ curl -L -o $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/v${OPERATOR_SDK_VERSION}/operator-sdk_`go env GOOS`_`go env GOARCH`;\ chmod +x $(OPERATOR_SDK) ;\ diff --git a/autoinstrumentation/dotnet/Dockerfile b/autoinstrumentation/dotnet/Dockerfile index 9a15a272e4..ac39b37ec2 100644 --- a/autoinstrumentation/dotnet/Dockerfile +++ b/autoinstrumentation/dotnet/Dockerfile @@ -8,8 +8,8 @@ ARG version WORKDIR /autoinstrumentation -ADD https://github.com/logicmonitor/lm-telemetry-sdk-dotnet/releases/download/$version/lm-telemetry-dotnet-instrumentation-$version.zip . +ADD https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/download/v$version/opentelemetry-dotnet-instrumentation-linux-glibc.zip . -RUN tar -xvf lm-telemetry-dotnet-instrumentation-$version.zip +RUN unzip opentelemetry-dotnet-instrumentation-linux-glibc.zip RUN chmod -R go+r . \ No newline at end of file diff --git a/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml index 4accf2e653..2a775b8bc4 100644 --- a/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -30,7 +30,7 @@ metadata: capabilities: Basic Install categories: Logging & Tracing certified: "false" - containerImage: ghcr.io/logicmonitor/opentelemetry-operator/opentelemetry-operator + containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator createdAt: "2020-12-16T13:37:00+00:00" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.16.0+git @@ -276,24 +276,6 @@ spec: control-plane: controller-manager spec: containers: - - args: - - --secure-listen-address=0.0.0.0:8443 - - --upstream=http://127.0.0.1:8080/ - - --logtostderr=true - - --v=0 - image: gcr.io/kubebuilder/kube-rbac-proxy:v0.11.0 - name: kube-rbac-proxy - ports: - - containerPort: 8443 - name: https - protocol: TCP - resources: - limits: - cpu: 500m - memory: 128Mi - requests: - cpu: 5m - memory: 64Mi - args: - --metrics-addr=127.0.0.1:8080 - --enable-leader-election @@ -326,6 +308,24 @@ spec: - mountPath: /tmp/k8s-webhook-server/serving-certs name: cert readOnly: true + - args: + - --secure-listen-address=0.0.0.0:8443 + - --upstream=http://127.0.0.1:8080/ + - --logtostderr=true + - --v=0 + image: gcr.io/kubebuilder/kube-rbac-proxy:v0.11.0 + name: kube-rbac-proxy + ports: + - containerPort: 8443 + name: https + protocol: TCP + resources: + limits: + cpu: 500m + memory: 128Mi + requests: + cpu: 5m + memory: 64Mi serviceAccountName: opentelemetry-operator-controller-manager terminationGracePeriodSeconds: 10 volumes: diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 7394a6d059..de5aa4ca3a 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -1,2 +1,8 @@ resources: - - manager.yaml +- manager.yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +images: +- name: controller + newName: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator + newTag: 0.54.0-29-g91d0683 diff --git a/config/manifests/bases/opentelemetry-operator.clusterserviceversion.yaml b/config/manifests/bases/opentelemetry-operator.clusterserviceversion.yaml index 3d33ef4350..b36f42e8e6 100644 --- a/config/manifests/bases/opentelemetry-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/opentelemetry-operator.clusterserviceversion.yaml @@ -6,7 +6,7 @@ metadata: capabilities: Basic Install categories: Logging & Tracing certified: "false" - containerImage: ghcr.io/logicmonitor/opentelemetry-operator/opentelemetry-operator + containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator createdAt: "2020-12-16T13:37:00+00:00" description: Provides the OpenTelemetry components, including the Collector repository: github.com/open-telemetry/opentelemetry-operator diff --git a/main.go b/main.go index 5362b65a58..4cba6631ea 100644 --- a/main.go +++ b/main.go @@ -95,7 +95,7 @@ func main() { pflag.StringVar(&autoInstrumentationJava, "auto-instrumentation-java-image", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java:%s", v.AutoInstrumentationJava), "The default OpenTelemetry Java instrumentation image. This image is used when no image is specified in the CustomResource.") pflag.StringVar(&autoInstrumentationNodeJS, "auto-instrumentation-nodejs-image", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-nodejs:%s", v.AutoInstrumentationNodeJS), "The default OpenTelemetry NodeJS instrumentation image. This image is used when no image is specified in the CustomResource.") pflag.StringVar(&autoInstrumentationPython, "auto-instrumentation-python-image", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-python:%s", v.AutoInstrumentationPython), "The default OpenTelemetry Python instrumentation image. This image is used when no image is specified in the CustomResource.") - pflag.StringVar(&autoInstrumentationDotNet, "auto-instrumentation-dot-net", fmt.Sprintf("ghcr.io/logicmonitor/opentelemetry-operator/autoinstrumentation-dotnet:%s", v.AutoInstrumentationDotNet), "The default OpenTelemetry DotNet instrumentation image. This image is used when no image is specified in the CustomResource.") + pflag.StringVar(&autoInstrumentationDotNet, "auto-instrumentation-dot-net", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-dotnet:%s", v.AutoInstrumentationDotNet), "The default OpenTelemetry DotNet instrumentation image. This image is used when no image is specified in the CustomResource.") pflag.StringArrayVar(&labelsFilter, "labels", []string{}, "Labels to filter away from propagating onto deploys") pflag.IntVar(&webhookPort, "webhook-port", 9443, "The port the webhook endpoint binds to.") pflag.Parse() diff --git a/pkg/instrumentation/dotnet.go b/pkg/instrumentation/dotnet.go index 48b8f83565..ee933ef339 100644 --- a/pkg/instrumentation/dotnet.go +++ b/pkg/instrumentation/dotnet.go @@ -27,9 +27,9 @@ const ( envDotNetAdditionalDeps = "DOTNET_ADDITIONAL_DEPS" envDotNetSharedStore = "DOTNET_SHARED_STORE" envDotNetStartupHook = "DOTNET_STARTUP_HOOKS" - dotNetAdditionalDepsPath = "./otel-auto-instrumentation/bin/tracer-home/AdditionalDeps" - dotNetSharedStorePath = "/otel-auto-instrumentation/bin/tracer-home/store" - dotNetStartupHookPath = "/otel-auto-instrumentation/bin/tracer-home/netcoreapp3.1/LMStartupHook.dll" + dotNetAdditionalDepsPath = "./otel-auto-instrumentation/AdditionalDeps" + dotNetSharedStorePath = "/otel-auto-instrumentation/store" + dotNetStartupHookPath = "/otel-auto-instrumentation/netcoreapp3.1/OpenTelemetry.AutoInstrumentation.StartupHook.dll" ) func injectDotNetSDK(logger logr.Logger, dotNetSpec v1alpha1.DotNet, pod corev1.Pod, index int) corev1.Pod { diff --git a/tests/e2e/instrumentation-dotnet/01-assert.yaml b/tests/e2e/instrumentation-dotnet/01-assert.yaml index eef6a93573..ce0c6b1231 100644 --- a/tests/e2e/instrumentation-dotnet/01-assert.yaml +++ b/tests/e2e/instrumentation-dotnet/01-assert.yaml @@ -13,11 +13,11 @@ spec: - name: OTEL_DOTNET_TRACER_INSTRUMENTATIONS value: AspNet,HttpClient,SqlClient - name: DOTNET_STARTUP_HOOKS - value: "/otel-auto-instrumentation/bin/tracer-home/netcoreapp3.1/LMStartupHook.dll" + value: "/otel-auto-instrumentation/netcoreapp3.1/OpenTelemetry.AutoInstrumentation.StartupHook.dll" - name: DOTNET_ADDITIONAL_DEPS - value: ./otel-auto-instrumentation/bin/tracer-home/AdditionalDeps + value: ./otel-auto-instrumentation/AdditionalDeps - name: DOTNET_SHARED_STORE - value: /otel-auto-instrumentation/bin/tracer-home/store + value: /otel-auto-instrumentation/store - name: OTEL_TRACES_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT From 7087fb416c5a567468106b5a80ea2d9ad78264ad Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Wed, 13 Jul 2022 14:37:52 +0530 Subject: [PATCH 19/33] fixes version for dotnet instrumentation --- README.md | 2 +- autoinstrumentation/dotnet/version.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 64364cf39a..f6431c58fd 100644 --- a/README.md +++ b/README.md @@ -166,7 +166,7 @@ When using sidecar mode the OpenTelemetry collector container will have the envi ### OpenTelemetry auto-instrumentation injection -The operator can inject and configure OpenTelemetry auto-instrumentation libraries. Currently Java, NodeJS and Python are supported. +The operator can inject and configure OpenTelemetry auto-instrumentation libraries. Currently DotNet, Java, NodeJS and Python are supported. To use auto-instrumentation, configure an `Instrumentation` resource with the configuration for the SDK and instrumentation. diff --git a/autoinstrumentation/dotnet/version.txt b/autoinstrumentation/dotnet/version.txt index 93a33ab427..d76821f8c2 100644 --- a/autoinstrumentation/dotnet/version.txt +++ b/autoinstrumentation/dotnet/version.txt @@ -1 +1 @@ -0.0.1-alpha \ No newline at end of file +0.2.0-beta.1 \ No newline at end of file From d29df8bf778902c2eef4240f6fc17c26390858cf Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Wed, 13 Jul 2022 15:22:57 +0530 Subject: [PATCH 20/33] version changes --- .../opentelemetry-operator.clusterserviceversion.yaml | 6 +++--- config/manager/kustomization.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml index 2a775b8bc4..e87a7b644a 100644 --- a/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -37,7 +37,7 @@ metadata: operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: github.com/open-telemetry/opentelemetry-operator support: OpenTelemetry Community - name: opentelemetry-operator.v0.55.0 + name: opentelemetry-operator.v0.55.0-27-g7087fb4 namespace: placeholder spec: apiservicedefinitions: {} @@ -279,7 +279,7 @@ spec: - args: - --metrics-addr=127.0.0.1:8080 - --enable-leader-election - image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.55.0 + image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.55.0-27-g7087fb4 livenessProbe: httpGet: path: /healthz @@ -389,7 +389,7 @@ spec: maturity: alpha provider: name: OpenTelemetry Community - version: 0.55.0 + version: 0.55.0-27-g7087fb4 webhookdefinitions: - admissionReviewVersions: - v1 diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index de5aa4ca3a..451279b489 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -5,4 +5,4 @@ kind: Kustomization images: - name: controller newName: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - newTag: 0.54.0-29-g91d0683 + newTag: 0.55.0-27-g7087fb4 From 6010409718b6d325aa6df7480ba91eb92be44b9f Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Wed, 13 Jul 2022 15:48:06 +0530 Subject: [PATCH 21/33] restores clusterversion file --- ...emetry-operator.clusterserviceversion.yaml | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml index e87a7b644a..a64ee0beb5 100644 --- a/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -37,7 +37,7 @@ metadata: operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: github.com/open-telemetry/opentelemetry-operator support: OpenTelemetry Community - name: opentelemetry-operator.v0.55.0-27-g7087fb4 + name: opentelemetry-operator.v0.55.0 namespace: placeholder spec: apiservicedefinitions: {} @@ -276,10 +276,28 @@ spec: control-plane: controller-manager spec: containers: + - args: + - --secure-listen-address=0.0.0.0:8443 + - --upstream=http://127.0.0.1:8080/ + - --logtostderr=true + - --v=0 + image: gcr.io/kubebuilder/kube-rbac-proxy:v0.11.0 + name: kube-rbac-proxy + ports: + - containerPort: 8443 + name: https + protocol: TCP + resources: + limits: + cpu: 500m + memory: 128Mi + requests: + cpu: 5m + memory: 64Mi - args: - --metrics-addr=127.0.0.1:8080 - --enable-leader-election - image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.55.0-27-g7087fb4 + image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.55.0 livenessProbe: httpGet: path: /healthz @@ -308,24 +326,6 @@ spec: - mountPath: /tmp/k8s-webhook-server/serving-certs name: cert readOnly: true - - args: - - --secure-listen-address=0.0.0.0:8443 - - --upstream=http://127.0.0.1:8080/ - - --logtostderr=true - - --v=0 - image: gcr.io/kubebuilder/kube-rbac-proxy:v0.11.0 - name: kube-rbac-proxy - ports: - - containerPort: 8443 - name: https - protocol: TCP - resources: - limits: - cpu: 500m - memory: 128Mi - requests: - cpu: 5m - memory: 64Mi serviceAccountName: opentelemetry-operator-controller-manager terminationGracePeriodSeconds: 10 volumes: @@ -389,7 +389,7 @@ spec: maturity: alpha provider: name: OpenTelemetry Community - version: 0.55.0-27-g7087fb4 + version: 0.55.0 webhookdefinitions: - admissionReviewVersions: - v1 From f75b3fcc60961fe84a5fa2b53ce7d5b15a4b929b Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Wed, 13 Jul 2022 16:32:49 +0530 Subject: [PATCH 22/33] restores changes in Makefile --- Makefile | 10 ++++++++-- config/manager/kustomization.yaml | 8 +------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 96a6206a4d..d871bf2f07 100644 --- a/Makefile +++ b/Makefile @@ -48,12 +48,12 @@ else GOTEST_OPTS=-race -v endif -KUBE_VERSION ?= 1.21 +KUBE_VERSION ?= 1.24 KIND_CONFIG ?= kind-$(KUBE_VERSION).yaml OPERATOR_SDK_VERSION ?= 1.17.0 -CERTMANAGER_VERSION ?= 1.6.1 +CERTMANAGER_VERSION ?= 1.8.0 ifndef ignore-not-found ignore-not-found = false @@ -208,6 +208,9 @@ CMCTL = $(shell pwd)/bin/cmctl cmctl: @{ \ set -e ;\ + if (`pwd`/bin/cmctl version | grep ${CERTMANAGER_VERSION}) > /dev/null 2>&1 ; then \ + exit 0; \ + fi ;\ TMP_DIR=$$(mktemp -d) ;\ curl -L -o $$TMP_DIR/cmctl.tar.gz https://github.com/jetstack/cert-manager/releases/download/v$(CERTMANAGER_VERSION)/cmctl-`go env GOOS`-`go env GOARCH`.tar.gz ;\ tar xzf $$TMP_DIR/cmctl.tar.gz -C $$TMP_DIR ;\ @@ -290,6 +293,9 @@ OPERATOR_SDK = $(shell pwd)/bin/operator-sdk operator-sdk: @{ \ set -e ;\ + if (`pwd`/bin/operator-sdk version | grep ${OPERATOR_SDK_VERSION}) > /dev/null 2>&1 ; then \ + exit 0; \ + fi ;\ [ -d bin ] || mkdir bin ;\ curl -L -o $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/v${OPERATOR_SDK_VERSION}/operator-sdk_`go env GOOS`_`go env GOARCH`;\ chmod +x $(OPERATOR_SDK) ;\ diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 451279b489..bffbe8a58a 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -1,8 +1,2 @@ resources: -- manager.yaml -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -images: -- name: controller - newName: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - newTag: 0.55.0-27-g7087fb4 + - manager.yaml \ No newline at end of file From ef5bdb01a4925c859678184311b8cd998de2438e Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Wed, 13 Jul 2022 17:14:57 +0530 Subject: [PATCH 23/33] minor change --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 4cba6631ea..70d24c869e 100644 --- a/main.go +++ b/main.go @@ -95,7 +95,7 @@ func main() { pflag.StringVar(&autoInstrumentationJava, "auto-instrumentation-java-image", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java:%s", v.AutoInstrumentationJava), "The default OpenTelemetry Java instrumentation image. This image is used when no image is specified in the CustomResource.") pflag.StringVar(&autoInstrumentationNodeJS, "auto-instrumentation-nodejs-image", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-nodejs:%s", v.AutoInstrumentationNodeJS), "The default OpenTelemetry NodeJS instrumentation image. This image is used when no image is specified in the CustomResource.") pflag.StringVar(&autoInstrumentationPython, "auto-instrumentation-python-image", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-python:%s", v.AutoInstrumentationPython), "The default OpenTelemetry Python instrumentation image. This image is used when no image is specified in the CustomResource.") - pflag.StringVar(&autoInstrumentationDotNet, "auto-instrumentation-dot-net", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-dotnet:%s", v.AutoInstrumentationDotNet), "The default OpenTelemetry DotNet instrumentation image. This image is used when no image is specified in the CustomResource.") + pflag.StringVar(&autoInstrumentationDotNet, "auto-instrumentation-dotnet-image", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-dotnet:%s", v.AutoInstrumentationDotNet), "The default OpenTelemetry DotNet instrumentation image. This image is used when no image is specified in the CustomResource.") pflag.StringArrayVar(&labelsFilter, "labels", []string{}, "Labels to filter away from propagating onto deploys") pflag.IntVar(&webhookPort, "webhook-port", 9443, "The port the webhook endpoint binds to.") pflag.Parse() From 76cfb829ec36dc2b8429a27a849f286cef25739e Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Wed, 13 Jul 2022 18:22:52 +0530 Subject: [PATCH 24/33] Adds configuration details to dockerfile --- autoinstrumentation/dotnet/Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/autoinstrumentation/dotnet/Dockerfile b/autoinstrumentation/dotnet/Dockerfile index ac39b37ec2..af31050341 100644 --- a/autoinstrumentation/dotnet/Dockerfile +++ b/autoinstrumentation/dotnet/Dockerfile @@ -2,6 +2,11 @@ # - Download your dotnet auto-instrumentation artefacts to `/autoinstrumentation` directory. This is required as when instrumenting the pod, # one init container will be created to copy the files to your app's container. # - Grant the necessary access to the files in the `/autoinstrumentation` directory. +# - Following environment variables are injected to the application container to enable the auto-instrumentation. +# DOTNET_ADDITIONAL_DEPS=%InstallationLocation%/AdditionalDeps +# DOTNET_SHARED_STORE=%InstallationLocation%/store +# DOTNET_STARTUP_HOOKS=%InstallationLocation%/netcoreapp3.1/OpenTelemetry.AutoInstrumentation.StartupHook.dll + FROM busybox ARG version From dec4b39a81b829fa621e8823b33106b45977e26e Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Tue, 19 Jul 2022 12:31:31 +0530 Subject: [PATCH 25/33] updates version of dotnet auto-instrumentation --- versions.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions.txt b/versions.txt index cba39d7a1e..fdff330075 100644 --- a/versions.txt +++ b/versions.txt @@ -24,4 +24,4 @@ autoinstrumentation-python=0.30b1 # Represents the current release of DotNet instrumentation. # Should match autoinstrumentation/dotnet/version.txt -autoinstrumentation-dotnet=0.0.1-alpha \ No newline at end of file +autoinstrumentation-dotnet=0.2.0-beta.1 \ No newline at end of file From 8d85f1f8e73946a187d2816ab0fd2298199d0770 Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Wed, 20 Jul 2022 15:06:07 +0530 Subject: [PATCH 26/33] changes env var name from OTEL_DOTNET_TRACER_INSTRUMENTATIONS to OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS --- pkg/instrumentation/dotnet_test.go | 4 ++-- .../instrumentation-dotnet-multicontainer/01-assert.yaml | 6 +++--- .../instrumentation-dotnet-multicontainer/02-assert.yaml | 2 +- .../instrumentation-dotnet/00-install-instrumentation.yaml | 2 +- tests/e2e/instrumentation-dotnet/01-assert.yaml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/instrumentation/dotnet_test.go b/pkg/instrumentation/dotnet_test.go index bf8317f1e0..7e3e827e6f 100644 --- a/pkg/instrumentation/dotnet_test.go +++ b/pkg/instrumentation/dotnet_test.go @@ -34,7 +34,7 @@ func TestInjectDotNetSDK(t *testing.T) { }{ { name: "DOTNET_STARTUP_HOOKS, DOTNET_SHARED_STORE, DOTNET_ADDITIONAL_DEPS not defined", - DotNet: v1alpha1.DotNet{Image: "foo/bar:1", Env: []corev1.EnvVar{{Name: "OTEL_DOTNET_TRACER_INSTRUMENTATIONS", Value: "AspNet,HttpClient,SqlClient"}}}, + DotNet: v1alpha1.DotNet{Image: "foo/bar:1", Env: []corev1.EnvVar{{Name: "OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS", Value: "AspNet,HttpClient,SqlClient"}}}, pod: corev1.Pod{ Spec: corev1.PodSpec{ Containers: []corev1.Container{ @@ -73,7 +73,7 @@ func TestInjectDotNetSDK(t *testing.T) { }, Env: []corev1.EnvVar{ { - Name: "OTEL_DOTNET_TRACER_INSTRUMENTATIONS", + Name: "OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS", Value: "AspNet,HttpClient,SqlClient", }, { diff --git a/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml b/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml index e92cd12643..14d08396b0 100644 --- a/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml +++ b/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml @@ -4,14 +4,14 @@ metadata: annotations: sidecar.opentelemetry.io/inject: "true" instrumentation.opentelemetry.io/container-names: myapp,myrabbit - instrumentation.opentelemetry.io/inject-java: "true" + instrumentation.opentelemetry.io/inject-dotnet: "true" labels: app: my-pod-with-sidecar spec: containers: - name: myapp env: - - name: OTEL_DOTNET_TRACER_INSTRUMENTATIONS + - name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS value: AspNet,HttpClient,SqlClient - name: DOTNET_STARTUP_HOOKS value: "/otel-auto-instrumentation/netcoreapp3.1/OpenTelemetry.AutoInstrumentation.StartupHook.dll" @@ -44,7 +44,7 @@ spec: name: opentelemetry-auto-instrumentation - name: myrabbit env: - - name: OTEL_DOTNET_TRACER_INSTRUMENTATIONS + - name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS value: AspNet,HttpClient,SqlClient - name: DOTNET_STARTUP_HOOKS value: "/otel-auto-instrumentation/netcoreapp3.1/OpenTelemetry.AutoInstrumentation.StartupHook.dll" diff --git a/tests/e2e/instrumentation-dotnet-multicontainer/02-assert.yaml b/tests/e2e/instrumentation-dotnet-multicontainer/02-assert.yaml index ad7487b2b0..035ede63e2 100644 --- a/tests/e2e/instrumentation-dotnet-multicontainer/02-assert.yaml +++ b/tests/e2e/instrumentation-dotnet-multicontainer/02-assert.yaml @@ -14,7 +14,7 @@ spec: - mountPath: /var/run/secrets/kubernetes.io/serviceaccount - name: myrabbit env: - - name: OTEL_DOTNET_TRACER_INSTRUMENTATIONS + - name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS value: AspNet,HttpClient,SqlClient - name: DOTNET_STARTUP_HOOKS value: "/otel-auto-instrumentation/netcoreapp3.1/OpenTelemetry.AutoInstrumentation.StartupHook.dll" diff --git a/tests/e2e/instrumentation-dotnet/00-install-instrumentation.yaml b/tests/e2e/instrumentation-dotnet/00-install-instrumentation.yaml index a2c1dd3f79..fcbca325be 100644 --- a/tests/e2e/instrumentation-dotnet/00-install-instrumentation.yaml +++ b/tests/e2e/instrumentation-dotnet/00-install-instrumentation.yaml @@ -26,5 +26,5 @@ spec: argument: "0.25" dotnet: env: - - name: OTEL_DOTNET_TRACER_INSTRUMENTATIONS + - name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS value: AspNet,HttpClient,SqlClient diff --git a/tests/e2e/instrumentation-dotnet/01-assert.yaml b/tests/e2e/instrumentation-dotnet/01-assert.yaml index ce0c6b1231..6e45502da2 100644 --- a/tests/e2e/instrumentation-dotnet/01-assert.yaml +++ b/tests/e2e/instrumentation-dotnet/01-assert.yaml @@ -10,7 +10,7 @@ spec: containers: - name: myapp env: - - name: OTEL_DOTNET_TRACER_INSTRUMENTATIONS + - name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS value: AspNet,HttpClient,SqlClient - name: DOTNET_STARTUP_HOOKS value: "/otel-auto-instrumentation/netcoreapp3.1/OpenTelemetry.AutoInstrumentation.StartupHook.dll" From bac4b3d9198d7ff9b19dcc1a22d8d7375df07488 Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Wed, 20 Jul 2022 15:51:00 +0530 Subject: [PATCH 27/33] removes java related env variables --- .../00-install-instrumentation.yaml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/e2e/instrumentation-dotnet-multicontainer/00-install-instrumentation.yaml b/tests/e2e/instrumentation-dotnet-multicontainer/00-install-instrumentation.yaml index f77a3f835f..b62f9579c4 100644 --- a/tests/e2e/instrumentation-dotnet-multicontainer/00-install-instrumentation.yaml +++ b/tests/e2e/instrumentation-dotnet-multicontainer/00-install-instrumentation.yaml @@ -1,7 +1,7 @@ apiVersion: opentelemetry.io/v1alpha1 kind: Instrumentation metadata: - name: java + name: dotnet spec: env: - name: OTEL_TRACES_EXPORTER @@ -24,11 +24,7 @@ spec: sampler: type: parentbased_traceidratio argument: "0.25" - java: + dotnet: env: - - name: OTEL_JAVAAGENT_DEBUG - value: "true" - - name: OTEL_INSTRUMENTATION_JDBC_ENABLED - value: "false" - - name: SPLUNK_PROFILER_ENABLED - value: "false" + - name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS + value: AspNet,HttpClient,SqlClient \ No newline at end of file From c3d81e1f4b307563f0b4536a542e8ec80463d476 Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Wed, 20 Jul 2022 16:30:16 +0530 Subject: [PATCH 28/33] fixes e2e test cases --- tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml | 2 +- tests/e2e/instrumentation-dotnet-multicontainer/02-assert.yaml | 2 +- tests/e2e/instrumentation-dotnet/01-assert.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml b/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml index 14d08396b0..a68c5ddc5a 100644 --- a/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml +++ b/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml @@ -68,9 +68,9 @@ spec: value: my-deployment-with-sidecar - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME - name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME - - name: OTEL_RESOURCE_ATTRIBUTES - name: OTEL_PROPAGATORS value: jaeger,b3 + - name: OTEL_RESOURCE_ATTRIBUTES volumeMounts: - mountPath: /var/run/secrets/kubernetes.io/serviceaccount - mountPath: /otel-auto-instrumentation diff --git a/tests/e2e/instrumentation-dotnet-multicontainer/02-assert.yaml b/tests/e2e/instrumentation-dotnet-multicontainer/02-assert.yaml index 035ede63e2..4a8e2d8e14 100644 --- a/tests/e2e/instrumentation-dotnet-multicontainer/02-assert.yaml +++ b/tests/e2e/instrumentation-dotnet-multicontainer/02-assert.yaml @@ -38,9 +38,9 @@ spec: value: my-deployment-with-sidecar - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME - name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME - - name: OTEL_RESOURCE_ATTRIBUTES - name: OTEL_PROPAGATORS value: jaeger,b3 + - name: OTEL_RESOURCE_ATTRIBUTES volumeMounts: - mountPath: /var/run/secrets/kubernetes.io/serviceaccount - mountPath: /otel-auto-instrumentation diff --git a/tests/e2e/instrumentation-dotnet/01-assert.yaml b/tests/e2e/instrumentation-dotnet/01-assert.yaml index 6e45502da2..f26410ee9f 100644 --- a/tests/e2e/instrumentation-dotnet/01-assert.yaml +++ b/tests/e2e/instrumentation-dotnet/01-assert.yaml @@ -34,9 +34,9 @@ spec: value: my-deployment-with-sidecar - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME - name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME - - name: OTEL_RESOURCE_ATTRIBUTES - name: OTEL_PROPAGATORS value: jaeger,b3 + - name: OTEL_RESOURCE_ATTRIBUTES volumeMounts: - mountPath: /var/run/secrets/kubernetes.io/serviceaccount - mountPath: /otel-auto-instrumentation From e8d4019715f95ec1dbfbe2f7be1472963fea923c Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Wed, 20 Jul 2022 16:55:56 +0530 Subject: [PATCH 29/33] fixes e2e test case --- tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml b/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml index a68c5ddc5a..7332b5477a 100644 --- a/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml +++ b/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml @@ -35,9 +35,9 @@ spec: value: my-deployment-with-sidecar - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME - name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME - - name: OTEL_RESOURCE_ATTRIBUTES - name: OTEL_PROPAGATORS value: jaeger,b3 + - name: OTEL_RESOURCE_ATTRIBUTES volumeMounts: - mountPath: /var/run/secrets/kubernetes.io/serviceaccount - mountPath: /otel-auto-instrumentation From 23a41985fcfaa79c243291b28717dfc724917474 Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Mon, 25 Jul 2022 17:42:00 +0530 Subject: [PATCH 30/33] deletes .DS_Store file --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index a3585876b6842aef6ec2eca2c673c194487ea3b6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~O=`nH427SXECStl+2w30pQvfVyQljO&;ssLc!1UOG})p;=82 zR;?Ceh}WZ?+UmMqI#RP8R>OzYoz15hnq@nzF`-!xQ4j$USP Date: Tue, 26 Jul 2022 15:09:22 +0530 Subject: [PATCH 31/33] sets OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS to default value --- README.md | 3 ++ apis/v1alpha1/instrumentation_webhook.go | 30 ++++++++--- apis/v1alpha1/instrumentation_webhook_test.go | 34 +++++++++++++ .../00-install-instrumentation.yaml | 4 +- .../01-assert.yaml | 2 + .../02-assert.yaml | 2 + .../00-install-instrumentation.yaml | 2 +- .../e2e/instrumentation-dotnet/01-assert.yaml | 2 +- .../02-install-instrumentation.yaml | 30 +++++++++++ .../e2e/instrumentation-dotnet/03-assert.yaml | 50 +++++++++++++++++++ .../03-install-app.yaml | 24 +++++++++ 11 files changed, 173 insertions(+), 10 deletions(-) create mode 100644 tests/e2e/instrumentation-dotnet/02-install-instrumentation.yaml create mode 100644 tests/e2e/instrumentation-dotnet/03-assert.yaml create mode 100644 tests/e2e/instrumentation-dotnet/03-install-app.yaml diff --git a/README.md b/README.md index f6431c58fd..e060cb3696 100644 --- a/README.md +++ b/README.md @@ -221,6 +221,9 @@ The possible values for the annotation can be * `"my-other-namespace/my-instrumentation"` - name and namespace of `Instrumentation` CR instance in another namespace. * `"false"` - do not inject + +>**Note:** For `DotNet` auto-instrumentation, by default, operator sets the `OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS` environment variable which specifies the list of traces source instrumentations you want to enable. The value that is set by default by the operator is all available instrumentations supported by the `openTelemery-dotnet-instrumentation` release consumed in the image, i.e. `AspNet,HttpClient,SqlClient`. This value can be overriden by configuring the environment variable explicitely. + #### Multi-container pods If nothing else is specified, instrumentation is performed on the first container available in the pod spec. diff --git a/apis/v1alpha1/instrumentation_webhook.go b/apis/v1alpha1/instrumentation_webhook.go index 0a19653ce8..3516802d78 100644 --- a/apis/v1alpha1/instrumentation_webhook.go +++ b/apis/v1alpha1/instrumentation_webhook.go @@ -27,12 +27,14 @@ import ( ) const ( - AnnotationDefaultAutoInstrumentationJava = "instrumentation.opentelemetry.io/default-auto-instrumentation-java-image" - AnnotationDefaultAutoInstrumentationNodeJS = "instrumentation.opentelemetry.io/default-auto-instrumentation-nodejs-image" - AnnotationDefaultAutoInstrumentationPython = "instrumentation.opentelemetry.io/default-auto-instrumentation-python-image" - AnnotationDefaultAutoInstrumentationDotNet = "instrumentation.opentelemetry.io/default-auto-instrumentation-dotnet-image" - envPrefix = "OTEL_" - envSplunkPrefix = "SPLUNK_" + AnnotationDefaultAutoInstrumentationJava = "instrumentation.opentelemetry.io/default-auto-instrumentation-java-image" + AnnotationDefaultAutoInstrumentationNodeJS = "instrumentation.opentelemetry.io/default-auto-instrumentation-nodejs-image" + AnnotationDefaultAutoInstrumentationPython = "instrumentation.opentelemetry.io/default-auto-instrumentation-python-image" + AnnotationDefaultAutoInstrumentationDotNet = "instrumentation.opentelemetry.io/default-auto-instrumentation-dotnet-image" + envPrefix = "OTEL_" + envSplunkPrefix = "SPLUNK_" + envOtelDotnetAutoTracesEnabledInstrumentations = "OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS" + defaultEnabledTracesInstrumentations = "AspNet,HttpClient,SqlClient" ) // log is for logging in this package. @@ -78,6 +80,13 @@ func (r *Instrumentation) Default() { r.Spec.DotNet.Image = val } } + // by default set all the available instrumentations for dotnet unless the env is already set + if !r.isEnvVarSet(envOtelDotnetAutoTracesEnabledInstrumentations) { + r.Spec.DotNet.Env = append(r.Spec.DotNet.Env, corev1.EnvVar{ + Name: envOtelDotnetAutoTracesEnabledInstrumentations, + Value: defaultEnabledTracesInstrumentations, + }) + } } // +kubebuilder:webhook:verbs=create;update,path=/validate-opentelemetry-io-v1alpha1-instrumentation,mutating=false,failurePolicy=fail,groups=opentelemetry.io,resources=instrumentations,versions=v1alpha1,name=vinstrumentationcreateupdate.kb.io,sideEffects=none,admissionReviewVersions=v1 @@ -146,3 +155,12 @@ func (in *Instrumentation) validateEnv(envs []corev1.EnvVar) error { } return nil } + +func (in *Instrumentation) isEnvVarSet(name string) bool { + for _, env := range in.Spec.DotNet.Env { + if env.Name == name { + return true + } + } + return false +} diff --git a/apis/v1alpha1/instrumentation_webhook_test.go b/apis/v1alpha1/instrumentation_webhook_test.go index 622e3ce8e6..89ffb74cf0 100644 --- a/apis/v1alpha1/instrumentation_webhook_test.go +++ b/apis/v1alpha1/instrumentation_webhook_test.go @@ -18,6 +18,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -28,6 +29,7 @@ func TestInstrumentationDefaultingWebhook(t *testing.T) { AnnotationDefaultAutoInstrumentationJava: "java-img:1", AnnotationDefaultAutoInstrumentationNodeJS: "nodejs-img:1", AnnotationDefaultAutoInstrumentationPython: "python-img:1", + AnnotationDefaultAutoInstrumentationDotNet: "dotnet-img:1", }, }, } @@ -35,6 +37,38 @@ func TestInstrumentationDefaultingWebhook(t *testing.T) { assert.Equal(t, "java-img:1", inst.Spec.Java.Image) assert.Equal(t, "nodejs-img:1", inst.Spec.NodeJS.Image) assert.Equal(t, "python-img:1", inst.Spec.Python.Image) + assert.Equal(t, "dotnet-img:1", inst.Spec.DotNet.Image) + assert.Equal(t, true, inst.isEnvVarSet(envOtelDotnetAutoTracesEnabledInstrumentations)) +} + +func TestInstrumentationDefaultingWebhookOtelDotNetTracesEnabledInstruEnvSet(t *testing.T) { + inst := &Instrumentation{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{ + AnnotationDefaultAutoInstrumentationJava: "java-img:1", + AnnotationDefaultAutoInstrumentationNodeJS: "nodejs-img:1", + AnnotationDefaultAutoInstrumentationPython: "python-img:1", + AnnotationDefaultAutoInstrumentationDotNet: "dotnet-img:1", + }, + }, + Spec: InstrumentationSpec{ + DotNet: DotNet{ + Env: []v1.EnvVar{ + { + Name: envOtelDotnetAutoTracesEnabledInstrumentations, + Value: "AspNet,HttpClient", + }, + }, + }, + }, + } + inst.Default() + for _, env := range inst.Spec.DotNet.Env { + if env.Name == envOtelDotnetAutoTracesEnabledInstrumentations { + assert.Equal(t, "AspNet,HttpClient", env.Value) + break + } + } } func TestInstrumentationValidatingWebhook(t *testing.T) { diff --git a/tests/e2e/instrumentation-dotnet-multicontainer/00-install-instrumentation.yaml b/tests/e2e/instrumentation-dotnet-multicontainer/00-install-instrumentation.yaml index b62f9579c4..391b502dfa 100644 --- a/tests/e2e/instrumentation-dotnet-multicontainer/00-install-instrumentation.yaml +++ b/tests/e2e/instrumentation-dotnet-multicontainer/00-install-instrumentation.yaml @@ -26,5 +26,5 @@ spec: argument: "0.25" dotnet: env: - - name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS - value: AspNet,HttpClient,SqlClient \ No newline at end of file + - name: OTEL_LOG_LEVEL + value: "debug" \ No newline at end of file diff --git a/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml b/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml index 7332b5477a..1532df6abb 100644 --- a/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml +++ b/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml @@ -11,6 +11,8 @@ spec: containers: - name: myapp env: + - name: OTEL_LOG_LEVEL + value: "debug" - name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS value: AspNet,HttpClient,SqlClient - name: DOTNET_STARTUP_HOOKS diff --git a/tests/e2e/instrumentation-dotnet-multicontainer/02-assert.yaml b/tests/e2e/instrumentation-dotnet-multicontainer/02-assert.yaml index 4a8e2d8e14..8cb31810bb 100644 --- a/tests/e2e/instrumentation-dotnet-multicontainer/02-assert.yaml +++ b/tests/e2e/instrumentation-dotnet-multicontainer/02-assert.yaml @@ -14,6 +14,8 @@ spec: - mountPath: /var/run/secrets/kubernetes.io/serviceaccount - name: myrabbit env: + - name: OTEL_LOG_LEVEL + value: "debug" - name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS value: AspNet,HttpClient,SqlClient - name: DOTNET_STARTUP_HOOKS diff --git a/tests/e2e/instrumentation-dotnet/00-install-instrumentation.yaml b/tests/e2e/instrumentation-dotnet/00-install-instrumentation.yaml index fcbca325be..affbe29822 100644 --- a/tests/e2e/instrumentation-dotnet/00-install-instrumentation.yaml +++ b/tests/e2e/instrumentation-dotnet/00-install-instrumentation.yaml @@ -27,4 +27,4 @@ spec: dotnet: env: - name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS - value: AspNet,HttpClient,SqlClient + value: AspNet,HttpClient diff --git a/tests/e2e/instrumentation-dotnet/01-assert.yaml b/tests/e2e/instrumentation-dotnet/01-assert.yaml index f26410ee9f..9b5320b07f 100644 --- a/tests/e2e/instrumentation-dotnet/01-assert.yaml +++ b/tests/e2e/instrumentation-dotnet/01-assert.yaml @@ -11,7 +11,7 @@ spec: - name: myapp env: - name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS - value: AspNet,HttpClient,SqlClient + value: AspNet,HttpClient - name: DOTNET_STARTUP_HOOKS value: "/otel-auto-instrumentation/netcoreapp3.1/OpenTelemetry.AutoInstrumentation.StartupHook.dll" - name: DOTNET_ADDITIONAL_DEPS diff --git a/tests/e2e/instrumentation-dotnet/02-install-instrumentation.yaml b/tests/e2e/instrumentation-dotnet/02-install-instrumentation.yaml new file mode 100644 index 0000000000..391b502dfa --- /dev/null +++ b/tests/e2e/instrumentation-dotnet/02-install-instrumentation.yaml @@ -0,0 +1,30 @@ +apiVersion: opentelemetry.io/v1alpha1 +kind: Instrumentation +metadata: + name: dotnet +spec: + env: + - name: OTEL_TRACES_EXPORTER + value: otlp + - name: OTEL_EXPORTER_OTLP_ENDPOINT + value: http://localhost:4317 + - name: OTEL_EXPORTER_OTLP_TIMEOUT + value: "20" + - name: OTEL_TRACES_SAMPLER + value: parentbased_traceidratio + - name: OTEL_TRACES_SAMPLER_ARG + value: "0.85" + - name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED + value: "true" + exporter: + endpoint: http://localhost:4317 + propagators: + - jaeger + - b3 + sampler: + type: parentbased_traceidratio + argument: "0.25" + dotnet: + env: + - name: OTEL_LOG_LEVEL + value: "debug" \ No newline at end of file diff --git a/tests/e2e/instrumentation-dotnet/03-assert.yaml b/tests/e2e/instrumentation-dotnet/03-assert.yaml new file mode 100644 index 0000000000..c0a38522b8 --- /dev/null +++ b/tests/e2e/instrumentation-dotnet/03-assert.yaml @@ -0,0 +1,50 @@ +apiVersion: v1 +kind: Pod +metadata: + annotations: + sidecar.opentelemetry.io/inject: "true" + instrumentation.opentelemetry.io/inject-dotnet: "true" + labels: + app: my-pod-with-sidecar +spec: + containers: + - name: myapp + env: + - name: OTEL_LOG_LEVEL + value: "debug" + - name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS + value: AspNet,HttpClient,SqlClient + - name: DOTNET_STARTUP_HOOKS + value: "/otel-auto-instrumentation/netcoreapp3.1/OpenTelemetry.AutoInstrumentation.StartupHook.dll" + - name: DOTNET_ADDITIONAL_DEPS + value: ./otel-auto-instrumentation/AdditionalDeps + - name: DOTNET_SHARED_STORE + value: /otel-auto-instrumentation/store + - name: OTEL_TRACES_EXPORTER + value: otlp + - name: OTEL_EXPORTER_OTLP_ENDPOINT + value: http://localhost:4317 + - name: OTEL_EXPORTER_OTLP_TIMEOUT + value: "20" + - name: OTEL_TRACES_SAMPLER + value: parentbased_traceidratio + - name: OTEL_TRACES_SAMPLER_ARG + value: "0.85" + - name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED + value: "true" + - name: OTEL_SERVICE_NAME + value: my-deployment-with-sidecar + - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME + - name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME + - name: OTEL_PROPAGATORS + value: jaeger,b3 + - name: OTEL_RESOURCE_ATTRIBUTES + volumeMounts: + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - mountPath: /otel-auto-instrumentation + name: opentelemetry-auto-instrumentation + - name: otc-container + initContainers: + - name: opentelemetry-auto-instrumentation +status: + phase: Running diff --git a/tests/e2e/instrumentation-dotnet/03-install-app.yaml b/tests/e2e/instrumentation-dotnet/03-install-app.yaml new file mode 100644 index 0000000000..15c652bac4 --- /dev/null +++ b/tests/e2e/instrumentation-dotnet/03-install-app.yaml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: my-deployment-with-sidecar +spec: + selector: + matchLabels: + app: my-pod-with-sidecar + replicas: 1 + template: + metadata: + labels: + app: my-pod-with-sidecar + annotations: + sidecar.opentelemetry.io/inject: "true" + instrumentation.opentelemetry.io/inject-dotnet: "true" + spec: + securityContext: + runAsUser: 1000 + runAsGroup: 3000 + fsGroup: 2000 + containers: + - name: myapp + image: docker.io/adib070/mvc From 66d978e0e708d309578b805d552f5ae47074980e Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Tue, 26 Jul 2022 15:30:36 +0530 Subject: [PATCH 32/33] fixes e2e test case --- tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml b/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml index 1532df6abb..9fca3fec8f 100644 --- a/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml +++ b/tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml @@ -46,6 +46,8 @@ spec: name: opentelemetry-auto-instrumentation - name: myrabbit env: + - name: OTEL_LOG_LEVEL + value: "debug" - name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS value: AspNet,HttpClient,SqlClient - name: DOTNET_STARTUP_HOOKS From a2effd9c64d59f38a7ace35ffb0195d8bf1f453f Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Tue, 26 Jul 2022 16:47:32 +0530 Subject: [PATCH 33/33] fixes e2e test case --- .../02-install-instrumentation.yaml | 30 ----------- .../e2e/instrumentation-dotnet/03-assert.yaml | 50 ------------------- .../03-install-app.yaml | 24 --------- 3 files changed, 104 deletions(-) delete mode 100644 tests/e2e/instrumentation-dotnet/02-install-instrumentation.yaml delete mode 100644 tests/e2e/instrumentation-dotnet/03-assert.yaml delete mode 100644 tests/e2e/instrumentation-dotnet/03-install-app.yaml diff --git a/tests/e2e/instrumentation-dotnet/02-install-instrumentation.yaml b/tests/e2e/instrumentation-dotnet/02-install-instrumentation.yaml deleted file mode 100644 index 391b502dfa..0000000000 --- a/tests/e2e/instrumentation-dotnet/02-install-instrumentation.yaml +++ /dev/null @@ -1,30 +0,0 @@ -apiVersion: opentelemetry.io/v1alpha1 -kind: Instrumentation -metadata: - name: dotnet -spec: - env: - - name: OTEL_TRACES_EXPORTER - value: otlp - - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: http://localhost:4317 - - name: OTEL_EXPORTER_OTLP_TIMEOUT - value: "20" - - name: OTEL_TRACES_SAMPLER - value: parentbased_traceidratio - - name: OTEL_TRACES_SAMPLER_ARG - value: "0.85" - - name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED - value: "true" - exporter: - endpoint: http://localhost:4317 - propagators: - - jaeger - - b3 - sampler: - type: parentbased_traceidratio - argument: "0.25" - dotnet: - env: - - name: OTEL_LOG_LEVEL - value: "debug" \ No newline at end of file diff --git a/tests/e2e/instrumentation-dotnet/03-assert.yaml b/tests/e2e/instrumentation-dotnet/03-assert.yaml deleted file mode 100644 index c0a38522b8..0000000000 --- a/tests/e2e/instrumentation-dotnet/03-assert.yaml +++ /dev/null @@ -1,50 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - annotations: - sidecar.opentelemetry.io/inject: "true" - instrumentation.opentelemetry.io/inject-dotnet: "true" - labels: - app: my-pod-with-sidecar -spec: - containers: - - name: myapp - env: - - name: OTEL_LOG_LEVEL - value: "debug" - - name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS - value: AspNet,HttpClient,SqlClient - - name: DOTNET_STARTUP_HOOKS - value: "/otel-auto-instrumentation/netcoreapp3.1/OpenTelemetry.AutoInstrumentation.StartupHook.dll" - - name: DOTNET_ADDITIONAL_DEPS - value: ./otel-auto-instrumentation/AdditionalDeps - - name: DOTNET_SHARED_STORE - value: /otel-auto-instrumentation/store - - name: OTEL_TRACES_EXPORTER - value: otlp - - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: http://localhost:4317 - - name: OTEL_EXPORTER_OTLP_TIMEOUT - value: "20" - - name: OTEL_TRACES_SAMPLER - value: parentbased_traceidratio - - name: OTEL_TRACES_SAMPLER_ARG - value: "0.85" - - name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED - value: "true" - - name: OTEL_SERVICE_NAME - value: my-deployment-with-sidecar - - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME - - name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME - - name: OTEL_PROPAGATORS - value: jaeger,b3 - - name: OTEL_RESOURCE_ATTRIBUTES - volumeMounts: - - mountPath: /var/run/secrets/kubernetes.io/serviceaccount - - mountPath: /otel-auto-instrumentation - name: opentelemetry-auto-instrumentation - - name: otc-container - initContainers: - - name: opentelemetry-auto-instrumentation -status: - phase: Running diff --git a/tests/e2e/instrumentation-dotnet/03-install-app.yaml b/tests/e2e/instrumentation-dotnet/03-install-app.yaml deleted file mode 100644 index 15c652bac4..0000000000 --- a/tests/e2e/instrumentation-dotnet/03-install-app.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: my-deployment-with-sidecar -spec: - selector: - matchLabels: - app: my-pod-with-sidecar - replicas: 1 - template: - metadata: - labels: - app: my-pod-with-sidecar - annotations: - sidecar.opentelemetry.io/inject: "true" - instrumentation.opentelemetry.io/inject-dotnet: "true" - spec: - securityContext: - runAsUser: 1000 - runAsGroup: 3000 - fsGroup: 2000 - containers: - - name: myapp - image: docker.io/adib070/mvc