All files signals-state.ts

100% Statements 10/10
100% Branches 0/0
100% Functions 8/8
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33                                  2x 2x 2x 2x     11x 9x 4x     18x 18x 18x    
// SPDX-FileCopyrightText: 2025 Anaconda, Inc
// SPDX-License-Identifier: Apache-2.0
 
// src/signals-state.ts
import type { AnacondaMetrics } from './metrics.js';
import type { AnacondaTrace, ASpan } from './traces.js';
import type { AttrMap } from './types.js';
import { localTimeString as lts } from './common.js';
 
// A local NOOP span for tests and fallback paths
class NOOPASpan implements ASpan {
  addEvent(name: string, attributes?: AttrMap): void {}
  addException(exception: Error): void {}
  setErrorStatus(msg?: string): void {}
  addAttributes(attributes: AttrMap): void {}
}
 
export let __initialized = false;
export let __metrics: AnacondaMetrics | undefined = undefined;
export let __tracing: AnacondaTrace | undefined = undefined;
export const __noopASpan: ASpan = new NOOPASpan();
 
// setters so other modules can update state (imports are read-only)
export function __setInitialized(v: boolean) { __initialized = v; }
export function __setMetrics(v: AnacondaMetrics | undefined) { __metrics = v; }
export function __setTracing(v: AnacondaTrace | undefined) { __tracing = v; }
 
export function __resetSignals(): void {
  __initialized = false;
  __metrics = undefined;
  __tracing = undefined;
}