mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-13 23:55:56 +08:00
feat: added support for instrumentation scope in logs (#6378)
* feat: added support for instrumentation scope in logs * chore: remove console logs * fix: the logic for rendering prefix * feat: address review comments --------- Co-authored-by: SagarRajput-7 <162284829+SagarRajput-7@users.noreply.github.com>
This commit is contained in:
parent
8403a3362d
commit
471803115e
@ -17,6 +17,7 @@ describe('getLogIndicatorType', () => {
|
|||||||
body: 'Sample log Message',
|
body: 'Sample log Message',
|
||||||
resources_string: {},
|
resources_string: {},
|
||||||
attributesString: {},
|
attributesString: {},
|
||||||
|
scope_string: {},
|
||||||
attributes_string: {},
|
attributes_string: {},
|
||||||
attributesInt: {},
|
attributesInt: {},
|
||||||
attributesFloat: {},
|
attributesFloat: {},
|
||||||
@ -40,6 +41,7 @@ describe('getLogIndicatorType', () => {
|
|||||||
body: 'Sample log Message',
|
body: 'Sample log Message',
|
||||||
resources_string: {},
|
resources_string: {},
|
||||||
attributesString: {},
|
attributesString: {},
|
||||||
|
scope_string: {},
|
||||||
attributes_string: {},
|
attributes_string: {},
|
||||||
attributesInt: {},
|
attributesInt: {},
|
||||||
attributesFloat: {},
|
attributesFloat: {},
|
||||||
@ -62,6 +64,7 @@ describe('getLogIndicatorType', () => {
|
|||||||
body: 'Sample log Message',
|
body: 'Sample log Message',
|
||||||
resources_string: {},
|
resources_string: {},
|
||||||
attributesString: {},
|
attributesString: {},
|
||||||
|
scope_string: {},
|
||||||
attributes_string: {},
|
attributes_string: {},
|
||||||
attributesInt: {},
|
attributesInt: {},
|
||||||
attributesFloat: {},
|
attributesFloat: {},
|
||||||
@ -83,6 +86,7 @@ describe('getLogIndicatorType', () => {
|
|||||||
body: 'Sample log',
|
body: 'Sample log',
|
||||||
resources_string: {},
|
resources_string: {},
|
||||||
attributesString: {},
|
attributesString: {},
|
||||||
|
scope_string: {},
|
||||||
attributes_string: {
|
attributes_string: {
|
||||||
log_level: 'INFO' as never,
|
log_level: 'INFO' as never,
|
||||||
},
|
},
|
||||||
@ -112,6 +116,7 @@ describe('getLogIndicatorTypeForTable', () => {
|
|||||||
attributesString: {},
|
attributesString: {},
|
||||||
attributes_string: {},
|
attributes_string: {},
|
||||||
attributesInt: {},
|
attributesInt: {},
|
||||||
|
scope_string: {},
|
||||||
attributesFloat: {},
|
attributesFloat: {},
|
||||||
severity_text: 'WARN',
|
severity_text: 'WARN',
|
||||||
};
|
};
|
||||||
@ -130,6 +135,7 @@ describe('getLogIndicatorTypeForTable', () => {
|
|||||||
severity_number: 0,
|
severity_number: 0,
|
||||||
body: 'Sample log message',
|
body: 'Sample log message',
|
||||||
resources_string: {},
|
resources_string: {},
|
||||||
|
scope_string: {},
|
||||||
attributesString: {},
|
attributesString: {},
|
||||||
attributes_string: {},
|
attributes_string: {},
|
||||||
attributesInt: {},
|
attributesInt: {},
|
||||||
@ -166,6 +172,7 @@ describe('logIndicatorBySeverityNumber', () => {
|
|||||||
body: 'Sample log Message',
|
body: 'Sample log Message',
|
||||||
resources_string: {},
|
resources_string: {},
|
||||||
attributesString: {},
|
attributesString: {},
|
||||||
|
scope_string: {},
|
||||||
attributes_string: {},
|
attributes_string: {},
|
||||||
attributesInt: {},
|
attributesInt: {},
|
||||||
attributesFloat: {},
|
attributesFloat: {},
|
||||||
|
@ -157,6 +157,11 @@ export const getFieldAttributes = (field: string): IFieldAttributes => {
|
|||||||
const stringWithoutPrefix = field.slice('resources_'.length);
|
const stringWithoutPrefix = field.slice('resources_'.length);
|
||||||
const parts = splitOnce(stringWithoutPrefix, '.');
|
const parts = splitOnce(stringWithoutPrefix, '.');
|
||||||
[dataType, newField] = parts;
|
[dataType, newField] = parts;
|
||||||
|
} else if (field.startsWith('scope_string')) {
|
||||||
|
logType = MetricsType.Scope;
|
||||||
|
const stringWithoutPrefix = field.slice('scope_'.length);
|
||||||
|
const parts = splitOnce(stringWithoutPrefix, '.');
|
||||||
|
[dataType, newField] = parts;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { dataType, newField, logType };
|
return { dataType, newField, logType };
|
||||||
@ -187,6 +192,7 @@ export const aggregateAttributesResourcesToString = (logData: ILog): string => {
|
|||||||
traceId: logData.traceId,
|
traceId: logData.traceId,
|
||||||
attributes: {},
|
attributes: {},
|
||||||
resources: {},
|
resources: {},
|
||||||
|
scope: {},
|
||||||
severity_text: logData.severity_text,
|
severity_text: logData.severity_text,
|
||||||
severity_number: logData.severity_number,
|
severity_number: logData.severity_number,
|
||||||
};
|
};
|
||||||
@ -198,6 +204,9 @@ export const aggregateAttributesResourcesToString = (logData: ILog): string => {
|
|||||||
} else if (key.startsWith('resources_')) {
|
} else if (key.startsWith('resources_')) {
|
||||||
outputJson.resources = outputJson.resources || {};
|
outputJson.resources = outputJson.resources || {};
|
||||||
Object.assign(outputJson.resources, logData[key as keyof ILog]);
|
Object.assign(outputJson.resources, logData[key as keyof ILog]);
|
||||||
|
} else if (key.startsWith('scope_string')) {
|
||||||
|
outputJson.scope = outputJson.scope || {};
|
||||||
|
Object.assign(outputJson.scope, logData[key as keyof ILog]);
|
||||||
} else {
|
} else {
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
@ -53,6 +53,7 @@ export enum KeyOperationTableHeader {
|
|||||||
export enum MetricsType {
|
export enum MetricsType {
|
||||||
Tag = 'tag',
|
Tag = 'tag',
|
||||||
Resource = 'resource',
|
Resource = 'resource',
|
||||||
|
Scope = 'scope',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum WidgetKeys {
|
export enum WidgetKeys {
|
||||||
|
@ -81,8 +81,10 @@ export const AggregatorFilter = memo(function AggregatorFilter({
|
|||||||
prefix: item.type || '',
|
prefix: item.type || '',
|
||||||
condition: !item.isColumn,
|
condition: !item.isColumn,
|
||||||
}),
|
}),
|
||||||
|
!item.isColumn && item.type ? item.type : '',
|
||||||
)}
|
)}
|
||||||
dataType={item.dataType}
|
dataType={item.dataType}
|
||||||
|
type={item.type || ''}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
value: `${item.key}${selectValueDivider}${createIdFromObjectFields(
|
value: `${item.key}${selectValueDivider}${createIdFromObjectFields(
|
||||||
@ -187,6 +189,9 @@ export const AggregatorFilter = memo(function AggregatorFilter({
|
|||||||
prefix: query.aggregateAttribute.type || '',
|
prefix: query.aggregateAttribute.type || '',
|
||||||
condition: !query.aggregateAttribute.isColumn,
|
condition: !query.aggregateAttribute.isColumn,
|
||||||
}),
|
}),
|
||||||
|
!query.aggregateAttribute.isColumn && query.aggregateAttribute.type
|
||||||
|
? query.aggregateAttribute.type
|
||||||
|
: '',
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -75,8 +75,10 @@ export const GroupByFilter = memo(function GroupByFilter({
|
|||||||
prefix: item.type || '',
|
prefix: item.type || '',
|
||||||
condition: !item.isColumn,
|
condition: !item.isColumn,
|
||||||
}),
|
}),
|
||||||
|
!item.isColumn && item.type ? item.type : '',
|
||||||
)}
|
)}
|
||||||
dataType={item.dataType || ''}
|
dataType={item.dataType || ''}
|
||||||
|
type={item.type || ''}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
value: `${item.id}`,
|
value: `${item.id}`,
|
||||||
@ -166,6 +168,7 @@ export const GroupByFilter = memo(function GroupByFilter({
|
|||||||
prefix: item.type || '',
|
prefix: item.type || '',
|
||||||
condition: !item.isColumn,
|
condition: !item.isColumn,
|
||||||
}),
|
}),
|
||||||
|
!item.isColumn && item.type ? item.type : '',
|
||||||
)}`,
|
)}`,
|
||||||
value: `${item.id}`,
|
value: `${item.id}`,
|
||||||
}),
|
}),
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { MetricsType } from 'container/MetricsApplication/constant';
|
import { MetricsType } from 'container/MetricsApplication/constant';
|
||||||
|
|
||||||
export function removePrefix(str: string): string {
|
export function removePrefix(str: string, type: string): string {
|
||||||
const tagPrefix = `${MetricsType.Tag}_`;
|
const tagPrefix = `${MetricsType.Tag}_`;
|
||||||
const resourcePrefix = `${MetricsType.Resource}_`;
|
const resourcePrefix = `${MetricsType.Resource}_`;
|
||||||
|
const scopePrefix = `${MetricsType.Scope}_`;
|
||||||
|
|
||||||
if (str.startsWith(tagPrefix)) {
|
if (str.startsWith(tagPrefix)) {
|
||||||
return str.slice(tagPrefix.length);
|
return str.slice(tagPrefix.length);
|
||||||
@ -10,5 +11,9 @@ export function removePrefix(str: string): string {
|
|||||||
if (str.startsWith(resourcePrefix)) {
|
if (str.startsWith(resourcePrefix)) {
|
||||||
return str.slice(resourcePrefix.length);
|
return str.slice(resourcePrefix.length);
|
||||||
}
|
}
|
||||||
|
if (str.startsWith(scopePrefix) && type === MetricsType.Scope) {
|
||||||
|
return str.slice(scopePrefix.length);
|
||||||
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -3,25 +3,23 @@ import './QueryBuilderSearch.styles.scss';
|
|||||||
import { Tooltip } from 'antd';
|
import { Tooltip } from 'antd';
|
||||||
|
|
||||||
import { TagContainer, TagLabel, TagValue } from './style';
|
import { TagContainer, TagLabel, TagValue } from './style';
|
||||||
import { getOptionType } from './utils';
|
|
||||||
|
|
||||||
function OptionRenderer({
|
function OptionRenderer({
|
||||||
label,
|
label,
|
||||||
value,
|
value,
|
||||||
dataType,
|
dataType,
|
||||||
|
type,
|
||||||
}: OptionRendererProps): JSX.Element {
|
}: OptionRendererProps): JSX.Element {
|
||||||
const optionType = getOptionType(label);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className="option">
|
<span className="option">
|
||||||
{optionType ? (
|
{type ? (
|
||||||
<Tooltip title={`${value}`} placement="topLeft">
|
<Tooltip title={`${value}`} placement="topLeft">
|
||||||
<div className="selectOptionContainer">
|
<div className="selectOptionContainer">
|
||||||
<div className="option-value">{value}</div>
|
<div className="option-value">{value}</div>
|
||||||
<div className="option-meta-data-container">
|
<div className="option-meta-data-container">
|
||||||
<TagContainer>
|
<TagContainer>
|
||||||
<TagLabel>Type: </TagLabel>
|
<TagLabel>Type: </TagLabel>
|
||||||
<TagValue>{optionType}</TagValue>
|
<TagValue>{type}</TagValue>
|
||||||
</TagContainer>
|
</TagContainer>
|
||||||
<TagContainer>
|
<TagContainer>
|
||||||
<TagLabel>Data type: </TagLabel>
|
<TagLabel>Data type: </TagLabel>
|
||||||
@ -43,6 +41,7 @@ interface OptionRendererProps {
|
|||||||
label: string;
|
label: string;
|
||||||
value: string;
|
value: string;
|
||||||
dataType: string;
|
dataType: string;
|
||||||
|
type: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OptionRenderer;
|
export default OptionRenderer;
|
||||||
|
@ -410,6 +410,7 @@ function QueryBuilderSearch({
|
|||||||
label={option.label}
|
label={option.label}
|
||||||
value={option.value}
|
value={option.value}
|
||||||
dataType={option.dataType || ''}
|
dataType={option.dataType || ''}
|
||||||
|
type={option.type || ''}
|
||||||
/>
|
/>
|
||||||
{option.selected && <StyledCheckOutlined />}
|
{option.selected && <StyledCheckOutlined />}
|
||||||
</Select.Option>
|
</Select.Option>
|
||||||
|
@ -260,6 +260,20 @@
|
|||||||
background: rgba(189, 153, 121, 0.1);
|
background: rgba(189, 153, 121, 0.1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.scope {
|
||||||
|
border: 1px solid rgba(113, 144, 249, 0.2);
|
||||||
|
|
||||||
|
.ant-typography {
|
||||||
|
color: var(--bg-robin-400);
|
||||||
|
background: rgba(113, 144, 249, 0.1);
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-tag-close-icon {
|
||||||
|
background: rgba(113, 144, 249, 0.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,25 @@
|
|||||||
letter-spacing: -0.06px;
|
letter-spacing: -0.06px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.scope {
|
||||||
|
border-radius: 50px;
|
||||||
|
background: rgba(113, 144, 249, 0.1) !important;
|
||||||
|
color: var(--bg-robin-400) !important;
|
||||||
|
|
||||||
|
.dot {
|
||||||
|
background-color: var(--bg-robin-400);
|
||||||
|
}
|
||||||
|
.text {
|
||||||
|
color: var(--bg-robin-400);
|
||||||
|
font-family: Inter;
|
||||||
|
font-size: 12px;
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 18px; /* 150% */
|
||||||
|
letter-spacing: -0.06px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.option-meta-data-container {
|
.option-meta-data-container {
|
||||||
|
@ -16,4 +16,5 @@ export type Option = {
|
|||||||
selected?: boolean;
|
selected?: boolean;
|
||||||
dataType?: string;
|
dataType?: string;
|
||||||
isIndexed?: boolean;
|
isIndexed?: boolean;
|
||||||
|
type?: string;
|
||||||
};
|
};
|
||||||
|
@ -46,6 +46,7 @@ export const useOptions = (
|
|||||||
value: item.key,
|
value: item.key,
|
||||||
dataType: item.dataType,
|
dataType: item.dataType,
|
||||||
isIndexed: item?.isIndexed,
|
isIndexed: item?.isIndexed,
|
||||||
|
type: item?.type || '',
|
||||||
})),
|
})),
|
||||||
[getLabel],
|
[getLabel],
|
||||||
);
|
);
|
||||||
|
@ -9,6 +9,7 @@ export interface ILog {
|
|||||||
severityNumber: number;
|
severityNumber: number;
|
||||||
body: string;
|
body: string;
|
||||||
resources_string: Record<string, never>;
|
resources_string: Record<string, never>;
|
||||||
|
scope_string: Record<string, never>;
|
||||||
attributesString: Record<string, never>;
|
attributesString: Record<string, never>;
|
||||||
attributes_string: Record<string, never>;
|
attributes_string: Record<string, never>;
|
||||||
attributesInt: Record<string, never>;
|
attributesInt: Record<string, never>;
|
||||||
@ -22,6 +23,7 @@ type OmitAttributesResources = Pick<
|
|||||||
Exclude<
|
Exclude<
|
||||||
keyof ILog,
|
keyof ILog,
|
||||||
| 'resources_string'
|
| 'resources_string'
|
||||||
|
| 'scope_string'
|
||||||
| 'attributesString'
|
| 'attributesString'
|
||||||
| 'attributes_string'
|
| 'attributes_string'
|
||||||
| 'attributesInt'
|
| 'attributesInt'
|
||||||
@ -32,4 +34,5 @@ type OmitAttributesResources = Pick<
|
|||||||
export type ILogAggregateAttributesResources = OmitAttributesResources & {
|
export type ILogAggregateAttributesResources = OmitAttributesResources & {
|
||||||
attributes: Record<string, never>;
|
attributes: Record<string, never>;
|
||||||
resources: Record<string, never>;
|
resources: Record<string, never>;
|
||||||
|
scope: Record<string, never>;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user