hobots 1.3.5 → 1.5.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/README.md +35 -17
- package/dist/index.cjs +79 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +123 -110
- package/dist/index.d.ts +123 -110
- package/dist/index.js +69 -11
- package/dist/index.js.map +1 -1
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +6 -2
- package/dist/protocol.d.ts +6 -2
- package/docs/README.md +4 -1
- package/docs/api-reference.md +87 -11
- package/docs/concepts.md +441 -0
- package/docs/getting-started.md +17 -2
- package/docs/manager.md +37 -7
- package/docs/monitor.md +38 -3
- package/docs/protocol.md +3 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,121 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Breadcrumb, EventUser, Severity, EventPayload, TransactionPayload, CheckInPayload, HeartbeatPayload, SpanStatus, SpanData, CheckInStatus } from './protocol.cjs';
|
|
2
2
|
export { Envelope, EnvelopeItem, ExceptionData, StackFrame } from './protocol.cjs';
|
|
3
3
|
import { ManagerPollRequest, ManagerPollResponse, ManagerRunUpdateRequest } from './manager/protocol.cjs';
|
|
4
4
|
export { ManagerAgentInfo, ManagerRunDescriptor, ManagerRunError, ManagerRunStatus, ManagerRunUpdateResponse, ManagerRunUpdateStatus, RunLogEntry, RunLogLevel } from './manager/protocol.cjs';
|
|
5
5
|
|
|
6
|
+
/** API oficial da Hobots — o SDK sempre fala com ela em produção. */
|
|
7
|
+
declare const DEFAULT_BASE_URL = "https://api2.hobots.app";
|
|
8
|
+
interface ResolvedConfig {
|
|
9
|
+
/** Client Secret do projeto (enviado como Authorization: Bearer, nunca na URL) */
|
|
10
|
+
key: string;
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
/** Ingestão do Monitor: <baseUrl>/v1/ingest */
|
|
13
|
+
ingestEndpoint: string;
|
|
14
|
+
/** API do Manager: <baseUrl>/v1/manager */
|
|
15
|
+
managerBaseUrl: string;
|
|
16
|
+
}
|
|
17
|
+
interface ConfigInput {
|
|
18
|
+
clientSecret: string;
|
|
19
|
+
}
|
|
20
|
+
/** Resolve o clientSecret nos endpoints do Monitor e do Manager. */
|
|
21
|
+
declare function resolveConfig(options: ConfigInput, prefix?: string): ResolvedConfig;
|
|
22
|
+
|
|
23
|
+
type BreadcrumbInput = Omit<Breadcrumb, 'timestamp'> & {
|
|
24
|
+
timestamp?: string;
|
|
25
|
+
};
|
|
26
|
+
/** Estado contextual anexado aos eventos: tags, usuário, contexts, extras e breadcrumbs. */
|
|
27
|
+
declare class Scope {
|
|
28
|
+
tags: Record<string, string>;
|
|
29
|
+
user?: EventUser;
|
|
30
|
+
contexts: Record<string, Record<string, unknown>>;
|
|
31
|
+
extra: Record<string, unknown>;
|
|
32
|
+
level?: Severity;
|
|
33
|
+
fingerprint?: string[];
|
|
34
|
+
breadcrumbs: Breadcrumb[];
|
|
35
|
+
setTag(key: string, value: string): this;
|
|
36
|
+
setTags(tags: Record<string, string>): this;
|
|
37
|
+
setUser(user: EventUser | null): this;
|
|
38
|
+
setContext(name: string, context: Record<string, unknown> | null): this;
|
|
39
|
+
setExtra(key: string, value: unknown): this;
|
|
40
|
+
setExtras(extras: Record<string, unknown>): this;
|
|
41
|
+
setLevel(level: Severity): this;
|
|
42
|
+
setFingerprint(fingerprint: string[]): this;
|
|
43
|
+
addBreadcrumb(crumb: BreadcrumbInput, maxBreadcrumbs: number): this;
|
|
44
|
+
clearBreadcrumbs(): this;
|
|
45
|
+
clone(): Scope;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface Logger {
|
|
49
|
+
debug: (...args: unknown[]) => void;
|
|
50
|
+
warn: (...args: unknown[]) => void;
|
|
51
|
+
error: (...args: unknown[]) => void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
declare class Client {
|
|
55
|
+
readonly options: InitOptions;
|
|
56
|
+
readonly config: ResolvedConfig;
|
|
57
|
+
readonly logger: Logger;
|
|
58
|
+
private readonly transport;
|
|
59
|
+
constructor(options: InitOptions);
|
|
60
|
+
captureException(error: unknown, hint: CaptureHint | undefined, scope: Scope): string;
|
|
61
|
+
captureMessage(message: string, level: Severity, hint: CaptureHint | undefined, scope: Scope): string;
|
|
62
|
+
captureEvent(event: EventPayload, hint: CaptureHint | undefined, scope: Scope): string;
|
|
63
|
+
private prepareEvent;
|
|
64
|
+
sendTransaction(payload: TransactionPayload): void;
|
|
65
|
+
sendCheckIn(payload: CheckInPayload): void;
|
|
66
|
+
sendHeartbeat(payload: HeartbeatPayload): void;
|
|
67
|
+
flush(timeoutMs?: number): Promise<boolean>;
|
|
68
|
+
close(timeoutMs?: number): Promise<boolean>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
declare class Span {
|
|
72
|
+
private readonly transaction;
|
|
73
|
+
readonly parentSpanId: string;
|
|
74
|
+
readonly op?: string | undefined;
|
|
75
|
+
readonly description?: string | undefined;
|
|
76
|
+
readonly spanId: string;
|
|
77
|
+
readonly startTimestamp: string;
|
|
78
|
+
status: SpanStatus;
|
|
79
|
+
endTimestamp?: string;
|
|
80
|
+
data?: Record<string, unknown>;
|
|
81
|
+
constructor(transaction: Transaction, parentSpanId: string, op?: string | undefined, description?: string | undefined);
|
|
82
|
+
setStatus(status: SpanStatus): this;
|
|
83
|
+
setData(key: string, value: unknown): this;
|
|
84
|
+
/** Span aninhado (filho deste span). */
|
|
85
|
+
startChild(op?: string, description?: string): Span;
|
|
86
|
+
finish(): void;
|
|
87
|
+
toJSON(): SpanData;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Uma unidade de trabalho nomeada (ex.: uma execução de rotina, uma sincronização).
|
|
91
|
+
* Spans filhos medem as etapas internas (chamadas HTTP, queries, etc.).
|
|
92
|
+
*/
|
|
93
|
+
declare class Transaction {
|
|
94
|
+
private readonly client;
|
|
95
|
+
name: string;
|
|
96
|
+
readonly op?: string | undefined;
|
|
97
|
+
private readonly sampled;
|
|
98
|
+
/** Correlaciona a uma execução do Manager — preenchido automaticamente em ctx.tx */
|
|
99
|
+
private readonly runId?;
|
|
100
|
+
readonly eventId: string;
|
|
101
|
+
readonly spanId: string;
|
|
102
|
+
readonly startTimestamp: string;
|
|
103
|
+
status: string;
|
|
104
|
+
private readonly spans;
|
|
105
|
+
private readonly tags;
|
|
106
|
+
private finished;
|
|
107
|
+
constructor(client: Client | undefined, name: string, op?: string | undefined, sampled?: boolean,
|
|
108
|
+
/** Correlaciona a uma execução do Manager — preenchido automaticamente em ctx.tx */
|
|
109
|
+
runId?: string | undefined);
|
|
110
|
+
createSpan(parentSpanId: string, op?: string, description?: string): Span;
|
|
111
|
+
/** Span direto da transaction. */
|
|
112
|
+
startChild(op?: string, description?: string): Span;
|
|
113
|
+
setTag(key: string, value: string): this;
|
|
114
|
+
setStatus(status: string): this;
|
|
115
|
+
setName(name: string): this;
|
|
116
|
+
finish(): void;
|
|
117
|
+
}
|
|
118
|
+
|
|
6
119
|
/** Opções do Manager dentro de `init({ manager: ... })`. Credencial (clientSecret), identidade (instanceId) e debug vêm do init. */
|
|
7
120
|
interface ManagerOptions {
|
|
8
121
|
/** Intervalo entre polls sem trabalho. Default: 5_000 (mínimo 1_000) */
|
|
@@ -38,6 +151,8 @@ interface ManagerAgentOptions extends ManagerOptions {
|
|
|
38
151
|
instanceId: string;
|
|
39
152
|
/** Loga atividade do SDK no console */
|
|
40
153
|
debug?: boolean;
|
|
154
|
+
/** Client do Monitor compartilhado — usado para enviar a transaction de performance de cada run (ctx.tx) */
|
|
155
|
+
client?: Client;
|
|
41
156
|
}
|
|
42
157
|
interface RunLogger {
|
|
43
158
|
debug(message: string): void;
|
|
@@ -50,6 +165,12 @@ interface RunContext {
|
|
|
50
165
|
task: string;
|
|
51
166
|
/** Log bufferizado — enviado ao servidor em PATCHes incrementais com throttle */
|
|
52
167
|
log: RunLogger;
|
|
168
|
+
/**
|
|
169
|
+
* Transaction de performance desta execução — já correlacionada à run e finalizada
|
|
170
|
+
* automaticamente ao fim do handler. Use `ctx.tx.startChild(op, description)` pra medir
|
|
171
|
+
* as etapas (steps) da task; elas aparecem como waterfall na aba de performance da execução.
|
|
172
|
+
*/
|
|
173
|
+
tx: Transaction;
|
|
53
174
|
/** Dispara em cancelamento (run cancelada no app), timeout ou shutdown — cancelamento cooperativo */
|
|
54
175
|
signal: AbortSignal;
|
|
55
176
|
/**
|
|
@@ -112,115 +233,6 @@ interface CaptureHint {
|
|
|
112
233
|
fingerprint?: string[];
|
|
113
234
|
}
|
|
114
235
|
|
|
115
|
-
/** API oficial da Hobots — o SDK sempre fala com ela em produção. */
|
|
116
|
-
declare const DEFAULT_BASE_URL = "https://api2.hobots.app";
|
|
117
|
-
interface ResolvedConfig {
|
|
118
|
-
/** Client Secret do projeto (enviado como Authorization: Bearer, nunca na URL) */
|
|
119
|
-
key: string;
|
|
120
|
-
baseUrl: string;
|
|
121
|
-
/** Ingestão do Monitor: <baseUrl>/v1/ingest */
|
|
122
|
-
ingestEndpoint: string;
|
|
123
|
-
/** API do Manager: <baseUrl>/v1/manager */
|
|
124
|
-
managerBaseUrl: string;
|
|
125
|
-
}
|
|
126
|
-
interface ConfigInput {
|
|
127
|
-
clientSecret: string;
|
|
128
|
-
}
|
|
129
|
-
/** Resolve o clientSecret nos endpoints do Monitor e do Manager. */
|
|
130
|
-
declare function resolveConfig(options: ConfigInput, prefix?: string): ResolvedConfig;
|
|
131
|
-
|
|
132
|
-
type BreadcrumbInput = Omit<Breadcrumb, 'timestamp'> & {
|
|
133
|
-
timestamp?: string;
|
|
134
|
-
};
|
|
135
|
-
/** Estado contextual anexado aos eventos: tags, usuário, contexts, extras e breadcrumbs. */
|
|
136
|
-
declare class Scope {
|
|
137
|
-
tags: Record<string, string>;
|
|
138
|
-
user?: EventUser;
|
|
139
|
-
contexts: Record<string, Record<string, unknown>>;
|
|
140
|
-
extra: Record<string, unknown>;
|
|
141
|
-
level?: Severity;
|
|
142
|
-
fingerprint?: string[];
|
|
143
|
-
breadcrumbs: Breadcrumb[];
|
|
144
|
-
setTag(key: string, value: string): this;
|
|
145
|
-
setTags(tags: Record<string, string>): this;
|
|
146
|
-
setUser(user: EventUser | null): this;
|
|
147
|
-
setContext(name: string, context: Record<string, unknown> | null): this;
|
|
148
|
-
setExtra(key: string, value: unknown): this;
|
|
149
|
-
setExtras(extras: Record<string, unknown>): this;
|
|
150
|
-
setLevel(level: Severity): this;
|
|
151
|
-
setFingerprint(fingerprint: string[]): this;
|
|
152
|
-
addBreadcrumb(crumb: BreadcrumbInput, maxBreadcrumbs: number): this;
|
|
153
|
-
clearBreadcrumbs(): this;
|
|
154
|
-
clone(): Scope;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
interface Logger {
|
|
158
|
-
debug: (...args: unknown[]) => void;
|
|
159
|
-
warn: (...args: unknown[]) => void;
|
|
160
|
-
error: (...args: unknown[]) => void;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
declare class Client {
|
|
164
|
-
readonly options: InitOptions;
|
|
165
|
-
readonly config: ResolvedConfig;
|
|
166
|
-
readonly logger: Logger;
|
|
167
|
-
private readonly transport;
|
|
168
|
-
constructor(options: InitOptions);
|
|
169
|
-
captureException(error: unknown, hint: CaptureHint | undefined, scope: Scope): string;
|
|
170
|
-
captureMessage(message: string, level: Severity, hint: CaptureHint | undefined, scope: Scope): string;
|
|
171
|
-
captureEvent(event: EventPayload, hint: CaptureHint | undefined, scope: Scope): string;
|
|
172
|
-
private prepareEvent;
|
|
173
|
-
sendTransaction(payload: TransactionPayload): void;
|
|
174
|
-
sendCheckIn(payload: CheckInPayload): void;
|
|
175
|
-
sendHeartbeat(payload: HeartbeatPayload): void;
|
|
176
|
-
flush(timeoutMs?: number): Promise<boolean>;
|
|
177
|
-
close(timeoutMs?: number): Promise<boolean>;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
declare class Span {
|
|
181
|
-
private readonly transaction;
|
|
182
|
-
readonly parentSpanId: string;
|
|
183
|
-
readonly op?: string | undefined;
|
|
184
|
-
readonly description?: string | undefined;
|
|
185
|
-
readonly spanId: string;
|
|
186
|
-
readonly startTimestamp: string;
|
|
187
|
-
status: string;
|
|
188
|
-
endTimestamp?: string;
|
|
189
|
-
data?: Record<string, unknown>;
|
|
190
|
-
constructor(transaction: Transaction, parentSpanId: string, op?: string | undefined, description?: string | undefined);
|
|
191
|
-
setStatus(status: string): this;
|
|
192
|
-
setData(key: string, value: unknown): this;
|
|
193
|
-
/** Span aninhado (filho deste span). */
|
|
194
|
-
startChild(op?: string, description?: string): Span;
|
|
195
|
-
finish(): void;
|
|
196
|
-
toJSON(): SpanData;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Uma unidade de trabalho nomeada (ex.: uma execução de rotina, uma sincronização).
|
|
200
|
-
* Spans filhos medem as etapas internas (chamadas HTTP, queries, etc.).
|
|
201
|
-
*/
|
|
202
|
-
declare class Transaction {
|
|
203
|
-
private readonly client;
|
|
204
|
-
name: string;
|
|
205
|
-
readonly op?: string | undefined;
|
|
206
|
-
private readonly sampled;
|
|
207
|
-
readonly eventId: string;
|
|
208
|
-
readonly spanId: string;
|
|
209
|
-
readonly startTimestamp: string;
|
|
210
|
-
status: string;
|
|
211
|
-
private readonly spans;
|
|
212
|
-
private readonly tags;
|
|
213
|
-
private finished;
|
|
214
|
-
constructor(client: Client | undefined, name: string, op?: string | undefined, sampled?: boolean);
|
|
215
|
-
createSpan(parentSpanId: string, op?: string, description?: string): Span;
|
|
216
|
-
/** Span direto da transaction. */
|
|
217
|
-
startChild(op?: string, description?: string): Span;
|
|
218
|
-
setTag(key: string, value: string): this;
|
|
219
|
-
setStatus(status: string): this;
|
|
220
|
-
setName(name: string): this;
|
|
221
|
-
finish(): void;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
236
|
interface CheckInOptions {
|
|
225
237
|
monitorSlug: string;
|
|
226
238
|
status: CheckInStatus;
|
|
@@ -284,6 +296,7 @@ declare class ManagerAgent {
|
|
|
284
296
|
private readonly registry;
|
|
285
297
|
readonly logger: Logger;
|
|
286
298
|
private readonly api;
|
|
299
|
+
private readonly client;
|
|
287
300
|
private readonly pollIntervalMs;
|
|
288
301
|
private readonly concurrency;
|
|
289
302
|
private readonly instanceId;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,121 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Breadcrumb, EventUser, Severity, EventPayload, TransactionPayload, CheckInPayload, HeartbeatPayload, SpanStatus, SpanData, CheckInStatus } from './protocol.js';
|
|
2
2
|
export { Envelope, EnvelopeItem, ExceptionData, StackFrame } from './protocol.js';
|
|
3
3
|
import { ManagerPollRequest, ManagerPollResponse, ManagerRunUpdateRequest } from './manager/protocol.js';
|
|
4
4
|
export { ManagerAgentInfo, ManagerRunDescriptor, ManagerRunError, ManagerRunStatus, ManagerRunUpdateResponse, ManagerRunUpdateStatus, RunLogEntry, RunLogLevel } from './manager/protocol.js';
|
|
5
5
|
|
|
6
|
+
/** API oficial da Hobots — o SDK sempre fala com ela em produção. */
|
|
7
|
+
declare const DEFAULT_BASE_URL = "https://api2.hobots.app";
|
|
8
|
+
interface ResolvedConfig {
|
|
9
|
+
/** Client Secret do projeto (enviado como Authorization: Bearer, nunca na URL) */
|
|
10
|
+
key: string;
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
/** Ingestão do Monitor: <baseUrl>/v1/ingest */
|
|
13
|
+
ingestEndpoint: string;
|
|
14
|
+
/** API do Manager: <baseUrl>/v1/manager */
|
|
15
|
+
managerBaseUrl: string;
|
|
16
|
+
}
|
|
17
|
+
interface ConfigInput {
|
|
18
|
+
clientSecret: string;
|
|
19
|
+
}
|
|
20
|
+
/** Resolve o clientSecret nos endpoints do Monitor e do Manager. */
|
|
21
|
+
declare function resolveConfig(options: ConfigInput, prefix?: string): ResolvedConfig;
|
|
22
|
+
|
|
23
|
+
type BreadcrumbInput = Omit<Breadcrumb, 'timestamp'> & {
|
|
24
|
+
timestamp?: string;
|
|
25
|
+
};
|
|
26
|
+
/** Estado contextual anexado aos eventos: tags, usuário, contexts, extras e breadcrumbs. */
|
|
27
|
+
declare class Scope {
|
|
28
|
+
tags: Record<string, string>;
|
|
29
|
+
user?: EventUser;
|
|
30
|
+
contexts: Record<string, Record<string, unknown>>;
|
|
31
|
+
extra: Record<string, unknown>;
|
|
32
|
+
level?: Severity;
|
|
33
|
+
fingerprint?: string[];
|
|
34
|
+
breadcrumbs: Breadcrumb[];
|
|
35
|
+
setTag(key: string, value: string): this;
|
|
36
|
+
setTags(tags: Record<string, string>): this;
|
|
37
|
+
setUser(user: EventUser | null): this;
|
|
38
|
+
setContext(name: string, context: Record<string, unknown> | null): this;
|
|
39
|
+
setExtra(key: string, value: unknown): this;
|
|
40
|
+
setExtras(extras: Record<string, unknown>): this;
|
|
41
|
+
setLevel(level: Severity): this;
|
|
42
|
+
setFingerprint(fingerprint: string[]): this;
|
|
43
|
+
addBreadcrumb(crumb: BreadcrumbInput, maxBreadcrumbs: number): this;
|
|
44
|
+
clearBreadcrumbs(): this;
|
|
45
|
+
clone(): Scope;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface Logger {
|
|
49
|
+
debug: (...args: unknown[]) => void;
|
|
50
|
+
warn: (...args: unknown[]) => void;
|
|
51
|
+
error: (...args: unknown[]) => void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
declare class Client {
|
|
55
|
+
readonly options: InitOptions;
|
|
56
|
+
readonly config: ResolvedConfig;
|
|
57
|
+
readonly logger: Logger;
|
|
58
|
+
private readonly transport;
|
|
59
|
+
constructor(options: InitOptions);
|
|
60
|
+
captureException(error: unknown, hint: CaptureHint | undefined, scope: Scope): string;
|
|
61
|
+
captureMessage(message: string, level: Severity, hint: CaptureHint | undefined, scope: Scope): string;
|
|
62
|
+
captureEvent(event: EventPayload, hint: CaptureHint | undefined, scope: Scope): string;
|
|
63
|
+
private prepareEvent;
|
|
64
|
+
sendTransaction(payload: TransactionPayload): void;
|
|
65
|
+
sendCheckIn(payload: CheckInPayload): void;
|
|
66
|
+
sendHeartbeat(payload: HeartbeatPayload): void;
|
|
67
|
+
flush(timeoutMs?: number): Promise<boolean>;
|
|
68
|
+
close(timeoutMs?: number): Promise<boolean>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
declare class Span {
|
|
72
|
+
private readonly transaction;
|
|
73
|
+
readonly parentSpanId: string;
|
|
74
|
+
readonly op?: string | undefined;
|
|
75
|
+
readonly description?: string | undefined;
|
|
76
|
+
readonly spanId: string;
|
|
77
|
+
readonly startTimestamp: string;
|
|
78
|
+
status: SpanStatus;
|
|
79
|
+
endTimestamp?: string;
|
|
80
|
+
data?: Record<string, unknown>;
|
|
81
|
+
constructor(transaction: Transaction, parentSpanId: string, op?: string | undefined, description?: string | undefined);
|
|
82
|
+
setStatus(status: SpanStatus): this;
|
|
83
|
+
setData(key: string, value: unknown): this;
|
|
84
|
+
/** Span aninhado (filho deste span). */
|
|
85
|
+
startChild(op?: string, description?: string): Span;
|
|
86
|
+
finish(): void;
|
|
87
|
+
toJSON(): SpanData;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Uma unidade de trabalho nomeada (ex.: uma execução de rotina, uma sincronização).
|
|
91
|
+
* Spans filhos medem as etapas internas (chamadas HTTP, queries, etc.).
|
|
92
|
+
*/
|
|
93
|
+
declare class Transaction {
|
|
94
|
+
private readonly client;
|
|
95
|
+
name: string;
|
|
96
|
+
readonly op?: string | undefined;
|
|
97
|
+
private readonly sampled;
|
|
98
|
+
/** Correlaciona a uma execução do Manager — preenchido automaticamente em ctx.tx */
|
|
99
|
+
private readonly runId?;
|
|
100
|
+
readonly eventId: string;
|
|
101
|
+
readonly spanId: string;
|
|
102
|
+
readonly startTimestamp: string;
|
|
103
|
+
status: string;
|
|
104
|
+
private readonly spans;
|
|
105
|
+
private readonly tags;
|
|
106
|
+
private finished;
|
|
107
|
+
constructor(client: Client | undefined, name: string, op?: string | undefined, sampled?: boolean,
|
|
108
|
+
/** Correlaciona a uma execução do Manager — preenchido automaticamente em ctx.tx */
|
|
109
|
+
runId?: string | undefined);
|
|
110
|
+
createSpan(parentSpanId: string, op?: string, description?: string): Span;
|
|
111
|
+
/** Span direto da transaction. */
|
|
112
|
+
startChild(op?: string, description?: string): Span;
|
|
113
|
+
setTag(key: string, value: string): this;
|
|
114
|
+
setStatus(status: string): this;
|
|
115
|
+
setName(name: string): this;
|
|
116
|
+
finish(): void;
|
|
117
|
+
}
|
|
118
|
+
|
|
6
119
|
/** Opções do Manager dentro de `init({ manager: ... })`. Credencial (clientSecret), identidade (instanceId) e debug vêm do init. */
|
|
7
120
|
interface ManagerOptions {
|
|
8
121
|
/** Intervalo entre polls sem trabalho. Default: 5_000 (mínimo 1_000) */
|
|
@@ -38,6 +151,8 @@ interface ManagerAgentOptions extends ManagerOptions {
|
|
|
38
151
|
instanceId: string;
|
|
39
152
|
/** Loga atividade do SDK no console */
|
|
40
153
|
debug?: boolean;
|
|
154
|
+
/** Client do Monitor compartilhado — usado para enviar a transaction de performance de cada run (ctx.tx) */
|
|
155
|
+
client?: Client;
|
|
41
156
|
}
|
|
42
157
|
interface RunLogger {
|
|
43
158
|
debug(message: string): void;
|
|
@@ -50,6 +165,12 @@ interface RunContext {
|
|
|
50
165
|
task: string;
|
|
51
166
|
/** Log bufferizado — enviado ao servidor em PATCHes incrementais com throttle */
|
|
52
167
|
log: RunLogger;
|
|
168
|
+
/**
|
|
169
|
+
* Transaction de performance desta execução — já correlacionada à run e finalizada
|
|
170
|
+
* automaticamente ao fim do handler. Use `ctx.tx.startChild(op, description)` pra medir
|
|
171
|
+
* as etapas (steps) da task; elas aparecem como waterfall na aba de performance da execução.
|
|
172
|
+
*/
|
|
173
|
+
tx: Transaction;
|
|
53
174
|
/** Dispara em cancelamento (run cancelada no app), timeout ou shutdown — cancelamento cooperativo */
|
|
54
175
|
signal: AbortSignal;
|
|
55
176
|
/**
|
|
@@ -112,115 +233,6 @@ interface CaptureHint {
|
|
|
112
233
|
fingerprint?: string[];
|
|
113
234
|
}
|
|
114
235
|
|
|
115
|
-
/** API oficial da Hobots — o SDK sempre fala com ela em produção. */
|
|
116
|
-
declare const DEFAULT_BASE_URL = "https://api2.hobots.app";
|
|
117
|
-
interface ResolvedConfig {
|
|
118
|
-
/** Client Secret do projeto (enviado como Authorization: Bearer, nunca na URL) */
|
|
119
|
-
key: string;
|
|
120
|
-
baseUrl: string;
|
|
121
|
-
/** Ingestão do Monitor: <baseUrl>/v1/ingest */
|
|
122
|
-
ingestEndpoint: string;
|
|
123
|
-
/** API do Manager: <baseUrl>/v1/manager */
|
|
124
|
-
managerBaseUrl: string;
|
|
125
|
-
}
|
|
126
|
-
interface ConfigInput {
|
|
127
|
-
clientSecret: string;
|
|
128
|
-
}
|
|
129
|
-
/** Resolve o clientSecret nos endpoints do Monitor e do Manager. */
|
|
130
|
-
declare function resolveConfig(options: ConfigInput, prefix?: string): ResolvedConfig;
|
|
131
|
-
|
|
132
|
-
type BreadcrumbInput = Omit<Breadcrumb, 'timestamp'> & {
|
|
133
|
-
timestamp?: string;
|
|
134
|
-
};
|
|
135
|
-
/** Estado contextual anexado aos eventos: tags, usuário, contexts, extras e breadcrumbs. */
|
|
136
|
-
declare class Scope {
|
|
137
|
-
tags: Record<string, string>;
|
|
138
|
-
user?: EventUser;
|
|
139
|
-
contexts: Record<string, Record<string, unknown>>;
|
|
140
|
-
extra: Record<string, unknown>;
|
|
141
|
-
level?: Severity;
|
|
142
|
-
fingerprint?: string[];
|
|
143
|
-
breadcrumbs: Breadcrumb[];
|
|
144
|
-
setTag(key: string, value: string): this;
|
|
145
|
-
setTags(tags: Record<string, string>): this;
|
|
146
|
-
setUser(user: EventUser | null): this;
|
|
147
|
-
setContext(name: string, context: Record<string, unknown> | null): this;
|
|
148
|
-
setExtra(key: string, value: unknown): this;
|
|
149
|
-
setExtras(extras: Record<string, unknown>): this;
|
|
150
|
-
setLevel(level: Severity): this;
|
|
151
|
-
setFingerprint(fingerprint: string[]): this;
|
|
152
|
-
addBreadcrumb(crumb: BreadcrumbInput, maxBreadcrumbs: number): this;
|
|
153
|
-
clearBreadcrumbs(): this;
|
|
154
|
-
clone(): Scope;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
interface Logger {
|
|
158
|
-
debug: (...args: unknown[]) => void;
|
|
159
|
-
warn: (...args: unknown[]) => void;
|
|
160
|
-
error: (...args: unknown[]) => void;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
declare class Client {
|
|
164
|
-
readonly options: InitOptions;
|
|
165
|
-
readonly config: ResolvedConfig;
|
|
166
|
-
readonly logger: Logger;
|
|
167
|
-
private readonly transport;
|
|
168
|
-
constructor(options: InitOptions);
|
|
169
|
-
captureException(error: unknown, hint: CaptureHint | undefined, scope: Scope): string;
|
|
170
|
-
captureMessage(message: string, level: Severity, hint: CaptureHint | undefined, scope: Scope): string;
|
|
171
|
-
captureEvent(event: EventPayload, hint: CaptureHint | undefined, scope: Scope): string;
|
|
172
|
-
private prepareEvent;
|
|
173
|
-
sendTransaction(payload: TransactionPayload): void;
|
|
174
|
-
sendCheckIn(payload: CheckInPayload): void;
|
|
175
|
-
sendHeartbeat(payload: HeartbeatPayload): void;
|
|
176
|
-
flush(timeoutMs?: number): Promise<boolean>;
|
|
177
|
-
close(timeoutMs?: number): Promise<boolean>;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
declare class Span {
|
|
181
|
-
private readonly transaction;
|
|
182
|
-
readonly parentSpanId: string;
|
|
183
|
-
readonly op?: string | undefined;
|
|
184
|
-
readonly description?: string | undefined;
|
|
185
|
-
readonly spanId: string;
|
|
186
|
-
readonly startTimestamp: string;
|
|
187
|
-
status: string;
|
|
188
|
-
endTimestamp?: string;
|
|
189
|
-
data?: Record<string, unknown>;
|
|
190
|
-
constructor(transaction: Transaction, parentSpanId: string, op?: string | undefined, description?: string | undefined);
|
|
191
|
-
setStatus(status: string): this;
|
|
192
|
-
setData(key: string, value: unknown): this;
|
|
193
|
-
/** Span aninhado (filho deste span). */
|
|
194
|
-
startChild(op?: string, description?: string): Span;
|
|
195
|
-
finish(): void;
|
|
196
|
-
toJSON(): SpanData;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Uma unidade de trabalho nomeada (ex.: uma execução de rotina, uma sincronização).
|
|
200
|
-
* Spans filhos medem as etapas internas (chamadas HTTP, queries, etc.).
|
|
201
|
-
*/
|
|
202
|
-
declare class Transaction {
|
|
203
|
-
private readonly client;
|
|
204
|
-
name: string;
|
|
205
|
-
readonly op?: string | undefined;
|
|
206
|
-
private readonly sampled;
|
|
207
|
-
readonly eventId: string;
|
|
208
|
-
readonly spanId: string;
|
|
209
|
-
readonly startTimestamp: string;
|
|
210
|
-
status: string;
|
|
211
|
-
private readonly spans;
|
|
212
|
-
private readonly tags;
|
|
213
|
-
private finished;
|
|
214
|
-
constructor(client: Client | undefined, name: string, op?: string | undefined, sampled?: boolean);
|
|
215
|
-
createSpan(parentSpanId: string, op?: string, description?: string): Span;
|
|
216
|
-
/** Span direto da transaction. */
|
|
217
|
-
startChild(op?: string, description?: string): Span;
|
|
218
|
-
setTag(key: string, value: string): this;
|
|
219
|
-
setStatus(status: string): this;
|
|
220
|
-
setName(name: string): this;
|
|
221
|
-
finish(): void;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
236
|
interface CheckInOptions {
|
|
225
237
|
monitorSlug: string;
|
|
226
238
|
status: CheckInStatus;
|
|
@@ -284,6 +296,7 @@ declare class ManagerAgent {
|
|
|
284
296
|
private readonly registry;
|
|
285
297
|
readonly logger: Logger;
|
|
286
298
|
private readonly api;
|
|
299
|
+
private readonly client;
|
|
287
300
|
private readonly pollIntervalMs;
|
|
288
301
|
private readonly concurrency;
|
|
289
302
|
private readonly instanceId;
|