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

Add links to logs from trace #93

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft

Add links to logs from trace #93

wants to merge 26 commits into from

Conversation

aocenas
Copy link
Member

@aocenas aocenas commented Dec 14, 2021

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.

region,
queryMode: 'Logs',
// Just use the data from the data frame. Needs to be filled in during transform.
logGroupNames: ['${__data.fields.__log_group}'],
Copy link
Member Author

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}"'
Copy link
Member Author

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 });
Copy link
Member Author

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) {
Copy link
Member Author

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.

@yaelleC yaelleC changed the base branch from master to main February 24, 2022 13:14
@yaelleC yaelleC requested a review from a team as a code owner February 24, 2022 13:14
@yaelleC yaelleC requested review from fridgepoet and iwysiu and removed request for a team February 24, 2022 13:14
@CLAassistant
Copy link

CLAassistant commented Jun 15, 2022

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ sarahzinger
❌ aocenas
You have signed the CLA already but the status is still pending? Let us recheck it.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@fridgepoet fridgepoet requested review from sarahzinger and removed request for fridgepoet July 29, 2022 12:43
@github-actions
Copy link

Backend code coverage report for PR #93
No changes

@github-actions
Copy link

github-actions bot commented Dec 20, 2022

Frontend code coverage report for PR #93

Plugin Main PR Difference
src 87.5% 87.64% .14%

@sarahzinger sarahzinger marked this pull request as draft January 23, 2023 20:42
@armanjal
Copy link

armanjal commented Dec 3, 2024

This would be a really cool feature to see ! Super useful @aocenas @sarahzinger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add links to logs from a span
4 participants