From 8ebb76bd0c40ea7e3cb4b0e3a3f216c204447f67 Mon Sep 17 00:00:00 2001 From: Vishal Sharma Date: Tue, 14 Feb 2023 10:48:47 +0530 Subject: [PATCH] fix: resource attribute tag key type is updated (#2231) * fix: resource attribute tag key type is updated from array to string * chore: convert tag key from array to string --- frontend/src/api/trace/getSpans.ts | 2 +- frontend/src/api/trace/getSpansAggregate.ts | 2 +- .../src/container/MetricsApplication/Tabs/util.ts | 2 +- .../container/Trace/Search/AllTags/Tag/TagKey.tsx | 2 +- .../container/Trace/Search/AllTags/Tag/index.tsx | 4 ++-- .../container/Trace/Search/AllTags/Tag/utils.ts | 8 ++++---- .../src/container/Trace/Search/AllTags/index.tsx | 4 ++-- frontend/src/container/Trace/Search/util.ts | 14 +++++++------- frontend/src/lib/resourceAttributes.ts | 2 +- frontend/src/types/reducer/trace.ts | 2 +- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/frontend/src/api/trace/getSpans.ts b/frontend/src/api/trace/getSpans.ts index 55fa677e38..06555d20fe 100644 --- a/frontend/src/api/trace/getSpans.ts +++ b/frontend/src/api/trace/getSpans.ts @@ -10,7 +10,7 @@ const getSpans = async ( ): Promise | ErrorResponse> => { try { const updatedSelectedTags = props.selectedTags.map((e) => ({ - Key: e.Key[0], + Key: e.Key, Operator: e.Operator, StringValues: e.StringValues, NumberValues: e.NumberValues, diff --git a/frontend/src/api/trace/getSpansAggregate.ts b/frontend/src/api/trace/getSpansAggregate.ts index d0cc04c2b4..373e677ab1 100644 --- a/frontend/src/api/trace/getSpansAggregate.ts +++ b/frontend/src/api/trace/getSpansAggregate.ts @@ -28,7 +28,7 @@ const getSpanAggregate = async ( }); const updatedSelectedTags = props.selectedTags.map((e) => ({ - Key: e.Key[0], + Key: e.Key, Operator: e.Operator, StringValues: e.StringValues, NumberValues: e.NumberValues, diff --git a/frontend/src/container/MetricsApplication/Tabs/util.ts b/frontend/src/container/MetricsApplication/Tabs/util.ts index 376d2b4770..a0e29e60fa 100644 --- a/frontend/src/container/MetricsApplication/Tabs/util.ts +++ b/frontend/src/container/MetricsApplication/Tabs/util.ts @@ -6,7 +6,7 @@ import { Tags } from 'types/reducer/trace'; export const dbSystemTags: Tags[] = [ { - Key: ['db.system.(string)'], + Key: 'db.system.(string)', StringValues: [''], NumberValues: [], BoolValues: [], diff --git a/frontend/src/container/Trace/Search/AllTags/Tag/TagKey.tsx b/frontend/src/container/Trace/Search/AllTags/Tag/TagKey.tsx index 22c5788469..5d241efec0 100644 --- a/frontend/src/container/Trace/Search/AllTags/Tag/TagKey.tsx +++ b/frontend/src/container/Trace/Search/AllTags/Tag/TagKey.tsx @@ -16,7 +16,7 @@ function TagsKey(props: TagsKeysProps): JSX.Element { const { index, setLocalSelectedTags, tag } = props; - const [selectedKey, setSelectedKey] = useState(tag.Key[0] || ''); + const [selectedKey, setSelectedKey] = useState(tag.Key || ''); const traces = useSelector((state) => state.traces); diff --git a/frontend/src/container/Trace/Search/AllTags/Tag/index.tsx b/frontend/src/container/Trace/Search/AllTags/Tag/index.tsx index f95afab615..90003b0142 100644 --- a/frontend/src/container/Trace/Search/AllTags/Tag/index.tsx +++ b/frontend/src/container/Trace/Search/AllTags/Tag/index.tsx @@ -150,12 +150,12 @@ function SingleTags(props: AllTagsProps): JSX.Element { } - {selectedKey[0] ? ( + {selectedKey ? ( ) : ( diff --git a/frontend/src/container/Trace/Search/AllTags/Tag/utils.ts b/frontend/src/container/Trace/Search/AllTags/Tag/utils.ts index 9faefef523..0ac195c3d1 100644 --- a/frontend/src/container/Trace/Search/AllTags/Tag/utils.ts +++ b/frontend/src/container/Trace/Search/AllTags/Tag/utils.ts @@ -72,7 +72,7 @@ export function onTagValueChange( export function disableTagValue( selectedOperator: OperatorValues, setLocalValue: React.Dispatch>, - selectedKeys: string[], + selectedKeys: string, setLocalSelectedTags: React.Dispatch>, index: number, ): boolean { @@ -169,9 +169,9 @@ export function selectOptions( return []; } -export function mapOperators(selectedKey: string[]): AllMenuProps[] { +export function mapOperators(selectedKey: string): AllMenuProps[] { return AllMenu.filter((e) => - e?.supportedTypes?.includes(extractTagType(selectedKey[0])), + e?.supportedTypes?.includes(extractTagType(selectedKey)), ); } @@ -192,7 +192,7 @@ export function onTagKeySelect( setLocalSelectedTags((tags) => [ ...tags.slice(0, index), { - Key: [value], + Key: value, Operator: tag.Operator, StringValues: tag.StringValues, NumberValues: tag.NumberValues, diff --git a/frontend/src/container/Trace/Search/AllTags/index.tsx b/frontend/src/container/Trace/Search/AllTags/index.tsx index f37209eccb..effb0c87b9 100644 --- a/frontend/src/container/Trace/Search/AllTags/index.tsx +++ b/frontend/src/container/Trace/Search/AllTags/index.tsx @@ -39,7 +39,7 @@ function AllTags({ setLocalSelectedTags((tags) => [ ...tags, { - Key: [], + Key: '', Operator: 'Equals', StringValues: [], NumberValues: [], @@ -94,7 +94,7 @@ function AllTags({ {localSelectedTags.map((tags, index) => ( onCloseHandler(index)} diff --git a/frontend/src/container/Trace/Search/util.ts b/frontend/src/container/Trace/Search/util.ts index e03a19e5bb..347d1df54f 100644 --- a/frontend/src/container/Trace/Search/util.ts +++ b/frontend/src/container/Trace/Search/util.ts @@ -59,7 +59,7 @@ export const parseQueryToTags = (query: string): PayloadProps => { // If the operator is Exists or NotExists, then return the tag object without values if (operator === 'Exists' || operator === 'NotExists') { return { - Key: [tagName], + Key: tagName, StringValues: [], NumberValues: [], BoolValues: [], @@ -97,7 +97,7 @@ export const parseQueryToTags = (query: string): PayloadProps => { // Return the tag object return { - Key: [tagName], + Key: tagName, StringValues, NumberValues, BoolValues, @@ -120,31 +120,31 @@ export const parseTagsToQuery = (tags: Tags): PayloadProps => { const payload = tags .map(({ StringValues, NumberValues, BoolValues, Key, Operator }) => { // Check if the key of the tag is undefined - if (!Key[0]) { + if (!Key) { isError = true; } if (Operator === 'Exists' || Operator === 'NotExists') { - return `${Key[0]} ${Operator}`; + return `${Key} ${Operator}`; } // Check if the tag has string values if (StringValues.length > 0) { // Format the string values and join them with a ',' const formattedStringValues = formatValues(StringValues); - return `${Key[0]} ${Operator} (${formattedStringValues})`; + return `${Key} ${Operator} (${formattedStringValues})`; } // Check if the tag has number values if (NumberValues.length > 0) { // Format the number values and join them with a ',' const formattedNumberValues = formatValues(NumberValues); - return `${Key[0]} ${Operator} (${formattedNumberValues})`; + return `${Key} ${Operator} (${formattedNumberValues})`; } // Check if the tag has boolean values if (BoolValues.length > 0) { // Format the boolean values and join them with a ',' const formattedBoolValues = formatValues(BoolValues); - return `${Key[0]} ${Operator} (${formattedBoolValues})`; + return `${Key} ${Operator} (${formattedBoolValues})`; } return ''; diff --git a/frontend/src/lib/resourceAttributes.ts b/frontend/src/lib/resourceAttributes.ts index 1d21799ad9..3c3fdd99e1 100644 --- a/frontend/src/lib/resourceAttributes.ts +++ b/frontend/src/lib/resourceAttributes.ts @@ -37,7 +37,7 @@ export const convertRawQueriesToTraceSelectedTags = ( queries: IResourceAttributeQuery[], ): Tags[] => queries.map((query) => ({ - Key: [convertMetricKeyToTrace(query.tagKey)], + Key: convertMetricKeyToTrace(query.tagKey), Operator: convertOperatorLabelToTraceOperator(query.operator), StringValues: query.tagValue, NumberValues: [], diff --git a/frontend/src/types/reducer/trace.ts b/frontend/src/types/reducer/trace.ts index fda615160c..701f27efa6 100644 --- a/frontend/src/types/reducer/trace.ts +++ b/frontend/src/types/reducer/trace.ts @@ -47,7 +47,7 @@ interface SpansAggregateData { } export interface Tags { - Key: string[]; + Key: string; Operator: OperatorValues; StringValues: string[]; NumberValues: number[];