-
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 16 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: 1619785437887 | ||
| }; | ||
| const spectator = buildComponent({ | ||
| providers: [tableCellRowDataProvider(logEvent), tableCellDataProvider('2021-04-30T12:23:57.889149Z')] | ||
| }); | ||
|
|
||
| expect(spectator.queryAll('.relative-timestamp')[0]).toContainText('2 ms'); | ||
| expect(spectator.component.duration).toBe(2); | ||
| }); | ||
| }); |
62 changes: 62 additions & 0 deletions
62
...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,62 @@ | ||
| import { ChangeDetectionStrategy, Component, Inject, OnInit } from '@angular/core'; | ||
| import { DateCoercer, 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: DateOrNumber; | ||
| } | ||
|
|
||
| type DateOrNumber = Date | number; | ||
| @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<DateOrNumber> implements OnInit { | ||
| public readonly dateFormat: DateFormatOptions = { | ||
| mode: DateFormatMode.DateAndTimeWithSeconds | ||
| }; | ||
| public readonly duration: number; | ||
| private readonly dateCoercer: DateCoercer = new DateCoercer(); | ||
|
|
||
| public constructor( | ||
| @Inject(TABLE_COLUMN_CONFIG) columnConfig: TableColumnConfig, | ||
| @Inject(TABLE_COLUMN_INDEX) index: number, | ||
| @Inject(TABLE_DATA_PARSER) | ||
| parser: TableCellParserBase<DateOrNumber, DateOrNumber, unknown>, | ||
| @Inject(TABLE_CELL_DATA) cellData: DateOrNumber, | ||
| @Inject(TABLE_ROW_DATA) rowData: RowData | ||
| ) { | ||
| super(columnConfig, index, parser, cellData, rowData); | ||
| this.duration = | ||
| (this.dateCoercer.coerce(cellData)?.getTime() ?? NaN) - | ||
| (this.dateCoercer.coerce(rowData.baseTimestamp)?.getTime() ?? NaN); | ||
| } | ||
| } |
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
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
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
49 changes: 49 additions & 0 deletions
49
...tracing/src/shared/dashboard/widgets/log-detail/data/log-detail-data-source.model.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,49 @@ | ||
| import { Dictionary } from '@hypertrace/common'; | ||
| import { createModelFactory, SpectatorModel } from '@hypertrace/dashboards/testing'; | ||
| import { LogEvent } from '@hypertrace/distributed-tracing'; | ||
| import { GraphQlRequestService } from '@hypertrace/graphql-client'; | ||
| import { ModelApi } from '@hypertrace/hyperdash'; | ||
| import { runFakeRxjs } from '@hypertrace/test-utils'; | ||
| import { mockProvider } from '@ngneat/spectator/jest'; | ||
| import { of } from 'rxjs'; | ||
| import { LogDetailDataSourceModel } from './log-detail-data-source.model'; | ||
|
|
||
| describe('Log Detail data source model', () => { | ||
| let spectator!: SpectatorModel<LogDetailDataSourceModel>; | ||
| const attributes: Dictionary<unknown> = { | ||
| key1: 'value1', | ||
| key2: 'value2' | ||
| }; | ||
| const logEvent: LogEvent = { | ||
| traceId: 'id1', | ||
| attributes: attributes, | ||
| spanId: 's-id1', | ||
| timestamp: '2021-05-05T00:00:00Z', | ||
| summary: 'test log event' | ||
| }; | ||
|
|
||
| const buildModel = createModelFactory({ | ||
| providers: [ | ||
| mockProvider(GraphQlRequestService, { | ||
| query: jest.fn().mockReturnValue(of({})) | ||
| }) | ||
| ] | ||
| }); | ||
| beforeEach(() => { | ||
| const mockApi: Partial<ModelApi> = {}; | ||
| spectator = buildModel(LogDetailDataSourceModel); | ||
| spectator.model.logEvent = logEvent; | ||
| spectator.model.api = mockApi as ModelApi; | ||
| }); | ||
|
|
||
| test('test attribute data', () => { | ||
| runFakeRxjs(({ expectObservable }) => { | ||
| expectObservable(spectator.model.getData()).toBe('(x|)', { | ||
| x: expect.objectContaining({ | ||
| key1: 'value1', | ||
| key2: 'value2' | ||
| }) | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
21 changes: 21 additions & 0 deletions
21
...uted-tracing/src/shared/dashboard/widgets/log-detail/data/log-detail-data-source.model.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,21 @@ | ||
| import { Dictionary } from '@hypertrace/common'; | ||
| import { Model, ModelProperty, PLAIN_OBJECT_PROPERTY } from '@hypertrace/hyperdash'; | ||
| import { Observable, of } from 'rxjs'; | ||
| import { GraphQlDataSourceModel } from '../../../data/graphql/graphql-data-source.model'; | ||
| import { LogEvent } from '../../waterfall/waterfall/waterfall-chart'; | ||
|
|
||
| @Model({ | ||
| type: 'log-detail-data-source' | ||
| }) | ||
| export class LogDetailDataSourceModel extends GraphQlDataSourceModel<Dictionary<unknown>> { | ||
| @ModelProperty({ | ||
| key: 'log-event', | ||
| required: true, | ||
| type: PLAIN_OBJECT_PROPERTY.type | ||
| }) | ||
| public logEvent?: LogEvent; | ||
|
|
||
| public getData(): Observable<Dictionary<unknown>> { | ||
| return of(this.logEvent?.attributes ?? {}); | ||
| } | ||
| } | ||
7 changes: 7 additions & 0 deletions
7
...tracing/src/shared/dashboard/widgets/log-detail/log-detail-widget-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,7 @@ | ||
| @import 'font'; | ||
|
|
||
| .content { | ||
| @include body-2-regular(); | ||
| margin-left: 175px; | ||
| margin-top: 15px; | ||
| } |
44 changes: 44 additions & 0 deletions
44
...cing/src/shared/dashboard/widgets/log-detail/log-detail-widget-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,44 @@ | ||
| import { Dictionary, FormattingModule } from '@hypertrace/common'; | ||
| import { ListViewComponent, LoadAsyncModule } from '@hypertrace/components'; | ||
| import { mockDashboardWidgetProviders } from '@hypertrace/dashboards/testing'; | ||
| import { createComponentFactory } from '@ngneat/spectator/jest'; | ||
| import { MockComponent } from 'ng-mocks'; | ||
| import { of } from 'rxjs'; | ||
| import { LogDetailWidgetRendererComponent } from './log-detail-widget-renderer.component'; | ||
| import { LogDetailWidgetModel } from './log-detail-widget.model'; | ||
|
|
||
| describe('log detail widget renderer component', () => { | ||
| let mockModel: Partial<LogDetailWidgetModel> = {}; | ||
| const buildComponent = createComponentFactory({ | ||
| component: LogDetailWidgetRendererComponent, | ||
| providers: [], | ||
| imports: [FormattingModule, LoadAsyncModule], | ||
| declarations: [MockComponent(ListViewComponent)], | ||
| shallow: true | ||
| }); | ||
| const attributes: Dictionary<unknown> = { | ||
| key1: 1, | ||
| key2: 2 | ||
| }; | ||
|
|
||
| test('should render list view with provided data', () => { | ||
| mockModel = { | ||
| getData: jest.fn(() => of(attributes)) | ||
| }; | ||
| const spectator = buildComponent({ | ||
| providers: [...mockDashboardWidgetProviders(mockModel)] | ||
| }); | ||
| expect(spectator.query('.content')).toExist(); | ||
| expect(spectator.query(ListViewComponent)!.header).toEqual(spectator.component.header); | ||
| expect(spectator.query(ListViewComponent)!.records).toEqual([ | ||
| { | ||
| key: 'key1', | ||
| value: 1 | ||
| }, | ||
| { | ||
| key: 'key2', | ||
| value: 2 | ||
| } | ||
| ]); | ||
| }); | ||
| }); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this page really needs to be a widget - I wouldn't actively avoid it, and if the work is already done it's fine - but for future pages, we really need to get out of the habit of making complex full-screen widgets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense for this to be a widget so that it can go in as a full page list in the trace level view in Phase 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd extend the same argument to those views too though 😉 If I understand the comment/remember the screen, the trace view today is one big widget, and with this it will now have two views - the sequence and the log list, right? When we do that work, I'd make the same argument that the tabs and their contents need not be (but easily could be) dashboards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@itssharmasandeep This is for the tab view right? don't we fetch all the details beforehand and show the tab as a normal component?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but since we're using table dashboard, so for child template we need data source, right?
Currently I am not fetching anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I think my comment got lost. My original comment was about the table itself - if that needed to be a dashboard (and likewise, everything downstream). The dashboards have really... evolved past how they were intended to be used. Here for example, we could just as easily remove the data source and pass the data directly to the widget - it's not providing any value if it's a custom pass through for a custom widget. (just to clarify, we don't need to change this here, but it's something we should be cognizant of as we build new screens).
As far as this data source goes, can we just reuse
StaticDataSourcesince this one's not doing anything but unwrapping which we could do elsewhere? Or if we keep it, it shouldn't extendGraphQlDataSourceModelbecause it's not querying GQL.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to aaron's point.
@itssharmasandeep For the sheet/tab view, we don't necessarily need a data source/widget for child template. You can just pass any ng-template in it and it would render. For the page view, we can use the static data source like Aaron described above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shared the details on slack