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

Instrumentations support select #2778

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ metadata:
categories: Logging & Tracing,Monitoring
certified: "false"
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
createdAt: "2024-03-25T10:41:54Z"
createdAt: "2024-03-25T15:01:37Z"
description: Provides the OpenTelemetry components, including the Collector
operators.operatorframework.io/builder: operator-sdk-v1.29.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
Expand Down Expand Up @@ -488,6 +488,8 @@ spec:
- --zap-log-level=info
- --zap-time-encoding=rfc3339nano
- --feature-gates=+operator.autoinstrumentation.go,+operator.autoinstrumentation.nginx
- --target-allocator-image=ghcr.io/open-telemetry/opentelemetry-operator/target-allocator:v0.96.0-20-g4f69d5b
- --operator-opamp-bridge-image=ghcr.io/open-telemetry/opentelemetry-operator/operator-opamp-bridge:v0.96.0-20-g4f69d5b
swiatekm marked this conversation as resolved.
Show resolved Hide resolved
image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.96.0
livenessProbe:
httpGet:
Expand Down
7 changes: 5 additions & 2 deletions pkg/instrumentation/podmutator.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ import (
)

var (
errNoInstancesAvailable = errors.New("no OpenTelemetry Instrumentation instances available")
errMultipleInstancesPossible = errors.New("multiple OpenTelemetry Instrumentation instances available, cannot determine which one to select")
errNoInstancesAvailable = errors.New("no OpenTelemetry Instrumentation instances available")
)

type instPodMutator struct {
Expand Down Expand Up @@ -424,7 +425,9 @@ func (pm *instPodMutator) selectInstrumentationInstanceFromNamespace(ctx context
switch s := len(availableInstrument); {
swiatekm marked this conversation as resolved.
Show resolved Hide resolved
case s == 0:
return nil, errNoInstancesAvailable
case s > 1:
return nil, errMultipleInstancesPossible
default:
return &availableInstrument[len(availableInstrument)-1], nil
return &otelInsts.Items[0], nil
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Pod
metadata:
annotations:
instrumentation.opentelemetry.io/inject-java: "true"
sidecar.opentelemetry.io/inject: "true"
labels:
app: my-java-without-select
spec:
containers:
- name: myapp
image: ghcr.io/open-telemetry/opentelemetry-operator/e2e-test-app-java:main
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: [ "ALL" ]

Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,32 @@ spec:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-java-without-select
spec:
selector:
matchLabels:
app: my-java-without-select
replicas: 1
template:
metadata:
labels:
app: my-java-without-select
annotations:
sidecar.opentelemetry.io/inject: "true"
instrumentation.opentelemetry.io/inject-java: "true"
spec:
securityContext:
runAsUser: 1000
runAsGroup: 3000
fsGroup: 3000
containers:
- name: myapp
image: ghcr.io/open-telemetry/opentelemetry-operator/e2e-test-app-java:main
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ spec:
- apply:
file: 01-install-app-select.yaml
- assert:
file: 01-assert-select.yaml
file: 01-assert*.yaml
catch:
- podLogs:
selector: app=my-java-select