@bsb/observable-axiom 1.0.1 → 1.1.2
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/bsb-tests.json +14 -0
- package/lib/plugins/observable-axiom/index.d.ts +41 -41
- package/lib/plugins/observable-axiom/index.js +41 -78
- package/lib/schemas/observable-axiom.json +0 -104
- package/lib/schemas/observable-axiom.plugin.json +1 -105
- package/package.json +5 -8
- package/src/plugins/observable-axiom/index.ts +21 -25
- package/tsconfig.json +2 -2
package/bsb-tests.json
ADDED
|
@@ -26,27 +26,27 @@
|
|
|
26
26
|
*/
|
|
27
27
|
import { BSBObservable, BSBObservableConstructor, BSBError } from "@bsb/base";
|
|
28
28
|
import { DTrace, LogMeta } from "@bsb/base";
|
|
29
|
-
import
|
|
30
|
-
export declare const Config: import("@bsb/base").BSBPluginConfigClass<
|
|
31
|
-
serviceName:
|
|
32
|
-
serviceVersion:
|
|
33
|
-
axiom:
|
|
34
|
-
token:
|
|
35
|
-
dataset:
|
|
36
|
-
orgId:
|
|
37
|
-
url:
|
|
38
|
-
}
|
|
39
|
-
enabled:
|
|
40
|
-
logs:
|
|
41
|
-
metrics:
|
|
42
|
-
traces:
|
|
43
|
-
}
|
|
44
|
-
export:
|
|
45
|
-
flushIntervalMs:
|
|
46
|
-
maxBatchSize:
|
|
47
|
-
}
|
|
48
|
-
resourceAttributes:
|
|
49
|
-
}
|
|
29
|
+
import * as av from "@anyvali/js";
|
|
30
|
+
export declare const Config: import("@bsb/base").BSBPluginConfigClass<av.ObjectSchema<{
|
|
31
|
+
serviceName: av.OptionalSchema<av.StringSchema>;
|
|
32
|
+
serviceVersion: av.OptionalSchema<av.StringSchema>;
|
|
33
|
+
axiom: av.ObjectSchema<{
|
|
34
|
+
token: av.StringSchema;
|
|
35
|
+
dataset: av.OptionalSchema<av.StringSchema>;
|
|
36
|
+
orgId: av.OptionalSchema<av.StringSchema>;
|
|
37
|
+
url: av.OptionalSchema<av.StringSchema>;
|
|
38
|
+
}>;
|
|
39
|
+
enabled: av.ObjectSchema<{
|
|
40
|
+
logs: av.OptionalSchema<av.BoolSchema>;
|
|
41
|
+
metrics: av.OptionalSchema<av.BoolSchema>;
|
|
42
|
+
traces: av.OptionalSchema<av.BoolSchema>;
|
|
43
|
+
}>;
|
|
44
|
+
export: av.ObjectSchema<{
|
|
45
|
+
flushIntervalMs: av.OptionalSchema<av.Int32Schema>;
|
|
46
|
+
maxBatchSize: av.OptionalSchema<av.Int32Schema>;
|
|
47
|
+
}>;
|
|
48
|
+
resourceAttributes: av.OptionalSchema<av.RecordSchema<av.StringSchema>>;
|
|
49
|
+
}>>;
|
|
50
50
|
/**
|
|
51
51
|
* Axiom observable plugin for unified observability
|
|
52
52
|
*
|
|
@@ -55,26 +55,26 @@ export declare const Config: import("@bsb/base").BSBPluginConfigClass<z.ZodObjec
|
|
|
55
55
|
* Exports metrics as structured events
|
|
56
56
|
*/
|
|
57
57
|
export declare class Plugin extends BSBObservable<InstanceType<typeof Config>> {
|
|
58
|
-
static Config: import("@bsb/base").BSBPluginConfigClass<
|
|
59
|
-
serviceName:
|
|
60
|
-
serviceVersion:
|
|
61
|
-
axiom:
|
|
62
|
-
token:
|
|
63
|
-
dataset:
|
|
64
|
-
orgId:
|
|
65
|
-
url:
|
|
66
|
-
}
|
|
67
|
-
enabled:
|
|
68
|
-
logs:
|
|
69
|
-
metrics:
|
|
70
|
-
traces:
|
|
71
|
-
}
|
|
72
|
-
export:
|
|
73
|
-
flushIntervalMs:
|
|
74
|
-
maxBatchSize:
|
|
75
|
-
}
|
|
76
|
-
resourceAttributes:
|
|
77
|
-
}
|
|
58
|
+
static Config: import("@bsb/base").BSBPluginConfigClass<av.ObjectSchema<{
|
|
59
|
+
serviceName: av.OptionalSchema<av.StringSchema>;
|
|
60
|
+
serviceVersion: av.OptionalSchema<av.StringSchema>;
|
|
61
|
+
axiom: av.ObjectSchema<{
|
|
62
|
+
token: av.StringSchema;
|
|
63
|
+
dataset: av.OptionalSchema<av.StringSchema>;
|
|
64
|
+
orgId: av.OptionalSchema<av.StringSchema>;
|
|
65
|
+
url: av.OptionalSchema<av.StringSchema>;
|
|
66
|
+
}>;
|
|
67
|
+
enabled: av.ObjectSchema<{
|
|
68
|
+
logs: av.OptionalSchema<av.BoolSchema>;
|
|
69
|
+
metrics: av.OptionalSchema<av.BoolSchema>;
|
|
70
|
+
traces: av.OptionalSchema<av.BoolSchema>;
|
|
71
|
+
}>;
|
|
72
|
+
export: av.ObjectSchema<{
|
|
73
|
+
flushIntervalMs: av.OptionalSchema<av.Int32Schema>;
|
|
74
|
+
maxBatchSize: av.OptionalSchema<av.Int32Schema>;
|
|
75
|
+
}>;
|
|
76
|
+
resourceAttributes: av.OptionalSchema<av.RecordSchema<av.StringSchema>>;
|
|
77
|
+
}>>;
|
|
78
78
|
private logFormatter;
|
|
79
79
|
private axiom;
|
|
80
80
|
private tracerProvider;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* BSB (Better-Service-Base) is an event-bus based microservice framework.
|
|
4
3
|
* Copyright (C) 2016 - 2025 BetterCorp (PTY) Ltd
|
|
@@ -25,71 +24,36 @@
|
|
|
25
24
|
* You should have received a copy of the GNU Affero General Public License
|
|
26
25
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
27
26
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return result;
|
|
59
|
-
};
|
|
60
|
-
})();
|
|
61
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
-
exports.Plugin = exports.Config = void 0;
|
|
63
|
-
const base_1 = require("@bsb/base");
|
|
64
|
-
const zod_1 = require("zod");
|
|
65
|
-
const js_1 = require("@axiomhq/js");
|
|
66
|
-
const api = __importStar(require("@opentelemetry/api"));
|
|
67
|
-
const resources_1 = require("@opentelemetry/resources");
|
|
68
|
-
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
69
|
-
const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
|
|
70
|
-
const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
|
|
71
|
-
const exporter_trace_otlp_http_1 = require("@opentelemetry/exporter-trace-otlp-http");
|
|
72
|
-
const ConfigSchema = zod_1.z.object({
|
|
73
|
-
serviceName: zod_1.z.string().default("bsb-service"),
|
|
74
|
-
serviceVersion: zod_1.z.string().optional(),
|
|
75
|
-
axiom: zod_1.z.object({
|
|
76
|
-
token: zod_1.z.string().describe("Axiom API token"),
|
|
77
|
-
dataset: zod_1.z.string().default("bsb-logs").describe("Axiom dataset name"),
|
|
78
|
-
orgId: zod_1.z.string().optional().describe("Axiom organization ID (for cloud)"),
|
|
79
|
-
url: zod_1.z.url().optional().describe("Custom Axiom URL (for self-hosted)"),
|
|
80
|
-
}),
|
|
81
|
-
enabled: zod_1.z.object({
|
|
82
|
-
logs: zod_1.z.boolean().default(true),
|
|
83
|
-
metrics: zod_1.z.boolean().default(true),
|
|
84
|
-
traces: zod_1.z.boolean().default(true),
|
|
85
|
-
}),
|
|
86
|
-
export: zod_1.z.object({
|
|
87
|
-
flushIntervalMs: zod_1.z.number().int().min(100).default(5000),
|
|
88
|
-
maxBatchSize: zod_1.z.number().int().min(1).default(1000),
|
|
89
|
-
}),
|
|
90
|
-
resourceAttributes: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).default({}),
|
|
91
|
-
});
|
|
92
|
-
exports.Config = (0, base_1.createConfigSchema)({
|
|
27
|
+
import { BSBObservable, createConfigSchema, LogFormatter, BSBError } from "@bsb/base";
|
|
28
|
+
import * as av from "@anyvali/js";
|
|
29
|
+
import { Axiom } from "@axiomhq/js";
|
|
30
|
+
import * as api from "@opentelemetry/api";
|
|
31
|
+
import { defaultResource, resourceFromAttributes } from "@opentelemetry/resources";
|
|
32
|
+
import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from "@opentelemetry/semantic-conventions";
|
|
33
|
+
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
|
|
34
|
+
import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
35
|
+
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
36
|
+
const ConfigSchema = av.object({
|
|
37
|
+
serviceName: av.optional(av.string()).default("bsb-service"),
|
|
38
|
+
serviceVersion: av.optional(av.string()),
|
|
39
|
+
axiom: av.object({
|
|
40
|
+
token: av.string(),
|
|
41
|
+
dataset: av.optional(av.string()).default("bsb-logs"),
|
|
42
|
+
orgId: av.optional(av.string()),
|
|
43
|
+
url: av.optional(av.string().format("url")),
|
|
44
|
+
}, { unknownKeys: "strip" }),
|
|
45
|
+
enabled: av.object({
|
|
46
|
+
logs: av.optional(av.bool()).default(true),
|
|
47
|
+
metrics: av.optional(av.bool()).default(true),
|
|
48
|
+
traces: av.optional(av.bool()).default(true),
|
|
49
|
+
}, { unknownKeys: "strip" }),
|
|
50
|
+
export: av.object({
|
|
51
|
+
flushIntervalMs: av.optional(av.int32().min(100)).default(5000),
|
|
52
|
+
maxBatchSize: av.optional(av.int32().min(1)).default(1000),
|
|
53
|
+
}, { unknownKeys: "strip" }),
|
|
54
|
+
resourceAttributes: av.optional(av.record(av.string())).default({}),
|
|
55
|
+
}, { unknownKeys: "strip" });
|
|
56
|
+
export const Config = createConfigSchema({
|
|
93
57
|
name: 'observable-axiom',
|
|
94
58
|
description: 'Axiom.co observability integration for logs, metrics, and traces',
|
|
95
59
|
version: '1.0.0',
|
|
@@ -140,10 +104,10 @@ class BSBIdGenerator {
|
|
|
140
104
|
* Exports traces via OTLP (Axiom supports OpenTelemetry)
|
|
141
105
|
* Exports metrics as structured events
|
|
142
106
|
*/
|
|
143
|
-
class Plugin extends
|
|
107
|
+
export class Plugin extends BSBObservable {
|
|
144
108
|
constructor(config) {
|
|
145
109
|
super(config);
|
|
146
|
-
this.logFormatter = new
|
|
110
|
+
this.logFormatter = new LogFormatter();
|
|
147
111
|
this.axiom = null;
|
|
148
112
|
this.tracerProvider = null;
|
|
149
113
|
this.tracer = null;
|
|
@@ -165,20 +129,20 @@ class Plugin extends base_1.BSBObservable {
|
|
|
165
129
|
if (this.config.axiom.url) {
|
|
166
130
|
axiomOptions.url = this.config.axiom.url;
|
|
167
131
|
}
|
|
168
|
-
this.axiom = new
|
|
132
|
+
this.axiom = new Axiom(axiomOptions);
|
|
169
133
|
}
|
|
170
134
|
// Initialize OpenTelemetry for traces (Axiom supports OTLP natively)
|
|
171
135
|
if (this.config.enabled.traces) {
|
|
172
|
-
const resource =
|
|
173
|
-
[
|
|
174
|
-
...(this.config.serviceVersion && { [
|
|
136
|
+
const resource = defaultResource().merge(resourceFromAttributes({
|
|
137
|
+
[ATTR_SERVICE_NAME]: this.config.serviceName,
|
|
138
|
+
...(this.config.serviceVersion && { [ATTR_SERVICE_VERSION]: this.config.serviceVersion }),
|
|
175
139
|
...this.config.resourceAttributes,
|
|
176
140
|
}));
|
|
177
141
|
// Axiom OTLP endpoint (from docs: https://axiom.co/docs/send-data/opentelemetry)
|
|
178
142
|
const otlpUrl = this.config.axiom.url
|
|
179
143
|
? `${this.config.axiom.url}/v1/traces`
|
|
180
144
|
: `https://api.axiom.co/v1/traces`;
|
|
181
|
-
const traceExporter = new
|
|
145
|
+
const traceExporter = new OTLPTraceExporter({
|
|
182
146
|
url: otlpUrl,
|
|
183
147
|
headers: {
|
|
184
148
|
"Authorization": `Bearer ${this.config.axiom.token}`,
|
|
@@ -189,11 +153,11 @@ class Plugin extends base_1.BSBObservable {
|
|
|
189
153
|
this.idGenerator = new BSBIdGenerator();
|
|
190
154
|
// Create tracer provider with custom ID generator and span processor
|
|
191
155
|
// Use shorter batch delay for faster exports during debugging
|
|
192
|
-
this.tracerProvider = new
|
|
156
|
+
this.tracerProvider = new NodeTracerProvider({
|
|
193
157
|
resource,
|
|
194
158
|
idGenerator: this.idGenerator,
|
|
195
159
|
spanProcessors: [
|
|
196
|
-
new
|
|
160
|
+
new BatchSpanProcessor(traceExporter, {
|
|
197
161
|
scheduledDelayMillis: 1000, // Export every 1 second (default is 5000)
|
|
198
162
|
maxQueueSize: 2048,
|
|
199
163
|
maxExportBatchSize: 512,
|
|
@@ -280,7 +244,7 @@ class Plugin extends base_1.BSBObservable {
|
|
|
280
244
|
this.queueLog("warn", trace, pluginName, message, meta);
|
|
281
245
|
}
|
|
282
246
|
error(trace, pluginName, message, meta) {
|
|
283
|
-
if (message instanceof
|
|
247
|
+
if (message instanceof BSBError) {
|
|
284
248
|
if (message.raw !== null) {
|
|
285
249
|
this.queueLog("error", message.raw.trace, pluginName, message.raw.message, message.raw.meta);
|
|
286
250
|
}
|
|
@@ -441,5 +405,4 @@ class Plugin extends base_1.BSBObservable {
|
|
|
441
405
|
this.axiom = null;
|
|
442
406
|
}
|
|
443
407
|
}
|
|
444
|
-
|
|
445
|
-
Plugin.Config = exports.Config;
|
|
408
|
+
Plugin.Config = Config;
|
|
@@ -2,110 +2,6 @@
|
|
|
2
2
|
"pluginName": "observable-axiom",
|
|
3
3
|
"version": "1.0.0",
|
|
4
4
|
"events": {},
|
|
5
|
-
"configSchema": {
|
|
6
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"serviceName": {
|
|
10
|
-
"default": "bsb-service",
|
|
11
|
-
"type": "string"
|
|
12
|
-
},
|
|
13
|
-
"serviceVersion": {
|
|
14
|
-
"type": "string"
|
|
15
|
-
},
|
|
16
|
-
"axiom": {
|
|
17
|
-
"type": "object",
|
|
18
|
-
"properties": {
|
|
19
|
-
"token": {
|
|
20
|
-
"type": "string",
|
|
21
|
-
"description": "Axiom API token"
|
|
22
|
-
},
|
|
23
|
-
"dataset": {
|
|
24
|
-
"default": "bsb-logs",
|
|
25
|
-
"description": "Axiom dataset name",
|
|
26
|
-
"type": "string"
|
|
27
|
-
},
|
|
28
|
-
"orgId": {
|
|
29
|
-
"description": "Axiom organization ID (for cloud)",
|
|
30
|
-
"type": "string"
|
|
31
|
-
},
|
|
32
|
-
"url": {
|
|
33
|
-
"description": "Custom Axiom URL (for self-hosted)",
|
|
34
|
-
"type": "string",
|
|
35
|
-
"format": "uri"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"required": [
|
|
39
|
-
"token",
|
|
40
|
-
"dataset"
|
|
41
|
-
],
|
|
42
|
-
"additionalProperties": false
|
|
43
|
-
},
|
|
44
|
-
"enabled": {
|
|
45
|
-
"type": "object",
|
|
46
|
-
"properties": {
|
|
47
|
-
"logs": {
|
|
48
|
-
"default": true,
|
|
49
|
-
"type": "boolean"
|
|
50
|
-
},
|
|
51
|
-
"metrics": {
|
|
52
|
-
"default": true,
|
|
53
|
-
"type": "boolean"
|
|
54
|
-
},
|
|
55
|
-
"traces": {
|
|
56
|
-
"default": true,
|
|
57
|
-
"type": "boolean"
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
"required": [
|
|
61
|
-
"logs",
|
|
62
|
-
"metrics",
|
|
63
|
-
"traces"
|
|
64
|
-
],
|
|
65
|
-
"additionalProperties": false
|
|
66
|
-
},
|
|
67
|
-
"export": {
|
|
68
|
-
"type": "object",
|
|
69
|
-
"properties": {
|
|
70
|
-
"flushIntervalMs": {
|
|
71
|
-
"default": 5000,
|
|
72
|
-
"type": "integer",
|
|
73
|
-
"minimum": 100,
|
|
74
|
-
"maximum": 9007199254740991
|
|
75
|
-
},
|
|
76
|
-
"maxBatchSize": {
|
|
77
|
-
"default": 1000,
|
|
78
|
-
"type": "integer",
|
|
79
|
-
"minimum": 1,
|
|
80
|
-
"maximum": 9007199254740991
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
"required": [
|
|
84
|
-
"flushIntervalMs",
|
|
85
|
-
"maxBatchSize"
|
|
86
|
-
],
|
|
87
|
-
"additionalProperties": false
|
|
88
|
-
},
|
|
89
|
-
"resourceAttributes": {
|
|
90
|
-
"default": {},
|
|
91
|
-
"type": "object",
|
|
92
|
-
"propertyNames": {
|
|
93
|
-
"type": "string"
|
|
94
|
-
},
|
|
95
|
-
"additionalProperties": {
|
|
96
|
-
"type": "string"
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
"required": [
|
|
101
|
-
"serviceName",
|
|
102
|
-
"axiom",
|
|
103
|
-
"enabled",
|
|
104
|
-
"export",
|
|
105
|
-
"resourceAttributes"
|
|
106
|
-
],
|
|
107
|
-
"additionalProperties": false
|
|
108
|
-
},
|
|
109
5
|
"pluginType": "observable",
|
|
110
6
|
"capabilities": {
|
|
111
7
|
"logging": {
|
|
@@ -14,109 +14,5 @@
|
|
|
14
14
|
],
|
|
15
15
|
"documentation": [],
|
|
16
16
|
"dependencies": [],
|
|
17
|
-
"image": "./axiom-co-logo.png"
|
|
18
|
-
"configSchema": {
|
|
19
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
20
|
-
"type": "object",
|
|
21
|
-
"properties": {
|
|
22
|
-
"serviceName": {
|
|
23
|
-
"default": "bsb-service",
|
|
24
|
-
"type": "string"
|
|
25
|
-
},
|
|
26
|
-
"serviceVersion": {
|
|
27
|
-
"type": "string"
|
|
28
|
-
},
|
|
29
|
-
"axiom": {
|
|
30
|
-
"type": "object",
|
|
31
|
-
"properties": {
|
|
32
|
-
"token": {
|
|
33
|
-
"type": "string",
|
|
34
|
-
"description": "Axiom API token"
|
|
35
|
-
},
|
|
36
|
-
"dataset": {
|
|
37
|
-
"default": "bsb-logs",
|
|
38
|
-
"description": "Axiom dataset name",
|
|
39
|
-
"type": "string"
|
|
40
|
-
},
|
|
41
|
-
"orgId": {
|
|
42
|
-
"description": "Axiom organization ID (for cloud)",
|
|
43
|
-
"type": "string"
|
|
44
|
-
},
|
|
45
|
-
"url": {
|
|
46
|
-
"description": "Custom Axiom URL (for self-hosted)",
|
|
47
|
-
"type": "string",
|
|
48
|
-
"format": "uri"
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
"required": [
|
|
52
|
-
"token",
|
|
53
|
-
"dataset"
|
|
54
|
-
],
|
|
55
|
-
"additionalProperties": false
|
|
56
|
-
},
|
|
57
|
-
"enabled": {
|
|
58
|
-
"type": "object",
|
|
59
|
-
"properties": {
|
|
60
|
-
"logs": {
|
|
61
|
-
"default": true,
|
|
62
|
-
"type": "boolean"
|
|
63
|
-
},
|
|
64
|
-
"metrics": {
|
|
65
|
-
"default": true,
|
|
66
|
-
"type": "boolean"
|
|
67
|
-
},
|
|
68
|
-
"traces": {
|
|
69
|
-
"default": true,
|
|
70
|
-
"type": "boolean"
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
"required": [
|
|
74
|
-
"logs",
|
|
75
|
-
"metrics",
|
|
76
|
-
"traces"
|
|
77
|
-
],
|
|
78
|
-
"additionalProperties": false
|
|
79
|
-
},
|
|
80
|
-
"export": {
|
|
81
|
-
"type": "object",
|
|
82
|
-
"properties": {
|
|
83
|
-
"flushIntervalMs": {
|
|
84
|
-
"default": 5000,
|
|
85
|
-
"type": "integer",
|
|
86
|
-
"minimum": 100,
|
|
87
|
-
"maximum": 9007199254740991
|
|
88
|
-
},
|
|
89
|
-
"maxBatchSize": {
|
|
90
|
-
"default": 1000,
|
|
91
|
-
"type": "integer",
|
|
92
|
-
"minimum": 1,
|
|
93
|
-
"maximum": 9007199254740991
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
"required": [
|
|
97
|
-
"flushIntervalMs",
|
|
98
|
-
"maxBatchSize"
|
|
99
|
-
],
|
|
100
|
-
"additionalProperties": false
|
|
101
|
-
},
|
|
102
|
-
"resourceAttributes": {
|
|
103
|
-
"default": {},
|
|
104
|
-
"type": "object",
|
|
105
|
-
"propertyNames": {
|
|
106
|
-
"type": "string"
|
|
107
|
-
},
|
|
108
|
-
"additionalProperties": {
|
|
109
|
-
"type": "string"
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
"required": [
|
|
114
|
-
"serviceName",
|
|
115
|
-
"axiom",
|
|
116
|
-
"enabled",
|
|
117
|
-
"export",
|
|
118
|
-
"resourceAttributes"
|
|
119
|
-
],
|
|
120
|
-
"additionalProperties": false
|
|
121
|
-
}
|
|
17
|
+
"image": "./axiom-co-logo.png"
|
|
122
18
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsb/observable-axiom",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Axiom.co observability integration for BSB framework",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "lib/plugins/observable-axiom/index.js",
|
|
6
7
|
"types": "lib/plugins/observable-axiom/index.d.ts",
|
|
7
8
|
"scripts": {
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
"@bsb/base": "^9.0.0"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
37
|
+
"@anyvali/js": "^0.2.0",
|
|
36
38
|
"@axiomhq/js": "^1.4.0",
|
|
37
39
|
"@opentelemetry/api": "^1.9.0",
|
|
38
40
|
"@opentelemetry/exporter-trace-otlp-http": "^0.211.0",
|
|
@@ -40,18 +42,13 @@
|
|
|
40
42
|
"@opentelemetry/sdk-node": "^0.211.0",
|
|
41
43
|
"@opentelemetry/sdk-trace-base": "^2.5.0",
|
|
42
44
|
"@opentelemetry/sdk-trace-node": "^2.5.0",
|
|
43
|
-
"@opentelemetry/semantic-conventions": "^1.39.0"
|
|
44
|
-
"zod": "^4.3.6"
|
|
45
|
+
"@opentelemetry/semantic-conventions": "^1.39.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"@bsb/base": "
|
|
48
|
+
"@bsb/base": "^9.0.0",
|
|
48
49
|
"@types/node": "^25.2.1",
|
|
49
50
|
"rimraf": "^6.1.2",
|
|
50
51
|
"typescript": "^5.9.3"
|
|
51
52
|
},
|
|
52
53
|
"homepage": "https://io.bsbcode.dev/packages/nodejs/@bsb/observable-axiom"
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
BSBError
|
|
34
34
|
} from "@bsb/base";
|
|
35
35
|
import { DTrace, LogMeta } from "@bsb/base";
|
|
36
|
-
import
|
|
36
|
+
import * as av from "@anyvali/js";
|
|
37
37
|
import { Axiom } from "@axiomhq/js";
|
|
38
38
|
import * as api from "@opentelemetry/api";
|
|
39
39
|
import { defaultResource, resourceFromAttributes } from "@opentelemetry/resources";
|
|
@@ -43,30 +43,26 @@ import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
|
43
43
|
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
44
44
|
import type { IdGenerator } from "@opentelemetry/sdk-trace-base";
|
|
45
45
|
|
|
46
|
-
const ConfigSchema =
|
|
47
|
-
serviceName:
|
|
48
|
-
serviceVersion:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}),
|
|
67
|
-
|
|
68
|
-
resourceAttributes: z.record(z.string(), z.string()).default({}),
|
|
69
|
-
});
|
|
46
|
+
const ConfigSchema = av.object({
|
|
47
|
+
serviceName: av.optional(av.string()).default("bsb-service"),
|
|
48
|
+
serviceVersion: av.optional(av.string()),
|
|
49
|
+
axiom: av.object({
|
|
50
|
+
token: av.string(),
|
|
51
|
+
dataset: av.optional(av.string()).default("bsb-logs"),
|
|
52
|
+
orgId: av.optional(av.string()),
|
|
53
|
+
url: av.optional(av.string().format("url")),
|
|
54
|
+
}, { unknownKeys: "strip" }),
|
|
55
|
+
enabled: av.object({
|
|
56
|
+
logs: av.optional(av.bool()).default(true),
|
|
57
|
+
metrics: av.optional(av.bool()).default(true),
|
|
58
|
+
traces: av.optional(av.bool()).default(true),
|
|
59
|
+
}, { unknownKeys: "strip" }),
|
|
60
|
+
export: av.object({
|
|
61
|
+
flushIntervalMs: av.optional(av.int32().min(100)).default(5000),
|
|
62
|
+
maxBatchSize: av.optional(av.int32().min(1)).default(1000),
|
|
63
|
+
}, { unknownKeys: "strip" }),
|
|
64
|
+
resourceAttributes: av.optional(av.record(av.string())).default({}),
|
|
65
|
+
}, { unknownKeys: "strip" });
|
|
70
66
|
|
|
71
67
|
export const Config = createConfigSchema(
|
|
72
68
|
{
|
package/tsconfig.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ES2020",
|
|
4
|
-
"module": "
|
|
4
|
+
"module": "NodeNext",
|
|
5
5
|
"lib": ["ES2020"],
|
|
6
6
|
"declaration": true,
|
|
7
7
|
"outDir": "./lib",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"esModuleInterop": true,
|
|
11
11
|
"skipLibCheck": true,
|
|
12
12
|
"forceConsistentCasingInFileNames": true,
|
|
13
|
-
"moduleResolution": "
|
|
13
|
+
"moduleResolution": "NodeNext",
|
|
14
14
|
"resolveJsonModule": true,
|
|
15
15
|
"types": ["node"]
|
|
16
16
|
},
|