Skip to content

Commit 16bd77d

Browse files
committed
[processor/k8sattributes] Move feature gate k8sattr.rfc3339 to stable
1 parent 58ab68a commit 16bd77d

File tree

5 files changed

+36
-140
lines changed

5 files changed

+36
-140
lines changed

.chloggen/k8sattr.rfc3339.stable.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: k8sattributesprocessor
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Move `k8sattr.rfc3339` feature gate to stable.
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [33304]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

processor/k8sattributesprocessor/README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,5 @@ as tags.
330330

331331
## Timestamp Format
332332

333-
By default, the `k8s.pod.start_time` uses [Time.String()](https://pkg.go.dev/time#Time.String) to format the
334-
timestamp value.
335-
336-
The `k8sattr.rfc3339` feature gate can be enabled to format the `k8s.pod.start_time` timestamp value with an RFC3339
337-
compliant timestamp. See [Time.MarshalText()](https://pkg.go.dev/time#Time.MarshalText) for more information.
333+
By default, the `k8s.pod.start_time` uses [Time.MarshalText()](https://pkg.go.dev/time#Time.MarshalText) to format the
334+
timestamp value as an RFC3339 compliant timestamp.

processor/k8sattributesprocessor/internal/kube/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import (
2626
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor/internal/observability"
2727
)
2828

29-
// Upgrade to StageStable in v0.92.0
3029
var enableRFC3339Timestamp = featuregate.GlobalRegistry().MustRegister(
3130
"k8sattr.rfc3339",
32-
featuregate.StageBeta,
31+
featuregate.StageStable,
3332
featuregate.WithRegisterDescription("When enabled, uses RFC3339 format for k8s.pod.start_time value"),
3433
featuregate.WithRegisterFromVersion("v0.82.0"),
34+
featuregate.WithRegisterToVersion("v0.102.0"),
3535
)
3636

3737
// WatchClient is the main interface provided by this package to a kubernetes cluster.

processor/k8sattributesprocessor/internal/kube/client_test.go

Lines changed: 5 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111

1212
"github.com/stretchr/testify/assert"
1313
"github.com/stretchr/testify/require"
14-
"go.opentelemetry.io/collector/featuregate"
1514
"go.uber.org/zap"
1615
"go.uber.org/zap/zapcore"
1716
"go.uber.org/zap/zaptest/observer"
@@ -643,136 +642,6 @@ func TestHandlerWrongType(t *testing.T) {
643642
}
644643
}
645644

646-
func TestRFC3339FeatureGate(t *testing.T) {
647-
err := featuregate.GlobalRegistry().Set(enableRFC3339Timestamp.ID(), true)
648-
require.NoError(t, err)
649-
650-
c, _ := newTestClientWithRulesAndFilters(t, Filters{})
651-
// Disable saving ip into k8s.pod.ip
652-
c.Associations[0].Sources[0].Name = ""
653-
654-
pod := &api_v1.Pod{
655-
ObjectMeta: meta_v1.ObjectMeta{
656-
Name: "auth-service-abc12-xyz3",
657-
UID: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
658-
Namespace: "ns1",
659-
CreationTimestamp: meta_v1.Now(),
660-
Labels: map[string]string{
661-
"label1": "lv1",
662-
"label2": "k1=v1 k5=v5 extra!",
663-
},
664-
Annotations: map[string]string{
665-
"annotation1": "av1",
666-
},
667-
OwnerReferences: []meta_v1.OwnerReference{
668-
{
669-
APIVersion: "apps/v1",
670-
Kind: "ReplicaSet",
671-
Name: "auth-service-66f5996c7c",
672-
UID: "207ea729-c779-401d-8347-008ecbc137e3",
673-
},
674-
{
675-
APIVersion: "apps/v1",
676-
Kind: "DaemonSet",
677-
Name: "auth-daemonset",
678-
UID: "c94d3814-2253-427a-ab13-2cf609e4dafa",
679-
},
680-
{
681-
APIVersion: "batch/v1",
682-
Kind: "Job",
683-
Name: "auth-cronjob-27667920",
684-
UID: "59f27ac1-5c71-42e5-abe9-2c499d603706",
685-
},
686-
{
687-
APIVersion: "apps/v1",
688-
Kind: "StatefulSet",
689-
Name: "pi-statefulset",
690-
UID: "03755eb1-6175-47d5-afd5-05cfc30244d7",
691-
},
692-
},
693-
},
694-
Spec: api_v1.PodSpec{
695-
NodeName: "node1",
696-
Hostname: "host1",
697-
},
698-
Status: api_v1.PodStatus{
699-
PodIP: "1.1.1.1",
700-
},
701-
}
702-
703-
isController := true
704-
replicaset := &apps_v1.ReplicaSet{
705-
ObjectMeta: meta_v1.ObjectMeta{
706-
Name: "auth-service-66f5996c7c",
707-
Namespace: "ns1",
708-
UID: "207ea729-c779-401d-8347-008ecbc137e3",
709-
OwnerReferences: []meta_v1.OwnerReference{
710-
{
711-
Name: "auth-service",
712-
Kind: "Deployment",
713-
UID: "ffff-gggg-hhhh-iiii-eeeeeeeeeeee",
714-
Controller: &isController,
715-
},
716-
},
717-
},
718-
}
719-
720-
rfc3339ts, err := pod.GetCreationTimestamp().MarshalText()
721-
require.NoError(t, err)
722-
723-
testCases := []struct {
724-
name string
725-
rules ExtractionRules
726-
attributes map[string]string
727-
}{{
728-
name: "metadata",
729-
rules: ExtractionRules{
730-
DeploymentName: true,
731-
DeploymentUID: true,
732-
Namespace: true,
733-
PodName: true,
734-
PodUID: true,
735-
PodHostName: true,
736-
Node: true,
737-
StartTime: true,
738-
},
739-
attributes: map[string]string{
740-
"k8s.deployment.name": "auth-service",
741-
"k8s.deployment.uid": "ffff-gggg-hhhh-iiii-eeeeeeeeeeee",
742-
"k8s.namespace.name": "ns1",
743-
"k8s.node.name": "node1",
744-
"k8s.pod.name": "auth-service-abc12-xyz3",
745-
"k8s.pod.hostname": "host1",
746-
"k8s.pod.uid": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
747-
"k8s.pod.start_time": string(rfc3339ts),
748-
},
749-
},
750-
}
751-
for _, tc := range testCases {
752-
t.Run(tc.name, func(t *testing.T) {
753-
c.Rules = tc.rules
754-
755-
// manually call the data removal functions here
756-
// normally the informer does this, but fully emulating the informer in this test is annoying
757-
transformedPod := removeUnnecessaryPodData(pod, c.Rules)
758-
transformedReplicaset := removeUnnecessaryReplicaSetData(replicaset)
759-
c.handleReplicaSetAdd(transformedReplicaset)
760-
c.handlePodAdd(transformedPod)
761-
p, ok := c.GetPod(newPodIdentifier("connection", "", pod.Status.PodIP))
762-
require.True(t, ok)
763-
764-
assert.Equal(t, len(tc.attributes), len(p.Attributes))
765-
for k, v := range tc.attributes {
766-
got, ok := p.Attributes[k]
767-
assert.True(t, ok)
768-
assert.Equal(t, v, got)
769-
}
770-
})
771-
}
772-
err = featuregate.GlobalRegistry().Set(enableRFC3339Timestamp.ID(), false)
773-
require.NoError(t, err)
774-
}
775-
776645
func TestExtractionRules(t *testing.T) {
777646
c, _ := newTestClientWithRulesAndFilters(t, Filters{})
778647

@@ -955,7 +824,11 @@ func TestExtractionRules(t *testing.T) {
955824
"k8s.pod.name": "auth-service-abc12-xyz3",
956825
"k8s.pod.hostname": "host1",
957826
"k8s.pod.uid": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
958-
"k8s.pod.start_time": pod.GetCreationTimestamp().String(),
827+
"k8s.pod.start_time": func() string {
828+
b, err := pod.GetCreationTimestamp().MarshalText()
829+
require.NoError(t, err)
830+
return string(b)
831+
}(),
959832
},
960833
}, {
961834
name: "labels",

processor/k8sattributesprocessor/testdata/e2e/namespacedrbac/collector/deployment.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ spec:
2121
command:
2222
- /otelcontribcol
2323
- --config=/conf/relay.yaml
24-
- --feature-gates=k8sattr.rfc3339
2524
image: "otelcontribcol:latest"
2625
imagePullPolicy: Never
2726
ports:

0 commit comments

Comments
 (0)