Configuration
initPulse(config)
Section titled “initPulse(config)”Call once at application startup before any observe() calls.
import { initPulse } from "@pulse/sdk";
initPulse({ apiKey: "pulse_sk_...", apiUrl: "https://pulse.yourcompany.com", batchSize: 20, flushInterval: 10000, enabled: process.env.NODE_ENV === "production",});import osfrom pulse_sdk import init_pulse
init_pulse({ "api_key": "pulse_sk_...", "api_url": "https://pulse.yourcompany.com", "batch_size": 20, "flush_interval": 10000, "enabled": os.environ.get("ENV") == "production",})Options
Section titled “Options”| Option | Type | Required | Description |
|---|---|---|---|
apiKey | string | Yes | Your Pulse API key. Must start with pulse_sk_. |
apiUrl | string | No | Pulse server URL. Default: http://localhost:3000 |
batchSize | number | No | Number of traces to buffer before flushing. Range: 1-100. Default: 10 |
flushInterval | number | No | Milliseconds between periodic flushes. Minimum: 1000. Default: 5000 |
enabled | boolean | No | Enable or disable tracing. Default: true |
Batching behavior
Section titled “Batching behavior”Traces are buffered in memory and sent to the server in two situations:
- Buffer reaches
batchSizeand flushes immediately. - The
flushIntervaltimer fires and flushes what is buffered.
On process exit (beforeExit, SIGINT, SIGTERM), the SDK flushes all remaining traces before shutdown.
Validation
Section titled “Validation”initPulse() validates values at startup:
apiKeymust be a non-empty string starting withpulse_sk_.batchSizemust be an integer between1and100.flushIntervalmust be at least1000ms.
Invalid values throw immediately so misconfiguration is caught early.
Disabling tracing
Section titled “Disabling tracing”Set enabled: false to turn off all tracing. observe() still returns a working client but skips trace capture.
initPulse({ apiKey: "pulse_sk_...", enabled: false,});init_pulse({ "api_key": "pulse_sk_...", "enabled": False,})