diff --git a/.chloggen/3330-python-otel-logs-exporter.yaml b/.chloggen/3330-python-otel-logs-exporter.yaml new file mode 100644 index 0000000000..021c205811 --- /dev/null +++ b/.chloggen/3330-python-otel-logs-exporter.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) +component: auto-instrumentation + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: set OTEL_LOGS_EXPORTER env var to otlp in python instrumentation + +# One or more tracking issues related to the change +issues: [3330] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index b762ef419f..ce4cc811db 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -62,8 +62,6 @@ jobs: with: path: bin key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile') }}-${{ steps.setup-go.outputs.go-version }} - - name: Install chainsaw - uses: kyverno/action-install-chainsaw@v0.2.11 - name: Install tools run: make install-tools - name: Prepare e2e tests diff --git a/.github/workflows/reusable-operator-hub-release.yaml b/.github/workflows/reusable-operator-hub-release.yaml index d453b92a93..e9de4190e2 100644 --- a/.github/workflows/reusable-operator-hub-release.yaml +++ b/.github/workflows/reusable-operator-hub-release.yaml @@ -56,7 +56,7 @@ jobs: env: VERSION: ${{ env.version }} run: | - mkdir operators/opentelemetry-operator/${VERSION} + mkdir operators/opentelemetry-operator/${VERSION} cp -R ./tmp/bundle/${{ inputs.folder }}/* operators/opentelemetry-operator/${VERSION} rm -rf ./tmp @@ -73,7 +73,7 @@ jobs: message="Update the opentelemetry to $VERSION" body="Release opentelemetry-operator \`$VERSION\`. - cc @pavolloffay @frzifus @yuriolisa @jaronoff97 @TylerHelmuth @swiatekm + cc @pavolloffay @frzifus @yuriolisa @jaronoff97 @TylerHelmuth @swiatekm @iblancasa " branch="update-opentelemetry-operator-to-${VERSION}" diff --git a/Makefile b/Makefile index 384a7ea1f7..183887ec7c 100644 --- a/Makefile +++ b/Makefile @@ -473,7 +473,7 @@ KUSTOMIZE_VERSION ?= v5.0.3 CONTROLLER_TOOLS_VERSION ?= v0.16.1 GOLANGCI_LINT_VERSION ?= v1.57.2 KIND_VERSION ?= v0.20.0 -CHAINSAW_VERSION ?= v0.2.5 +CHAINSAW_VERSION ?= v0.2.8 .PHONY: install-tools install-tools: kustomize golangci-lint kind controller-gen envtest crdoc kind operator-sdk chainsaw diff --git a/README.md b/README.md index 97b4ed9049..c94bb0670b 100644 --- a/README.md +++ b/README.md @@ -608,7 +608,7 @@ spec: mode: statefulset targetAllocator: enabled: true - config: + config: receivers: prometheus: config: @@ -740,7 +740,7 @@ spec: ### Configure resource attributes with labels -You can also use common labels to set resource attributes. +You can also use common labels to set resource attributes. The following labels are supported: - `app.kubernetes.io/name` becomes `service.name` @@ -782,12 +782,12 @@ The priority for setting resource attributes is as follows (first found wins): 1. Resource attributes set via `OTEL_RESOURCE_ATTRIBUTES` and `OTEL_SERVICE_NAME` environment variables 2. Resource attributes set via annotations (with the `resource.opentelemetry.io/` prefix) -3. Resource attributes set via labels (e.g. `app.kubernetes.io/name`) +3. Resource attributes set via labels (e.g. `app.kubernetes.io/name`) if the `Instrumentation` CR has defaults.useLabelsForResourceAttributes=true (see above) 4. Resource attributes calculated from the pod's metadata (e.g. `k8s.pod.name`) 5. Resource attributes set via the `Instrumentation` CR (in the `spec.resource.resourceAttributes` section) -This priority is applied for each resource attribute separately, so it is possible to set some attributes via +This priority is applied for each resource attribute separately, so it is possible to set some attributes via annotations and others via labels. ## Compatibility matrix @@ -807,7 +807,7 @@ We strive to be compatible with the widest range of Kubernetes versions as possi We use `cert-manager` for some features of this operator and the third column shows the versions of the `cert-manager` that are known to work with this operator's versions. The Target Allocator supports prometheus-operator CRDs like ServiceMonitor, and it does so by using packages imported from prometheus-operator itself. The table shows which version is shipped with a given operator version. -Generally speaking, these are backwards compatible, but specific features require the appropriate package versions. +Generally speaking, these are backwards compatible, but specific features require the appropriate package versions. The OpenTelemetry Operator _might_ work on versions outside of the given range, but when opening new issues, please make sure to test your scenario on a supported version. @@ -849,6 +849,7 @@ Approvers ([@open-telemetry/operator-approvers](https://github.com/orgs/open-tel - [Benedikt Bongartz](https://github.com/frzifus), Red Hat - [Tyler Helmuth](https://github.com/TylerHelmuth), Honeycomb - [Yuri Oliveira Sa](https://github.com/yuriolisa), Red Hat +- [Israel Blancas](https://github.com/iblancasa), Red Hat Emeritus Approvers: diff --git a/RELEASE.md b/RELEASE.md index 046a05c81c..55570bfa3a 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -49,4 +49,5 @@ The operator should be released within a week after the [OpenTelemetry collector | v0.113.0 | @pavolloffay | | v0.114.0 | @TylerHelmuth | | v0.115.0 | @jaronoff97 | -| v0.116.0 | @swiatekm | \ No newline at end of file +| v0.116.0 | @swiatekm | +| v0.117.0 | @iblancasa | diff --git a/autoinstrumentation/java/version.txt b/autoinstrumentation/java/version.txt index 834f262953..c8e38b6140 100644 --- a/autoinstrumentation/java/version.txt +++ b/autoinstrumentation/java/version.txt @@ -1 +1 @@ -2.8.0 +2.9.0 diff --git a/autoinstrumentation/nodejs/package.json b/autoinstrumentation/nodejs/package.json index 7e5886a89c..d971d98733 100644 --- a/autoinstrumentation/nodejs/package.json +++ b/autoinstrumentation/nodejs/package.json @@ -10,21 +10,21 @@ }, "devDependencies": { "copyfiles": "^2.4.1", - "rimraf": "^5.0.8", - "typescript": "^5.5.3" + "rimraf": "^6.0.1", + "typescript": "^5.6.3" }, "dependencies": { "@opentelemetry/api": "1.9.0", - "@opentelemetry/auto-instrumentations-node": "0.48.0", - "@opentelemetry/exporter-metrics-otlp-grpc": "0.52.1", - "@opentelemetry/exporter-prometheus": "0.52.1", - "@opentelemetry/exporter-trace-otlp-grpc": "0.52.1", - "@opentelemetry/resource-detector-alibaba-cloud": "0.28.10", - "@opentelemetry/resource-detector-aws": "1.5.2", - "@opentelemetry/resource-detector-container": "0.3.11", - "@opentelemetry/resource-detector-gcp": "0.29.10", - "@opentelemetry/resources": "1.25.1", - "@opentelemetry/sdk-metrics": "1.25.1", - "@opentelemetry/sdk-node": "0.52.1" + "@opentelemetry/auto-instrumentations-node": "0.51.0", + "@opentelemetry/exporter-metrics-otlp-grpc": "0.53.0", + "@opentelemetry/exporter-prometheus": "0.53.0", + "@opentelemetry/exporter-trace-otlp-grpc": "0.53.0", + "@opentelemetry/resource-detector-alibaba-cloud": "0.29.3", + "@opentelemetry/resource-detector-aws": "1.6.2", + "@opentelemetry/resource-detector-container": "0.4.4", + "@opentelemetry/resource-detector-gcp": "0.29.12", + "@opentelemetry/resources": "1.26.0", + "@opentelemetry/sdk-metrics": "1.26.0", + "@opentelemetry/sdk-node": "0.53.0" } } diff --git a/pkg/collector/upgrade/suite_test.go b/pkg/collector/upgrade/suite_test.go index c5e5cdbd23..7a571bc481 100644 --- a/pkg/collector/upgrade/suite_test.go +++ b/pkg/collector/upgrade/suite_test.go @@ -42,6 +42,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/rbac" + "github.com/open-telemetry/opentelemetry-operator/internal/version" ) var ( @@ -160,3 +161,9 @@ func TestMain(m *testing.M) { os.Exit(code) } + +func makeVersion(v string) version.Version { + return version.Version{ + OpenTelemetryCollector: v, + } +} diff --git a/pkg/collector/upgrade/upgrade.go b/pkg/collector/upgrade/upgrade.go index 9a1f426747..610fca140f 100644 --- a/pkg/collector/upgrade/upgrade.go +++ b/pkg/collector/upgrade/upgrade.go @@ -39,6 +39,17 @@ type VersionUpgrade struct { const RecordBufferSize int = 100 +func (u VersionUpgrade) semVer() *semver.Version { + if len(u.Version.OpenTelemetryCollector) == 0 { + return &Latest.Version + } + if v, err := semver.NewVersion(u.Version.OpenTelemetryCollector); err != nil { + return &Latest.Version + } else { + return v + } +} + // ManagedInstances finds all the otelcol instances for the current operator and upgrades them, if necessary. func (u VersionUpgrade) ManagedInstances(ctx context.Context) error { u.Log.Info("looking for managed instances to upgrade") @@ -107,9 +118,9 @@ func (u VersionUpgrade) ManagedInstance(_ context.Context, otelcol v1beta1.OpenT } updated := *(otelcol.DeepCopy()) - if instanceV.GreaterThan(&Latest.Version) { + if instanceV.GreaterThan(u.semVer()) { // Update with the latest known version, which is what we have from versions.txt - u.Log.V(4).Info("no upgrade routines are needed for the OpenTelemetry instance", "name", updated.Name, "namespace", updated.Namespace, "version", updated.Status.Version, "latest", Latest.Version.String()) + u.Log.V(4).Info("no upgrade routines are needed for the OpenTelemetry instance", "name", updated.Name, "namespace", updated.Namespace, "version", updated.Status.Version, "latest", u.semVer().String()) otelColV, err := semver.NewVersion(u.Version.OpenTelemetryCollector) if err != nil { @@ -126,6 +137,11 @@ func (u VersionUpgrade) ManagedInstance(_ context.Context, otelcol v1beta1.OpenT } for _, available := range versions { + // Don't run upgrades for versions after the webhook's set version. + // This is important only for testing. + if available.GreaterThan(u.semVer()) { + continue + } if available.GreaterThan(instanceV) { if available.upgrade != nil { otelcolV1alpha1 := &v1alpha1.OpenTelemetryCollector{} diff --git a/pkg/collector/upgrade/v0_104_0_test.go b/pkg/collector/upgrade/v0_104_0_test.go index bdf88e7c8e..0c5b939479 100644 --- a/pkg/collector/upgrade/v0_104_0_test.go +++ b/pkg/collector/upgrade/v0_104_0_test.go @@ -24,7 +24,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -46,7 +45,7 @@ func Test0_104_0Upgrade(t *testing.T) { versionUpgrade := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.104.0"), Client: k8sClient, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } @@ -56,7 +55,9 @@ func Test0_104_0Upgrade(t *testing.T) { t.Errorf("expect err: nil but got: %v", err) } assert.EqualValues(t, - map[string]string{}, + map[string]string{ + "feature-gates": "-component.UseLocalHostAsDefaultHost", + }, col.Spec.Args, "missing featuregate") } diff --git a/pkg/collector/upgrade/v0_105_0_test.go b/pkg/collector/upgrade/v0_105_0_test.go index c92880790d..b0af1cd8ea 100644 --- a/pkg/collector/upgrade/v0_105_0_test.go +++ b/pkg/collector/upgrade/v0_105_0_test.go @@ -23,7 +23,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -59,7 +58,7 @@ func Test0_105_0Upgrade(t *testing.T) { versionUpgrade := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.105.0"), Client: k8sClient, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_110_0_test.go b/pkg/collector/upgrade/v0_110_0_test.go new file mode 100644 index 0000000000..ec63f004c1 --- /dev/null +++ b/pkg/collector/upgrade/v0_110_0_test.go @@ -0,0 +1,66 @@ +// 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 upgrade_test + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/tools/record" + + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" + "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" +) + +func Test0_110_0Upgrade(t *testing.T) { + collectorInstance := v1beta1.OpenTelemetryCollector{ + TypeMeta: metav1.TypeMeta{ + Kind: "OpenTelemetryCollector", + APIVersion: "v1beta1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "otel-my-instance", + Namespace: "somewhere", + }, + Status: v1beta1.OpenTelemetryCollectorStatus{ + Version: "0.104.0", + }, + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ + Args: map[string]string{ + "foo": "bar", + "feature-gates": "+baz,-component.UseLocalHostAsDefaultHost", + }, + }, + Config: v1beta1.Config{}, + }, + } + + versionUpgrade := &upgrade.VersionUpgrade{ + Log: logger, + Version: makeVersion("0.110.0"), + Client: k8sClient, + Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), + } + + col, err := versionUpgrade.ManagedInstance(context.Background(), collectorInstance) + if err != nil { + t.Errorf("expect err: nil but got: %v", err) + } + assert.EqualValues(t, + map[string]string{"foo": "bar", "feature-gates": "+baz"}, col.Spec.Args) +} diff --git a/pkg/collector/upgrade/v0_15_0_test.go b/pkg/collector/upgrade/v0_15_0_test.go index 0a01a3e847..4063f85829 100644 --- a/pkg/collector/upgrade/v0_15_0_test.go +++ b/pkg/collector/upgrade/v0_15_0_test.go @@ -25,7 +25,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -57,7 +56,7 @@ func TestRemoveMetricsTypeFlags(t *testing.T) { // test up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.15.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_19_0_test.go b/pkg/collector/upgrade/v0_19_0_test.go index 63162e5dce..3c3a5e66d0 100644 --- a/pkg/collector/upgrade/v0_19_0_test.go +++ b/pkg/collector/upgrade/v0_19_0_test.go @@ -26,7 +26,6 @@ import ( "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/adapters" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -74,7 +73,7 @@ service: // test up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.19.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } @@ -124,7 +123,7 @@ service: // test up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.19.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } @@ -191,7 +190,7 @@ service: // test up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.19.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_24_0_test.go b/pkg/collector/upgrade/v0_24_0_test.go index caf53bdfd2..52669150ff 100644 --- a/pkg/collector/upgrade/v0_24_0_test.go +++ b/pkg/collector/upgrade/v0_24_0_test.go @@ -24,7 +24,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -64,7 +63,7 @@ service: // test up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.24.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_31_0_test.go b/pkg/collector/upgrade/v0_31_0_test.go index 861cdb492d..dd340ed655 100644 --- a/pkg/collector/upgrade/v0_31_0_test.go +++ b/pkg/collector/upgrade/v0_31_0_test.go @@ -24,7 +24,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -63,7 +62,7 @@ service: // test up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.31.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_36_0_test.go b/pkg/collector/upgrade/v0_36_0_test.go index 7695d39c00..346adb424c 100644 --- a/pkg/collector/upgrade/v0_36_0_test.go +++ b/pkg/collector/upgrade/v0_36_0_test.go @@ -24,7 +24,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -79,7 +78,7 @@ service: up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.36.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_38_0_test.go b/pkg/collector/upgrade/v0_38_0_test.go index 26e3d69bbb..efa74d9c6a 100644 --- a/pkg/collector/upgrade/v0_38_0_test.go +++ b/pkg/collector/upgrade/v0_38_0_test.go @@ -24,7 +24,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -72,7 +71,7 @@ service: // EXPECTED: drop logging args and configure logging parameters into config from args up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.38.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_39_0_test.go b/pkg/collector/upgrade/v0_39_0_test.go index 204c576c8a..39ffa04436 100644 --- a/pkg/collector/upgrade/v0_39_0_test.go +++ b/pkg/collector/upgrade/v0_39_0_test.go @@ -24,7 +24,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -74,7 +73,7 @@ service: // drop processors.memory_limiter field 'ballast_size_mib' up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.39.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_41_0_test.go b/pkg/collector/upgrade/v0_41_0_test.go index 01903044a5..f13047eefa 100644 --- a/pkg/collector/upgrade/v0_41_0_test.go +++ b/pkg/collector/upgrade/v0_41_0_test.go @@ -24,7 +24,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -64,7 +63,7 @@ service: // TESTCASE 1: restructure cors for both allowed_origin & allowed_headers up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.41.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_43_0_test.go b/pkg/collector/upgrade/v0_43_0_test.go index 348b1d0b96..957849f941 100644 --- a/pkg/collector/upgrade/v0_43_0_test.go +++ b/pkg/collector/upgrade/v0_43_0_test.go @@ -24,7 +24,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -70,7 +69,7 @@ service: // test up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.43.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_56_0_test.go b/pkg/collector/upgrade/v0_56_0_test.go index 57ced4b07a..fd29c55aed 100644 --- a/pkg/collector/upgrade/v0_56_0_test.go +++ b/pkg/collector/upgrade/v0_56_0_test.go @@ -23,7 +23,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -50,7 +49,7 @@ func Test0_56_0Upgrade(t *testing.T) { collectorInstance.Status.Version = "0.55.0" versionUpgrade := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.56.0"), Client: k8sClient, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_57_2_test.go b/pkg/collector/upgrade/v0_57_2_test.go index a3ca59919c..c43b869591 100644 --- a/pkg/collector/upgrade/v0_57_2_test.go +++ b/pkg/collector/upgrade/v0_57_2_test.go @@ -23,7 +23,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -67,7 +66,7 @@ service: //Test to remove port and change endpoint value. versionUpgrade := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.57.2"), Client: k8sClient, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_61_0_test.go b/pkg/collector/upgrade/v0_61_0_test.go index f702695672..91bfdc447f 100644 --- a/pkg/collector/upgrade/v0_61_0_test.go +++ b/pkg/collector/upgrade/v0_61_0_test.go @@ -23,7 +23,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -72,7 +71,7 @@ func Test0_61_0Upgrade(t *testing.T) { versionUpgrade := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.61.0"), Client: k8sClient, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/collector/upgrade/v0_9_0_test.go b/pkg/collector/upgrade/v0_9_0_test.go index c428034000..06c5c8cf7f 100644 --- a/pkg/collector/upgrade/v0_9_0_test.go +++ b/pkg/collector/upgrade/v0_9_0_test.go @@ -25,7 +25,6 @@ import ( "k8s.io/client-go/tools/record" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" ) @@ -56,7 +55,7 @@ func TestRemoveConnectionDelay(t *testing.T) { // test up := &upgrade.VersionUpgrade{ Log: logger, - Version: version.Get(), + Version: makeVersion("0.9.0"), Client: nil, Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize), } diff --git a/pkg/instrumentation/podmutator_test.go b/pkg/instrumentation/podmutator_test.go index 400d44c22b..dd471ad789 100644 --- a/pkg/instrumentation/podmutator_test.go +++ b/pkg/instrumentation/podmutator_test.go @@ -1258,6 +1258,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, { Name: "OTEL_EXPORTER_OTLP_ENDPOINT", Value: "http://localhost:4318", @@ -1361,6 +1365,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, { Name: "OTEL_EXPORTER_OTLP_ENDPOINT", Value: "http://localhost:4318", @@ -1454,6 +1462,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, { Name: "OTEL_EXPORTER_OTLP_ENDPOINT", Value: "http://localhost:4318", @@ -1562,6 +1574,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, { Name: "OTEL_EXPORTER_OTLP_ENDPOINT", Value: "http://localhost:4318", @@ -1653,6 +1669,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, { Name: "OTEL_EXPORTER_OTLP_ENDPOINT", Value: "http://localhost:4318", @@ -1746,6 +1766,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, { Name: "OTEL_EXPORTER_OTLP_ENDPOINT", Value: "http://localhost:4318", @@ -4125,6 +4149,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, { Name: "OTEL_SERVICE_NAME", Value: "python1", @@ -4200,6 +4228,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, { Name: "OTEL_SERVICE_NAME", Value: "python2", diff --git a/pkg/instrumentation/python.go b/pkg/instrumentation/python.go index d3cfc51ca4..c0745cd814 100644 --- a/pkg/instrumentation/python.go +++ b/pkg/instrumentation/python.go @@ -26,6 +26,7 @@ const ( envPythonPath = "PYTHONPATH" envOtelTracesExporter = "OTEL_TRACES_EXPORTER" envOtelMetricsExporter = "OTEL_METRICS_EXPORTER" + envOtelLogsExporter = "OTEL_LOGS_EXPORTER" envOtelExporterOTLPProtocol = "OTEL_EXPORTER_OTLP_PROTOCOL" pythonPathPrefix = "/otel-auto-instrumentation-python/opentelemetry/instrumentation/auto_instrumentation" pythonPathSuffix = "/otel-auto-instrumentation-python" @@ -70,7 +71,7 @@ func injectPythonSDK(pythonSpec v1alpha1.Python, pod corev1.Pod, index int) (cor }) } - // Set OTEL_TRACES_EXPORTER to HTTP exporter if not set by user because it is what our autoinstrumentation supports. + // Set OTEL_TRACES_EXPORTER to otlp exporter if not set by user because it is what our autoinstrumentation supports. idx = getIndexOfEnv(container.Env, envOtelTracesExporter) if idx == -1 { container.Env = append(container.Env, corev1.EnvVar{ @@ -79,7 +80,7 @@ func injectPythonSDK(pythonSpec v1alpha1.Python, pod corev1.Pod, index int) (cor }) } - // Set OTEL_METRICS_EXPORTER to HTTP exporter if not set by user because it is what our autoinstrumentation supports. + // Set OTEL_METRICS_EXPORTER to otlp exporter if not set by user because it is what our autoinstrumentation supports. idx = getIndexOfEnv(container.Env, envOtelMetricsExporter) if idx == -1 { container.Env = append(container.Env, corev1.EnvVar{ @@ -88,6 +89,15 @@ func injectPythonSDK(pythonSpec v1alpha1.Python, pod corev1.Pod, index int) (cor }) } + // Set OTEL_LOGS_EXPORTER to otlp exporter if not set by user because it is what our autoinstrumentation supports. + idx = getIndexOfEnv(container.Env, envOtelLogsExporter) + if idx == -1 { + container.Env = append(container.Env, corev1.EnvVar{ + Name: envOtelLogsExporter, + Value: "otlp", + }) + } + container.VolumeMounts = append(container.VolumeMounts, corev1.VolumeMount{ Name: pythonVolumeName, MountPath: pythonInstrMountPath, diff --git a/pkg/instrumentation/python_test.go b/pkg/instrumentation/python_test.go index 2ced01bb07..01fe9b1665 100644 --- a/pkg/instrumentation/python_test.go +++ b/pkg/instrumentation/python_test.go @@ -90,6 +90,10 @@ func TestInjectPythonSDK(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, }, }, }, @@ -163,6 +167,10 @@ func TestInjectPythonSDK(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, }, }, }, @@ -235,6 +243,10 @@ func TestInjectPythonSDK(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, }, }, }, @@ -307,6 +319,86 @@ func TestInjectPythonSDK(t *testing.T) { Name: "OTEL_TRACES_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, + }, + }, + }, + }, + }, + err: nil, + }, + { + name: "OTEL_LOGS_EXPORTER defined", + Python: v1alpha1.Python{Image: "foo/bar:1"}, + pod: corev1.Pod{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Env: []corev1.EnvVar{ + { + Name: "OTEL_LOGS_EXPORTER", + Value: "somebackend", + }, + }, + }, + }, + }, + }, + expected: corev1.Pod{ + Spec: corev1.PodSpec{ + Volumes: []corev1.Volume{ + { + Name: "opentelemetry-auto-instrumentation-python", + VolumeSource: corev1.VolumeSource{ + EmptyDir: &corev1.EmptyDirVolumeSource{ + SizeLimit: &defaultVolumeLimitSize, + }, + }, + }, + }, + InitContainers: []corev1.Container{ + { + Name: "opentelemetry-auto-instrumentation-python", + Image: "foo/bar:1", + Command: []string{"cp", "-r", "/autoinstrumentation/.", "/otel-auto-instrumentation-python"}, + VolumeMounts: []corev1.VolumeMount{{ + Name: "opentelemetry-auto-instrumentation-python", + MountPath: "/otel-auto-instrumentation-python", + }}, + }, + }, + Containers: []corev1.Container{ + { + VolumeMounts: []corev1.VolumeMount{ + { + Name: "opentelemetry-auto-instrumentation-python", + MountPath: "/otel-auto-instrumentation-python", + }, + }, + Env: []corev1.EnvVar{ + { + Name: "OTEL_LOGS_EXPORTER", + Value: "somebackend", + }, + { + Name: "PYTHONPATH", + Value: fmt.Sprintf("%s:%s", "/otel-auto-instrumentation-python/opentelemetry/instrumentation/auto_instrumentation", "/otel-auto-instrumentation-python"), + }, + { + Name: "OTEL_EXPORTER_OTLP_PROTOCOL", + Value: "http/protobuf", + }, + { + Name: "OTEL_TRACES_EXPORTER", + Value: "otlp", + }, + { + Name: "OTEL_METRICS_EXPORTER", + Value: "otlp", + }, }, }, }, @@ -379,6 +471,10 @@ func TestInjectPythonSDK(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, }, }, }, diff --git a/pkg/instrumentation/sdk_test.go b/pkg/instrumentation/sdk_test.go index c3abedac04..38013ed3ac 100644 --- a/pkg/instrumentation/sdk_test.go +++ b/pkg/instrumentation/sdk_test.go @@ -1261,6 +1261,10 @@ func TestInjectPython(t *testing.T) { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", }, + { + Name: "OTEL_LOGS_EXPORTER", + Value: "otlp", + }, { Name: "OTEL_SERVICE_NAME", Value: "app", diff --git a/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml index d0e8c12567..72f6e7e712 100644 --- a/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml @@ -26,6 +26,8 @@ spec: value: otlp - name: OTEL_METRICS_EXPORTER value: otlp + - name: OTEL_LOGS_EXPORTER + value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT value: http://localhost:4317 - name: OTEL_EXPORTER_OTLP_TIMEOUT @@ -74,6 +76,8 @@ spec: value: otlp - name: OTEL_METRICS_EXPORTER value: otlp + - name: OTEL_LOGS_EXPORTER + value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT value: http://localhost:4317 - name: OTEL_EXPORTER_OTLP_TIMEOUT diff --git a/tests/e2e-instrumentation/instrumentation-python-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-python-multicontainer/02-assert.yaml index da7c987e54..5e2cbf06e2 100644 --- a/tests/e2e-instrumentation/instrumentation-python-multicontainer/02-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-python-multicontainer/02-assert.yaml @@ -37,6 +37,8 @@ spec: value: otlp - name: OTEL_METRICS_EXPORTER value: otlp + - name: OTEL_LOGS_EXPORTER + value: otlp - name: OTEL_EXPORTER_OTLP_ENDPOINT value: http://localhost:4317 - name: OTEL_EXPORTER_OTLP_TIMEOUT diff --git a/tests/e2e-instrumentation/instrumentation-python/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-python/01-assert.yaml index 62cf682ba0..94ff9058d7 100644 --- a/tests/e2e-instrumentation/instrumentation-python/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-python/01-assert.yaml @@ -29,6 +29,8 @@ spec: value: http/protobuf - name: OTEL_METRICS_EXPORTER value: otlp + - name: OTEL_LOGS_EXPORTER + value: otlp - name: OTEL_EXPORTER_OTLP_TIMEOUT value: "20" - name: OTEL_TRACES_SAMPLER diff --git a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer-go/02-assert.yaml b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer-go/02-assert.yaml index 71d4e05d06..63c9e239e3 100644 --- a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer-go/02-assert.yaml +++ b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer-go/02-assert.yaml @@ -43,6 +43,8 @@ spec: value: otlp - name: OTEL_METRICS_EXPORTER value: otlp + - name: OTEL_LOGS_EXPORTER + value: otlp - name: OTEL_EXPORTER_OTLP_TIMEOUT value: "20" - name: OTEL_TRACES_SAMPLER diff --git a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml index 61eabd4e91..b0edc6701f 100644 --- a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml +++ b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml @@ -185,6 +185,8 @@ spec: value: otlp - name: OTEL_METRICS_EXPORTER value: otlp + - name: OTEL_LOGS_EXPORTER + value: otlp - name: OTEL_TRACES_SAMPLER value: parentbased_traceidratio - name: OTEL_TRACES_SAMPLER_ARG