Skip to content
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

feat: add resource_deployment_environment as fast filter in traces page #5864

Merged
24 changes: 19 additions & 5 deletions frontend/src/pages/TracesExplorer/Filter/filterUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { getAttributesValues } from 'api/queryBuilder/getAttributesValues';
import { convertMetricKeyToTrace } from 'hooks/useResourceAttribute/utils';
import { Dispatch, SetStateAction, useEffect, useState } from 'react';
import {
BaseAutocompleteData,
Expand All @@ -8,10 +9,14 @@ import {
import { TagFilterItem } from 'types/api/queryBuilder/queryBuilderData';
import { DataSource } from 'types/common/queryBuilder';

export const AllTraceFilterKeyValue = {
const RESOURCE_DEPLOYMENT_ENVIRONMENT = convertMetricKeyToTrace(
'resource_deployment_environment',
);
ahmadshaheer marked this conversation as resolved.
Show resolved Hide resolved
export const AllTraceFilterKeyValue: Record<string, string> = {
durationNanoMin: 'Duration',
durationNano: 'Duration',
durationNanoMax: 'Duration',
[RESOURCE_DEPLOYMENT_ENVIRONMENT]: 'Environment',
hasError: 'Status',
serviceName: 'Service Name',
name: 'Operation / Name',
Expand All @@ -22,7 +27,7 @@ export const AllTraceFilterKeyValue = {
httpRoute: 'HTTP Route',
httpUrl: 'HTTP URL',
traceID: 'Trace ID',
};
} as const;

export type AllTraceFilterKeys = keyof typeof AllTraceFilterKeyValue;

Expand Down Expand Up @@ -64,7 +69,7 @@ export const addFilter = (
| undefined
>
>,
keys?: BaseAutocompleteData,
keys: BaseAutocompleteData,
): void => {
setSelectedFilters((prevFilters) => {
const isDuration = [
Expand Down Expand Up @@ -122,7 +127,7 @@ export const removeFilter = (
| undefined
>
>,
keys?: BaseAutocompleteData,
keys: BaseAutocompleteData,
): void => {
setSelectedFilters((prevFilters) => {
if (!prevFilters || !prevFilters[filterType]?.values.length) {
Expand Down Expand Up @@ -202,6 +207,15 @@ export const traceFilterKeys: Record<
isJSON: false,
id: 'serviceName--string--tag--true',
},

[RESOURCE_DEPLOYMENT_ENVIRONMENT]: {
key: RESOURCE_DEPLOYMENT_ENVIRONMENT,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${RESOURCE_DEPLOYMENT_ENVIRONMENT}--string--resource--false`,
},
name: {
key: 'name',
dataType: DataTypes.String,
Expand Down Expand Up @@ -282,7 +296,7 @@ export const traceFilterKeys: Record<
isJSON: false,
id: 'durationNanoMax--float64--tag--true',
},
};
} as const;

interface AggregateValuesProps {
value: AllTraceFilterKeys;
Expand Down
Loading