2025-07-31 12:16:55 +05:30
|
|
|
import { TelemetryFieldKey } from 'api/v5/v5';
|
2025-08-07 20:17:34 +05:30
|
|
|
import { isEmpty } from 'lodash-es';
|
2023-07-06 14:22:44 +03:00
|
|
|
import { IField } from 'types/api/logs/fields';
|
2025-07-02 12:00:17 +04:30
|
|
|
import {
|
|
|
|
|
IBuilderQuery,
|
|
|
|
|
TagFilterItem,
|
|
|
|
|
} from 'types/api/queryBuilder/queryBuilderData';
|
2023-07-06 14:22:44 +03:00
|
|
|
|
|
|
|
|
export const convertKeysToColumnFields = (
|
2025-07-31 12:16:55 +05:30
|
|
|
keys: TelemetryFieldKey[],
|
2023-07-06 14:22:44 +03:00
|
|
|
): IField[] =>
|
2025-08-07 20:17:34 +05:30
|
|
|
keys
|
|
|
|
|
.filter((item) => !isEmpty(item.name))
|
|
|
|
|
.map((item) => ({
|
|
|
|
|
dataType: item.fieldDataType ?? '',
|
|
|
|
|
name: item.name,
|
|
|
|
|
type: item.fieldContext ?? '',
|
|
|
|
|
}));
|
2025-07-02 12:00:17 +04:30
|
|
|
/**
|
|
|
|
|
* Determines if a query represents a trace-to-logs navigation
|
|
|
|
|
* by checking for the presence of a trace_id filter.
|
|
|
|
|
*/
|
|
|
|
|
export const isTraceToLogsQuery = (queryData: IBuilderQuery): boolean => {
|
|
|
|
|
// Check if this is a trace-to-logs query by looking for trace_id filter
|
|
|
|
|
if (!queryData?.filters?.items) return false;
|
|
|
|
|
|
|
|
|
|
const traceIdFilter = queryData.filters.items.find(
|
|
|
|
|
(item: TagFilterItem) => item.key?.key === 'trace_id',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return !!traceIdFilter;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type EmptyLogsListConfig = {
|
|
|
|
|
title: string;
|
|
|
|
|
subTitle: string;
|
|
|
|
|
description: string | string[];
|
|
|
|
|
documentationLinks?: Array<{
|
|
|
|
|
text: string;
|
|
|
|
|
url: string;
|
|
|
|
|
}>;
|
|
|
|
|
showClearFiltersButton?: boolean;
|
|
|
|
|
onClearFilters?: () => void;
|
|
|
|
|
clearFiltersButtonText?: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const getEmptyLogsListConfig = (
|
|
|
|
|
handleClearFilters: () => void,
|
|
|
|
|
): EmptyLogsListConfig => ({
|
|
|
|
|
title: 'No logs found for this trace.',
|
|
|
|
|
subTitle: 'This could be because :',
|
|
|
|
|
description: [
|
|
|
|
|
'Logs are not linked to Traces.',
|
|
|
|
|
'Logs are not being sent to SigNoz.',
|
|
|
|
|
'No logs are associated with this particular trace/span.',
|
|
|
|
|
],
|
|
|
|
|
documentationLinks: [
|
|
|
|
|
{
|
|
|
|
|
text: 'Sending logs to SigNoz',
|
|
|
|
|
url: 'https://signoz.io/docs/logs-management/send-logs-to-signoz/',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text: 'Correlate traces and logs',
|
|
|
|
|
url:
|
|
|
|
|
'https://signoz.io/docs/traces-management/guides/correlate-traces-and-logs/',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
clearFiltersButtonText: 'Clear filters from Trace to view other logs',
|
|
|
|
|
showClearFiltersButton: true,
|
|
|
|
|
onClearFilters: handleClearFilters,
|
|
|
|
|
});
|