* Creates a safe attribute object for OpenTelemetry
( data: Record<string, unknown> )
| 30 | * Creates a safe attribute object for OpenTelemetry |
| 31 | */ |
| 32 | function createSafeAttributes( |
| 33 | data: Record<string, unknown> |
| 34 | ): Array<{ key: string; value: { stringValue: string } }> { |
| 35 | if (!data || typeof data !== 'object') { |
| 36 | return [] |
| 37 | } |
| 38 | |
| 39 | const attributes: Array<{ key: string; value: { stringValue: string } }> = [] |
| 40 | |
| 41 | Object.entries(data).forEach(([key, value]) => { |
| 42 | if (value !== undefined && value !== null && key) { |
| 43 | attributes.push({ |
| 44 | key, |
| 45 | value: { stringValue: safeStringValue(value) }, |
| 46 | }) |
| 47 | } |
| 48 | }) |
| 49 | |
| 50 | return attributes |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Forwards telemetry data to OpenTelemetry collector |
no test coverage detected