Skip to content

Commit

Permalink
[receiver/awss3receiver] Add support RFC3399 format for starttime and…
Browse files Browse the repository at this point in the history
… endtime
  • Loading branch information
sters committed Dec 11, 2024
1 parent 28ede1d commit 95a7f37
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 4 deletions.
27 changes: 27 additions & 0 deletions .chloggen/awss3receiver-add-support-rfc3339.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# 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. filelogreceiver)
component: awss3receiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Add support RFC3339 format for starttime and endtime"

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [36787]

# (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:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
2 changes: 1 addition & 1 deletion receiver/awss3receiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The following exporter configuration parameters are supported.

### Time format for `starttime` and `endtime`
The `starttime` and `endtime` fields are used to specify the time range for which to retrieve data.
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`.
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`.

### Encodings
By default, the receiver understands the following encodings:
Expand Down
2 changes: 1 addition & 1 deletion receiver/awss3receiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (c Config) Validate() error {
}

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

for _, layout := range layouts {
if t, err := time.Parse(layout, timeStr); err == nil {
Expand Down
15 changes: 14 additions & 1 deletion receiver/awss3receiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestLoadConfig(t *testing.T) {
},
{
id: component.NewIDWithName(metadata.Type, "1"),
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",
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",
},
{
id: component.NewIDWithName(metadata.Type, "2"),
Expand Down Expand Up @@ -94,6 +94,19 @@ func TestLoadConfig(t *testing.T) {
},
},
},
{
id: component.NewIDWithName(metadata.Type, "4"),
expected: &Config{
S3Downloader: S3DownloaderConfig{
Region: "us-east-1",
S3Bucket: "abucket",
S3Partition: "minute",
EndpointPartitionID: "aws",
},
StartTime: "2024-01-31T15:00:00Z",
EndTime: "2024-02-03T00:00:00Z",
},
},
}

for _, tt := range tests {
Expand Down
6 changes: 5 additions & 1 deletion receiver/awss3receiver/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ awss3/3:
suffix: "nop"
notifications:
opampextension: "opamp/bar"

awss3/4:
s3downloader:
s3_bucket: abucket
starttime: "2024-01-31T15:00:00Z"
endtime: "2024-02-03T00:00:00Z"

0 comments on commit 95a7f37

Please sign in to comment.