Skip to content

Commit 4a46f6b

Browse files
authored
feat: adding an explore interval selection model (#678)
* feat: adding an explore interval selection model * refactor: removing unused code * refactor: fixing test * refactor: fix lint * refactor: fixing formatting
1 parent 2d8d0ff commit 4a46f6b

File tree

6 files changed

+47
-3
lines changed

6 files changed

+47
-3
lines changed

projects/observability/src/public-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Schema
66

77
export * from './shared/graphql/model/schema/entity';
8+
export * from './shared/graphql/model/schema/explore';
89
export * from './shared/graphql/model/schema/filter/entity/graphql-entity-filter';
910
export * from './shared/graphql/model/schema/neighbor';
1011
export * from './shared/graphql/model/schema/specifications/entity-specification';

projects/observability/src/shared/dashboard/data/graphql/observability-graphql-data-source.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { PercentageCompositeDataSourceModel } from './percentage/percentage-comp
2020
import { EntitySpecificationModel } from './specifiers/entity-specification.model';
2121
import { ErrorPercentageMetricAggregationSpecificationModel } from './specifiers/error-percentage-metric-aggregation.model';
2222
import { ExploreSelectionSpecificationModel } from './specifiers/explore-selection-specification.model';
23+
import { ExploreIntervalTimestampSelectionSpecificationModel } from './specifiers/explore/explorer-interval-timestamp-selection.model';
2324
import { MetricTimeseriesBandSpecificationModel } from './specifiers/metric-timeseries-band-specification.model';
2425
import { MetricTimeseriesSpecificationModel } from './specifiers/metric-timeseries-specification.model';
2526
import { NeighborEntitySpecificationModel } from './specifiers/neighbor-entity-specification.model';
@@ -46,6 +47,7 @@ import { ApiTraceWaterfallDataSourceModel } from './waterfall/api-trace-waterfal
4647
DashboardCoreModule.with({
4748
models: [
4849
ExploreSelectionSpecificationModel,
50+
ExploreIntervalTimestampSelectionSpecificationModel,
4951
ExploreTableDataSourceModel,
5052
ApiTraceWaterfallDataSourceModel,
5153
EntityMetricTimeseriesDataSourceModel,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Dictionary } from '@hypertrace/common';
2+
import { Specification, SpecificationModel } from '@hypertrace/distributed-tracing';
3+
import { Model } from '@hypertrace/hyperdash';
4+
import {
5+
ExploreSpecification,
6+
ExploreValue
7+
} from './../../../../../graphql/model/schema/specifications/explore-specification';
8+
import { ExploreSpecificationBuilder } from './../../../../../graphql/request/builders/specification/explore/explore-specification-builder';
9+
10+
@Model({
11+
type: 'explorer-interval-timestamp-selection',
12+
displayName: 'Explore Interval Timestamp Seleaction'
13+
})
14+
export class ExploreIntervalTimestampSelectionSpecificationModel extends SpecificationModel<Specification> {
15+
protected buildInnerSpec(): ExploreSpecification {
16+
return new ExploreSpecificationBuilder().exploreSpecificationForInterval();
17+
}
18+
19+
public extractFromServerData(resultContainer: Dictionary<ExploreValue>): ExploreValue {
20+
return this.innerSpec.extractFromServerData(resultContainer) as ExploreValue;
21+
}
22+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const INTERVAL_START_QUERY_KEY = '__intervalStart';

projects/observability/src/shared/graphql/request/builders/specification/explore/explore-specification-builder.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
1+
import { DateCoercer } from '@hypertrace/common';
12
import {
3+
AttributeMetadataType,
24
convertToGraphQlMetricAggregationType,
35
GraphQlMetricAggregationType,
46
MetricAggregationType
57
} from '@hypertrace/distributed-tracing';
68
import { GraphQlEnumArgument } from '@hypertrace/graphql-client';
9+
import { INTERVAL_START_QUERY_KEY } from '../../../../model/schema/explore';
710
import { ExploreSpecification } from '../../../../model/schema/specifications/explore-specification';
811
import { GraphQlObservabilityArgumentBuilder } from '../../argument/graphql-observability-argument-builder';
912

1013
export class ExploreSpecificationBuilder {
1114
private readonly argBuilder: GraphQlObservabilityArgumentBuilder = new GraphQlObservabilityArgumentBuilder();
15+
private readonly dateCoercer: DateCoercer = new DateCoercer();
16+
17+
public exploreSpecificationForInterval(): ExploreSpecification {
18+
return {
19+
resultAlias: () => INTERVAL_START_QUERY_KEY,
20+
name: INTERVAL_START_QUERY_KEY,
21+
asGraphQlSelections: () => [],
22+
extractFromServerData: serverData => ({
23+
value: this.dateCoercer.coerce(serverData[INTERVAL_START_QUERY_KEY]),
24+
type: AttributeMetadataType.Timestamp
25+
}),
26+
asGraphQlOrderByFragment: () => ({
27+
key: INTERVAL_START_QUERY_KEY
28+
})
29+
};
30+
}
1231

1332
public exploreSpecificationForKey(key: string, aggregation?: MetricAggregationType): ExploreSpecification {
1433
const queryAlias = aggregation === undefined ? key : `${aggregation}_${key}`;

projects/observability/src/shared/graphql/request/handlers/explore/explore-graphql-query-handler.service.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import {
1313
GraphQlQueryHandler,
1414
GraphQlSelection
1515
} from '@hypertrace/graphql-client';
16+
import { INTERVAL_START_QUERY_KEY } from '../../../model/schema/explore';
1617
import { GraphQlGroupBy } from '../../../model/schema/groupby/graphql-group-by';
1718
import { ExploreSpecification, ExploreValue } from '../../../model/schema/specifications/explore-specification';
1819
import { GraphQlObservabilityArgumentBuilder } from '../../builders/argument/graphql-observability-argument-builder';
1920
import { ExploreSpecificationBuilder } from '../../builders/specification/explore/explore-specification-builder';
2021

21-
const INTERVAL_START_QUERY_KEY = '__intervalStart';
22-
22+
export const GQL_EXPLORE_RESULT_INTERVAL_KEY = Symbol('Interval Start');
2323
@Injectable({ providedIn: 'root' })
2424
export class ExploreGraphQlQueryHandlerService
2525
implements GraphQlQueryHandler<GraphQlExploreRequest, GraphQlExploreResponse> {
@@ -127,7 +127,6 @@ export class ExploreGraphQlQueryHandlerService
127127
}
128128

129129
export const EXPLORE_GQL_REQUEST = Symbol('GraphQL Query Request');
130-
export const GQL_EXPLORE_RESULT_INTERVAL_KEY = Symbol('Interval Start');
131130

132131
export interface GraphQlExploreRequest {
133132
requestType: typeof EXPLORE_GQL_REQUEST;

0 commit comments

Comments
 (0)