mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Tracing: Do not try to render trace view in dashboard if data missing (#76630)
* Check for process and span id * Remove log * Update tests * Check for key
This commit is contained in:
parent
f9484fcf82
commit
4c22027ab7
@ -143,6 +143,58 @@ describe('transformTraceData()', () => {
|
|||||||
expect(transformTraceData(traceData)).toEqual(null);
|
expect(transformTraceData(traceData)).toEqual(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return null for any span without a spanID', () => {
|
||||||
|
const traceData = {
|
||||||
|
traceID,
|
||||||
|
processes,
|
||||||
|
spans: [
|
||||||
|
{
|
||||||
|
traceID,
|
||||||
|
operationName: 'rootOperation',
|
||||||
|
references: [
|
||||||
|
{
|
||||||
|
refType: 'CHILD_OF',
|
||||||
|
traceID,
|
||||||
|
spanID: rootSpanID,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
startTime,
|
||||||
|
duration,
|
||||||
|
tags: [],
|
||||||
|
processID: 'p1',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
} as unknown as TraceResponse;
|
||||||
|
|
||||||
|
expect(transformTraceData(traceData)).toEqual(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return null for any span without a processID', () => {
|
||||||
|
const traceData = {
|
||||||
|
traceID,
|
||||||
|
processes,
|
||||||
|
spans: [
|
||||||
|
{
|
||||||
|
traceID,
|
||||||
|
spanID: '41f71485ed2593e4',
|
||||||
|
operationName: 'rootOperation',
|
||||||
|
references: [
|
||||||
|
{
|
||||||
|
refType: 'CHILD_OF',
|
||||||
|
traceID,
|
||||||
|
spanID: rootSpanID,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
startTime,
|
||||||
|
duration,
|
||||||
|
tags: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
} as unknown as TraceResponse;
|
||||||
|
|
||||||
|
expect(transformTraceData(traceData)).toEqual(null);
|
||||||
|
});
|
||||||
|
|
||||||
it('should return trace data with correct traceName based on root span with missing ref', () => {
|
it('should return trace data with correct traceName based on root span with missing ref', () => {
|
||||||
const traceData = {
|
const traceData = {
|
||||||
traceID,
|
traceID,
|
||||||
|
@ -74,7 +74,7 @@ export function orderTags(tags: TraceKeyValuePair[], topPrefixes?: string[]) {
|
|||||||
* generally requires.
|
* generally requires.
|
||||||
*/
|
*/
|
||||||
export default function transformTraceData(data: TraceResponse | undefined): Trace | null {
|
export default function transformTraceData(data: TraceResponse | undefined): Trace | null {
|
||||||
if (!data?.traceID) {
|
if (!data?.traceID || data?.spans.some((x) => !x.processID || !x.spanID)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const traceID = data.traceID.toLowerCase();
|
const traceID = data.traceID.toLowerCase();
|
||||||
|
@ -46,7 +46,7 @@ class ColorGenerator {
|
|||||||
_getColorIndex(key: string): number {
|
_getColorIndex(key: string): number {
|
||||||
let i = this.cache.get(key);
|
let i = this.cache.get(key);
|
||||||
if (i == null) {
|
if (i == null) {
|
||||||
const hash = this.hashCode(key.toLowerCase());
|
const hash = this.hashCode(key ? key.toLowerCase() : '');
|
||||||
i = Math.abs(hash % this.colorsHex.length);
|
i = Math.abs(hash % this.colorsHex.length);
|
||||||
|
|
||||||
if (this.prevColorIndex !== undefined) {
|
if (this.prevColorIndex !== undefined) {
|
||||||
|
Loading…
Reference in New Issue
Block a user