-
Notifications
You must be signed in to change notification settings - Fork 11
feat: relative timestamp table cell renderer and log events table in sheet #818
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
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
202b00c
feat: fetching log records and showing log icon
itssharmasandeep 2e7f58b
feat: log detail widget and log timestamp table cell renderer components
itssharmasandeep 3cb722e
fix: adding trace start time
itssharmasandeep 8f0b5c8
fix: adding trace start time to span data
itssharmasandeep b03c83d
Merge branch 'log-icon' into log-components
itssharmasandeep 533c904
Revert "fix: adding trace start time to span data"
itssharmasandeep a1d101d
fix: addressing review comments
itssharmasandeep 8033540
Revert "fix: adding trace start time"
itssharmasandeep cd1214b
Revert "fix: adding trace start time to span data"
itssharmasandeep e51b716
Merge branch 'log-icon' into log-components
itssharmasandeep e2aef98
fix: changing log-timestamp to relative timestamp
itssharmasandeep 552f7bc
fix: addressing review comments
itssharmasandeep 2e642b8
refactor: removing unwanted changes
itssharmasandeep 2e90a3a
fix: lint errors
itssharmasandeep 171dc8a
fix: adding and fixing tests
itssharmasandeep 36e8d44
fix: address review comment and test fix
itssharmasandeep 8886ae2
fix: addressing review comments
itssharmasandeep 11bee55
Revert "fix: addressing review comments"
itssharmasandeep 77d168d
fix: addressing review comments
itssharmasandeep fe85d1c
Merge branch 'log-icon' into log-components
itssharmasandeep 129b6a4
fix: test cases
itssharmasandeep 8466606
Merge branch 'log-icon' into log-components
itssharmasandeep 10f3d37
fix: test case
itssharmasandeep 929f90b
Merge branch 'main' into log-icon
itssharmasandeep b45756d
fix: addressing review comments
itssharmasandeep 01b9bbc
fix: lint errors
itssharmasandeep e25a66c
Merge remote-tracking branch 'origin/log-icon' into log-icon
itssharmasandeep 2874cca
Merge branch 'log-icon' into log-components
itssharmasandeep 88f233a
fix: test cases
itssharmasandeep 411ab62
Merge branch 'main' into log-components
itssharmasandeep 5a4126a
Merge remote-tracking branch origin/main into log-components
itssharmasandeep 08ba01b
Merge branch 'log-components' of github.com:hypertrace/hypertrace-ui …
itssharmasandeep c5b8a42
fix: creating table instead of widget renderer
itssharmasandeep 29f2bdd
feat: log records in the span sheet (#819)
itssharmasandeep bf4b7ae
Merge branch 'main' into log-components
itssharmasandeep dd1b677
Merge remote-tracking branch 'origin/main' into log-components
itssharmasandeep e0b2ef4
fix: addressing review comments
itssharmasandeep 2b87274
Merge branch 'main' into log-components
itssharmasandeep File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...s/data-renderers/relative-timestamp/relative-timestamp-table-cell-renderer.component.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@import 'font'; | ||
|
||
.relative-timestamp { | ||
@include ellipsis-overflow(); | ||
|
||
&.first-column { | ||
@include body-1-medium($gray-9); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...ata-renderers/relative-timestamp/relative-timestamp-table-cell-renderer.component.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { DisplayDatePipe } from '@hypertrace/common'; | ||
import { | ||
TableCellNoOpParser, | ||
tableCellProviders, | ||
tableCellRowDataProvider, | ||
TooltipDirective | ||
} from '@hypertrace/components'; | ||
import { createComponentFactory } from '@ngneat/spectator/jest'; | ||
import { MockComponent, MockPipe } from 'ng-mocks'; | ||
import { tableCellDataProvider } from '../../test/cell-providers'; | ||
import { | ||
RelativeTimestampTableCellRendererComponent, | ||
RowData | ||
} from './relative-timestamp-table-cell-renderer.component'; | ||
|
||
describe('relative timestamp table cell renderer component', () => { | ||
const buildComponent = createComponentFactory({ | ||
component: RelativeTimestampTableCellRendererComponent, | ||
providers: [ | ||
tableCellProviders( | ||
{ | ||
id: 'test' | ||
}, | ||
new TableCellNoOpParser(undefined!) | ||
) | ||
], | ||
declarations: [MockComponent(TooltipDirective), MockPipe(DisplayDatePipe)], | ||
shallow: true | ||
}); | ||
|
||
test('testing component properties', () => { | ||
const logEvent: RowData = { | ||
baseTimestamp: new Date(1619785437887) | ||
}; | ||
const spectator = buildComponent({ | ||
providers: [tableCellRowDataProvider(logEvent), tableCellDataProvider(new Date(1619785437887))] | ||
}); | ||
|
||
expect(spectator.queryAll('.relative-timestamp')[0]).toContainText('0 ms'); | ||
expect(spectator.component.duration).toBe(0); | ||
}); | ||
}); |
57 changes: 57 additions & 0 deletions
57
...lls/data-renderers/relative-timestamp/relative-timestamp-table-cell-renderer.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { ChangeDetectionStrategy, Component, Inject, OnInit } from '@angular/core'; | ||
import { DateFormatMode, DateFormatOptions, Dictionary } from '@hypertrace/common'; | ||
import { TableColumnConfig } from '../../../table-api'; | ||
import { | ||
TABLE_CELL_DATA, | ||
TABLE_COLUMN_CONFIG, | ||
TABLE_COLUMN_INDEX, | ||
TABLE_DATA_PARSER, | ||
TABLE_ROW_DATA | ||
} from '../../table-cell-injection'; | ||
import { TableCellParserBase } from '../../table-cell-parser-base'; | ||
import { TableCellRenderer } from '../../table-cell-renderer'; | ||
import { TableCellRendererBase } from '../../table-cell-renderer-base'; | ||
import { CoreTableCellParserType } from '../../types/core-table-cell-parser-type'; | ||
import { CoreTableCellRendererType } from '../../types/core-table-cell-renderer-type'; | ||
import { TableCellAlignmentType } from '../../types/table-cell-alignment-type'; | ||
|
||
export interface RowData extends Dictionary<unknown> { | ||
baseTimestamp: Date; | ||
} | ||
@Component({ | ||
selector: 'ht-relative-timestamp-table-cell-renderer', | ||
styleUrls: ['./relative-timestamp-table-cell-renderer.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
template: ` | ||
<div | ||
class="relative-timestamp" | ||
[htTooltip]="this.value | htDisplayDate: this.dateFormat" | ||
[ngClass]="{ 'first-column': this.isFirstColumn }" | ||
> | ||
{{ this.duration }} ms | ||
</div> | ||
` | ||
}) | ||
@TableCellRenderer({ | ||
type: CoreTableCellRendererType.RelativeTimestamp, | ||
alignment: TableCellAlignmentType.Left, | ||
parser: CoreTableCellParserType.NoOp | ||
}) | ||
export class RelativeTimestampTableCellRendererComponent extends TableCellRendererBase<Date> implements OnInit { | ||
public readonly dateFormat: DateFormatOptions = { | ||
mode: DateFormatMode.DateAndTimeWithSeconds | ||
}; | ||
public readonly duration: number; | ||
|
||
public constructor( | ||
@Inject(TABLE_COLUMN_CONFIG) columnConfig: TableColumnConfig, | ||
@Inject(TABLE_COLUMN_INDEX) index: number, | ||
@Inject(TABLE_DATA_PARSER) | ||
parser: TableCellParserBase<Date, Date, unknown>, | ||
@Inject(TABLE_CELL_DATA) cellData: Date, | ||
@Inject(TABLE_ROW_DATA) rowData: RowData | ||
) { | ||
super(columnConfig, index, parser, cellData, rowData); | ||
this.duration = cellData?.getTime() - rowData?.baseTimestamp?.getTime(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...ects/distributed-tracing/src/shared/components/log-events/log-events-table.component.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@import 'font'; | ||
|
||
.log-events-table { | ||
margin-top: 25px; | ||
} | ||
|
||
.content { | ||
@include body-2-regular(); | ||
margin-left: 175px; | ||
margin-top: 15px; | ||
} |
70 changes: 70 additions & 0 deletions
70
...s/distributed-tracing/src/shared/components/log-events/log-events-table.component.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { HttpClientTestingModule } from '@angular/common/http/testing'; | ||
import { fakeAsync, flush } from '@angular/core/testing'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { IconLibraryTestingModule } from '@hypertrace/assets-library'; | ||
import { NavigationService } from '@hypertrace/common'; | ||
import { TableComponent, TableModule } from '@hypertrace/components'; | ||
import { runFakeRxjs } from '@hypertrace/test-utils'; | ||
import { createHostFactory, mockProvider, Spectator } from '@ngneat/spectator/jest'; | ||
import { EMPTY } from 'rxjs'; | ||
import { LogEventsTableComponent, LogEventsTableViewType } from './log-events-table.component'; | ||
import { LogEventsTableModule } from './log-events-table.module'; | ||
|
||
describe('LogEventsTableComponent', () => { | ||
let spectator: Spectator<LogEventsTableComponent>; | ||
|
||
const createHost = createHostFactory({ | ||
component: LogEventsTableComponent, | ||
imports: [LogEventsTableModule, TableModule, HttpClientTestingModule, IconLibraryTestingModule], | ||
declareComponent: false, | ||
providers: [ | ||
mockProvider(ActivatedRoute, { | ||
queryParamMap: EMPTY | ||
}), | ||
mockProvider(NavigationService, { | ||
navigation$: EMPTY | ||
}) | ||
] | ||
}); | ||
|
||
test('should render data correctly for sheet view', fakeAsync(() => { | ||
spectator = createHost( | ||
`<ht-log-events-table [logEvents]="logEvents" [logEventsTableViewType]="logEventsTableViewType" [spanStartTime]="spanStartTime"></ht-log-events-table>`, | ||
{ | ||
hostProps: { | ||
logEvents: [ | ||
{ attributes: { attr1: 1, attr2: 2 }, summary: 'test', timestamp: '2021-04-30T12:23:57.889149Z' } | ||
], | ||
logEventsTableViewType: LogEventsTableViewType.Condensed, | ||
spanStartTime: 1619785437887 | ||
} | ||
} | ||
); | ||
|
||
expect(spectator.query('.log-events-table')).toExist(); | ||
expect(spectator.query(TableComponent)).toExist(); | ||
expect(spectator.query(TableComponent)!.resizable).toBe(false); | ||
expect(spectator.query(TableComponent)!.columnConfigs).toMatchObject([ | ||
expect.objectContaining({ | ||
id: 'timestamp' | ||
}), | ||
expect.objectContaining({ | ||
id: 'summary' | ||
}) | ||
]); | ||
expect(spectator.query(TableComponent)!.pageable).toBe(false); | ||
expect(spectator.query(TableComponent)!.detailContent).not.toBeNull(); | ||
|
||
runFakeRxjs(({ expectObservable }) => { | ||
expect(spectator.component.dataSource).toBeDefined(); | ||
expectObservable(spectator.component.dataSource!.getData(undefined!)).toBe('(x|)', { | ||
x: { | ||
data: [expect.objectContaining({ summary: 'test' })], | ||
totalCount: 1 | ||
} | ||
}); | ||
|
||
flush(); | ||
}); | ||
})); | ||
}); |
121 changes: 121 additions & 0 deletions
121
projects/distributed-tracing/src/shared/components/log-events/log-events-table.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import { ChangeDetectionStrategy, Component, Input, OnChanges } from '@angular/core'; | ||
import { DateCoercer, Dictionary } from '@hypertrace/common'; | ||
import { | ||
CoreTableCellRendererType, | ||
ListViewHeader, | ||
ListViewRecord, | ||
TableColumnConfig, | ||
TableDataResponse, | ||
TableDataSource, | ||
TableMode, | ||
TableRow | ||
} from '@hypertrace/components'; | ||
import { LogEvent } from '@hypertrace/distributed-tracing'; | ||
import { isEmpty } from 'lodash-es'; | ||
import { Observable, of } from 'rxjs'; | ||
|
||
export const enum LogEventsTableViewType { | ||
Condensed = 'condensed', | ||
Detailed = 'detailed' | ||
} | ||
|
||
@Component({ | ||
selector: 'ht-log-events-table', | ||
styleUrls: ['./log-events-table.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
template: ` | ||
<div class="log-events-table"> | ||
<ht-table | ||
[columnConfigs]="this.columnConfigs" | ||
[data]="this.dataSource" | ||
[pageable]="false" | ||
[resizable]="false" | ||
mode=${TableMode.Detail} | ||
[detailContent]="detailContent" | ||
></ht-table> | ||
</div> | ||
<ng-template #detailContent let-row="row"> | ||
<div class="content"> | ||
<ht-list-view | ||
[records]="this.getLogEventAttributeRecords(row.attributes)" | ||
[header]="this.header" | ||
data-sensitive-pii | ||
></ht-list-view> | ||
</div> | ||
</ng-template> | ||
` | ||
}) | ||
export class LogEventsTableComponent implements OnChanges { | ||
@Input() | ||
public logEvents: LogEvent[] = []; | ||
|
||
@Input() | ||
public logEventsTableViewType: LogEventsTableViewType = LogEventsTableViewType.Condensed; | ||
|
||
@Input() | ||
public spanStartTime?: number; | ||
|
||
public readonly header: ListViewHeader = { keyLabel: 'key', valueLabel: 'value' }; | ||
private readonly dateCoercer: DateCoercer = new DateCoercer(); | ||
|
||
public dataSource?: TableDataSource<TableRow>; | ||
public columnConfigs: TableColumnConfig[] = []; | ||
|
||
public ngOnChanges(): void { | ||
this.buildDataSource(); | ||
this.columnConfigs = this.getTableColumnConfigs(); | ||
} | ||
|
||
public getLogEventAttributeRecords(attributes: Dictionary<unknown>): ListViewRecord[] { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: missing tests :) |
||
if (!isEmpty(attributes)) { | ||
return Object.entries(attributes).map(([key, value]) => ({ | ||
key: key, | ||
value: value as string | number | ||
})); | ||
} | ||
|
||
return []; | ||
} | ||
|
||
private buildDataSource(): void { | ||
this.dataSource = { | ||
getData: (): Observable<TableDataResponse<TableRow>> => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we can define the type of TableRow returned from this method for clarity. |
||
of({ | ||
data: this.logEvents.map((logEvent: LogEvent) => ({ | ||
...logEvent, | ||
timestamp: this.dateCoercer.coerce(logEvent.timestamp), | ||
baseTimestamp: this.dateCoercer.coerce(this.spanStartTime) | ||
})), | ||
totalCount: this.logEvents.length | ||
}), | ||
getScope: () => undefined | ||
}; | ||
} | ||
|
||
private getTableColumnConfigs(): TableColumnConfig[] { | ||
if (this.logEventsTableViewType === LogEventsTableViewType.Condensed) { | ||
return [ | ||
{ | ||
id: 'timestamp', | ||
name: 'timestamp', | ||
title: 'Timestamp', | ||
display: CoreTableCellRendererType.RelativeTimestamp, | ||
visible: true, | ||
width: '150px', | ||
sortable: false, | ||
filterable: false | ||
}, | ||
{ | ||
id: 'summary', | ||
name: 'summary', | ||
title: 'Summary', | ||
visible: true, | ||
sortable: false, | ||
filterable: false | ||
} | ||
]; | ||
} | ||
|
||
return []; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
projects/distributed-tracing/src/shared/components/log-events/log-events-table.module.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { FormattingModule } from '@hypertrace/common'; | ||
import { IconModule, ListViewModule, TableModule, TooltipModule } from '@hypertrace/components'; | ||
import { LogEventsTableComponent } from './log-events-table.component'; | ||
@NgModule({ | ||
imports: [CommonModule, TableModule, IconModule, TooltipModule, FormattingModule, ListViewModule], | ||
declarations: [LogEventsTableComponent], | ||
exports: [LogEventsTableComponent] | ||
}) | ||
export class LogEventsTableModule {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.