import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from '@opentelemetry/semantic-conventions';

export const OTEL_ENV_VARS = {
	enabled: 'N8N_OTEL_ENABLED',
	exporterEndpoint: 'N8N_OTEL_EXPORTER_OTLP_ENDPOINT',
	exporterTracingPath: 'N8N_OTEL_EXPORTER_OTLP_TRACING_PATH',
	exporterHeaders: 'N8N_OTEL_EXPORTER_OTLP_HEADERS',
	exporterServiceName: 'N8N_OTEL_EXPORTER_SERVICE_NAME',
	tracesSampleRate: 'N8N_OTEL_TRACES_SAMPLE_RATE',
	startupConnectivityTimeoutMs: 'N8N_OTEL_STARTUP_CONNECTIVITY_TIMEOUT_MS',
	includeNodeSpans: 'N8N_OTEL_TRACES_INCLUDE_NODE_SPANS',
	injectOutbound: 'N8N_OTEL_TRACES_INJECT_OUTBOUND',
	productionExecutionsOnly: 'N8N_OTEL_TRACES_PRODUCTION_ONLY',
} as const;

export const OTEL_TEST_SPAN_NAME = 'n8n.test_trace';

export const ATTR = {
	OTEL_SERVICE_NAME: ATTR_SERVICE_NAME,
	OTEL_SERVICE_VERSION: ATTR_SERVICE_VERSION,

	INSTANCE_ID: 'n8n.instance.id',
	INSTANCE_ROLE: 'n8n.instance.role',

	IS_TEST_TRACE: 'n8n.test',

	PROJECT_ID: 'n8n.project.id',

	WORKFLOW_ID: 'n8n.workflow.id',
	WORKFLOW_VERSION_ID: 'n8n.workflow.version_id',
	WORKFLOW_NAME: 'n8n.workflow.name',
	WORKFLOW_NODE_COUNT: 'n8n.workflow.node_count',
	WORKFLOW_CUSTOM_PREFIX: 'n8n.workflow.custom.',

	EXECUTION_ID: 'n8n.execution.id',
	EXECUTION_MODE: 'n8n.execution.mode',
	EXECUTION_STATUS: 'n8n.execution.status',
	EXECUTION_IS_RETRY: 'n8n.execution.is_retry',
	EXECUTION_RETRY_OF: 'n8n.execution.retry_of',
	EXECUTION_ERROR_TYPE: 'n8n.execution.error_type',

	NODE_ID: 'n8n.node.id',
	NODE_NAME: 'n8n.node.name',
	NODE_TYPE: 'n8n.node.type',
	NODE_TYPE_VERSION: 'n8n.node.type_version',
	NODE_ITEMS_INPUT: 'n8n.node.items.input',
	NODE_ITEMS_OUTPUT: 'n8n.node.items.output',
	NODE_TERMINATION_REASON: 'n8n.node.termination_reason',
	PROJECT_CUSTOM_PREFIX: 'n8n.project.custom.',
	NODE_CUSTOM_PREFIX: 'n8n.node.custom.',

	CONTINUATION_REASON: 'n8n.continuation.reason',
} as const;
