initialize()
Initialize the Respan telemetry client
Overview
The initialize() method sets up the tracing client and establishes connection to Respan. This must be called before using any tracing methods.
Signature
Basic Usage
Constructor Options
Complete Example
Environment Variables
You can also configure using environment variables:
.env
Configuration Options
apiKey
Your Respan API key from the dashboard
baseURL
Respan API base URL
appName
Application name for identifying traces in the dashboard
instrumentModules
Modules to automatically instrument:
openAI: OpenAI SDK classanthropic: Anthropic SDK class
disableBatch
If true, sends spans immediately instead of batching them
logLevel
Logging verbosity: "debug", "info", "warn", "error"
Best Practices
- Always call
initialize()before using any tracing methods - Initialize once at application startup
- Use environment variables for sensitive configuration
- Call
shutdown()before application exit to flush pending spans - Enable auto-instrumentation for supported SDKs