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

feat: apply timezone to the date/time in tabular data throughout the app #6565

Conversation

ahmadshaheer
Copy link
Collaborator

@ahmadshaheer ahmadshaheer commented Dec 1, 2024

Summary

Apply timezone support to Tabular Data

Traces explorer

  • Explorer
    • List view
      • timestamp
  • Views
    • List
      • created at

Logs explorer

  • List View
    • Raw -> timestamp
    • Columns
      • for each column, check the data type (i.e. if it's timestamp, display the timestamp based on the specified timezone) (inside useTableView) [note: I checked all the columns, it seems that we don't get timestamp for any other column, added timezone support to the timestamp column]
    • Default
      • display the timestamp based on the specified timezone (inside ListLogView)
      • Log field (similar to Raw, timestamp is inside the text) [note: for displaying the timezone adjusted timestamp we need to parse the timestamp, skipping this for now]
  • Pipelines
    • Pipelines Tab
      • List
        • Last Edited
      • Details
        • Timestamp
        • Processed Output
    • Change History
      • Last Deployed Time
  • Views
    • List
      • time
  • Log details
    • check if we can apply timezone dynamically to the date/time values [note: Applied timezone adjustment to timestamp field]

Dashboard

  • Listing Page
    • Dashboard date
    • Edit metadata modal
  • Panel types (Details page ) :
    • Table [note: I couldn't find a case where we get timestamp for any columns]
  • Panel types (New Panel) :
    • Table [note: I couldn't find a case where we get timestamp for any columns]
  • Panel types (Edit Panel) :
    • Table [note: I couldn't find a case where we get timestamp for any columns]

Alerts

  • Triggered Alerts List
    • Firing Since
  • Alert Rules List
    • Created At
    • Updated At
  • Alert Details
    • Alert History Tab
      • Timeline Table
        • Created At

Exceptions

  • List

    • First seen
    • Last seen
  • Details page

    • Date

Licenses

  • History
    • Valid from
    • Valid Until

Related Issues / PR's

Part of https://github.com/SigNoz/engineering-pod/issues/2005

Screenshots

NA

Affected Areas and Manually Tested Areas


Important

Introduces timezone-based formatting for date/time displays across the app using a new formatTimestamp function.

  • Behavior:
    • Introduces formatTimestamp function in useTimezone hook for timezone-based timestamp formatting.
    • Replaces dayjs formatting with formatTimestamp in components like ListLogView, RawLogView, TableView, and others.
    • Updates timestamp rendering in tables, logs, and alerts to use formatTimestamp.
  • Components:
    • CustomTimePicker, LogsPanelComponent, TracesTableComponent, SaveView, and others now use formatTimestamp for date/time display.
    • useTimezoneFormatter hook added to handle timezone-based formatting with caching.
  • Misc:
    • Removes direct dayjs usage for timestamp formatting in favor of formatTimestamp.
    • Updates TimezoneProvider to include formatTimestamp in its context.

This description was created by Ellipsis for a7da3f3. It will automatically update as commits are pushed.

Copy link

github-actions bot commented Dec 1, 2024

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

@github-actions github-actions bot added the enhancement New feature or request label Dec 1, 2024
Copy link

github-actions bot commented Dec 1, 2024

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

@ahmadshaheer ahmadshaheer changed the base branch from fix/open-timepicker-after-closing-the-timezone-picker to fix/make-the-x-axis-and-tooltip-time-format-consistent December 1, 2024 16:06
Copy link

github-actions bot commented Dec 1, 2024

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Reviewed everything up to 614823a in 1 minute and 9 seconds

More details
  • Looked at 1072 lines of code in 25 files
  • Skipped 0 files when reviewing.
  • Skipped posting 10 drafted comments based on config settings.
1. frontend/src/hooks/useTimezoneFormatter/useTimezoneFormatter.ts:24
  • Draft comment:
    Consider adding a default value for userTimezone to ensure that the hook functions correctly even if no timezone is provided. This can help prevent potential errors or unexpected behavior.
  • Reason this comment was not posted:
    Confidence changes required: 20%
    The PR introduces a new hook useTimezoneFormatter to format timestamps according to the user's timezone. This hook is used throughout the application to replace direct usage of dayjs for formatting timestamps. The hook also includes a caching mechanism to improve performance by avoiding redundant calculations for the same input. The caching mechanism is implemented using a Map and includes logic to clear expired entries when the cache size exceeds a certain limit. The hook is integrated into the TimezoneProvider, and the formatTimestamp function is exposed via the useTimezone hook. This change is applied consistently across various components and containers in the application, ensuring that all timestamps are formatted according to the user's selected timezone. The PR appears to be well-implemented, with attention to performance and consistency across the codebase. However, there are a few areas where improvements can be made, such as ensuring that the cache cleanup logic is efficient and does not introduce unnecessary complexity. Overall, the PR is a positive step towards improving the user experience by ensuring that timestamps are displayed in the user's preferred timezone.
2. frontend/src/hooks/useTimezoneFormatter/useTimezoneFormatter.ts:55
  • Draft comment:
    Consider adding error handling for invalid timestamp inputs to prevent potential runtime errors. This can help ensure that the application remains stable even if unexpected input is provided.
  • Reason this comment was not posted:
    Confidence changes required: 20%
    The PR introduces a new hook useTimezoneFormatter to format timestamps according to the user's timezone. This hook is used throughout the application to replace direct usage of dayjs for formatting timestamps. The hook also includes a caching mechanism to improve performance by avoiding redundant calculations for the same input. The caching mechanism is implemented using a Map and includes logic to clear expired entries when the cache size exceeds a certain limit. The hook is integrated into the TimezoneProvider, and the formatTimestamp function is exposed via the useTimezone hook. This change is applied consistently across various components and containers in the application, ensuring that all timestamps are formatted according to the user's selected timezone. The PR appears to be well-implemented, with attention to performance and consistency across the codebase. However, there are a few areas where improvements can be made, such as ensuring that the cache cleanup logic is efficient and does not introduce unnecessary complexity. Overall, the PR is a positive step towards improving the user experience by ensuring that timestamps are displayed in the user's preferred timezone.
3. frontend/src/hooks/useTimezoneFormatter/useTimezoneFormatter.ts:64
  • Draft comment:
    Consider adding a fallback mechanism for formatting timestamps in case the dayjs library fails to format the input. This can help ensure that the application remains functional even if there are issues with the library.
  • Reason this comment was not posted:
    Confidence changes required: 20%
    The PR introduces a new hook useTimezoneFormatter to format timestamps according to the user's timezone. This hook is used throughout the application to replace direct usage of dayjs for formatting timestamps. The hook also includes a caching mechanism to improve performance by avoiding redundant calculations for the same input. The caching mechanism is implemented using a Map and includes logic to clear expired entries when the cache size exceeds a certain limit. The hook is integrated into the TimezoneProvider, and the formatTimestamp function is exposed via the useTimezone hook. This change is applied consistently across various components and containers in the application, ensuring that all timestamps are formatted according to the user's selected timezone. The PR appears to be well-implemented, with attention to performance and consistency across the codebase. However, there are a few areas where improvements can be made, such as ensuring that the cache cleanup logic is efficient and does not introduce unnecessary complexity. Overall, the PR is a positive step towards improving the user experience by ensuring that timestamps are displayed in the user's preferred timezone.
4. frontend/src/components/Logs/RawLogView/index.tsx:98
  • Draft comment:
    Avoid using hardcoded color values. Use design tokens or predefined color constants instead. This issue is also present in other files.
  • Reason this comment was not posted:
    Comment was not on a valid diff hunk.
5. frontend/src/components/Logs/TableView/useTableView.tsx:86
  • Draft comment:
    Avoid using hardcoded color values. Use design tokens or predefined color constants instead. This issue is also present in other files.
  • Reason this comment was not posted:
    Marked as duplicate.
6. frontend/src/components/ResizeTable/TableComponent/Time.tsx:7
  • Draft comment:
    Avoid using hardcoded color values. Use design tokens or predefined color constants instead. This issue is also present in other files.
  • Reason this comment was not posted:
    Marked as duplicate.
7. frontend/src/container/AlertHistory/Timeline/Table/Table.tsx:43
  • Draft comment:
    Avoid using hardcoded color values. Use design tokens or predefined color constants instead. This issue is also present in other files.
  • Reason this comment was not posted:
    Marked as duplicate.
8. frontend/src/container/AlertHistory/Timeline/Table/useTimelineTable.tsx:82
  • Draft comment:
    Avoid using hardcoded color values. Use design tokens or predefined color constants instead. This issue is also present in other files.
  • Reason this comment was not posted:
    Marked as duplicate.
9. frontend/src/container/AllError/index.tsx:290
  • Draft comment:
    Avoid using hardcoded color values. Use design tokens or predefined color constants instead. This issue is also present in other files.
  • Reason this comment was not posted:
    Marked as duplicate.
10. frontend/src/container/ErrorDetails/index.tsx:137
  • Draft comment:
    Avoid using hardcoded color values. Use design tokens or predefined color constants instead. This issue is also present in other files.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_iOGxRTp2CFORkaBs


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

github-actions bot commented Dec 1, 2024

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Incremental review on a7da3f3 in 31 seconds

More details
  • Looked at 630 lines of code in 23 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. frontend/src/components/Logs/ListLogView/index.tsx:174
  • Draft comment:
    Consider simplifying the function name formatTimezoneAdjustedTimestamp to improve readability and maintainability. A shorter name like formatTimestamp or formatWithTimezone could be more concise and still convey the intended functionality. This suggestion applies to all instances where formatTimezoneAdjustedTimestamp is used.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The PR replaces the function name formatTimestamp with formatTimezoneAdjustedTimestamp across multiple files. This change is consistent and aligns with the PR description. However, the new function name is quite long and could be simplified for better readability and maintainability.
2. frontend/src/container/ListOfDashboard/DashboardsList.tsx:396
  • Draft comment:
    Avoid using hardcoded color values. Use design tokens or predefined color constants instead. This issue is also present in other files.
  • Reason this comment was not posted:
    Comment was not on a valid diff hunk.

Workflow ID: wflow_qb7uqU1frUG7XyNY


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

github-actions bot commented Dec 1, 2024

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

@ahmadshaheer ahmadshaheer changed the base branch from fix/make-the-x-axis-and-tooltip-time-format-consistent to feat/timezone-formatter-custom-hook-and-adjust-graphs-timezone December 2, 2024 05:30
Copy link

github-actions bot commented Dec 2, 2024

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

@ahmadshaheer ahmadshaheer force-pushed the feat/apply-timezone-to-tabular-data-throughout-the-app branch from a7da3f3 to 0a21911 Compare December 2, 2024 06:14
Copy link

github-actions bot commented Dec 2, 2024

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

return { formatTimezoneAdjustedTimestamp };
}

export default useTimezoneFormatter;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahmadshaheer - for this check for comments and suggestion added here in this PR - #6566

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, @SagarRajput-7 👍

Copy link
Contributor

@SagarRajput-7 SagarRajput-7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahmadshaheer - under this too many files and consumers are changed, hoping that we have tested things throughly. Code-wise things look good

… page when groupe filter is applied (#6570)

* feat: add timezone support to triggered alerts page when groupe filter is applied

* feat: apply timezone adjustment to ingestion settings
#6566)

* feat: display timezone adjusted time range in time picker

* fix: make x axis and tooltip time format consistent in uPlot graphs

* fix: open the timepicker on clicking the input after closing the timezone picker by clicking outside

* feat: custom hook for formatting timezone

* feat: add timezone support to traces explorer timestamp column

* feat: add timezone support to saved views

* chore: improve timezone formatter custom hook

* feat: add support for timezone adjusted timestamp in raw log view (logs explorer -> list view)

* feat: add support for timezone adjusted timestamp in log table view (logs explorer -> list view)

* feat: add support for timezone adjusted timestamp in log default view (logs explorer -> list view)

* feat: add support for timezone adjusted timestamp in log details side pane

* feat: add support for timezone adjusted timestamp in pipeline pages

* feat: add support for timezone in dashboard list

* feat: add support for timezone adjusted created/updated at in alert rules list page

* feat: add support for timezone adjusted created at in timeline table of alert history page

* feat: add support for timezone adjusted Firing Since in triggered alerts page

* feat: add support for timezone adjusted Timestamp for List Panel of dashboard

* feat: add support for timezone adjusted First/Last Seen in exceptions list page

* feat: add support for timezone adjusted date in exception details page

* feat: add support for timezone adjusted Valid From/To in History tab of Licences

* chore: rename formatTimestamp -> formatTimezoneAdjustedTimestamp

* feat: add timezone support to logs explorer chart (built with Chartjs)

* chore: remove unnecessary chartjs-adapter-date-fns import

* chore: improve cache key

* chore: make clearCacheEntries DRYer

* chore: add docstring to formatTimezoneAdjustedTimestamp
@ahmadshaheer ahmadshaheer merged commit 638f257 into feat/timezone-formatter-custom-hook-and-adjust-graphs-timezone Dec 3, 2024
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants