project setup with core files including configuration, package management, and basic structure. Added .gitignore, README, and various TypeScript types for CMS components. Implemented initial components and layouts for the application.

This commit is contained in:
Peter Meier
2025-12-13 23:26:13 +01:00
parent ea288a5bbc
commit b1a556dc6d
167 changed files with 19057 additions and 131 deletions

View File

@@ -0,0 +1,78 @@
/**
* Einfaches Distributed Tracing
* Erstellt Trace-IDs für Request-Tracking
*/
interface TraceContext {
traceId: string;
spanId: string;
parentSpanId?: string;
startTime: number;
}
const traces = new Map<string, TraceContext>();
/**
* Erstellt einen neuen Trace
*/
export function createTrace(traceId?: string): TraceContext {
const id = traceId || generateTraceId();
const trace: TraceContext = {
traceId: id,
spanId: generateSpanId(),
startTime: Date.now(),
};
traces.set(id, trace);
return trace;
}
/**
* Erstellt einen Child-Span
*/
export function createSpan(traceId: string, parentSpanId?: string): string {
const trace = traces.get(traceId);
if (!trace) {
throw new Error(`Trace ${traceId} not found`);
}
const spanId = generateSpanId();
trace.parentSpanId = parentSpanId || trace.spanId;
return spanId;
}
/**
* Beendet einen Trace und gibt die Dauer zurück
*/
export function endTrace(traceId: string): number {
const trace = traces.get(traceId);
if (!trace) {
return 0;
}
const duration = Date.now() - trace.startTime;
traces.delete(traceId);
return duration;
}
/**
* Generiert eine Trace-ID
*/
function generateTraceId(): string {
return `trace-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
}
/**
* Generiert eine Span-ID
*/
function generateSpanId(): string {
return `span-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
}
/**
* Holt Trace-Informationen
*/
export function getTrace(traceId: string): TraceContext | undefined {
return traces.get(traceId);
}