Skip to content

feat: log records in a new tab #916

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 14 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { Observable } from 'rxjs';
import { LogEventsTableViewType } from '../../../shared/components/log-events/log-events-table.component';
import { LogEvent } from '../../../shared/dashboard/widgets/waterfall/waterfall/waterfall-chart';
import { TraceDetailService } from './../trace-detail.service';

@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-container *ngIf="this.logEvents$ | async as logEvents">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are fetching from graphql then we should use *htLoadAsync so that we can show the loader icon

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, for this
Data is already being fetched before this, on the page level. and here it will be only used as a static data observable (shareReplay)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay. I hope that doesn't change :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to use loadAsync. If in case fetchLogEvents starts returning a new observable, we would have to remember to update this template as well.

<ht-log-events-table
[logEvents]="logEvents"
logEventsTableViewType="${LogEventsTableViewType.Detailed}"
></ht-log-events-table>
</ng-container>
`
})
export class TraceLogsComponent {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is not a dash page. It works. But I am not sure if we should be diverge from the dashboard pattern.

@aaron-steinfeld thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, we should try to reign dashboards back in to pages that look like dashboards. If we later need to embed this as a widget in another page, we could widgetize it for sharing at that point - but no need to build these custom single-page, single-purpose widgets.

public readonly logEvents$: Observable<LogEvent[]>;

public constructor(private readonly traceDetailService: TraceDetailService) {
this.logEvents$ = this.traceDetailService.fetchLogEvents();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { TraceDetailService } from './../trace-detail.service';
import { traceSequenceDashboard } from './trace-sequence.dashboard';

@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ht-navigable-dashboard
*htLoadAsync="this.traceVariables$ as traceVariables"
class="scrollable-container"
[padding]="0"
[variables]="traceVariables"
navLocation="${traceSequenceDashboard.location}"
>
</ht-navigable-dashboard>
`
})
export class TraceSequenceComponent {
public readonly traceVariables$: Observable<TraceDetailVariables>;

public constructor(private readonly traceDetailService: TraceDetailService) {
this.traceVariables$ = this.traceDetailService.fetchTraceDetails().pipe(
map(details => ({
traceId: details.id,
startTime: details.startTime,
spanId: details.entrySpanId
}))
);
}
}

interface TraceDetailVariables {
traceId: string;
startTime?: string | number;
spanId?: string;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DashboardDefaultConfiguration } from '../../shared/dashboard/dashboard-wrapper/navigable-dashboard.module';
import { DashboardDefaultConfiguration } from '../../../shared/dashboard/dashboard-wrapper/navigable-dashboard.module';

export const traceDetailDashboard: DashboardDefaultConfiguration = {
location: 'TRACE_DETAIL',
export const traceSequenceDashboard: DashboardDefaultConfiguration = {
location: 'TRACE_SEQUENCE',
json: {
type: 'container-widget',
layout: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@
.summary-value {
margin-right: 24px;
}

.tabs {
margin-top: 16px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
import { IconType } from '@hypertrace/assets-library';
import { NavigationService, SubscriptionLifecycle } from '@hypertrace/common';
import { IconSize } from '@hypertrace/components';

import { Dashboard } from '@hypertrace/hyperdash';
import { Observable } from 'rxjs';

import { traceDetailDashboard } from './trace-detail.dashboard';
import { LogEvent } from '../../shared/dashboard/widgets/waterfall/waterfall/waterfall-chart';
import { TraceDetails, TraceDetailService } from './trace-detail.service';
@Component({
styleUrls: ['./trace-detail.page.component.scss'],
Expand Down Expand Up @@ -53,13 +50,16 @@ import { TraceDetails, TraceDetailService } from './trace-detail.service';
</div>
</div>

<ht-navigable-dashboard
class="scrollable-container"
[padding]="0"
navLocation="${traceDetailDashboard.location}"
(dashboardReady)="this.onDashboardReady($event)"
>
</ht-navigable-dashboard>
<ht-navigable-tab-group class="tabs">
<ht-navigable-tab path="sequence"> Sequence </ht-navigable-tab>
<ng-container *ngIf="this.logEvents$ | async as logEvents">
<ht-navigable-tab path="logs" [labelTag]="logEvents.length"> Logs </ht-navigable-tab>
</ng-container>
</ht-navigable-tab-group>

<div class="scrollable-container">
<router-outlet></router-outlet>
</div>
</div>
`
})
Expand All @@ -68,25 +68,15 @@ export class TraceDetailPageComponent {

public readonly traceDetails$: Observable<TraceDetails>;
public readonly exportSpans$: Observable<string>;
public readonly logEvents$: Observable<LogEvent[]>;

public constructor(
private readonly subscriptionLifecycle: SubscriptionLifecycle,
private readonly navigationService: NavigationService,
private readonly traceDetailService: TraceDetailService
) {
this.traceDetails$ = this.traceDetailService.fetchTraceDetails();
this.exportSpans$ = this.traceDetailService.fetchExportSpans();
}

public onDashboardReady(dashboard: Dashboard): void {
this.subscriptionLifecycle.add(
this.traceDetails$.subscribe(traceDetails => {
dashboard.setVariable('traceId', traceDetails.id);
dashboard.setVariable('spanId', traceDetails.entrySpanId);
dashboard.setVariable('startTime', traceDetails.startTime);
dashboard.refresh();
})
);
this.logEvents$ = this.traceDetailService.fetchLogEvents();
}

public onClickBack(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,42 @@ import {
IconModule,
LabelModule,
LoadAsyncModule,
NavigableTabModule,
SummaryValueModule,
TooltipModule
} from '@hypertrace/components';
import { LogEventsTableModule } from '../../shared/components/log-events/log-events-table.module';
import { NavigableDashboardModule } from '../../shared/dashboard/dashboard-wrapper/navigable-dashboard.module';
import { TracingDashboardModule } from '../../shared/dashboard/tracing-dashboard.module';
import { traceDetailDashboard } from './trace-detail.dashboard';
import { TraceLogsComponent } from './logs/trace-logs.component';
import { TraceSequenceComponent } from './sequence/trace-sequence.component';
import { traceSequenceDashboard } from './sequence/trace-sequence.dashboard';
import { TraceDetailPageComponent } from './trace-detail.page.component';

const ROUTE_CONFIG: TraceRoute[] = [
{
path: `:${TraceDetailPageComponent.TRACE_ID_PARAM_NAME}`,
component: TraceDetailPageComponent
component: TraceDetailPageComponent,
children: [
{
path: '',
redirectTo: 'sequence',
pathMatch: 'full'
},
{
path: 'sequence',
component: TraceSequenceComponent
},
{
path: 'logs',
component: TraceLogsComponent
}
]
}
];

@NgModule({
declarations: [TraceDetailPageComponent],
declarations: [TraceDetailPageComponent, TraceSequenceComponent, TraceLogsComponent],
imports: [
RouterModule.forChild(ROUTE_CONFIG),
CommonModule,
Expand All @@ -37,7 +56,9 @@ const ROUTE_CONFIG: TraceRoute[] = [
FormattingModule,
CopyShareableLinkToClipboardModule,
DownloadJsonModule,
NavigableDashboardModule.withDefaultDashboards(traceDetailDashboard)
NavigableDashboardModule.withDefaultDashboards(traceSequenceDashboard),
NavigableTabModule,
LogEventsTableModule
]
})
export class TraceDetailPageModule {}
Loading