Skip to content

Commit f776f3d

Browse files
feat: fetching log records and showing log icon (#817)
* feat: fetching log records and showing log icon
1 parent 58e2cd8 commit f776f3d

15 files changed

+144
-19
lines changed

projects/distributed-tracing/src/public-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export { WaterfallData } from './shared/dashboard/widgets/waterfall/waterfall/wa
102102
export { TraceWaterfallDataSourceModel } from './shared/dashboard/data/graphql/waterfall/trace-waterfall-data-source.model';
103103
export { traceDetailDashboard } from './pages/trace-detail/trace-detail.dashboard';
104104
export { TraceDetailPageComponent } from './pages/trace-detail/trace-detail.page.component';
105+
export { LogEvent } from './shared/dashboard/widgets/waterfall/waterfall/waterfall-chart';
105106

106107
// Datasources
107108
export * from './shared/dashboard/widgets/trace-detail/data/trace-detail-data-source.model';

projects/distributed-tracing/src/shared/components/span-detail/span-data.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Dictionary } from '@hypertrace/common';
2+
import { LogEvent } from '../../dashboard/widgets/waterfall/waterfall/waterfall-chart';
23

34
export interface SpanData {
45
id: string;
@@ -12,4 +13,6 @@ export interface SpanData {
1213
tags: Dictionary<unknown>;
1314
requestUrl: string;
1415
exitCallsBreakup?: Dictionary<string>;
16+
startTime: number;
17+
logEvents?: LogEvent[];
1518
}

projects/distributed-tracing/src/shared/components/span-detail/span-detail.component.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ describe('Span detail component', () => {
2828
responseHeaders: { header1: 'value1', header2: 'value2' },
2929
responseBody: '[{"data": 5000}]',
3030
tags: { tag1: 'value1', tag2: 'value2' },
31-
requestUrl: 'test-url'
31+
requestUrl: 'test-url',
32+
startTime: 1604567825671
3233
};
3334

3435
spectator = createHost(`<ht-span-detail [spanData]="spanData"></ht-span-detail>`, {
@@ -52,7 +53,8 @@ describe('Span detail component', () => {
5253
responseHeaders: { header1: 'value1', header2: 'value2' },
5354
responseBody: '[{"data": 5000}]',
5455
tags: { tag1: 'value1', tag2: 'value2' },
55-
requestUrl: 'test-url'
56+
requestUrl: 'test-url',
57+
startTime: 1604567825671
5658
};
5759

5860
spectator = createHost(`<ht-span-detail [spanData]="spanData"></ht-span-detail>`, {
@@ -77,7 +79,8 @@ describe('Span detail component', () => {
7779
responseHeaders: { header1: 'value1', header2: 'value2' },
7880
responseBody: '[{"data": 5000}]',
7981
tags: { tag1: 'value1', tag2: 'value2' },
80-
requestUrl: 'test-url'
82+
requestUrl: 'test-url',
83+
startTime: 1604567825671
8184
};
8285

8386
spectator = createHost(`<ht-span-detail [spanData]="spanData"></ht-span-detail>`, {
@@ -101,7 +104,8 @@ describe('Span detail component', () => {
101104
responseHeaders: {},
102105
responseBody: '',
103106
tags: { tag1: 'value1', tag2: 'value2' },
104-
requestUrl: 'test-url'
107+
requestUrl: 'test-url',
108+
startTime: 1604567825671
105109
};
106110

107111
spectator = createHost(`<ht-span-detail [spanData]="spanData"></ht-span-detail>`, {

projects/distributed-tracing/src/shared/dashboard/data/graphql/waterfall/trace-waterfall-data-source.model.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@ describe('Trace Waterfall data source model', () => {
9696
expect.objectContaining({
9797
name: 'errorCount'
9898
})
99+
],
100+
logEventProperties: [
101+
expect.objectContaining({
102+
name: 'attributes'
103+
}),
104+
expect.objectContaining({
105+
name: 'timestamp'
106+
}),
107+
expect.objectContaining({
108+
name: 'summary'
109+
})
99110
]
100111
}
101112
});
@@ -156,6 +167,17 @@ describe('Trace Waterfall data source model', () => {
156167
expect.objectContaining({
157168
name: 'errorCount'
158169
})
170+
],
171+
logEventProperties: [
172+
expect.objectContaining({
173+
name: 'attributes'
174+
}),
175+
expect.objectContaining({
176+
name: 'timestamp'
177+
}),
178+
expect.objectContaining({
179+
name: 'summary'
180+
})
159181
]
160182
}
161183
});

projects/distributed-tracing/src/shared/dashboard/data/graphql/waterfall/trace-waterfall-data-source.model.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
TRACE_GQL_REQUEST
1414
} from '../../../../graphql/request/handlers/traces/trace-graphql-query-handler.service';
1515
import { MetadataService } from '../../../../services/metadata/metadata.service';
16-
import { WaterfallData } from '../../../widgets/waterfall/waterfall/waterfall-chart';
16+
import { LogEvent, WaterfallData } from '../../../widgets/waterfall/waterfall/waterfall-chart';
1717
import { GraphQlDataSourceModel } from '../graphql-data-source.model';
1818

1919
@Model({
@@ -60,6 +60,12 @@ export class TraceWaterfallDataSourceModel extends GraphQlDataSourceModel<Waterf
6060
this.specificationBuilder.attributeSpecificationForKey('errorCount')
6161
];
6262

63+
protected readonly logEventSpecifications: Specification[] = [
64+
this.specificationBuilder.attributeSpecificationForKey('attributes'),
65+
this.specificationBuilder.attributeSpecificationForKey('timestamp'),
66+
this.specificationBuilder.attributeSpecificationForKey('summary')
67+
];
68+
6369
public getData(): Observable<WaterfallData[]> {
6470
return combineLatest([this.getTraceData(), this.getDurationAttribute()]).pipe(
6571
map(combinedData => this.mapResponseObject(combinedData[0], combinedData[1]))
@@ -73,7 +79,8 @@ export class TraceWaterfallDataSourceModel extends GraphQlDataSourceModel<Waterf
7379
spanLimit: 1000,
7480
timestamp: this.dateCoercer.coerce(this.startTime),
7581
traceProperties: [],
76-
spanProperties: this.spanSpecifications
82+
spanProperties: this.spanSpecifications,
83+
logEventProperties: this.logEventSpecifications
7784
});
7885
}
7986

@@ -102,7 +109,8 @@ export class TraceWaterfallDataSourceModel extends GraphQlDataSourceModel<Waterf
102109
apiName: span.displaySpanName as string,
103110
spanType: span.type as SpanType,
104111
tags: span.spanTags as Dictionary<unknown>,
105-
errorCount: span.errorCount as number
112+
errorCount: span.errorCount as number,
113+
logEvents: ((span.logEvents as Dictionary<LogEvent[]>) ?? {}).results
106114
}));
107115
}
108116
}

projects/distributed-tracing/src/shared/dashboard/widgets/waterfall/waterfall/span-name/span-name-cell-data.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export interface SpanNameCellData {
44
apiName?: string;
55
color?: string;
66
hasError?: boolean;
7+
hasLogs?: boolean;
78
}

projects/distributed-tracing/src/shared/dashboard/widgets/waterfall/waterfall/span-name/span-name-table-cell-renderer.component.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
.span-title {
99
display: grid;
10-
grid-template-columns: 3px min-content min-content min-content auto;
10+
grid-template-columns: 3px min-content min-content min-content min-content auto;
1111
grid-template-rows: 1fr;
1212
column-gap: 4px;
1313

@@ -41,6 +41,10 @@
4141
.text {
4242
@include ellipsis-overflow();
4343
}
44+
45+
.log-icon {
46+
margin: auto 0;
47+
}
4448
}
4549

4650
.clickable {

projects/distributed-tracing/src/shared/dashboard/widgets/waterfall/waterfall/span-name/span-name-table-cell-renderer.component.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,15 @@ describe('Span name table cell renderer component', () => {
6161
expect(spectator.query('.color-bar')).toExist();
6262
expect(spectator.query('.error-icon')).toExist();
6363
});
64+
65+
test('should render log icon ', () => {
66+
const spanNameDataWithColor = {
67+
...spanNameData,
68+
hasLogs: true
69+
};
70+
const spectator = buildComponent({
71+
providers: [tableCellDataProvider(spanNameDataWithColor)]
72+
});
73+
expect(spectator.query('.log-icon')).toExist();
74+
});
6475
});

projects/distributed-tracing/src/shared/dashboard/widgets/waterfall/waterfall/span-name/span-name-table-cell-renderer.component.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ import { WaterfallTableCellType } from './span-name-cell-type';
2828
size="${IconSize.Medium}"
2929
color="${Color.Red5}"
3030
></ht-icon>
31+
<ht-icon
32+
*ngIf="this.value.hasLogs"
33+
class="log-icon"
34+
icon="${IconType.Note}"
35+
size="${IconSize.Small}"
36+
color="${Color.Gray4}"
37+
></ht-icon>
3138
</div>
3239
`
3340
})

projects/distributed-tracing/src/shared/dashboard/widgets/waterfall/waterfall/waterfall-chart.component.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ describe('Waterfall Chart component', () => {
3131
responseHeaders: {},
3232
responseBody: 'Response Body',
3333
tags: {},
34-
errorCount: 0
34+
errorCount: 0,
35+
logEvents: []
3536
},
3637
{
3738
id: 'second-id',
@@ -52,7 +53,8 @@ describe('Waterfall Chart component', () => {
5253
responseHeaders: {},
5354
responseBody: '',
5455
tags: {},
55-
errorCount: 0
56+
errorCount: 0,
57+
logEvents: []
5658
},
5759
{
5860
id: 'third-id',
@@ -73,7 +75,8 @@ describe('Waterfall Chart component', () => {
7375
responseHeaders: {},
7476
responseBody: '',
7577
tags: {},
76-
errorCount: 0
78+
errorCount: 0,
79+
logEvents: []
7780
}
7881
];
7982

0 commit comments

Comments
 (0)