diff --git a/projects/observability/src/pages/explorer/explorer-service.ts b/projects/observability/src/pages/explorer/explorer-service.ts index 733101087..86cf55632 100644 --- a/projects/observability/src/pages/explorer/explorer-service.ts +++ b/projects/observability/src/pages/explorer/explorer-service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { forkJoinSafeEmpty, NavigationParams, NavigationParamsType } from '@hypertrace/common'; import { Filter, FilterBuilderLookupService } from '@hypertrace/components'; -import { Observable } from 'rxjs'; +import { Observable, of } from 'rxjs'; import { map } from 'rxjs/operators'; import { toFilterAttributeType } from '../../shared/graphql/model/metadata/attribute-metadata'; import { ObservabilityTraceType } from '../../shared/graphql/model/schema/observability-traces'; @@ -17,23 +17,25 @@ export class ExplorerService { ) {} public buildNavParamsWithFilters( scopeQueryParam: ScopeQueryParam, - filters: ExplorerDrilldownFilter[] + filters: (ExplorerDrilldownFilter | string)[] ): Observable { const filterStrings$: Observable[] = filters.map(filter => - this.metadataService - .getAttribute( - scopeQueryParam === ScopeQueryParam.EndpointTraces ? ObservabilityTraceType.Api : SPAN_SCOPE, - filter.field - ) - .pipe( - map(attribute => ({ ...attribute, type: toFilterAttributeType(attribute.type) })), - map( - filterAttribute => - this.filterBuilderLookupService - .lookup(filterAttribute.type) - .buildFilter(filterAttribute, filter.operator, filter.value, filter.subpath).urlString - ) - ) + typeof filter === 'string' + ? of(filter) + : this.metadataService + .getAttribute( + scopeQueryParam === ScopeQueryParam.EndpointTraces ? ObservabilityTraceType.Api : SPAN_SCOPE, + filter.field + ) + .pipe( + map(attribute => ({ ...attribute, type: toFilterAttributeType(attribute.type) })), + map( + filterAttribute => + this.filterBuilderLookupService + .lookup(filterAttribute.type) + .buildFilter(filterAttribute, filter.operator, filter.value, filter.subpath).urlString + ) + ) ); return forkJoinSafeEmpty(filterStrings$).pipe( diff --git a/projects/observability/src/shared/components/span-detail/tags/span-tags-detail.component.test.ts b/projects/observability/src/shared/components/span-detail/tags/span-tags-detail.component.test.ts index 5a4528f6b..25995bf36 100644 --- a/projects/observability/src/shared/components/span-detail/tags/span-tags-detail.component.test.ts +++ b/projects/observability/src/shared/components/span-detail/tags/span-tags-detail.component.test.ts @@ -1,6 +1,6 @@ import { CommonModule } from '@angular/common'; import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { MemoizeModule } from '@hypertrace/common'; +import { MemoizeModule, NavigationService } from '@hypertrace/common'; import { JsonViewerModule, LabelModule, @@ -31,7 +31,10 @@ describe('Span Tags Detail Component', () => { MemoizeModule ], declarations: [MockComponent(ExploreFilterLinkComponent)], - providers: [mockProvider(ExplorerService)] + providers: [ + mockProvider(ExplorerService), + mockProvider(NavigationService, { getAllValuesForQueryParameter: () => [] }) + ] }); test('should display tag records', () => { diff --git a/projects/observability/src/shared/components/span-detail/tags/span-tags-detail.component.ts b/projects/observability/src/shared/components/span-detail/tags/span-tags-detail.component.ts index a04e6ba93..981f79572 100644 --- a/projects/observability/src/shared/components/span-detail/tags/span-tags-detail.component.ts +++ b/projects/observability/src/shared/components/span-detail/tags/span-tags-detail.component.ts @@ -1,5 +1,5 @@ import { ChangeDetectionStrategy, Component, Input, OnChanges } from '@angular/core'; -import { Dictionary, NavigationParams, TypedSimpleChanges } from '@hypertrace/common'; +import { Dictionary, NavigationParams, NavigationService, TypedSimpleChanges } from '@hypertrace/common'; import { FilterOperator, ListViewDisplay, ListViewRecord } from '@hypertrace/components'; import { isNil } from 'lodash-es'; import { EMPTY, Observable, of } from 'rxjs'; @@ -34,7 +34,10 @@ export class SpanTagsDetailComponent implements OnChanges { public tagRecords$?: Observable; - public constructor(private readonly explorerService: ExplorerService) {} + public constructor( + private readonly explorerService: ExplorerService, + private readonly navigationService: NavigationService + ) {} public ngOnChanges(changes: TypedSimpleChanges): void { if (changes.tags && this.tags) { @@ -44,6 +47,7 @@ export class SpanTagsDetailComponent implements OnChanges { public getExploreNavigationParams = (tag: ListViewRecord): Observable => this.explorerService.buildNavParamsWithFilters(ScopeQueryParam.EndpointTraces, [ + ...this.navigationService.getAllValuesForQueryParameter('filter'), { field: 'tags', subpath: tag.key, operator: FilterOperator.Equals, value: tag.value } ]);