open-index/open-npm huggingface dataset:
npm package: @obseracloud/sdk
Description: Official Node.js SDK for ObseraCloud — zero-config observability
Author: ObseraCloud
Latest version: 0.1.0

# @obseracloud/sdk

Official Node.js / TypeScript SDK for [ObseraCloud](https://obseracloud.com) — zero-config observability for your applications.

## Installation

```bash
npm install @obseracloud/sdk
```

## Quick Start

```ts
import { ObseraCloud } from '@obseracloud/sdk'

ObseraCloud.init({
  tenantId: 'your-tenant-id',
  apiKey: process.env.OBSERA_API_KEY!,
  serviceName: 'my-api',
})

// Logs
ObseraCloud.log.info('Server started', { port: 3000 })
ObseraCloud.log.warn('High memory', { mb: 512 })
ObseraCloud.log.error('DB failed', { host: 'localhost' })

// Traces
const span = ObseraCloud.trace.start('process-order')
// ... your code ...
span.end()

// Trace with auto error capture
const result = await ObseraCloud.trace.wrap('fetch-user', async () => {
  return await db.getUser(userId)
})

// Metrics — counter
ObseraCloud.metric.counter('http.requests', 1, { method: 'GET', status: '200' })

// Metrics — gauge (current value)
ObseraCloud.metric.gauge('app.active_connections', 42)

// Metrics — histogram (distribution)
ObseraCloud.metric.histogram('http.response_time_ms', 124, { route: '/api/users' })

// Metrics — time a function automatically
const users = await ObseraCloud.metric.time('db.query_ms', () => db.findAll())
```

## Configuration

| Option | Required | Default | Description |
|--------|----------|---------|-------------|
| `tenantId` | ✅ | — | Your ObseraCloud tenant ID |
| `apiKey` | ✅ | — | Your ObseraCloud API key |
| `serviceName` | ❌ | `unknown-service` | Name of your service |
| `endpoint` | ❌ | `https://obseracloud.com/otlp` | Custom OTLP endpoint |
| `debug` | ❌ | `false` | Log SDK activity to console |

## Flush before exit

```ts
process.on('SIGTERM', async () => {
  await ObseraCloud.flush()
  process.exit(0)
})
```

## Find your credentials

Log in to [ObseraCloud](https://obseracloud.com) → **Settings** → **API Key**