SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
feat: has and nhas filters is now enabled (#3567)
Palash Gupta81b10d126a6d
diff --git a/frontend/src/container/LogDetailedView/config.ts b/frontend/src/container/LogDetailedView/config.tsnew file mode 100644index 0000000000..cd34023699--- /dev/null+++ b/frontend/src/container/LogDetailedView/config.ts@@ -0,0 +1,13 @@+import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';++export const typeToArrayTypeMapper: { [key in DataTypes]: DataTypes } = {+ [DataTypes.String]: DataTypes.ArrayString,+ [DataTypes.Float64]: DataTypes.ArrayFloat64,+ [DataTypes.Int64]: DataTypes.ArrayInt64,+ [DataTypes.bool]: DataTypes.ArrayBool,+ [DataTypes.EMPTY]: DataTypes.EMPTY,+ [DataTypes.ArrayFloat64]: DataTypes.ArrayFloat64,+ [DataTypes.ArrayInt64]: DataTypes.ArrayInt64,+ [DataTypes.ArrayString]: DataTypes.ArrayString,+ [DataTypes.ArrayBool]: DataTypes.ArrayBool,+};diff --git a/frontend/src/container/LogDetailedView/util.test.ts b/frontend/src/container/LogDetailedView/util.test.tsindex 4f080e23c1..d5918f2bca 100644--- a/frontend/src/container/LogDetailedView/util.test.ts+++ b/frontend/src/container/LogDetailedView/util.test.ts@@ -176,8 +176,8 @@ describe('Get Data Types utils', () => {});// Edge cases- it('should return Int64 for empty array input', () => {- expect(getDataTypes([])).toBe(DataTypes.Int64);+ it('should return Empty for empty array input', () => {+ expect(getDataTypes([])).toBe(DataTypes.EMPTY);});it('should handle mixed array (return based on first element)', () => {diff --git a/frontend/src/container/LogDetailedView/utils.tsx b/frontend/src/container/LogDetailedView/utils.tsxindex 02890e7dc9..5530c970d3 100644--- a/frontend/src/container/LogDetailedView/utils.tsx+++ b/frontend/src/container/LogDetailedView/utils.tsx@@ -5,6 +5,7 @@ import { ILog, ILogAggregateAttributesResources } from 'types/api/logs/log';import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';import BodyTitleRenderer from './BodyTitleRenderer';+import { typeToArrayTypeMapper } from './config';import { AnyObject, IFieldAttributes } from './LogDetailedView.types';export const recursiveParseJSON = (obj: string): Record<string, unknown> => {@@ -107,40 +108,6 @@ export function flattenObject(obj: AnyObject, prefix = ''): AnyObject {}, {});}-const isFloat = (num: number): boolean => num % 1 !== 0;--export const getDataTypes = (value: unknown): DataTypes => {- if (typeof value === 'string') {- return DataTypes.String;- }-- if (typeof value === 'number') {- return isFloat(value) ? DataTypes.Float64 : DataTypes.Int64;- }-- if (typeof value === 'boolean') {- return DataTypes.bool;- }-- if (Array.isArray(value)) {- const firstElement = value[0];-- if (typeof firstElement === 'string') {- return DataTypes.ArrayString;- }-- if (typeof firstElement === 'boolean') {- return DataTypes.ArrayBool;- }-- if (typeof firstElement === 'number') {- return isFloat(firstElement) ? DataTypes.ArrayFloat64 : DataTypes.ArrayInt64;- }- }-- return DataTypes.Int64;-};-export const generateFieldKeyForArray = (fieldKey: string,dataType: DataTypes,@@ -217,3 +184,45 @@ export const aggregateAttributesResourcesToString = (logData: ILog): string => {return JSON.stringify(outputJson, null, 2);};++const isFloat = (num: number): boolean => num % 1 !== 0;++const isBooleanString = (str: string): boolean =>+ str.toLowerCase() === 'true' || str.toLowerCase() === 'false';++const determineType = (val: unknown): DataTypes => {+ if (typeof val === 'string') {+ if (isBooleanString(val)) {+ return DataTypes.bool;+ }++ const numberValue = parseFloat(val);++ if (!Number.isNaN(numberValue)) {+ return isFloat(numberValue) ? DataTypes.Float64 : DataTypes.Int64;+ }++ return DataTypes.String;+ }++ if (typeof val === 'number') {+ return isFloat(val) ? DataTypes.Float64 : DataTypes.Int64;+ }++ if (typeof val === 'boolean') {+ return DataTypes.bool;+ }++ return DataTypes.EMPTY;+};++export const getDataTypes = (value: unknown): DataTypes => {+ const getArrayType = (elementType: DataTypes): DataTypes =>+ typeToArrayTypeMapper[elementType] || DataTypes.EMPTY;++ if (Array.isArray(value)) {+ return getArrayType(determineType(value[0]));+ }++ return determineType(value);+};diff --git a/frontend/src/container/QueryBuilder/filters/QueryBuilderSearch/index.tsx b/frontend/src/container/QueryBuilder/filters/QueryBuilderSearch/index.tsxindex 4b2c4fe6b3..59c693b6e6 100644--- a/frontend/src/container/QueryBuilder/filters/QueryBuilderSearch/index.tsx+++ b/frontend/src/container/QueryBuilder/filters/QueryBuilderSearch/index.tsx@@ -87,10 +87,7 @@ function QueryBuilderSearch({handleSearch(value);};- const isDisabled =- !!searchValue ||- OPERATORS.HAS === tagOperator ||- OPERATORS.NHAS === tagOperator;+ const isDisabled = !!searchValue;return (<Tag closable={!searchValue && closable} onClose={onCloseHandler}>