Implementation:Cypress io Cypress OTLPTraceExporter
| Knowledge Sources | |
|---|---|
| Domains | Telemetry, Cloud |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
Concrete OpenTelemetry span exporter for transmitting test execution telemetry to Cypress Cloud provided by the @packages/telemetry module.
Description
The OTLPTraceExporter class extends OTLPTraceExporterHttp from the OpenTelemetry SDK. It adds Cypress-specific features: optional encryption (JWE), delayed export until credentials are attached, project ID and record key headers, and custom HTTP sending logic. The attachProjectId and attachRecordKey methods enable the delayed export pattern.
Usage
Instantiated by the telemetry.init function when recording is enabled. The exporter is passed to a BatchSpanProcessor which batches spans before export.
Code Reference
Source Location
- Repository: cypress-io/cypress
- File: packages/telemetry/src/span-exporters/cloud-span-exporter.ts
- Lines: L27-188
Signature
export class OTLPTraceExporter extends OTLPTraceExporterHttp {
delayedItemsToExport: {
serviceRequest: string
onSuccess: () => void
onError: (error: OTLPExporterError) => void
}[]
enc: encryption | undefined
projectId?: string
recordKey?: string
requirementsToExport: 'met' | 'unmet' | 'unknown'
constructor(config?: OTLPExporterNodeConfigBasePlusEncryption)
attachProjectId(projectId: string | null | undefined): void
attachRecordKey(recordKey: string | null | undefined): void
}
Import
import { OTLPTraceExporter } from '@packages/telemetry/src/span-exporters/cloud-span-exporter'
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| config.encryption | object | No | Encryption functions for JWE |
| projectId | string | Yes (for recording) | Cypress Cloud project ID |
| recordKey | string | Yes (for recording) | Cypress Cloud record key |
Outputs
| Name | Type | Description |
|---|---|---|
| HTTP requests | OTLP | Spans exported to Cypress Cloud API endpoint |
| Encrypted data | JWE | Encrypted spans when encryption is configured |
Usage Examples
Initializing Telemetry with Cloud Exporter
import { OTLPTraceExporter } from '@packages/telemetry/src/span-exporters/cloud-span-exporter'
const exporter = new OTLPTraceExporter({
url: 'https://api.cypress.io/v1/traces',
encryption: encryptionModule,
})
// Later, when credentials are available:
exporter.attachProjectId('abc123')
exporter.attachRecordKey('record-key-xyz')
// Buffered spans are now flushed and exported