Skip to content

[pkg/ottl] Update contexts so that all time fields Getters return time.Time and Setters take time.Time #22010

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

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

Comments

@TylerHelmuth
Copy link
Member

TylerHelmuth commented May 16, 2023

OTTL contexts are updated so that all time fields Getters return time.Time and Setters take time.Time. The accessor names should be updated to drop the time precision (_nano).

Context and fields that need updating:

  • ottldatapoint
    • start_time_unix_nano
    • time_unix_nano
  • ottllog
    • time_unix_nano
    • observed_time_unix_nano
  • ottlspan
    • start_time_unix_nano
    • end_time_unix_nano
  • ottlspanevent
    • time_unix_nano

Will also need to update all the cache accessors to be able to handle getting and setting time.Time and time.Duration. Instead of getting and setting a pcommon.Map it should be expressed as a map[string]string.

@TylerHelmuth TylerHelmuth changed the title OTTL contexts are updated so that all time fields Getters return time.Time and Setters take time.Time. The accessor names should be updated to drop the time precision (_nano). [pkg/ottl] Update contexts so that all time fields Getters return time.Time and Setters take time.Time May 16, 2023
@TylerHelmuth TylerHelmuth added enhancement New feature or request priority:p2 Medium pkg/ottl labels May 16, 2023
@ptimofee
Copy link

ptimofee commented Jul 6, 2023

Just hit this with newly introduced in 0.81.0 Time() converter when wanted to convert some fields from k8s events to Timestamp to send event logs to ElasticSearch

      transform:
        error_mode: ignore
        log_statements:
        - context: log
          statements:
          - set(time_unix_nano, Time(body["object"]["eventTime"], "%Y-%m-%dT%H:%M:%SZ")) where body["object"]["eventTime"] != nil
          - set(time_unix_nano, Time(body["object"]["deprecatedLastTimestamp"], "%Y-%m-%dT%H:%M:%SZ")) where body["object"]["deprecatedLastTimestamp"] != nil

Looking forward to it!

@TylerHelmuth
Copy link
Member Author

@ptimofee FYI the Unix nano paths haven't been updated to accept Times yet, they still expect integers. See the main tracking issue for progress on tying all this together.

@TylerHelmuth
Copy link
Member Author

Nevermind, I see we are on the issue asking for this capability. Yes, we're working towards it.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2023

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions github-actions bot added the Stale label Sep 5, 2023
@TylerHelmuth TylerHelmuth removed the Stale label Sep 5, 2023
evan-bradley pushed a commit that referenced this issue Sep 14, 2023
Description: Update contexts so that time related setters and getters
support time objects.

Link to tracking Issue: #22010

Testing: unit tests for each new setter/getter

Documentation: READMEs for `ottldatapoint`, `ottllog`, `ottlspan`,
`ottlspanevent`.
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

No branches or pull requests

2 participants