-
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
Removed _Source use from get_trace_items
#191647
Conversation
and fixed downstream impacts
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
'transaction.type': string[]; | ||
'transaction.result'?: string[]; | ||
'faas.coldstart': boolean[]; | ||
'span.links'?: SpanLink[][]; |
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.
We need to verify taking span links from fields
works for our use case. My suspicion is that we need to take span links from _source
because fields
doesn't return an array of span link objects, but arrays for all leaf fields, such as span.links.trace.id
. Also, the content for OTel span links and APM span links will look slightly differently.
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.
Yes, it appears both will have to be specified: span.links.trace.id
and span.links.span.id
. Are there any additional leaf fields? I can experiment with collecting them and dedotting.
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.
it seems like span.links.trace.id
and span.links.trace.id
are string types, while the processed structure is an array of SpanLink[]
which implies there may be more than one span link per span, but I'm not able to find examples of spans with more than one SpanLink.
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.
@@ -71,21 +71,61 @@ export const Example: Story<any> = () => { | |||
return doc['processor.event'] === ProcessorEvent.error; | |||
}); | |||
|
|||
const errorDocs = events.splice(errorEventId, 1); |
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.
The issue here is the format the synth-trace data is returned, specifically error.exception.message
, which looks like:
error {
exception: [
{ message: "..." }
]
}
And now that we are using fields
, the expected format is flat: error.exception.message
.
Is there a better way to do this? A 'fields' formatter for snyth-trace? A global 'flatten' method available, perhaps?
dedot( | ||
{ | ||
'trace.id': transaction[SPAN_LINKS_TRACE_ID]?.[i], | ||
'span.id': transaction[SPAN_LINKS_SPAN_ID]?.[i], |
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.
This expression isn't ideal if these two arrays are not equal lengths. If they are not equal lengths, it means the map between the trace.ids and span.ids is wrong. I can add a ?? "0"
to line 152 so it doesn't blow up, but is there a better way to handle this?
Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services) |
'parent.id'?: string[]; | ||
'error.id': string[]; | ||
'error.log.message'?: string[]; | ||
'error.exception'?: Exception[]; |
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.
This needs to get resolved
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.
It seems like the error.exception.stacktrace...
fields are not accessible through the fields
query. Should I try injecting them through the _sources
response? @felixbarny
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.
Hm, yes, I think the exception stack trace (and possibly span links) need to be fetched from _source. Make sure to only fetch the fields you need from source using source filtering.
Note that the structure will be different for OTel values. So we'll probably want to normalize/convert the data to have a consistent model the UI can work with.
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.
Hey Bryce, Is there anything we can do to the fields
type, to make it behave like _sources
on InferSearchResponseOf
? I'm concerned about losing type safety. There are many places where we're forcing type casting, eg: fields[TRANSACTION_ID]?.[0] as string
If we manage do adjust the fields
type we'll probably simplify the changes in this PR.
@@ -6,83 +6,61 @@ | |||
*/ |
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.
Q: is there anything we can do to avoid changing the types here?
'timestamp.us': number[]; | ||
'trace.id': string[]; | ||
'service.name': string[]; | ||
'service.environment'?: string[]; | ||
'agent.name': string[]; | ||
'event.outcome'?: string[]; | ||
'parent.id'?: string[]; | ||
'processor.event': ['transaction']; | ||
'transaction.duration.us': number[]; | ||
'transaction.id': string[]; | ||
'transaction.name': string[]; | ||
'transaction.type': string[]; | ||
'transaction.result'?: string[]; | ||
'faas.coldstart'?: boolean[]; | ||
'span.links.span.id'?: string[]; | ||
'span.links.trace.id'?: string[]; |
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.
Q: Why is everything defined as arrays?
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.
the data returned by 'fields' is always wrapped in an array : https://www.elastic.co/guide/en/elasticsearch/reference/current/search-fields.html#search-fields-response
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.
I tend to agree with @crespocarlos here. IMHO the APIs must return the same payload whether we query for _source or fields.
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.
It shall be done.
Object.keys(event).forEach((key) => { | ||
const item = event[key]; | ||
if (!Array.isArray(item)) { | ||
event[key] = [item]; | ||
} | ||
}); |
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.
Tip
we could use reduce
to create a new object out of an array
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.
I'm not trying to create a new object from an array, I'm wrapping the values in the object with an array to match the new expected format that 'fields' returns. Maybe I'm misunderstanding your recommendation?
Object.keys(event).forEach((key) => { | ||
const item = event[key]; | ||
if (!Array.isArray(item)) { | ||
event[key] = [item]; | ||
} | ||
}); |
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.
Tip
we could use reduce
to create a new object out of an array
💔 Build Failed
Failed CI Steps
Test Failures
Metrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
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.
Please make sure the APIs return the same payload as before. This will simplify the amount of work and all tests must keep working as expected.
Summary
This PR switched out
_source
forfields
in theget_trace_items
API, and updates all downstream dependencies of that data. Additional APIs changed:get_top_dependency_spans
,get_derived_service_annotations
, andtrace_samples
.Checklist
Delete any items that are not applicable to this PR.
Risk Matrix
Delete this section if it is not applicable to this PR.
Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.
When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:
For maintainers