Skip to content

Commit ff70420

Browse files
authored
Move filelog.container.removeOriginalTimeField fg to stable (#37236)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Following #35169. This PR moves `filelog.container.removeOriginalTimeField` feature gate to stable. <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Related to #33389 <!--Describe what testing was performed and which tests were added.--> #### Testing Updated <!--Describe the documentation added.--> #### Documentation Updated <!--Please delete paragraphs that you did not use before submitting.--> Signed-off-by: ChrsMark <[email protected]>
1 parent 57a5d0d commit ff70420

File tree

5 files changed

+32
-122
lines changed

5 files changed

+32
-122
lines changed

.chloggen/fg_filelog_stable.yaml

+27
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: pkg/stanza
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Move `filelog.container.removeOriginalTimeField` 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: [33389]
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: [user]

pkg/stanza/docs/operators/container.md

-7
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,3 @@ receivers:
320320
</td>
321321
</tr>
322322
</table>
323-
324-
### Removing original time field
325-
326-
In order to remove the original time field from the log records users can enable the
327-
`filelog.container.removeOriginalTimeField` feature gate.
328-
The feature gate `filelog.container.removeOriginalTimeField` will be deprecated and eventually removed
329-
in the future, following the [feature lifecycle](https://github.com/open-telemetry/opentelemetry-collector/tree/main/featuregate#feature-lifecycle).

pkg/stanza/operator/parser/container/config.go

+4-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
"go.opentelemetry.io/collector/component"
1111
"go.opentelemetry.io/collector/featuregate"
12-
"go.uber.org/zap"
1312

1413
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/entry"
1514
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/errors"
@@ -25,11 +24,13 @@ const (
2524
removeOriginalTimeFieldFeatureFlag = "filelog.container.removeOriginalTimeField"
2625
)
2726

28-
var removeOriginalTimeField = featuregate.GlobalRegistry().MustRegister(
27+
var _ = featuregate.GlobalRegistry().MustRegister(
2928
removeOriginalTimeFieldFeatureFlag,
30-
featuregate.StageBeta,
29+
featuregate.StageStable,
3130
featuregate.WithRegisterDescription("When enabled, deletes the original `time` field from the Log Attributes. Time is parsed to Timestamp field, which should be used instead."),
3231
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33389"),
32+
featuregate.WithRegisterFromVersion("v0.105.0"),
33+
featuregate.WithRegisterToVersion("v0.118.0"),
3334
)
3435

3536
func init() {
@@ -79,14 +80,6 @@ func (c Config) Build(set component.TelemetrySettings) (operator.Operator, error
7980
}
8081
}
8182

82-
if !removeOriginalTimeField.IsEnabled() {
83-
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33389
84-
set.Logger.Info("`time` log record attribute will be removed in a future release. Switch now using the feature gate.",
85-
zap.String("attribute", "time"),
86-
zap.String("feature gate", removeOriginalTimeFieldFeatureFlag),
87-
)
88-
}
89-
9083
wg := sync.WaitGroup{}
9184

9285
p := &Parser{

pkg/stanza/operator/parser/container/parser.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,7 @@ func parseTime(e *entry.Entry, layout string) error {
343343
// timeutils.ParseGotime calls timeutils.SetTimestampYear before returning the timeValue
344344
e.Timestamp = timeValue
345345

346-
if removeOriginalTimeField.IsEnabled() {
347-
e.Delete(entry.NewAttributeField(parseFrom))
348-
}
346+
e.Delete(entry.NewAttributeField(parseFrom))
349347

350348
return nil
351349
}

pkg/stanza/operator/parser/container/parser_test.go

-101
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010

1111
"github.com/stretchr/testify/require"
1212
"go.opentelemetry.io/collector/component/componenttest"
13-
"go.opentelemetry.io/collector/featuregate"
1413

1514
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/entry"
1615
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator"
@@ -631,103 +630,3 @@ func TestCRIRecombineProcessWithFailedDownstreamOperator(t *testing.T) {
631630
})
632631
}
633632
}
634-
635-
func TestProcessWithTimeRemovalFlagDisabled(t *testing.T) {
636-
require.NoError(t, featuregate.GlobalRegistry().Set(removeOriginalTimeField.ID(), false))
637-
t.Cleanup(func() {
638-
require.NoError(t, featuregate.GlobalRegistry().Set(removeOriginalTimeField.ID(), true))
639-
})
640-
641-
cases := []struct {
642-
name string
643-
op func() (operator.Operator, error)
644-
input *entry.Entry
645-
expect *entry.Entry
646-
}{
647-
{
648-
"docker",
649-
func() (operator.Operator, error) {
650-
cfg := NewConfigWithID("test_id")
651-
cfg.AddMetadataFromFilePath = false
652-
cfg.Format = "docker"
653-
set := componenttest.NewNopTelemetrySettings()
654-
return cfg.Build(set)
655-
},
656-
&entry.Entry{
657-
Body: `{"log":"INFO: log line here","stream":"stdout","time":"2029-03-30T08:31:20.545192187Z"}`,
658-
},
659-
&entry.Entry{
660-
Attributes: map[string]any{
661-
"time": "2029-03-30T08:31:20.545192187Z",
662-
"log.iostream": "stdout",
663-
},
664-
Body: "INFO: log line here",
665-
Timestamp: time.Date(2029, time.March, 30, 8, 31, 20, 545192187, time.UTC),
666-
},
667-
},
668-
{
669-
"docker_with_auto_detection",
670-
func() (operator.Operator, error) {
671-
cfg := NewConfigWithID("test_id")
672-
cfg.AddMetadataFromFilePath = false
673-
set := componenttest.NewNopTelemetrySettings()
674-
return cfg.Build(set)
675-
},
676-
&entry.Entry{
677-
Body: `{"log":"INFO: log line here","stream":"stdout","time":"2029-03-30T08:31:20.545192187Z"}`,
678-
},
679-
&entry.Entry{
680-
Attributes: map[string]any{
681-
"time": "2029-03-30T08:31:20.545192187Z",
682-
"log.iostream": "stdout",
683-
},
684-
Body: "INFO: log line here",
685-
Timestamp: time.Date(2029, time.March, 30, 8, 31, 20, 545192187, time.UTC),
686-
},
687-
},
688-
{
689-
"docker_with_auto_detection_and_metadata_from_file_path",
690-
func() (operator.Operator, error) {
691-
cfg := NewConfigWithID("test_id")
692-
cfg.AddMetadataFromFilePath = true
693-
set := componenttest.NewNopTelemetrySettings()
694-
return cfg.Build(set)
695-
},
696-
&entry.Entry{
697-
Body: `{"log":"INFO: log line here","stream":"stdout","time":"2029-03-30T08:31:20.545192187Z"}`,
698-
Attributes: map[string]any{
699-
"log.file.path": "/var/log/pods/some_kube-scheduler-kind-control-plane_49cc7c1fd3702c40b2686ea7486091d3/kube-scheduler44/1.log",
700-
},
701-
},
702-
&entry.Entry{
703-
Attributes: map[string]any{
704-
"log.iostream": "stdout",
705-
"time": "2029-03-30T08:31:20.545192187Z",
706-
"log.file.path": "/var/log/pods/some_kube-scheduler-kind-control-plane_49cc7c1fd3702c40b2686ea7486091d3/kube-scheduler44/1.log",
707-
},
708-
Body: "INFO: log line here",
709-
Resource: map[string]any{
710-
"k8s.pod.name": "kube-scheduler-kind-control-plane",
711-
"k8s.pod.uid": "49cc7c1fd3702c40b2686ea7486091d3",
712-
"k8s.container.name": "kube-scheduler44",
713-
"k8s.container.restart_count": "1",
714-
"k8s.namespace.name": "some",
715-
},
716-
Timestamp: time.Date(2029, time.March, 30, 8, 31, 20, 545192187, time.UTC),
717-
},
718-
},
719-
}
720-
721-
for _, tc := range cases {
722-
t.Run(tc.name, func(t *testing.T) {
723-
op, err := tc.op()
724-
require.NoError(t, err, "did not expect operator function to return an error, this is a bug with the test case")
725-
726-
err = op.Process(context.Background(), tc.input)
727-
require.NoError(t, err)
728-
require.Equal(t, tc.expect, tc.input)
729-
// Stop the operator
730-
require.NoError(t, op.Stop())
731-
})
732-
}
733-
}

0 commit comments

Comments
 (0)