@abbacchio/transport 0.1.4 → 0.2.0
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/dist/client.d.ts +118 -71
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +397 -118
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/transports/bunyan.d.ts +6 -44
- package/dist/transports/bunyan.d.ts.map +1 -1
- package/dist/transports/bunyan.js +9 -62
- package/dist/transports/bunyan.js.map +1 -1
- package/dist/transports/console.d.ts +30 -0
- package/dist/transports/console.d.ts.map +1 -0
- package/dist/transports/console.js +89 -0
- package/dist/transports/console.js.map +1 -0
- package/dist/transports/pino.d.ts +13 -26
- package/dist/transports/pino.d.ts.map +1 -1
- package/dist/transports/pino.js +15 -43
- package/dist/transports/pino.js.map +1 -1
- package/dist/transports/winston.d.ts +6 -46
- package/dist/transports/winston.d.ts.map +1 -1
- package/dist/transports/winston.js +9 -64
- package/dist/transports/winston.js.map +1 -1
- package/package.json +2 -2
- package/src/client.ts +487 -129
- package/src/index.ts +1 -1
- package/src/tests/histogram.test.ts +189 -0
- package/src/transports/bunyan.ts +9 -68
- package/src/transports/console.ts +116 -0
- package/src/transports/pino.ts +19 -58
- package/src/transports/winston.ts +9 -71
- package/tsconfig.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,100 +1,147 @@
|
|
|
1
1
|
export interface AbbacchioClientOptions {
|
|
2
|
-
/**
|
|
2
|
+
/** Base URL of the OTLP server (e.g. "http://localhost:4002"). Logs go to {endpoint}/v1/logs */
|
|
3
|
+
endpoint?: string;
|
|
4
|
+
/** @deprecated Use `endpoint` instead. If set, used as the full URL for log ingestion. */
|
|
3
5
|
url?: string;
|
|
4
|
-
/** Secret key for encryption. If provided,
|
|
6
|
+
/** Secret key for encryption. If provided, payloads will be encrypted before sending */
|
|
5
7
|
secretKey?: string;
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
/** Number of
|
|
8
|
+
/** Service name — maps to OTLP resource attribute `service.name`. Defaults to 'default' */
|
|
9
|
+
serviceName?: string;
|
|
10
|
+
/** Additional OTLP resource attributes */
|
|
11
|
+
resourceAttributes?: Record<string, string>;
|
|
12
|
+
/** Number of log records to batch before sending. Defaults to 10 */
|
|
11
13
|
batchSize?: number;
|
|
12
14
|
/** Interval in ms between flushes. Defaults to 1000 */
|
|
13
15
|
interval?: number;
|
|
14
16
|
/** Additional headers to send with requests */
|
|
15
17
|
headers?: Record<string, string>;
|
|
16
|
-
/** Whether to send
|
|
18
|
+
/** Whether to send data to the server. Defaults to true */
|
|
17
19
|
enabled?: boolean;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
+
* A log entry in the format the transports produce before OTLP conversion.
|
|
23
|
+
*/
|
|
24
|
+
export interface LogRecord {
|
|
25
|
+
level?: number;
|
|
26
|
+
msg?: string;
|
|
27
|
+
message?: string;
|
|
28
|
+
time?: number;
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A metric data point to send via OTLP.
|
|
33
|
+
*/
|
|
34
|
+
export interface MetricRecord {
|
|
35
|
+
name: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
unit?: string;
|
|
38
|
+
type: 'sum' | 'gauge';
|
|
39
|
+
value: number;
|
|
40
|
+
attributes?: Record<string, unknown>;
|
|
41
|
+
isMonotonic?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A histogram data point to send via OTLP.
|
|
45
|
+
*
|
|
46
|
+
* Each record is a single observation. The client accumulates observations
|
|
47
|
+
* into OTLP Histogram data points (with explicit bucket boundaries) on flush.
|
|
48
|
+
*/
|
|
49
|
+
export interface HistogramRecord {
|
|
50
|
+
name: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
unit?: string;
|
|
53
|
+
/** The observed value (e.g. request duration in ms) */
|
|
54
|
+
value: number;
|
|
55
|
+
attributes?: Record<string, unknown>;
|
|
56
|
+
/**
|
|
57
|
+
* Explicit bucket boundaries. Defaults to a standard latency distribution:
|
|
58
|
+
* [5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 10000]
|
|
59
|
+
*/
|
|
60
|
+
explicitBounds?: number[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A trace span to send via OTLP.
|
|
64
|
+
*/
|
|
65
|
+
export interface SpanRecord {
|
|
66
|
+
traceId: string;
|
|
67
|
+
spanId: string;
|
|
68
|
+
parentSpanId?: string;
|
|
69
|
+
name: string;
|
|
70
|
+
kind?: number;
|
|
71
|
+
startTimeUnixNano: string;
|
|
72
|
+
endTimeUnixNano: string;
|
|
73
|
+
attributes?: Record<string, unknown>;
|
|
74
|
+
status?: {
|
|
75
|
+
code: number;
|
|
76
|
+
message?: string;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* OTLP-native HTTP client for Abbacchio.
|
|
81
|
+
* Sends logs to POST /v1/logs, metrics to POST /v1/metrics, traces to POST /v1/traces.
|
|
22
82
|
*/
|
|
23
83
|
export declare class AbbacchioClient {
|
|
24
|
-
private
|
|
84
|
+
private endpoint;
|
|
25
85
|
private secretKey?;
|
|
26
|
-
private
|
|
27
|
-
private
|
|
86
|
+
private serviceName;
|
|
87
|
+
private resourceAttributes;
|
|
28
88
|
private batchSize;
|
|
29
89
|
private interval;
|
|
30
90
|
private headers;
|
|
31
91
|
private enabled;
|
|
32
|
-
private
|
|
33
|
-
private
|
|
92
|
+
private logBuffer;
|
|
93
|
+
private metricBuffer;
|
|
94
|
+
private histogramBuffer;
|
|
95
|
+
private spanBuffer;
|
|
96
|
+
private logTimer;
|
|
97
|
+
private metricTimer;
|
|
98
|
+
private histogramTimer;
|
|
99
|
+
private spanTimer;
|
|
34
100
|
constructor(options?: AbbacchioClientOptions);
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Get the current channel
|
|
41
|
-
*/
|
|
42
|
-
getChannel(): string | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* Change the namespace dynamically after initialization
|
|
45
|
-
*/
|
|
46
|
-
setNamespace(namespace: string | undefined): void;
|
|
47
|
-
/**
|
|
48
|
-
* Get the current namespace
|
|
49
|
-
*/
|
|
50
|
-
getNamespace(): string | undefined;
|
|
51
|
-
/**
|
|
52
|
-
* Enable sending logs to the server
|
|
53
|
-
*/
|
|
101
|
+
/** Change the service name dynamically */
|
|
102
|
+
setServiceName(name: string): void;
|
|
103
|
+
/** Get the current service name */
|
|
104
|
+
getServiceName(): string;
|
|
105
|
+
/** Enable sending data to the server */
|
|
54
106
|
enable(): void;
|
|
55
|
-
/**
|
|
56
|
-
* Disable sending logs to the server. Logs will be silently dropped.
|
|
57
|
-
*/
|
|
107
|
+
/** Disable sending data to the server. Data will be silently dropped. */
|
|
58
108
|
disable(): void;
|
|
59
|
-
/**
|
|
60
|
-
* Check if the client is currently enabled
|
|
61
|
-
*/
|
|
109
|
+
/** Check if the client is currently enabled */
|
|
62
110
|
isEnabled(): boolean;
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
private
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
|
|
111
|
+
/** Add a log record to the buffer */
|
|
112
|
+
add(log: LogRecord | unknown): void;
|
|
113
|
+
/** Add multiple log records at once */
|
|
114
|
+
addBatch(logs: (LogRecord | unknown)[]): void;
|
|
115
|
+
/** Send logs immediately without batching */
|
|
116
|
+
send(logs: (LogRecord | unknown)[]): Promise<void>;
|
|
117
|
+
private scheduleLogFlush;
|
|
118
|
+
flushLogs(): Promise<void>;
|
|
119
|
+
private sendLogs;
|
|
120
|
+
/** Add a metric data point to the buffer */
|
|
121
|
+
addMetric(metric: MetricRecord): void;
|
|
122
|
+
private scheduleMetricFlush;
|
|
123
|
+
flushMetrics(): Promise<void>;
|
|
124
|
+
private sendMetrics;
|
|
125
|
+
private static DEFAULT_BOUNDS;
|
|
126
|
+
/** Add a histogram observation to the buffer */
|
|
127
|
+
addHistogram(record: HistogramRecord): void;
|
|
128
|
+
private scheduleHistogramFlush;
|
|
129
|
+
flushHistograms(): Promise<void>;
|
|
130
|
+
private sendHistograms;
|
|
131
|
+
/** Add a trace span to the buffer */
|
|
132
|
+
addSpan(span: SpanRecord): void;
|
|
133
|
+
private scheduleSpanFlush;
|
|
134
|
+
flushSpans(): Promise<void>;
|
|
135
|
+
private sendSpans;
|
|
136
|
+
/** Flush all buffers and close the client */
|
|
86
137
|
flush(): Promise<void>;
|
|
87
|
-
/**
|
|
88
|
-
* Send logs to the Abbacchio server
|
|
89
|
-
*/
|
|
90
|
-
private sendToServer;
|
|
91
|
-
/**
|
|
92
|
-
* Close the client and flush any remaining logs
|
|
93
|
-
*/
|
|
138
|
+
/** Close the client and flush any remaining data */
|
|
94
139
|
close(): Promise<void>;
|
|
140
|
+
private buildResourceAttributes;
|
|
141
|
+
private post;
|
|
95
142
|
}
|
|
96
143
|
/**
|
|
97
|
-
* Create a new Abbacchio client instance
|
|
144
|
+
* Create a new Abbacchio OTLP client instance
|
|
98
145
|
*/
|
|
99
146
|
export declare function createClient(options?: AbbacchioClientOptions): AbbacchioClient;
|
|
100
147
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts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