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.

931 B
Raw Blame
import type {
	DashboardtypesPanelSpecDTO,
	TelemetrytypesSignalDTO,
} from 'api/generated/services/sigNoz.schemas';
import { getPanelDefinition } from 'pages/DashboardPage/DashboardContainer/Panels/registry';
import type { PanelKind } from 'pages/DashboardPage/DashboardContainer/Panels/types/panelKind';
import {
	buildPluginSpec,
	type SeededPluginSpec,
} from 'pages/DashboardPage/DashboardContainer/Panels/utils/buildPluginSpec';

export type SwitchedPluginSpec = SeededPluginSpec;

/**
 * Plugin spec for a first-visit switch to `newKind`: the kind's defaults plus the cross-kind
 * config each section carries from `oldSpec`. Revisiting a kind restores its stash instead.
 */
export function getSwitchedPluginSpec(
	oldSpec: DashboardtypesPanelSpecDTO,
	newKind: PanelKind,
	signal: TelemetrytypesSignalDTO,
): SwitchedPluginSpec {
	return buildPluginSpec(getPanelDefinition(newKind).sections, {
		oldSpec,
		signal,
	});
}