Skip to content

Commit d501956

Browse files
stersmterhar
authored andcommitted
[receiver/awss3receiver] Add support RFC3339 format for starttime and endtime (open-telemetry#36787)
#### Description This PR adds support RFC3339 (`"2006-01-02T15:04:05Z07:00"`) format for `starttime` and `endtime` fields. Currently, those fields cannot specify timezone. It's depends on the situation. This change makes clear the timezone. #### Testing This PR adds a new test data `awss3/4` which tests specifying RFC3339.
1 parent b929021 commit d501956

File tree

5 files changed

+48
-4
lines changed

5 files changed

+48
-4
lines changed
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: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: awss3receiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "Add support RFC3339 format for starttime and endtime"
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: [36787]
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]

receiver/awss3receiver/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ The following exporter configuration parameters are supported.
3838

3939
### Time format for `starttime` and `endtime`
4040
The `starttime` and `endtime` fields are used to specify the time range for which to retrieve data.
41-
The time format is either `YYYY-MM-DD HH:MM` or simply `YYYY-MM-DD`, in which case the time is assumed to be `00:00`.
41+
The time format is either RFC3339,`YYYY-MM-DD HH:MM` or simply `YYYY-MM-DD`, in which case the time is assumed to be `00:00`.
4242

4343
### Encodings
4444
By default, the receiver understands the following encodings:

receiver/awss3receiver/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (c Config) Validate() error {
8585
}
8686

8787
func parseTime(timeStr, configName string) (time.Time, error) {
88-
layouts := []string{"2006-01-02 15:04", time.DateOnly}
88+
layouts := []string{time.RFC3339, "2006-01-02 15:04", time.DateOnly}
8989

9090
for _, layout := range layouts {
9191
if t, err := time.Parse(layout, timeStr); err == nil {

receiver/awss3receiver/config_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestLoadConfig(t *testing.T) {
5353
},
5454
{
5555
id: component.NewIDWithName(metadata.Type, "1"),
56-
errorMessage: "s3_partition must be either 'hour' or 'minute'; unable to parse starttime (a date), accepted formats: 2006-01-02 15:04, 2006-01-02; unable to parse endtime (2024-02-03a), accepted formats: 2006-01-02 15:04, 2006-01-02",
56+
errorMessage: "s3_partition must be either 'hour' or 'minute'; unable to parse starttime (a date), accepted formats: 2006-01-02T15:04:05Z07:00, 2006-01-02 15:04, 2006-01-02; unable to parse endtime (2024-02-03a), accepted formats: 2006-01-02T15:04:05Z07:00, 2006-01-02 15:04, 2006-01-02",
5757
},
5858
{
5959
id: component.NewIDWithName(metadata.Type, "2"),
@@ -94,6 +94,19 @@ func TestLoadConfig(t *testing.T) {
9494
},
9595
},
9696
},
97+
{
98+
id: component.NewIDWithName(metadata.Type, "4"),
99+
expected: &Config{
100+
S3Downloader: S3DownloaderConfig{
101+
Region: "us-east-1",
102+
S3Bucket: "abucket",
103+
S3Partition: "minute",
104+
EndpointPartitionID: "aws",
105+
},
106+
StartTime: "2024-01-31T15:00:00Z",
107+
EndTime: "2024-02-03T00:00:00Z",
108+
},
109+
},
97110
}
98111

99112
for _, tt := range tests {

receiver/awss3receiver/testdata/config.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ awss3/3:
2222
suffix: "nop"
2323
notifications:
2424
opampextension: "opamp/bar"
25-
25+
awss3/4:
26+
s3downloader:
27+
s3_bucket: abucket
28+
starttime: "2024-01-31T15:00:00Z"
29+
endtime: "2024-02-03T00:00:00Z"

0 commit comments

Comments
 (0)