-
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* 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) { | ||
return new Date(timestamp).getTime() * 1000; | ||
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. This will truncate the microsecond precision when the timestamp is of type 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. I did a refactor to keep the microsecond precision |
||
} | ||
|
||
return fallbackTimestamp || 0; | ||
} |
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, | ||
|
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