Skip to content

Commit

Permalink
Merge branch 'main' into 3370
Browse files Browse the repository at this point in the history
  • Loading branch information
Israel Blancas authored Oct 18, 2024
2 parents 19f5dbc + 01b0755 commit 7728e1d
Show file tree
Hide file tree
Showing 35 changed files with 308 additions and 62 deletions.
16 changes: 16 additions & 0 deletions .chloggen/3330-python-otel-logs-exporter.yaml
Original file line number Diff line number Diff line change
@@ -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:
2 changes: 0 additions & 2 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
- name: Install tools
run: make install-tools
- name: Prepare e2e tests
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reusable-operator-hub-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ spec:
mode: statefulset
targetAllocator:
enabled: true
config:
config:
receivers:
prometheus:
config:
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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
Expand All @@ -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.

Expand Down Expand Up @@ -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:

Expand Down
3 changes: 2 additions & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| v0.116.0 | @swiatekm |
| v0.117.0 | @iblancasa |
2 changes: 1 addition & 1 deletion autoinstrumentation/java/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.8.0
2.9.0
26 changes: 13 additions & 13 deletions autoinstrumentation/nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
7 changes: 7 additions & 0 deletions pkg/collector/upgrade/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -160,3 +161,9 @@ func TestMain(m *testing.M) {

os.Exit(code)
}

func makeVersion(v string) version.Version {
return version.Version{
OpenTelemetryCollector: v,
}
}
20 changes: 18 additions & 2 deletions pkg/collector/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 {
Expand All @@ -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{}
Expand Down
7 changes: 4 additions & 3 deletions pkg/collector/upgrade/v0_104_0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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),
}
Expand All @@ -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")
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/collector/upgrade/v0_105_0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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),
}
Expand Down
66 changes: 66 additions & 0 deletions pkg/collector/upgrade/v0_110_0_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
3 changes: 1 addition & 2 deletions pkg/collector/upgrade/v0_15_0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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),
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/collector/upgrade/v0_19_0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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),
}
Expand Down Expand Up @@ -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),
}
Expand Down Expand Up @@ -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),
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/collector/upgrade/v0_24_0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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),
}
Expand Down
Loading

0 comments on commit 7728e1d

Please sign in to comment.