mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 20:19:13 +08:00
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
This commit is contained in:
parent
309ffa4989
commit
8ebb76bd0c
@ -10,7 +10,7 @@ const getSpans = async (
|
|||||||
): Promise<SuccessResponse<PayloadProps> | ErrorResponse> => {
|
): Promise<SuccessResponse<PayloadProps> | ErrorResponse> => {
|
||||||
try {
|
try {
|
||||||
const updatedSelectedTags = props.selectedTags.map((e) => ({
|
const updatedSelectedTags = props.selectedTags.map((e) => ({
|
||||||
Key: e.Key[0],
|
Key: e.Key,
|
||||||
Operator: e.Operator,
|
Operator: e.Operator,
|
||||||
StringValues: e.StringValues,
|
StringValues: e.StringValues,
|
||||||
NumberValues: e.NumberValues,
|
NumberValues: e.NumberValues,
|
||||||
|
@ -28,7 +28,7 @@ const getSpanAggregate = async (
|
|||||||
});
|
});
|
||||||
|
|
||||||
const updatedSelectedTags = props.selectedTags.map((e) => ({
|
const updatedSelectedTags = props.selectedTags.map((e) => ({
|
||||||
Key: e.Key[0],
|
Key: e.Key,
|
||||||
Operator: e.Operator,
|
Operator: e.Operator,
|
||||||
StringValues: e.StringValues,
|
StringValues: e.StringValues,
|
||||||
NumberValues: e.NumberValues,
|
NumberValues: e.NumberValues,
|
||||||
|
@ -6,7 +6,7 @@ import { Tags } from 'types/reducer/trace';
|
|||||||
|
|
||||||
export const dbSystemTags: Tags[] = [
|
export const dbSystemTags: Tags[] = [
|
||||||
{
|
{
|
||||||
Key: ['db.system.(string)'],
|
Key: 'db.system.(string)',
|
||||||
StringValues: [''],
|
StringValues: [''],
|
||||||
NumberValues: [],
|
NumberValues: [],
|
||||||
BoolValues: [],
|
BoolValues: [],
|
||||||
|
@ -16,7 +16,7 @@ function TagsKey(props: TagsKeysProps): JSX.Element {
|
|||||||
|
|
||||||
const { index, setLocalSelectedTags, tag } = props;
|
const { index, setLocalSelectedTags, tag } = props;
|
||||||
|
|
||||||
const [selectedKey, setSelectedKey] = useState<string>(tag.Key[0] || '');
|
const [selectedKey, setSelectedKey] = useState<string>(tag.Key || '');
|
||||||
|
|
||||||
const traces = useSelector<AppState, TraceReducer>((state) => state.traces);
|
const traces = useSelector<AppState, TraceReducer>((state) => state.traces);
|
||||||
|
|
||||||
|
@ -150,12 +150,12 @@ function SingleTags(props: AllTagsProps): JSX.Element {
|
|||||||
}
|
}
|
||||||
</SelectComponent>
|
</SelectComponent>
|
||||||
|
|
||||||
{selectedKey[0] ? (
|
{selectedKey ? (
|
||||||
<TagValue
|
<TagValue
|
||||||
index={index}
|
index={index}
|
||||||
tag={tag}
|
tag={tag}
|
||||||
setLocalSelectedTags={setLocalSelectedTags}
|
setLocalSelectedTags={setLocalSelectedTags}
|
||||||
tagKey={selectedKey[0]}
|
tagKey={selectedKey}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<SelectComponent />
|
<SelectComponent />
|
||||||
|
@ -72,7 +72,7 @@ export function onTagValueChange(
|
|||||||
export function disableTagValue(
|
export function disableTagValue(
|
||||||
selectedOperator: OperatorValues,
|
selectedOperator: OperatorValues,
|
||||||
setLocalValue: React.Dispatch<React.SetStateAction<TagValueTypes[]>>,
|
setLocalValue: React.Dispatch<React.SetStateAction<TagValueTypes[]>>,
|
||||||
selectedKeys: string[],
|
selectedKeys: string,
|
||||||
setLocalSelectedTags: React.Dispatch<React.SetStateAction<Tags[]>>,
|
setLocalSelectedTags: React.Dispatch<React.SetStateAction<Tags[]>>,
|
||||||
index: number,
|
index: number,
|
||||||
): boolean {
|
): boolean {
|
||||||
@ -169,9 +169,9 @@ export function selectOptions(
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mapOperators(selectedKey: string[]): AllMenuProps[] {
|
export function mapOperators(selectedKey: string): AllMenuProps[] {
|
||||||
return AllMenu.filter((e) =>
|
return AllMenu.filter((e) =>
|
||||||
e?.supportedTypes?.includes(extractTagType(selectedKey[0])),
|
e?.supportedTypes?.includes(extractTagType(selectedKey)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ export function onTagKeySelect(
|
|||||||
setLocalSelectedTags((tags) => [
|
setLocalSelectedTags((tags) => [
|
||||||
...tags.slice(0, index),
|
...tags.slice(0, index),
|
||||||
{
|
{
|
||||||
Key: [value],
|
Key: value,
|
||||||
Operator: tag.Operator,
|
Operator: tag.Operator,
|
||||||
StringValues: tag.StringValues,
|
StringValues: tag.StringValues,
|
||||||
NumberValues: tag.NumberValues,
|
NumberValues: tag.NumberValues,
|
||||||
|
@ -39,7 +39,7 @@ function AllTags({
|
|||||||
setLocalSelectedTags((tags) => [
|
setLocalSelectedTags((tags) => [
|
||||||
...tags,
|
...tags,
|
||||||
{
|
{
|
||||||
Key: [],
|
Key: '',
|
||||||
Operator: 'Equals',
|
Operator: 'Equals',
|
||||||
StringValues: [],
|
StringValues: [],
|
||||||
NumberValues: [],
|
NumberValues: [],
|
||||||
@ -94,7 +94,7 @@ function AllTags({
|
|||||||
<CurrentTagsContainer>
|
<CurrentTagsContainer>
|
||||||
{localSelectedTags.map((tags, index) => (
|
{localSelectedTags.map((tags, index) => (
|
||||||
<Tags
|
<Tags
|
||||||
key={tags.Key.join(',')}
|
key={tags.Key}
|
||||||
tag={tags}
|
tag={tags}
|
||||||
index={index}
|
index={index}
|
||||||
onCloseHandler={(): void => onCloseHandler(index)}
|
onCloseHandler={(): void => onCloseHandler(index)}
|
||||||
|
@ -59,7 +59,7 @@ export const parseQueryToTags = (query: string): PayloadProps<Tags> => {
|
|||||||
// If the operator is Exists or NotExists, then return the tag object without values
|
// If the operator is Exists or NotExists, then return the tag object without values
|
||||||
if (operator === 'Exists' || operator === 'NotExists') {
|
if (operator === 'Exists' || operator === 'NotExists') {
|
||||||
return {
|
return {
|
||||||
Key: [tagName],
|
Key: tagName,
|
||||||
StringValues: [],
|
StringValues: [],
|
||||||
NumberValues: [],
|
NumberValues: [],
|
||||||
BoolValues: [],
|
BoolValues: [],
|
||||||
@ -97,7 +97,7 @@ export const parseQueryToTags = (query: string): PayloadProps<Tags> => {
|
|||||||
|
|
||||||
// Return the tag object
|
// Return the tag object
|
||||||
return {
|
return {
|
||||||
Key: [tagName],
|
Key: tagName,
|
||||||
StringValues,
|
StringValues,
|
||||||
NumberValues,
|
NumberValues,
|
||||||
BoolValues,
|
BoolValues,
|
||||||
@ -120,31 +120,31 @@ export const parseTagsToQuery = (tags: Tags): PayloadProps<string> => {
|
|||||||
const payload = tags
|
const payload = tags
|
||||||
.map(({ StringValues, NumberValues, BoolValues, Key, Operator }) => {
|
.map(({ StringValues, NumberValues, BoolValues, Key, Operator }) => {
|
||||||
// Check if the key of the tag is undefined
|
// Check if the key of the tag is undefined
|
||||||
if (!Key[0]) {
|
if (!Key) {
|
||||||
isError = true;
|
isError = true;
|
||||||
}
|
}
|
||||||
if (Operator === 'Exists' || Operator === 'NotExists') {
|
if (Operator === 'Exists' || Operator === 'NotExists') {
|
||||||
return `${Key[0]} ${Operator}`;
|
return `${Key} ${Operator}`;
|
||||||
}
|
}
|
||||||
// Check if the tag has string values
|
// Check if the tag has string values
|
||||||
if (StringValues.length > 0) {
|
if (StringValues.length > 0) {
|
||||||
// Format the string values and join them with a ','
|
// Format the string values and join them with a ','
|
||||||
const formattedStringValues = formatValues(StringValues);
|
const formattedStringValues = formatValues(StringValues);
|
||||||
return `${Key[0]} ${Operator} (${formattedStringValues})`;
|
return `${Key} ${Operator} (${formattedStringValues})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the tag has number values
|
// Check if the tag has number values
|
||||||
if (NumberValues.length > 0) {
|
if (NumberValues.length > 0) {
|
||||||
// Format the number values and join them with a ','
|
// Format the number values and join them with a ','
|
||||||
const formattedNumberValues = formatValues(NumberValues);
|
const formattedNumberValues = formatValues(NumberValues);
|
||||||
return `${Key[0]} ${Operator} (${formattedNumberValues})`;
|
return `${Key} ${Operator} (${formattedNumberValues})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the tag has boolean values
|
// Check if the tag has boolean values
|
||||||
if (BoolValues.length > 0) {
|
if (BoolValues.length > 0) {
|
||||||
// Format the boolean values and join them with a ','
|
// Format the boolean values and join them with a ','
|
||||||
const formattedBoolValues = formatValues(BoolValues);
|
const formattedBoolValues = formatValues(BoolValues);
|
||||||
return `${Key[0]} ${Operator} (${formattedBoolValues})`;
|
return `${Key} ${Operator} (${formattedBoolValues})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
|
@ -37,7 +37,7 @@ export const convertRawQueriesToTraceSelectedTags = (
|
|||||||
queries: IResourceAttributeQuery[],
|
queries: IResourceAttributeQuery[],
|
||||||
): Tags[] =>
|
): Tags[] =>
|
||||||
queries.map((query) => ({
|
queries.map((query) => ({
|
||||||
Key: [convertMetricKeyToTrace(query.tagKey)],
|
Key: convertMetricKeyToTrace(query.tagKey),
|
||||||
Operator: convertOperatorLabelToTraceOperator(query.operator),
|
Operator: convertOperatorLabelToTraceOperator(query.operator),
|
||||||
StringValues: query.tagValue,
|
StringValues: query.tagValue,
|
||||||
NumberValues: [],
|
NumberValues: [],
|
||||||
|
@ -47,7 +47,7 @@ interface SpansAggregateData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Tags {
|
export interface Tags {
|
||||||
Key: string[];
|
Key: string;
|
||||||
Operator: OperatorValues;
|
Operator: OperatorValues;
|
||||||
StringValues: string[];
|
StringValues: string[];
|
||||||
NumberValues: number[];
|
NumberValues: number[];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user