Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pkg/ottl] OTTL Converter Function that is able to create a new time.Time type from a string. #22007

Closed
Tracked by #16067
TylerHelmuth opened this issue May 16, 2023 · 3 comments · Fixed by #22811
Closed
Tracked by #16067
Assignees
Labels
enhancement New feature or request pkg/ottl priority:p2 Medium

Comments

@TylerHelmuth
Copy link
Member

TylerHelmuth commented May 16, 2023

Create an OTTL Converter Function(s), probably called Time, that is able to create a new time.Time type from a string. Something similar to https://pkg.go.dev/time#Parse or https://github.com/knz/strtime or https://github.com/itchyny/timefmt-go can be used.

The function should take 2 parameters, a string (represented as a StringGetter) that represents the time and a string (represented as a StringGetter) that represents the format that the time should be parse. We should also support standard names for common formats in the second parameter, like RFC3339 or ISO 8601 that the function would know how to interpret.

@TylerHelmuth TylerHelmuth changed the title There is an OTTL Factory Function, probably called Time, that is able to create a new time.Time type from a string. Something similar to https://pkg.go.dev/time#Parse can be used. [pkg/ottl] There is an OTTL Factory Function, probably called Time, that is able to create a new time.Time type from a string. Something similar to https://pkg.go.dev/time#Parse can be used. May 16, 2023
@TylerHelmuth TylerHelmuth changed the title [pkg/ottl] There is an OTTL Factory Function, probably called Time, that is able to create a new time.Time type from a string. Something similar to https://pkg.go.dev/time#Parse can be used. [pkg/ottl] OTTL Converter Function that is able to create a new time.Time type from a string. May 16, 2023
@TylerHelmuth TylerHelmuth added enhancement New feature or request priority:p2 Medium pkg/ottl labels May 16, 2023
@fchikwekwe
Copy link
Contributor

I've started working on this issue if someone could add me as assignee I would appreciate it.

@TylerHelmuth TylerHelmuth changed the title [pkg/ottl] OTTL Converter Function that is able to create a new time.Time type from a string. [pkg/ottl] OTTL Converter Function that is able to create a new time.Time type from a string or int. May 23, 2023
@TylerHelmuth TylerHelmuth changed the title [pkg/ottl] OTTL Converter Function that is able to create a new time.Time type from a string or int. [pkg/ottl] OTTL Converter Function that is able to create a new time.Time type from a string. May 23, 2023
@TylerHelmuth TylerHelmuth linked a pull request May 26, 2023 that will close this issue
@TylerHelmuth
Copy link
Member Author

https://github.com/lestrrat-go/strftime seems like the most popular package for strptime

TylerHelmuth added a commit that referenced this issue Jun 22, 2023
Description: Added a converter function that takes a time string and a
format string and converts to a golang time.Time object.

Link to tracking Issue: #22007 

Testing: Unit tests to check proper conversion from `stringGetter` to
golang `time.Time`

Documentation:

---------

Co-authored-by: Tyler Helmuth <[email protected]>
Caleb-Hurshman pushed a commit to observIQ/opentelemetry-collector-contrib that referenced this issue Jul 6, 2023
Description: Added a converter function that takes a time string and a
format string and converts to a golang time.Time object.

Link to tracking Issue: open-telemetry#22007 

Testing: Unit tests to check proper conversion from `stringGetter` to
golang `time.Time`

Documentation:

---------

Co-authored-by: Tyler Helmuth <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pkg/ottl priority:p2 Medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants