Skip to content

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.

629 B
Raw Blame
import { computeVariableDependencies } from '../../../VariablesBar/utils/variableDependencies';
import type { VariableFormModel } from '../variableFormModel';

/**
 * Detects a circular reference among QUERY variables (a query referencing
 * another that, transitively, references it back).
 *
 * Returns the names forming the cycle, or `null` when the set is acyclic.
 */
export function detectVariableCycle(
	variables: VariableFormModel[],
): string[] | null {
	const { hasCycle, cycleNodes } = computeVariableDependencies(
		variables.filter((variable) => variable.name),
	);

	return hasCycle ? (cycleNodes ?? []) : null;
}