-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add links to logs from trace #93
base: main
Are you sure you want to change the base?
Conversation
…nas/trace-to-logs
region, | ||
queryMode: 'Logs', | ||
// Just use the data from the data frame. Needs to be filled in during transform. | ||
logGroupNames: ['${__data.fields.__log_group}'], |
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 assume the __log_group field is already present.
): Promise<DataLink> { | ||
const logsDS = await getDataSourceSrv().get(datasourceUid); | ||
const filter = options.hasRequestId | ||
? 'filter @requestId = "${__data.fields.__request_id}" or @message like "${__data.fields.traceID}"' |
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 seems to be a filter that also x-ray uses when looking for logs from a trace in their UI.
for (const span of [...parentSpans, ...segmentSpans, ...subSegmentSpans]) { | ||
frame.add(span); | ||
for (const span of spans) { | ||
frame.add({ ...span, __request_id: requestId }); |
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.
Adding the request id that will be used for trace to logs links
@@ -223,6 +239,13 @@ function getProcess(segment: XrayTraceDataSegment): [string, TraceKeyValuePair[] | |||
return [segment.Document.name, tags]; | |||
} | |||
|
|||
function getLogGroup(document: XrayTraceDataSegmentDocument) { |
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.
Right now only getting lambda function log group is clear here. For some custom services, this will probably return 'unknown' still and the user will have to fill in the correct log group manually.
|
|
Backend code coverage report for PR #93 |
Frontend code coverage report for PR #93
|
This would be a really cool feature to see ! Super useful @aocenas @sarahzinger |
Closes: #94
Adds a config section to link a CloudWatch data source and links from trace to corresponding logs.
Links from the trace is a standards feature of TraceView we just need to supply the right data links in the DataFrame. The main complication here is to find out what is the correct log group which we should target.
In the case of a lambda function, this is fairly easy as can be seen in the getLogGroup function. For other cases, there should be something in the trace data that we get from X-ray something like trace_log_group attribute but that does not seem to be documented and needs to be clarified with the X-ray team.