mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-26 06:24:34 +08:00
[Refactor]: added tag for data type and type of logs (#3554)
This commit is contained in:
parent
14a59a26b2
commit
85d7752350
25
frontend/src/container/LogDetailedView/FieldRenderer.tsx
Normal file
25
frontend/src/container/LogDetailedView/FieldRenderer.tsx
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { blue } from '@ant-design/colors';
|
||||||
|
import { Tag } from 'antd';
|
||||||
|
|
||||||
|
import { FieldRendererProps } from './LogDetailedView.types';
|
||||||
|
import { getFieldAttributes } from './utils';
|
||||||
|
|
||||||
|
function FieldRenderer({ field }: FieldRendererProps): JSX.Element {
|
||||||
|
const { dataType, newField, logType } = getFieldAttributes(field);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span>
|
||||||
|
{dataType && newField && logType ? (
|
||||||
|
<>
|
||||||
|
<span style={{ color: blue[4] }}>{newField} </span>
|
||||||
|
<Tag>Type: {logType}</Tag>
|
||||||
|
<Tag>Data type: {dataType}</Tag>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<span style={{ color: blue[4] }}>{field}</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FieldRenderer;
|
@ -0,0 +1,11 @@
|
|||||||
|
import { MetricsType } from 'container/MetricsApplication/constant';
|
||||||
|
|
||||||
|
export interface FieldRendererProps {
|
||||||
|
field: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IFieldAttributes {
|
||||||
|
dataType?: string;
|
||||||
|
newField?: string;
|
||||||
|
logType?: MetricsType;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
import { blue, orange } from '@ant-design/colors';
|
import { orange } from '@ant-design/colors';
|
||||||
import { LinkOutlined } from '@ant-design/icons';
|
import { LinkOutlined } from '@ant-design/icons';
|
||||||
import { Input, Space, Tooltip } from 'antd';
|
import { Input, Space, Tooltip } from 'antd';
|
||||||
import { ColumnsType } from 'antd/es/table';
|
import { ColumnsType } from 'antd/es/table';
|
||||||
@ -21,6 +21,7 @@ import { SET_DETAILED_LOG_DATA } from 'types/actions/logs';
|
|||||||
import { ILog } from 'types/api/logs/log';
|
import { ILog } from 'types/api/logs/log';
|
||||||
|
|
||||||
import ActionItem, { ActionItemProps } from './ActionItem';
|
import ActionItem, { ActionItemProps } from './ActionItem';
|
||||||
|
import FieldRenderer from './FieldRenderer';
|
||||||
import { flattenObject, recursiveParseJSON } from './utils';
|
import { flattenObject, recursiveParseJSON } from './utils';
|
||||||
|
|
||||||
// Fields which should be restricted from adding it to query
|
// Fields which should be restricted from adding it to query
|
||||||
@ -91,7 +92,7 @@ function TableView({
|
|||||||
const columns: ColumnsType<DataType> = [
|
const columns: ColumnsType<DataType> = [
|
||||||
{
|
{
|
||||||
title: 'Action',
|
title: 'Action',
|
||||||
width: 30,
|
width: 11,
|
||||||
render: (fieldData: Record<string, string>): JSX.Element | null => {
|
render: (fieldData: Record<string, string>): JSX.Element | null => {
|
||||||
const fieldKey = fieldData.field.split('.').slice(-1);
|
const fieldKey = fieldData.field.split('.').slice(-1);
|
||||||
if (!RESTRICTED_FIELDS.includes(fieldKey[0])) {
|
if (!RESTRICTED_FIELDS.includes(fieldKey[0])) {
|
||||||
@ -110,12 +111,12 @@ function TableView({
|
|||||||
title: 'Field',
|
title: 'Field',
|
||||||
dataIndex: 'field',
|
dataIndex: 'field',
|
||||||
key: 'field',
|
key: 'field',
|
||||||
width: 30,
|
width: 50,
|
||||||
align: 'left',
|
align: 'left',
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
render: (field: string, record): JSX.Element => {
|
render: (field: string, record): JSX.Element => {
|
||||||
const fieldKey = field.split('.').slice(-1);
|
const fieldKey = field.split('.').slice(-1);
|
||||||
const renderedField = <span style={{ color: blue[4] }}>{field}</span>;
|
const renderedField = <FieldRenderer field={field} />;
|
||||||
|
|
||||||
if (record.field === 'trace_id') {
|
if (record.field === 'trace_id') {
|
||||||
const traceId = flattenLogData[record.field];
|
const traceId = flattenLogData[record.field];
|
||||||
@ -161,7 +162,7 @@ function TableView({
|
|||||||
title: 'Value',
|
title: 'Value',
|
||||||
dataIndex: 'value',
|
dataIndex: 'value',
|
||||||
key: 'value',
|
key: 'value',
|
||||||
width: 80,
|
width: 70,
|
||||||
ellipsis: false,
|
ellipsis: false,
|
||||||
render: (field, record): JSX.Element => {
|
render: (field, record): JSX.Element => {
|
||||||
if (record.field === 'body') {
|
if (record.field === 'body') {
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
import { MetricsType } from 'container/MetricsApplication/constant';
|
||||||
|
|
||||||
|
import { IFieldAttributes } from './LogDetailedView.types';
|
||||||
|
|
||||||
export const recursiveParseJSON = (obj: string): Record<string, unknown> => {
|
export const recursiveParseJSON = (obj: string): Record<string, unknown> => {
|
||||||
try {
|
try {
|
||||||
const value = JSON.parse(obj);
|
const value = JSON.parse(obj);
|
||||||
@ -32,3 +36,23 @@ export function flattenObject(obj: AnyObject, prefix = ''): AnyObject {
|
|||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getFieldAttributes = (field: string): IFieldAttributes => {
|
||||||
|
let dataType;
|
||||||
|
let newField;
|
||||||
|
let logType;
|
||||||
|
|
||||||
|
if (field.startsWith('attributes_')) {
|
||||||
|
logType = MetricsType.Tag;
|
||||||
|
const stringWithoutPrefix = field.slice('attributes_'.length);
|
||||||
|
const parts = stringWithoutPrefix.split('.');
|
||||||
|
[dataType, newField] = parts;
|
||||||
|
} else if (field.startsWith('resources_')) {
|
||||||
|
logType = MetricsType.Resource;
|
||||||
|
const stringWithoutPrefix = field.slice('resources_'.length);
|
||||||
|
const parts = stringWithoutPrefix.split('.');
|
||||||
|
[dataType, newField] = parts;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { dataType, newField, logType };
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user