hobots 1.7.5 → 1.7.6
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 +12 -12
- package/dist/index.cjs +26 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -19
- package/dist/index.d.ts +19 -19
- package/dist/index.js +26 -26
- package/dist/index.js.map +1 -1
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +9 -9
- package/dist/protocol.d.ts +9 -9
- package/docs/README.md +3 -3
- package/docs/api-reference.md +5 -5
- package/docs/concepts.md +19 -19
- package/docs/monitor.md +10 -10
- package/docs/tasks.md +6 -6
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Breadcrumb, EventUser, Severity, EventPayload, TransactionPayload, CheckInPayload, HeartbeatPayload,
|
|
1
|
+
import { Breadcrumb, EventUser, Severity, EventPayload, TransactionPayload, CheckInPayload, HeartbeatPayload, StepStatus, RunLogLevel, StepData, CheckInStatus } from './protocol.cjs';
|
|
2
2
|
export { AgentInfo, Envelope, EnvelopeItem, ExceptionData, PollRequest, PollResponse, RunDescriptor, RunError, RunLogEntry, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame } from './protocol.cjs';
|
|
3
3
|
|
|
4
4
|
/** API oficial da Hobots — o SDK sempre fala com ela em produção. */
|
|
@@ -66,27 +66,27 @@ declare class Client {
|
|
|
66
66
|
|
|
67
67
|
/** Recebe os eventos de lifecycle da transaction para espelhá-los nos logs da run. */
|
|
68
68
|
type LifecycleSink = (level: RunLogLevel, message: string) => void;
|
|
69
|
-
declare class
|
|
69
|
+
declare class Step {
|
|
70
70
|
private readonly transaction;
|
|
71
|
-
readonly
|
|
71
|
+
readonly parentStepId: string;
|
|
72
72
|
readonly op?: string | undefined;
|
|
73
73
|
readonly description?: string | undefined;
|
|
74
|
-
readonly
|
|
74
|
+
readonly stepId: string;
|
|
75
75
|
readonly startTimestamp: string;
|
|
76
|
-
status:
|
|
76
|
+
status: StepStatus;
|
|
77
77
|
endTimestamp?: string;
|
|
78
78
|
data?: Record<string, unknown>;
|
|
79
|
-
constructor(transaction: Transaction,
|
|
80
|
-
setStatus(status:
|
|
79
|
+
constructor(transaction: Transaction, parentStepId: string, op?: string | undefined, description?: string | undefined);
|
|
80
|
+
setStatus(status: StepStatus): this;
|
|
81
81
|
setData(key: string, value: unknown): this;
|
|
82
|
-
/**
|
|
83
|
-
startChild(op?: string, description?: string):
|
|
82
|
+
/** Step aninhada (filha desta step). */
|
|
83
|
+
startChild(op?: string, description?: string): Step;
|
|
84
84
|
finish(): void;
|
|
85
|
-
toJSON():
|
|
85
|
+
toJSON(): StepData;
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
* Uma unidade de trabalho nomeada (ex.: uma execução de rotina, uma sincronização).
|
|
89
|
-
*
|
|
89
|
+
* Steps filhas medem as etapas internas (chamadas HTTP, queries, etc.).
|
|
90
90
|
*/
|
|
91
91
|
declare class Transaction {
|
|
92
92
|
private readonly client;
|
|
@@ -96,10 +96,10 @@ declare class Transaction {
|
|
|
96
96
|
/** Correlaciona a uma execução de task — preenchido automaticamente em ctx.tx */
|
|
97
97
|
private readonly runId?;
|
|
98
98
|
readonly eventId: string;
|
|
99
|
-
readonly
|
|
99
|
+
readonly stepId: string;
|
|
100
100
|
readonly startTimestamp: string;
|
|
101
101
|
status: string;
|
|
102
|
-
private readonly
|
|
102
|
+
private readonly steps;
|
|
103
103
|
private readonly tags;
|
|
104
104
|
private finished;
|
|
105
105
|
private lifecycleSink?;
|
|
@@ -108,16 +108,16 @@ declare class Transaction {
|
|
|
108
108
|
/** Correlaciona a uma execução de task — preenchido automaticamente em ctx.tx */
|
|
109
109
|
runId?: string | undefined);
|
|
110
110
|
/**
|
|
111
|
-
* Ecoa no terminal o início/fim de
|
|
111
|
+
* Ecoa no terminal o início/fim de uma step ou transaction (sempre, independente de
|
|
112
112
|
* sampling ou do debug) e espelha a linha no sink de lifecycle, se conectado — é
|
|
113
113
|
* assim que os eventos de performance também aparecem nos logs da run no app.
|
|
114
114
|
*/
|
|
115
|
-
emit(kind: 'transaction' | '
|
|
115
|
+
emit(kind: 'transaction' | 'step', phase: 'start' | 'finish', label: string, startTs?: string, endTs?: string, status?: StepStatus | string): void;
|
|
116
116
|
/** Conecta o espelho de lifecycle (RunReporter) e faz replay do backlog em ordem. */
|
|
117
117
|
setLifecycleSink(sink: LifecycleSink): void;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
startChild(op?: string, description?: string):
|
|
118
|
+
createStep(parentStepId: string, op?: string, description?: string): Step;
|
|
119
|
+
/** Step direta da transaction. */
|
|
120
|
+
startChild(op?: string, description?: string): Step;
|
|
121
121
|
setTag(key: string, value: string): this;
|
|
122
122
|
setStatus(status: string): this;
|
|
123
123
|
setName(name: string): this;
|
|
@@ -284,4 +284,4 @@ declare function close(timeoutMs?: number): Promise<boolean>;
|
|
|
284
284
|
|
|
285
285
|
declare function scrubSecrets(text: string): string;
|
|
286
286
|
|
|
287
|
-
export { Breadcrumb, type BreadcrumbInput, type CaptureHint, type CheckInOptions, CheckInPayload, CheckInStatus, Client, DEFAULT_BASE_URL, EventPayload, EventUser, type HeartbeatOptions, HeartbeatPayload, type InitOptions, type RunContext, RunLogLevel, Scope, Severity,
|
|
287
|
+
export { Breadcrumb, type BreadcrumbInput, type CaptureHint, type CheckInOptions, CheckInPayload, CheckInStatus, Client, DEFAULT_BASE_URL, EventPayload, EventUser, type HeartbeatOptions, HeartbeatPayload, type InitOptions, type RunContext, RunLogLevel, Scope, Severity, Step, StepData, type TaskHandler, type TasksOptions, Transaction, TransactionPayload, type WithMonitorOptions, addBreadcrumb, captureException, captureMessage, checkIn, close, flush, getClient, init, register, scrubSecrets, setContext, setExtra, setTag, setTags, setUser, start, startTransaction, stop, withMonitor, withScope };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Breadcrumb, EventUser, Severity, EventPayload, TransactionPayload, CheckInPayload, HeartbeatPayload,
|
|
1
|
+
import { Breadcrumb, EventUser, Severity, EventPayload, TransactionPayload, CheckInPayload, HeartbeatPayload, StepStatus, RunLogLevel, StepData, CheckInStatus } from './protocol.js';
|
|
2
2
|
export { AgentInfo, Envelope, EnvelopeItem, ExceptionData, PollRequest, PollResponse, RunDescriptor, RunError, RunLogEntry, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame } from './protocol.js';
|
|
3
3
|
|
|
4
4
|
/** API oficial da Hobots — o SDK sempre fala com ela em produção. */
|
|
@@ -66,27 +66,27 @@ declare class Client {
|
|
|
66
66
|
|
|
67
67
|
/** Recebe os eventos de lifecycle da transaction para espelhá-los nos logs da run. */
|
|
68
68
|
type LifecycleSink = (level: RunLogLevel, message: string) => void;
|
|
69
|
-
declare class
|
|
69
|
+
declare class Step {
|
|
70
70
|
private readonly transaction;
|
|
71
|
-
readonly
|
|
71
|
+
readonly parentStepId: string;
|
|
72
72
|
readonly op?: string | undefined;
|
|
73
73
|
readonly description?: string | undefined;
|
|
74
|
-
readonly
|
|
74
|
+
readonly stepId: string;
|
|
75
75
|
readonly startTimestamp: string;
|
|
76
|
-
status:
|
|
76
|
+
status: StepStatus;
|
|
77
77
|
endTimestamp?: string;
|
|
78
78
|
data?: Record<string, unknown>;
|
|
79
|
-
constructor(transaction: Transaction,
|
|
80
|
-
setStatus(status:
|
|
79
|
+
constructor(transaction: Transaction, parentStepId: string, op?: string | undefined, description?: string | undefined);
|
|
80
|
+
setStatus(status: StepStatus): this;
|
|
81
81
|
setData(key: string, value: unknown): this;
|
|
82
|
-
/**
|
|
83
|
-
startChild(op?: string, description?: string):
|
|
82
|
+
/** Step aninhada (filha desta step). */
|
|
83
|
+
startChild(op?: string, description?: string): Step;
|
|
84
84
|
finish(): void;
|
|
85
|
-
toJSON():
|
|
85
|
+
toJSON(): StepData;
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
* Uma unidade de trabalho nomeada (ex.: uma execução de rotina, uma sincronização).
|
|
89
|
-
*
|
|
89
|
+
* Steps filhas medem as etapas internas (chamadas HTTP, queries, etc.).
|
|
90
90
|
*/
|
|
91
91
|
declare class Transaction {
|
|
92
92
|
private readonly client;
|
|
@@ -96,10 +96,10 @@ declare class Transaction {
|
|
|
96
96
|
/** Correlaciona a uma execução de task — preenchido automaticamente em ctx.tx */
|
|
97
97
|
private readonly runId?;
|
|
98
98
|
readonly eventId: string;
|
|
99
|
-
readonly
|
|
99
|
+
readonly stepId: string;
|
|
100
100
|
readonly startTimestamp: string;
|
|
101
101
|
status: string;
|
|
102
|
-
private readonly
|
|
102
|
+
private readonly steps;
|
|
103
103
|
private readonly tags;
|
|
104
104
|
private finished;
|
|
105
105
|
private lifecycleSink?;
|
|
@@ -108,16 +108,16 @@ declare class Transaction {
|
|
|
108
108
|
/** Correlaciona a uma execução de task — preenchido automaticamente em ctx.tx */
|
|
109
109
|
runId?: string | undefined);
|
|
110
110
|
/**
|
|
111
|
-
* Ecoa no terminal o início/fim de
|
|
111
|
+
* Ecoa no terminal o início/fim de uma step ou transaction (sempre, independente de
|
|
112
112
|
* sampling ou do debug) e espelha a linha no sink de lifecycle, se conectado — é
|
|
113
113
|
* assim que os eventos de performance também aparecem nos logs da run no app.
|
|
114
114
|
*/
|
|
115
|
-
emit(kind: 'transaction' | '
|
|
115
|
+
emit(kind: 'transaction' | 'step', phase: 'start' | 'finish', label: string, startTs?: string, endTs?: string, status?: StepStatus | string): void;
|
|
116
116
|
/** Conecta o espelho de lifecycle (RunReporter) e faz replay do backlog em ordem. */
|
|
117
117
|
setLifecycleSink(sink: LifecycleSink): void;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
startChild(op?: string, description?: string):
|
|
118
|
+
createStep(parentStepId: string, op?: string, description?: string): Step;
|
|
119
|
+
/** Step direta da transaction. */
|
|
120
|
+
startChild(op?: string, description?: string): Step;
|
|
121
121
|
setTag(key: string, value: string): this;
|
|
122
122
|
setStatus(status: string): this;
|
|
123
123
|
setName(name: string): this;
|
|
@@ -284,4 +284,4 @@ declare function close(timeoutMs?: number): Promise<boolean>;
|
|
|
284
284
|
|
|
285
285
|
declare function scrubSecrets(text: string): string;
|
|
286
286
|
|
|
287
|
-
export { Breadcrumb, type BreadcrumbInput, type CaptureHint, type CheckInOptions, CheckInPayload, CheckInStatus, Client, DEFAULT_BASE_URL, EventPayload, EventUser, type HeartbeatOptions, HeartbeatPayload, type InitOptions, type RunContext, RunLogLevel, Scope, Severity,
|
|
287
|
+
export { Breadcrumb, type BreadcrumbInput, type CaptureHint, type CheckInOptions, CheckInPayload, CheckInStatus, Client, DEFAULT_BASE_URL, EventPayload, EventUser, type HeartbeatOptions, HeartbeatPayload, type InitOptions, type RunContext, RunLogLevel, Scope, Severity, Step, StepData, type TaskHandler, type TasksOptions, Transaction, TransactionPayload, type WithMonitorOptions, addBreadcrumb, captureException, captureMessage, checkIn, close, flush, getClient, init, register, scrubSecrets, setContext, setExtra, setTag, setTags, setUser, start, startTransaction, stop, withMonitor, withScope };
|
package/dist/index.js
CHANGED
|
@@ -103,7 +103,7 @@ function scrubSecrets(text) {
|
|
|
103
103
|
|
|
104
104
|
// src/utils.ts
|
|
105
105
|
var SDK_NAME = "hobots";
|
|
106
|
-
var SDK_VERSION = true ? "1.7.
|
|
106
|
+
var SDK_VERSION = true ? "1.7.6" : "0.0.0-dev";
|
|
107
107
|
function isNode() {
|
|
108
108
|
return typeof process !== "undefined" && typeof process.versions?.node === "string";
|
|
109
109
|
}
|
|
@@ -659,10 +659,10 @@ var Scope = class _Scope {
|
|
|
659
659
|
};
|
|
660
660
|
|
|
661
661
|
// src/transaction.ts
|
|
662
|
-
function
|
|
662
|
+
function stepId() {
|
|
663
663
|
return uuid4().slice(0, 16);
|
|
664
664
|
}
|
|
665
|
-
function
|
|
665
|
+
function stepLabel(op, description) {
|
|
666
666
|
return [op, description].filter(Boolean).join(" \u2014 ") || "(sem nome)";
|
|
667
667
|
}
|
|
668
668
|
function levelForStatus(status) {
|
|
@@ -689,14 +689,14 @@ function colorForStatus(status) {
|
|
|
689
689
|
return "green";
|
|
690
690
|
}
|
|
691
691
|
}
|
|
692
|
-
var
|
|
693
|
-
constructor(transaction,
|
|
692
|
+
var Step = class {
|
|
693
|
+
constructor(transaction, parentStepId, op, description) {
|
|
694
694
|
this.transaction = transaction;
|
|
695
|
-
this.
|
|
695
|
+
this.parentStepId = parentStepId;
|
|
696
696
|
this.op = op;
|
|
697
697
|
this.description = description;
|
|
698
698
|
}
|
|
699
|
-
|
|
699
|
+
stepId = stepId();
|
|
700
700
|
startTimestamp = nowISO();
|
|
701
701
|
status = "ok";
|
|
702
702
|
endTimestamp;
|
|
@@ -709,17 +709,17 @@ var Span = class {
|
|
|
709
709
|
this.data = { ...this.data, [key]: value };
|
|
710
710
|
return this;
|
|
711
711
|
}
|
|
712
|
-
/**
|
|
712
|
+
/** Step aninhada (filha desta step). */
|
|
713
713
|
startChild(op, description) {
|
|
714
|
-
return this.transaction.
|
|
714
|
+
return this.transaction.createStep(this.stepId, op, description);
|
|
715
715
|
}
|
|
716
716
|
finish() {
|
|
717
717
|
if (this.endTimestamp) return;
|
|
718
718
|
this.endTimestamp = nowISO();
|
|
719
719
|
this.transaction.emit(
|
|
720
|
-
"
|
|
720
|
+
"step",
|
|
721
721
|
"finish",
|
|
722
|
-
|
|
722
|
+
stepLabel(this.op, this.description),
|
|
723
723
|
this.startTimestamp,
|
|
724
724
|
this.endTimestamp,
|
|
725
725
|
this.status
|
|
@@ -727,8 +727,8 @@ var Span = class {
|
|
|
727
727
|
}
|
|
728
728
|
toJSON() {
|
|
729
729
|
return {
|
|
730
|
-
|
|
731
|
-
|
|
730
|
+
step_id: this.stepId,
|
|
731
|
+
parent_step_id: this.parentStepId,
|
|
732
732
|
op: this.op,
|
|
733
733
|
description: this.description,
|
|
734
734
|
status: this.status,
|
|
@@ -748,10 +748,10 @@ var Transaction = class {
|
|
|
748
748
|
this.emit("transaction", "start", op ? `${name} (${op})` : name);
|
|
749
749
|
}
|
|
750
750
|
eventId = uuid4();
|
|
751
|
-
|
|
751
|
+
stepId = stepId();
|
|
752
752
|
startTimestamp = nowISO();
|
|
753
753
|
status = "ok";
|
|
754
|
-
|
|
754
|
+
steps = [];
|
|
755
755
|
tags = {};
|
|
756
756
|
finished = false;
|
|
757
757
|
lifecycleSink;
|
|
@@ -759,7 +759,7 @@ var Transaction = class {
|
|
|
759
759
|
// antes do RunReporter conectar) — replay no setLifecycleSink
|
|
760
760
|
lifecycleBacklog = [];
|
|
761
761
|
/**
|
|
762
|
-
* Ecoa no terminal o início/fim de
|
|
762
|
+
* Ecoa no terminal o início/fim de uma step ou transaction (sempre, independente de
|
|
763
763
|
* sampling ou do debug) e espelha a linha no sink de lifecycle, se conectado — é
|
|
764
764
|
* assim que os eventos de performance também aparecem nos logs da run no app.
|
|
765
765
|
*/
|
|
@@ -780,15 +780,15 @@ var Transaction = class {
|
|
|
780
780
|
this.lifecycleBacklog = [];
|
|
781
781
|
for (const [level, message] of backlog) sink(level, message);
|
|
782
782
|
}
|
|
783
|
-
|
|
784
|
-
const
|
|
785
|
-
this.
|
|
786
|
-
this.emit("
|
|
787
|
-
return
|
|
783
|
+
createStep(parentStepId, op, description) {
|
|
784
|
+
const step = new Step(this, parentStepId, op, description);
|
|
785
|
+
this.steps.push(step);
|
|
786
|
+
this.emit("step", "start", stepLabel(op, description));
|
|
787
|
+
return step;
|
|
788
788
|
}
|
|
789
|
-
/**
|
|
789
|
+
/** Step direta da transaction. */
|
|
790
790
|
startChild(op, description) {
|
|
791
|
-
return this.
|
|
791
|
+
return this.createStep(this.stepId, op, description);
|
|
792
792
|
}
|
|
793
793
|
setTag(key, value) {
|
|
794
794
|
this.tags[key] = value;
|
|
@@ -805,7 +805,7 @@ var Transaction = class {
|
|
|
805
805
|
finish() {
|
|
806
806
|
if (this.finished) return;
|
|
807
807
|
this.finished = true;
|
|
808
|
-
for (const
|
|
808
|
+
for (const step of this.steps) step.finish();
|
|
809
809
|
const endTimestamp = nowISO();
|
|
810
810
|
this.emit(
|
|
811
811
|
"transaction",
|
|
@@ -823,7 +823,7 @@ var Transaction = class {
|
|
|
823
823
|
status: this.status,
|
|
824
824
|
start_timestamp: this.startTimestamp,
|
|
825
825
|
timestamp: endTimestamp,
|
|
826
|
-
|
|
826
|
+
steps: this.steps.map((step) => step.toJSON()),
|
|
827
827
|
tags: Object.keys(this.tags).length > 0 ? this.tags : void 0,
|
|
828
828
|
run_id: this.runId
|
|
829
829
|
};
|
|
@@ -1654,7 +1654,7 @@ export {
|
|
|
1654
1654
|
Client,
|
|
1655
1655
|
DEFAULT_BASE_URL,
|
|
1656
1656
|
Scope,
|
|
1657
|
-
|
|
1657
|
+
Step,
|
|
1658
1658
|
Transaction,
|
|
1659
1659
|
addBreadcrumb,
|
|
1660
1660
|
captureException,
|