Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Support DotNet auto-instrumentation #976

Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
04aaed8
Adds support for dotnet auto-instrumentation
avadhut123pisal Apr 12, 2022
713a17e
changes default image for testing
avadhut123pisal Apr 12, 2022
16d05ae
adds dotnet auto-instrumentation to the ldflags in makefile
avadhut123pisal Apr 12, 2022
89295de
changes in Makefile
avadhut123pisal Apr 12, 2022
ac57c4a
fixes issue in makefile
avadhut123pisal Apr 12, 2022
c07be13
fixes issue in dockerfile
avadhut123pisal Apr 12, 2022
e75108b
passes dotnet sample app image to e2e test
avadhut123pisal Apr 12, 2022
cd91768
fixes version in the dot net autoinstrumentation version file
avadhut123pisal Apr 13, 2022
2b18d4b
resolves merge conflicts
avadhut123pisal Apr 21, 2022
96c4ed6
adds testing changes for dot-net-autoinstrumentation
avadhut123pisal Apr 21, 2022
0204ae0
fixes annotation
avadhut123pisal Apr 22, 2022
b010bda
downloads dot-net release from github
avadhut123pisal Apr 22, 2022
d34e3bd
removes git push condition check
avadhut123pisal Apr 22, 2022
de99d8d
removes git push condition check
avadhut123pisal Apr 22, 2022
554296f
changes repo to logicmonitor
avadhut123pisal Apr 22, 2022
db167e7
resolves merge conflicts
avadhut123pisal Apr 22, 2022
9d3caae
adds dontnet auto-instrumentation related details in readme
avadhut123pisal Apr 25, 2022
0dc98c4
Merge branch 'main' of github.com:open-telemetry/opentelemetry-operat…
avadhut123pisal Apr 25, 2022
8055d7e
Merge branch 'main' of github.com:open-telemetry/opentelemetry-operat…
avadhut123pisal Apr 26, 2022
d29eddb
adds docker image layer caching in github action
avadhut123pisal Apr 26, 2022
6c2113c
triggers action on pull request
avadhut123pisal Apr 26, 2022
89d5367
resolves merge conflicts
avadhut123pisal Apr 28, 2022
733f908
resolves merge conflicts
avadhut123pisal Jul 11, 2022
91d0683
Merge branch 'main' of github.com:open-telemetry/opentelemetry-operat…
avadhut123pisal Jul 11, 2022
8b07a24
Merge branch 'main' of github.com:open-telemetry/opentelemetry-operat…
avadhut123pisal Jul 13, 2022
7c7d4fb
adds e2e test cases for dotnet instrumentation
avadhut123pisal Jul 13, 2022
7087fb4
fixes version for dotnet instrumentation
avadhut123pisal Jul 13, 2022
d29df8b
version changes
avadhut123pisal Jul 13, 2022
6010409
restores clusterversion file
avadhut123pisal Jul 13, 2022
f75b3fc
restores changes in Makefile
avadhut123pisal Jul 13, 2022
ef5bdb0
minor change
avadhut123pisal Jul 13, 2022
76cfb82
Adds configuration details to dockerfile
avadhut123pisal Jul 13, 2022
dec4b39
updates version of dotnet auto-instrumentation
avadhut123pisal Jul 19, 2022
61657c3
resolves merge conflict
avadhut123pisal Jul 19, 2022
1176f83
Merge branch 'main' of github.com:avadhut123pisal/opentelemetry-opera…
avadhut123pisal Jul 20, 2022
8d85f1f
changes env var name from OTEL_DOTNET_TRACER_INSTRUMENTATIONS to OTEL…
avadhut123pisal Jul 20, 2022
bac4b3d
removes java related env variables
avadhut123pisal Jul 20, 2022
c3d81e1
fixes e2e test cases
avadhut123pisal Jul 20, 2022
e8d4019
fixes e2e test case
avadhut123pisal Jul 20, 2022
23a4198
deletes .DS_Store file
avadhut123pisal Jul 25, 2022
56316cb
sets OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS to default value
avadhut123pisal Jul 26, 2022
66d978e
fixes e2e test case
avadhut123pisal Jul 26, 2022
a2effd9
fixes e2e test case
avadhut123pisal Jul 26, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ jobs:
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
cache-to: type=local,dest=/tmp/.buildx-cache
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 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
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ 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}')"
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}"
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}"

# Image URL to use all building/pushing image targets
IMG_PREFIX ?= ghcr.io/${USER}/opentelemetry-operator
Expand Down Expand Up @@ -174,7 +175,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
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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 in the current namespace.
Expand Down Expand Up @@ -271,6 +276,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).
Expand Down
16 changes: 16 additions & 0 deletions apis/v1alpha1/instrumentation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
}
Expand Down
9 changes: 9 additions & 0 deletions apis/v1alpha1/instrumentation_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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_"
)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
23 changes: 23 additions & 0 deletions apis/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

121 changes: 121 additions & 0 deletions bundle/manifests/opentelemetry.io_instrumentations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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[''<KEY>'']`,
`metadata.annotations[''<KEY>'']`, 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
Expand Down
Loading