Skip to content

Commit e0cb143

Browse files
xray trace clickification polish
1 parent 482abdb commit e0cb143

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

userscripts/xray-trace-clickification.user.js

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,40 @@
11
// ==UserScript==
22
// @name XRay Trace Clickification
3-
// @namespace http://jonathanpezzino.com
3+
// @namespace https://github.com/softwareengineerprogrammer
44
// @version 0.1
5-
// @description try to take over the world!
5+
// @description Make xray trace IDs generated by lambda powertools clickable in CW dashboards
66
// @author softwareengineerprogrammer
77
// @match https://*.console.aws.amazon.com/cloudwatch/*
88
// @grant none
9+
// @updateURL https://softwareengineerprogrammer.github.io/userscripts/xray-trace-clickification.user.js
10+
// @downloadURL https://softwareengineerprogrammer.github.io/userscripts/xray-trace-clickification.user.js
911
// ==/UserScript==
1012

1113
(function () {
1214
'use strict';
13-
const clickifiedAttr = 'xray_trace_clickified';
15+
const CLICKIFIED_ATTR = 'xray_trace_clickified';
16+
17+
const blankTabImg = document.createElement('img');
18+
blankTabImg.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAtElEQVQoU7WSwRHCIBBF/4IkF3uJReh4toCMZViDZTiWoU3EKizAUwis2TjMZBggucgF5sNj2c8nbczZgVukhh32k2w2z3ibfiK9NNDFm87am2hyucyOhxNIb2U9gRp0D4eSlUdRVdXFsz+A3UfgVWCAFKkHMb+ltUVwDvm+vwZPimAMzdvIgiUoa04Jyj51qVK+x7o+KuadGJH6mlXm/A8cA9SlIpeq6IAG4IaKIc/kTyL6BavLmPJRH8tYAAAAAElFTkSuQmCC';
19+
blankTabImg.width = '7';
20+
blankTabImg.height = blankTabImg.width;
21+
blankTabImg.style = 'margin-bottom: 3.5px; margin-left: 1px;';
1422

1523
let clickify = function () {
16-
let traceIdElts = document.querySelectorAll(`div[data-test-id$="xray_trace_id-value"]:not([${clickifiedAttr}])`);
24+
let traceIdElts = document.querySelectorAll(`div[data-test-id$="xray_trace_id-value"]:not([${CLICKIFIED_ATTR}])`);
1725
console.debug('Found', traceIdElts.length, 'unclickified trace ID elements');
1826
traceIdElts.forEach(it => {
1927
let traceId = it.innerText;
2028
console.debug('Found xray trace ID:', traceId);
2129
let xrayLink = document.createElement('a');
22-
xrayLink.innerText = 'trace';
30+
xrayLink.style = 'margin-left: 0.25em;'
31+
xrayLink.innerHTML = `trace${blankTabImg.outerHTML}`;
2332
xrayLink.target = '_blank';
24-
let region = 'us-west-2' // FIXME TODO
25-
xrayLink.href = `https://us-west-2.console.aws.amazon.com/cloudwatch/home?region=us-west-2#servicelens:traces/${traceId}?~(query~()~context~())`
33+
let url = new URL(window.location.href);
34+
url.hash = `#servicelens:traces/${traceId}?~(query~()~context~())`;
35+
xrayLink.href = url.href;
2636
it.querySelector('.kvp-value').appendChild(xrayLink);
27-
it.setAttribute(clickifiedAttr, 'true');
37+
it.setAttribute(CLICKIFIED_ATTR, 'true');
2838
});
2939
};
3040

0 commit comments

Comments
 (0)