@bsb/observable-axiom 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -215
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @bsb/observable-axiom
|
|
2
2
|
|
|
3
|
-
Axiom.co integration for
|
|
3
|
+
Axiom.co observability integration for BSB. Exports logs, metrics, and traces to Axiom with OTLP tracing support.
|
|
4
4
|
|
|
5
|
-
## Features
|
|
5
|
+
## Key Features
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
- **Full TypeScript Support** - Type-safe configuration and no `any` types
|
|
7
|
+
- Unified observability: logs, metrics, and traces
|
|
8
|
+
- Axiom SDK for logs and events
|
|
9
|
+
- OpenTelemetry tracing via OTLP
|
|
10
|
+
- Batch processing with configurable flush interval
|
|
11
|
+
- Resource attributes for consistent service metadata
|
|
13
12
|
|
|
14
13
|
## Installation
|
|
15
14
|
|
|
@@ -19,233 +18,85 @@ npm install @bsb/observable-axiom
|
|
|
19
18
|
|
|
20
19
|
## Configuration
|
|
21
20
|
|
|
22
|
-
Add to your BSB configuration file:
|
|
21
|
+
Add the plugin to your BSB configuration file:
|
|
23
22
|
|
|
24
23
|
```yaml
|
|
25
24
|
plugins:
|
|
26
|
-
|
|
27
|
-
- observable-axiom
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
# Optional resource attributes (added to all telemetry)
|
|
49
|
-
resourceAttributes:
|
|
50
|
-
environment: production
|
|
51
|
-
region: us-east-1
|
|
52
|
-
cluster: main
|
|
25
|
+
observables:
|
|
26
|
+
- plugin: "@bsb/observable-axiom"
|
|
27
|
+
enabled: true
|
|
28
|
+
config:
|
|
29
|
+
serviceName: "my-service"
|
|
30
|
+
serviceVersion: "1.0.0"
|
|
31
|
+
axiom:
|
|
32
|
+
token: "${AXIOM_TOKEN}"
|
|
33
|
+
dataset: "bsb-logs"
|
|
34
|
+
orgId: "${AXIOM_ORG_ID}"
|
|
35
|
+
# url: "https://axiom.mycompany.com" # Optional for self-hosted
|
|
36
|
+
enabled:
|
|
37
|
+
logs: true
|
|
38
|
+
metrics: true
|
|
39
|
+
traces: true
|
|
40
|
+
export:
|
|
41
|
+
flushIntervalMs: 5000
|
|
42
|
+
maxBatchSize: 1000
|
|
43
|
+
resourceAttributes:
|
|
44
|
+
environment: "production"
|
|
45
|
+
region: "us-east-1"
|
|
46
|
+
cluster: "main"
|
|
53
47
|
```
|
|
54
48
|
|
|
49
|
+
### Configuration Options
|
|
50
|
+
|
|
51
|
+
| Option | Description | Default |
|
|
52
|
+
|--------|-------------|---------|
|
|
53
|
+
| `serviceName` | Service identifier | `"bsb-service"` |
|
|
54
|
+
| `serviceVersion` | Service version tag | - |
|
|
55
|
+
| `axiom.token` | Axiom API token | Required |
|
|
56
|
+
| `axiom.dataset` | Axiom dataset name | `"bsb-logs"` |
|
|
57
|
+
| `axiom.orgId` | Organization ID (Axiom Cloud) | - |
|
|
58
|
+
| `axiom.url` | Custom Axiom URL (self-hosted) | - |
|
|
59
|
+
| `enabled.logs` | Enable log export | `true` |
|
|
60
|
+
| `enabled.metrics` | Enable metric export | `true` |
|
|
61
|
+
| `enabled.traces` | Enable trace export | `true` |
|
|
62
|
+
| `export.flushIntervalMs` | Flush interval (ms) | `5000` |
|
|
63
|
+
| `export.maxBatchSize` | Max events per batch | `1000` |
|
|
64
|
+
| `resourceAttributes` | Custom attributes | `{}` |
|
|
65
|
+
|
|
55
66
|
## Environment Variables
|
|
56
67
|
|
|
57
68
|
```bash
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
AXIOM_TOKEN="xaat-your-token-here"
|
|
70
|
+
AXIOM_ORG_ID="your-org-id"
|
|
71
|
+
AXIOM_DATASET="bsb-logs"
|
|
61
72
|
```
|
|
62
73
|
|
|
63
|
-
## What Gets Exported
|
|
64
|
-
|
|
65
|
-
### Logs (to Axiom Dataset)
|
|
66
|
-
- Structured JSON with trace context
|
|
67
|
-
- Log levels: debug, info, warn, error
|
|
68
|
-
- Plugin name and service metadata
|
|
69
|
-
- Custom metadata from log calls
|
|
70
|
-
- Resource attributes
|
|
71
|
-
|
|
72
|
-
### Metrics (to Axiom Dataset as Events)
|
|
73
|
-
- Counters, gauges, histograms
|
|
74
|
-
- Stored as structured events
|
|
75
|
-
- Queryable with Axiom Processing Language (APL)
|
|
76
|
-
- Automatic timestamp and service tagging
|
|
77
|
-
|
|
78
|
-
### Traces (to Axiom via OTLP)
|
|
79
|
-
- Full distributed tracing
|
|
80
|
-
- Span lifecycle (start, end, error)
|
|
81
|
-
- Trace context propagation
|
|
82
|
-
- Exception tracking
|
|
83
|
-
|
|
84
74
|
## Usage
|
|
85
75
|
|
|
86
|
-
|
|
76
|
+
Once configured, logs, metrics, and traces are exported automatically:
|
|
87
77
|
|
|
88
78
|
```typescript
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
public async run(obs: Observable) {
|
|
94
|
-
// Logs automatically sent to Axiom
|
|
95
|
-
obs.log.info("Service started", { userId: 123 });
|
|
96
|
-
|
|
97
|
-
// Create child span (sent to Axiom traces)
|
|
98
|
-
const workObs = obs.span("process-request");
|
|
99
|
-
workObs.setAttribute("request.id", "req-123");
|
|
100
|
-
|
|
101
|
-
try {
|
|
102
|
-
await this.processRequest();
|
|
103
|
-
workObs.end();
|
|
104
|
-
} catch (error) {
|
|
105
|
-
workObs.recordException(error);
|
|
106
|
-
workObs.end();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Metrics also sent to Axiom
|
|
110
|
-
// (BSB metrics API will emit these as events)
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
## Axiom Setup
|
|
116
|
-
|
|
117
|
-
### 1. Create Account
|
|
118
|
-
Sign up at https://axiom.co
|
|
119
|
-
|
|
120
|
-
### 2. Create Dataset
|
|
121
|
-
```bash
|
|
122
|
-
axiom dataset create bsb-logs
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### 3. Create API Token
|
|
126
|
-
```bash
|
|
127
|
-
axiom token create bsb-ingest --scopes ingest --datasets bsb-logs
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### 4. Configure BSB
|
|
131
|
-
Add token to your configuration or environment variables.
|
|
132
|
-
|
|
133
|
-
## Querying Data in Axiom
|
|
134
|
-
|
|
135
|
-
### Logs Query (APL)
|
|
136
|
-
```apl
|
|
137
|
-
['bsb-logs']
|
|
138
|
-
| where service == "my-service"
|
|
139
|
-
| where level == "error"
|
|
140
|
-
| order by _time desc
|
|
141
|
-
| limit 100
|
|
79
|
+
this.log.info("Service started", { userId: 123 });
|
|
80
|
+
const workObs = this.obs.span("process-request");
|
|
81
|
+
await this.events.emitEvent("user.created", { userId: "123" });
|
|
82
|
+
workObs.end();
|
|
142
83
|
```
|
|
143
84
|
|
|
144
|
-
|
|
145
|
-
```apl
|
|
146
|
-
['bsb-logs']
|
|
147
|
-
| where metric_type == "counter"
|
|
148
|
-
| where metric_name == "requests_total"
|
|
149
|
-
| summarize sum(value) by bin(_time, 1m)
|
|
150
|
-
```
|
|
85
|
+
## Axiom Setup (Quick)
|
|
151
86
|
|
|
152
|
-
|
|
153
|
-
|
|
87
|
+
1. Create a dataset
|
|
88
|
+
2. Create an ingest token with dataset access
|
|
89
|
+
3. Set `AXIOM_TOKEN` and `AXIOM_DATASET` in the environment
|
|
154
90
|
|
|
155
|
-
##
|
|
91
|
+
## Documentation
|
|
156
92
|
|
|
157
|
-
|
|
158
|
-
BSB Application
|
|
159
|
-
↓
|
|
160
|
-
Observable (DTrace)
|
|
161
|
-
↓
|
|
162
|
-
observable-axiom
|
|
163
|
-
├── Logs/Metrics → Axiom SDK → Axiom Dataset
|
|
164
|
-
└── Traces → OTLP Exporter → Axiom Traces
|
|
165
|
-
```
|
|
93
|
+
Detailed documentation (used by the BSB Registry): `https://github.com/BetterCorp/better-service-base/blob/master/plugins/nodejs/observable-axiom/docs/plugin.md`
|
|
166
94
|
|
|
167
|
-
##
|
|
168
|
-
|
|
169
|
-
| Option | Type | Default | Description |
|
|
170
|
-
|--------|------|---------|-------------|
|
|
171
|
-
| `serviceName` | string | `"bsb-service"` | Service identifier |
|
|
172
|
-
| `serviceVersion` | string | - | Service version tag |
|
|
173
|
-
| `axiom.token` | string | **required** | Axiom API token |
|
|
174
|
-
| `axiom.dataset` | string | `"bsb-logs"` | Dataset name |
|
|
175
|
-
| `axiom.orgId` | string | - | Organization ID (cloud) |
|
|
176
|
-
| `axiom.url` | string | - | Custom URL (self-hosted) |
|
|
177
|
-
| `enabled.logs` | boolean | `true` | Enable log export |
|
|
178
|
-
| `enabled.metrics` | boolean | `true` | Enable metrics export |
|
|
179
|
-
| `enabled.traces` | boolean | `true` | Enable trace export |
|
|
180
|
-
| `export.flushIntervalMs` | number | `5000` | Flush interval (ms) |
|
|
181
|
-
| `export.maxBatchSize` | number | `1000` | Max events per batch |
|
|
182
|
-
| `resourceAttributes` | object | `{}` | Custom attributes |
|
|
183
|
-
|
|
184
|
-
## Comparison with Other Observability Plugins
|
|
185
|
-
|
|
186
|
-
| Plugin | Logs | Metrics | Traces | Backend |
|
|
187
|
-
|--------|------|---------|--------|---------|
|
|
188
|
-
| observable-axiom | ✅ | ✅ | ✅ | Axiom.co |
|
|
189
|
-
| observable-opentelemetry | ✅ | ✅ | ✅ | OTLP Collector |
|
|
190
|
-
| observable-zipkin | Console | ❌ | ✅ | Zipkin |
|
|
191
|
-
| observable-default | Console | ❌ | ❌ | - |
|
|
192
|
-
|
|
193
|
-
## Best Practices
|
|
194
|
-
|
|
195
|
-
### 1. Use Datasets Strategically
|
|
196
|
-
```yaml
|
|
197
|
-
# Production
|
|
198
|
-
axiom:
|
|
199
|
-
dataset: prod-logs
|
|
95
|
+
## Links
|
|
200
96
|
|
|
201
|
-
|
|
202
|
-
axiom
|
|
203
|
-
dataset: dev-logs
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
### 2. Set Resource Attributes
|
|
207
|
-
```yaml
|
|
208
|
-
resourceAttributes:
|
|
209
|
-
environment: ${ENVIRONMENT}
|
|
210
|
-
deployment: ${DEPLOYMENT_ID}
|
|
211
|
-
datacenter: ${DATACENTER}
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
### 3. Control Batch Size
|
|
215
|
-
```yaml
|
|
216
|
-
export:
|
|
217
|
-
# High-volume services
|
|
218
|
-
flushIntervalMs: 1000
|
|
219
|
-
maxBatchSize: 5000
|
|
220
|
-
|
|
221
|
-
# Low-volume services
|
|
222
|
-
flushIntervalMs: 10000
|
|
223
|
-
maxBatchSize: 100
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
### 4. Use Structured Logging
|
|
227
|
-
```typescript
|
|
228
|
-
// Good - queryable fields
|
|
229
|
-
obs.log.info("User logged in", {
|
|
230
|
-
userId: user.id,
|
|
231
|
-
email: user.email
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
// Bad - unstructured
|
|
235
|
-
obs.log.info(`User ${user.email} logged in`);
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
## Axiom Features
|
|
239
|
-
|
|
240
|
-
- **APL (Axiom Processing Language)** - Powerful query language
|
|
241
|
-
- **Service Maps** - Automatic trace visualization
|
|
242
|
-
- **Monitors & Alerts** - Real-time alerting on anomalies
|
|
243
|
-
- **Dashboards** - Custom visualizations
|
|
244
|
-
- **Notebooks** - Collaborative analysis
|
|
245
|
-
- **Retention** - Configurable data retention policies
|
|
97
|
+
- GitHub: `https://github.com/BetterCorp/better-service-base/tree/master/plugins/nodejs/observable-axiom`
|
|
98
|
+
- BSB Registry (package): `https://io.bsbcode.dev/packages/nodejs/@bsb/observable-axiom`
|
|
246
99
|
|
|
247
100
|
## License
|
|
248
101
|
|
|
249
|
-
AGPL-3.0
|
|
250
|
-
|
|
251
|
-
Commercial licenses available at https://www.bettercorp.dev
|
|
102
|
+
(AGPL-3.0-only OR Commercial)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsb/observable-axiom",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Axiom.co observability integration for BSB framework",
|
|
5
5
|
"main": "lib/plugins/observable-axiom/index.js",
|
|
6
6
|
"types": "lib/plugins/observable-axiom/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"license": "(AGPL-3.0-only OR Commercial)",
|
|
27
27
|
"author": {
|
|
28
28
|
"name": "BetterCorp (PTY) Ltd",
|
|
29
|
-
"email": "
|
|
29
|
+
"email": "ninja@bettercorp.dev",
|
|
30
30
|
"url": "https://bettercorp.dev/"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
@@ -49,6 +49,9 @@
|
|
|
49
49
|
"rimraf": "^6.1.2",
|
|
50
50
|
"typescript": "^5.9.3"
|
|
51
51
|
},
|
|
52
|
-
"homepage": "https://io.bsbcode.dev/
|
|
52
|
+
"homepage": "https://io.bsbcode.dev/packages/nodejs/@bsb/observable-axiom"
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|