-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[APM UI] Refactor to use @timestamp
and make timestamp.us
optional as fallback value
#194100
Draft
rmyz
wants to merge
3
commits into
elastic:main
Choose a base branch
from
rmyz:191046-apm-ui-make-timestamp-us-optional
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+75
−14
Draft
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
x-pack/plugins/observability_solution/apm/public/utils/get_timestamp.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export function getTimestamp(timestamp?: string, fallbackTimestamp?: number): number { | ||
if (!fallbackTimestamp && timestamp) { | ||
const date = new Date(timestamp); | ||
const milliseconds = date.getTime() * 1000; | ||
|
||
const microsecondsMatch = timestamp.match(/\.(\d{3})(\d{3})?Z$/); | ||
const microseconds = microsecondsMatch ? parseInt(microsecondsMatch[2] || '000', 10) : 0; | ||
|
||
return milliseconds + microseconds; | ||
} | ||
|
||
return fallbackTimestamp || 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ import { | |
ERROR_LOG_MESSAGE, | ||
EVENT_OUTCOME, | ||
FAAS_COLDSTART, | ||
FALLBACK_TIMESTAMP, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same in here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
PARENT_ID, | ||
PROCESSOR_EVENT, | ||
SERVICE_ENVIRONMENT, | ||
|
@@ -98,6 +99,7 @@ export async function getTraceItems({ | |
size: 1000, | ||
_source: [ | ||
TIMESTAMP, | ||
FALLBACK_TIMESTAMP, | ||
TRACE_ID, | ||
TRANSACTION_ID, | ||
PARENT_ID, | ||
|
@@ -229,6 +231,7 @@ async function getTraceDocsPerPage({ | |
search_after: searchAfter, | ||
_source: [ | ||
TIMESTAMP, | ||
FALLBACK_TIMESTAMP, | ||
TRACE_ID, | ||
PARENT_ID, | ||
SERVICE_NAME, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case
timestamp
andfallbackTimestamp
are bothtrue
thenfallbackTimestamp
is returned. I think it would be better to rely ontimestamp
in that scenario, wdyt?maybe an opposite condition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would make sense, let's see what others think and I can implement it if everyone agrees
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename these variables? Because as per this comment ☝️ I was confused of which one is the fallback
@timestamp
ortimestamp_us
const timestamp = getTimestamp(errorData?.error?.['@timestamp'], errorData?.error?.timestamp?.us);
In this case fallback is
timestamp_us
, but if we don't have it then the 'fallback' is@timestamp
I will keep the variables with the same name or close to the real field
timestamp
×tampUs
to avoid confusionThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to
timestamp
andtimestampUs
as the order of the params should always be the same