@thesight/sdk 0.1.0 → 0.1.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/dist/index.cjs +366 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +194 -0
- package/dist/index.d.ts +115 -13
- package/dist/index.js +335 -167
- package/dist/index.js.map +1 -1
- package/package.json +8 -6
- package/dist/exporter.d.ts +0 -43
- package/dist/exporter.d.ts.map +0 -1
- package/dist/exporter.js +0 -151
- package/dist/exporter.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/init.d.ts +0 -62
- package/dist/init.d.ts.map +0 -1
- package/dist/init.js +0 -78
- package/dist/init.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thesight/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Sight SDK — OpenTelemetry-native observability for Solana. One call (initSight) wires a NodeTracerProvider + Sight exporter, then InstrumentedConnection turns every transaction into a span with per-CPI compute-unit attribution, decoded Anchor errors, and wallet-to-program correlation.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/index.
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
7
8
|
"types": "./dist/index.d.ts",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
10
12
|
"import": "./dist/index.js",
|
|
11
|
-
"
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
12
14
|
}
|
|
13
15
|
},
|
|
14
16
|
"files": [
|
|
@@ -36,7 +38,7 @@
|
|
|
36
38
|
"access": "public"
|
|
37
39
|
},
|
|
38
40
|
"dependencies": {
|
|
39
|
-
"@thesight/core": "^0.1.
|
|
41
|
+
"@thesight/core": "^0.1.1",
|
|
40
42
|
"@solana/web3.js": "^1.95.0",
|
|
41
43
|
"@opentelemetry/api": "^1.8.0",
|
|
42
44
|
"@opentelemetry/core": "^1.24.0",
|
|
@@ -46,8 +48,8 @@
|
|
|
46
48
|
"@opentelemetry/semantic-conventions": "^1.24.0"
|
|
47
49
|
},
|
|
48
50
|
"scripts": {
|
|
49
|
-
"build": "
|
|
51
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --clean --sourcemap --target node20",
|
|
50
52
|
"test": "vitest run",
|
|
51
|
-
"dev": "
|
|
53
|
+
"dev": "tsup src/index.ts --format esm,cjs --dts --watch --sourcemap --target node20"
|
|
52
54
|
}
|
|
53
55
|
}
|
package/dist/exporter.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
2
|
-
import { type ExportResult } from '@opentelemetry/core';
|
|
3
|
-
export interface SightExporterConfig {
|
|
4
|
-
/** Project API key (`sk_live_...`). Sent as Bearer auth on every POST. */
|
|
5
|
-
apiKey: string;
|
|
6
|
-
/**
|
|
7
|
-
* Full ingest URL including the path (e.g. `https://ingest.thesight.dev/ingest`
|
|
8
|
-
* or `http://localhost:3001/ingest` for local dev).
|
|
9
|
-
*/
|
|
10
|
-
ingestUrl: string;
|
|
11
|
-
/** Inject a fake fetch in tests. Defaults to `globalThis.fetch`. */
|
|
12
|
-
fetchImpl?: typeof fetch;
|
|
13
|
-
/** Max spans per POST. Ingest enforces an upper bound of 100. */
|
|
14
|
-
maxBatchSize?: number;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* An OTel `SpanExporter` that translates OTel spans to Sight's custom
|
|
18
|
-
* ingest payload shape and POSTs them to `/ingest`.
|
|
19
|
-
*
|
|
20
|
-
* Each span becomes one object in the `spans` array. Solana-specific
|
|
21
|
-
* attributes flow through as-is (the set that `InstrumentedConnection`
|
|
22
|
-
* already populates — `solana.tx.signature`, `solana.tx.cu_used`,
|
|
23
|
-
* `solana.tx.program`, etc). The exporter intentionally does not attempt
|
|
24
|
-
* to translate span events or links — the ingest schema doesn't have
|
|
25
|
-
* slots for those, and we prefer dropping silently over guessing.
|
|
26
|
-
*
|
|
27
|
-
* The BatchSpanProcessor upstream handles retries, timeouts, and batching;
|
|
28
|
-
* this exporter stays a thin wire-format translator.
|
|
29
|
-
*/
|
|
30
|
-
export declare class SightSpanExporter implements SpanExporter {
|
|
31
|
-
private readonly apiKey;
|
|
32
|
-
private readonly ingestUrl;
|
|
33
|
-
private readonly fetchImpl;
|
|
34
|
-
private readonly maxBatchSize;
|
|
35
|
-
private shuttingDown;
|
|
36
|
-
constructor(config: SightExporterConfig);
|
|
37
|
-
export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): Promise<void>;
|
|
38
|
-
shutdown(): Promise<void>;
|
|
39
|
-
forceFlush(): Promise<void>;
|
|
40
|
-
private sendChunk;
|
|
41
|
-
private convertSpan;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=exporter.d.ts.map
|
package/dist/exporter.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exporter.d.ts","sourceRoot":"","sources":["../src/exporter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,qBAAqB,CAAC;AAI7B,MAAM,WAAW,mBAAmB;IAClC,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAID;;;;;;;;;;;;;GAaG;AACH,qBAAa,iBAAkB,YAAW,YAAY;IACpD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAC5C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,YAAY,CAAS;gBAEjB,MAAM,EAAE,mBAAmB;IAiBjC,MAAM,CACV,KAAK,EAAW,YAAY,EAAE,EAC9B,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,GAC7C,OAAO,CAAC,IAAI,CAAC;IA2BV,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;YAOnB,SAAS;IAsBvB,OAAO,CAAC,WAAW;CAuCpB"}
|
package/dist/exporter.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { hrTimeToMilliseconds, ExportResultCode, } from '@opentelemetry/core';
|
|
2
|
-
// ─── Exporter ────────────────────────────────────────────────────────────────
|
|
3
|
-
/**
|
|
4
|
-
* An OTel `SpanExporter` that translates OTel spans to Sight's custom
|
|
5
|
-
* ingest payload shape and POSTs them to `/ingest`.
|
|
6
|
-
*
|
|
7
|
-
* Each span becomes one object in the `spans` array. Solana-specific
|
|
8
|
-
* attributes flow through as-is (the set that `InstrumentedConnection`
|
|
9
|
-
* already populates — `solana.tx.signature`, `solana.tx.cu_used`,
|
|
10
|
-
* `solana.tx.program`, etc). The exporter intentionally does not attempt
|
|
11
|
-
* to translate span events or links — the ingest schema doesn't have
|
|
12
|
-
* slots for those, and we prefer dropping silently over guessing.
|
|
13
|
-
*
|
|
14
|
-
* The BatchSpanProcessor upstream handles retries, timeouts, and batching;
|
|
15
|
-
* this exporter stays a thin wire-format translator.
|
|
16
|
-
*/
|
|
17
|
-
export class SightSpanExporter {
|
|
18
|
-
apiKey;
|
|
19
|
-
ingestUrl;
|
|
20
|
-
fetchImpl;
|
|
21
|
-
maxBatchSize;
|
|
22
|
-
shuttingDown = false;
|
|
23
|
-
constructor(config) {
|
|
24
|
-
this.apiKey = config.apiKey;
|
|
25
|
-
this.ingestUrl = config.ingestUrl;
|
|
26
|
-
this.fetchImpl = config.fetchImpl ?? globalThis.fetch;
|
|
27
|
-
// Ingest's IngestPayload schema caps at 100 spans per POST. Allow
|
|
28
|
-
// operators to lower the batch size for tighter latency, but never
|
|
29
|
-
// raise it above the server's limit.
|
|
30
|
-
this.maxBatchSize = Math.min(100, config.maxBatchSize ?? 100);
|
|
31
|
-
if (!this.fetchImpl) {
|
|
32
|
-
throw new Error('SightSpanExporter: globalThis.fetch is not available. Node >= 18 ships ' +
|
|
33
|
-
'with fetch built in, or pass `fetchImpl` explicitly.');
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
async export(spans, resultCallback) {
|
|
37
|
-
if (this.shuttingDown) {
|
|
38
|
-
resultCallback({ code: ExportResultCode.FAILED, error: new Error('Exporter is shut down') });
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
// Split into chunks if the upstream processor handed us a larger
|
|
42
|
-
// batch than ingest will accept. Uncommon with a well-configured
|
|
43
|
-
// BatchSpanProcessor but cheap to handle defensively.
|
|
44
|
-
const chunks = [];
|
|
45
|
-
for (let i = 0; i < spans.length; i += this.maxBatchSize) {
|
|
46
|
-
chunks.push(spans.slice(i, i + this.maxBatchSize));
|
|
47
|
-
}
|
|
48
|
-
try {
|
|
49
|
-
for (const chunk of chunks) {
|
|
50
|
-
await this.sendChunk(chunk);
|
|
51
|
-
}
|
|
52
|
-
resultCallback({ code: ExportResultCode.SUCCESS });
|
|
53
|
-
}
|
|
54
|
-
catch (err) {
|
|
55
|
-
resultCallback({
|
|
56
|
-
code: ExportResultCode.FAILED,
|
|
57
|
-
error: err instanceof Error ? err : new Error(String(err)),
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async shutdown() {
|
|
62
|
-
this.shuttingDown = true;
|
|
63
|
-
}
|
|
64
|
-
async forceFlush() {
|
|
65
|
-
// The exporter is stateless — BatchSpanProcessor's own forceFlush
|
|
66
|
-
// drains the queue before calling export(). Nothing to do here.
|
|
67
|
-
}
|
|
68
|
-
// ─── Internal ──────────────────────────────────────────────────────────────
|
|
69
|
-
async sendChunk(spans) {
|
|
70
|
-
const payload = {
|
|
71
|
-
spans: spans.map((span) => this.convertSpan(span)),
|
|
72
|
-
};
|
|
73
|
-
const response = await this.fetchImpl(this.ingestUrl, {
|
|
74
|
-
method: 'POST',
|
|
75
|
-
headers: {
|
|
76
|
-
'Content-Type': 'application/json',
|
|
77
|
-
'Authorization': `Bearer ${this.apiKey}`,
|
|
78
|
-
},
|
|
79
|
-
body: JSON.stringify(payload),
|
|
80
|
-
});
|
|
81
|
-
if (!response.ok) {
|
|
82
|
-
const body = await safeReadText(response);
|
|
83
|
-
throw new Error(`Sight ingest returned ${response.status} ${response.statusText}: ${body}`);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
convertSpan(span) {
|
|
87
|
-
const attr = span.attributes;
|
|
88
|
-
const resource = span.resource.attributes;
|
|
89
|
-
const serviceName = typeof resource['service.name'] === 'string'
|
|
90
|
-
? resource['service.name']
|
|
91
|
-
: undefined;
|
|
92
|
-
const startTimeMs = hrTimeToMilliseconds(span.startTime);
|
|
93
|
-
const endTimeMs = hrTimeToMilliseconds(span.endTime);
|
|
94
|
-
const durationMs = Math.max(0, endTimeMs - startTimeMs);
|
|
95
|
-
const out = {
|
|
96
|
-
traceId: span.spanContext().traceId,
|
|
97
|
-
spanId: span.spanContext().spanId,
|
|
98
|
-
spanName: span.name,
|
|
99
|
-
startTimeMs,
|
|
100
|
-
durationMs,
|
|
101
|
-
};
|
|
102
|
-
const parentSpanId = span.parentSpanId;
|
|
103
|
-
if (parentSpanId)
|
|
104
|
-
out.parentSpanId = parentSpanId;
|
|
105
|
-
if (serviceName)
|
|
106
|
-
out.serviceName = serviceName;
|
|
107
|
-
copyIfString(attr, 'solana.tx.signature', out);
|
|
108
|
-
copyIfEnum(attr, 'solana.tx.status', out, ['confirmed', 'failed', 'timeout']);
|
|
109
|
-
copyIfNumber(attr, 'solana.tx.slot', out);
|
|
110
|
-
copyIfNumber(attr, 'solana.tx.cu_used', out);
|
|
111
|
-
copyIfNumber(attr, 'solana.tx.cu_budget', out);
|
|
112
|
-
copyIfNumber(attr, 'solana.tx.cu_utilization', out);
|
|
113
|
-
copyIfString(attr, 'solana.tx.program', out);
|
|
114
|
-
copyIfString(attr, 'solana.tx.instruction', out);
|
|
115
|
-
copyIfString(attr, 'solana.tx.error', out);
|
|
116
|
-
copyIfNumber(attr, 'solana.tx.error_code', out);
|
|
117
|
-
copyIfString(attr, 'solana.tx.error_program', out);
|
|
118
|
-
copyIfNumber(attr, 'solana.tx.submit_ms', out);
|
|
119
|
-
copyIfNumber(attr, 'solana.tx.confirmation_ms', out);
|
|
120
|
-
copyIfNumber(attr, 'solana.tx.fee_lamports', out);
|
|
121
|
-
return out;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
// ─── Helpers ────────────────────────────────────────────────────────────────
|
|
125
|
-
function copyIfString(attr, key, out) {
|
|
126
|
-
const v = attr[key];
|
|
127
|
-
if (typeof v === 'string') {
|
|
128
|
-
out[key] = v;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
function copyIfNumber(attr, key, out) {
|
|
132
|
-
const v = attr[key];
|
|
133
|
-
if (typeof v === 'number' && Number.isFinite(v)) {
|
|
134
|
-
out[key] = v;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
function copyIfEnum(attr, key, out, allowed) {
|
|
138
|
-
const v = attr[key];
|
|
139
|
-
if (typeof v === 'string' && allowed.includes(v)) {
|
|
140
|
-
out[key] = v;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
async function safeReadText(res) {
|
|
144
|
-
try {
|
|
145
|
-
return (await res.text()).slice(0, 500);
|
|
146
|
-
}
|
|
147
|
-
catch {
|
|
148
|
-
return '<no body>';
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
//# sourceMappingURL=exporter.js.map
|
package/dist/exporter.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exporter.js","sourceRoot":"","sources":["../src/exporter.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,gBAAgB,GAEjB,MAAM,qBAAqB,CAAC;AAkB7B,gFAAgF;AAEhF;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,iBAAiB;IACX,MAAM,CAAe;IACrB,SAAS,CAAY;IACrB,SAAS,CAAkB;IAC3B,YAAY,CAAS;IAC9B,YAAY,GAAG,KAAK,CAAC;IAE7B,YAAY,MAA2B;QACrC,IAAI,CAAC,MAAM,GAAM,MAAM,CAAC,MAAM,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,IAAK,UAAU,CAAC,KAAsB,CAAC;QACxE,kEAAkE;QAClE,mEAAmE;QACnE,qCAAqC;QACrC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,YAAY,IAAI,GAAG,CAAC,CAAC;QAE9D,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACb,yEAAyE;gBACvE,sDAAsD,CACzD,CAAC;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,MAAM,CACV,KAA8B,EAC9B,cAA8C;QAE9C,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,cAAc,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;YAC7F,OAAO;QACT,CAAC;QAED,iEAAiE;QACjE,iEAAiE;QACjE,sDAAsD;QACtD,MAAM,MAAM,GAAqB,EAAE,CAAC;QACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,C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,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,IAAI;IAIpD,mCAAmC;IACnC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI;IAInD;;;OAGG;IACG,0BAA0B,CAC9B,WAAW,EAAE,WAAW,GAAG,oBAAoB,EAC/C,OAAO,CAAC,EAAE,WAAW,GAAG;QAAE,UAAU,CAAC,EAAE,UAAU,CAAA;KAAE,GAClD,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,YAAY,CAAA;KAAE,CAAC;CAsJ3E;AAED,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAOtG,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/init.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
|
|
2
|
-
export interface InitSightConfig {
|
|
3
|
-
/** Project API key (`sk_live_...`) from the Sight dashboard. */
|
|
4
|
-
apiKey: string;
|
|
5
|
-
/**
|
|
6
|
-
* Human-readable service name that shows up on every span. Pick something
|
|
7
|
-
* that identifies this process — `'swap-bot'`, `'market-maker'`,
|
|
8
|
-
* `'trade-settler'`, etc.
|
|
9
|
-
*/
|
|
10
|
-
serviceName: string;
|
|
11
|
-
/** Optional version string for the service. Useful for correlating spans with a deploy. */
|
|
12
|
-
serviceVersion?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Full ingest URL. Defaults to the hosted Sight ingest. Override for
|
|
15
|
-
* local development (e.g. `http://localhost:3001/ingest`) or self-hosted
|
|
16
|
-
* deployments.
|
|
17
|
-
*/
|
|
18
|
-
ingestUrl?: string;
|
|
19
|
-
/** BatchSpanProcessor flush interval, in ms. Defaults to 5s. */
|
|
20
|
-
batchDelayMs?: number;
|
|
21
|
-
/** Max spans per HTTP POST. Clamped to 100 by the exporter. */
|
|
22
|
-
maxBatchSize?: number;
|
|
23
|
-
/** Inject a fetch implementation for tests. Defaults to global fetch. */
|
|
24
|
-
fetchImpl?: typeof fetch;
|
|
25
|
-
}
|
|
26
|
-
export interface SightTracerHandle {
|
|
27
|
-
provider: NodeTracerProvider;
|
|
28
|
-
/** Flush any pending spans and release the batch processor. */
|
|
29
|
-
shutdown: () => Promise<void>;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Initialize Sight tracing. Call this **once** near the top of your
|
|
33
|
-
* process entry point — typically in the same file that boots your
|
|
34
|
-
* HTTP server or worker.
|
|
35
|
-
*
|
|
36
|
-
* import { initSight, InstrumentedConnection } from '@thesight/sdk';
|
|
37
|
-
*
|
|
38
|
-
* initSight({
|
|
39
|
-
* apiKey: process.env.SIGHT_API_KEY!,
|
|
40
|
-
* serviceName: 'swap-bot',
|
|
41
|
-
* ingestUrl: process.env.SIGHT_INGEST_URL, // optional, defaults to prod
|
|
42
|
-
* });
|
|
43
|
-
*
|
|
44
|
-
* const connection = new InstrumentedConnection(process.env.RPC_URL!);
|
|
45
|
-
* const { signature } = await connection.sendAndConfirmInstrumented(tx);
|
|
46
|
-
*
|
|
47
|
-
* Registers a NodeTracerProvider as the global OTel tracer, so any call to
|
|
48
|
-
* `trace.getTracer(...)` (including the ones inside `InstrumentedConnection`)
|
|
49
|
-
* routes spans through the Sight exporter. Context propagation uses the
|
|
50
|
-
* Node async hooks manager so spans nest correctly across await boundaries.
|
|
51
|
-
*
|
|
52
|
-
* Returns a handle with a `shutdown()` method. Call it at graceful shutdown
|
|
53
|
-
* time so pending spans are flushed before the process exits:
|
|
54
|
-
*
|
|
55
|
-
* const sight = initSight({ ... });
|
|
56
|
-
* process.on('SIGTERM', async () => {
|
|
57
|
-
* await sight.shutdown();
|
|
58
|
-
* process.exit(0);
|
|
59
|
-
* });
|
|
60
|
-
*/
|
|
61
|
-
export declare function initSight(config: InitSightConfig): SightTracerHandle;
|
|
62
|
-
//# sourceMappingURL=init.d.ts.map
|
package/dist/init.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAQnE,MAAM,WAAW,eAAe;IAC9B,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB,2FAA2F;IAC3F,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,yEAAyE;IACzE,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,iBAAiB,CA8CpE"}
|
package/dist/init.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
|
|
2
|
-
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
3
|
-
import { Resource } from '@opentelemetry/resources';
|
|
4
|
-
import { SEMRESATTRS_SERVICE_NAME, SEMRESATTRS_SERVICE_VERSION } from '@opentelemetry/semantic-conventions';
|
|
5
|
-
import { SightSpanExporter } from './exporter.js';
|
|
6
|
-
// ─── Entry point ────────────────────────────────────────────────────────────
|
|
7
|
-
const DEFAULT_INGEST_URL = 'https://ingest.thesight.dev/ingest';
|
|
8
|
-
/**
|
|
9
|
-
* Initialize Sight tracing. Call this **once** near the top of your
|
|
10
|
-
* process entry point — typically in the same file that boots your
|
|
11
|
-
* HTTP server or worker.
|
|
12
|
-
*
|
|
13
|
-
* import { initSight, InstrumentedConnection } from '@thesight/sdk';
|
|
14
|
-
*
|
|
15
|
-
* initSight({
|
|
16
|
-
* apiKey: process.env.SIGHT_API_KEY!,
|
|
17
|
-
* serviceName: 'swap-bot',
|
|
18
|
-
* ingestUrl: process.env.SIGHT_INGEST_URL, // optional, defaults to prod
|
|
19
|
-
* });
|
|
20
|
-
*
|
|
21
|
-
* const connection = new InstrumentedConnection(process.env.RPC_URL!);
|
|
22
|
-
* const { signature } = await connection.sendAndConfirmInstrumented(tx);
|
|
23
|
-
*
|
|
24
|
-
* Registers a NodeTracerProvider as the global OTel tracer, so any call to
|
|
25
|
-
* `trace.getTracer(...)` (including the ones inside `InstrumentedConnection`)
|
|
26
|
-
* routes spans through the Sight exporter. Context propagation uses the
|
|
27
|
-
* Node async hooks manager so spans nest correctly across await boundaries.
|
|
28
|
-
*
|
|
29
|
-
* Returns a handle with a `shutdown()` method. Call it at graceful shutdown
|
|
30
|
-
* time so pending spans are flushed before the process exits:
|
|
31
|
-
*
|
|
32
|
-
* const sight = initSight({ ... });
|
|
33
|
-
* process.on('SIGTERM', async () => {
|
|
34
|
-
* await sight.shutdown();
|
|
35
|
-
* process.exit(0);
|
|
36
|
-
* });
|
|
37
|
-
*/
|
|
38
|
-
export function initSight(config) {
|
|
39
|
-
if (!config.apiKey) {
|
|
40
|
-
throw new Error('initSight: `apiKey` is required');
|
|
41
|
-
}
|
|
42
|
-
if (!config.serviceName) {
|
|
43
|
-
throw new Error('initSight: `serviceName` is required');
|
|
44
|
-
}
|
|
45
|
-
const resource = new Resource({
|
|
46
|
-
[SEMRESATTRS_SERVICE_NAME]: config.serviceName,
|
|
47
|
-
...(config.serviceVersion
|
|
48
|
-
? { [SEMRESATTRS_SERVICE_VERSION]: config.serviceVersion }
|
|
49
|
-
: {}),
|
|
50
|
-
});
|
|
51
|
-
const provider = new NodeTracerProvider({ resource });
|
|
52
|
-
const exporter = new SightSpanExporter({
|
|
53
|
-
apiKey: config.apiKey,
|
|
54
|
-
ingestUrl: config.ingestUrl ?? DEFAULT_INGEST_URL,
|
|
55
|
-
fetchImpl: config.fetchImpl,
|
|
56
|
-
maxBatchSize: config.maxBatchSize,
|
|
57
|
-
});
|
|
58
|
-
// BatchSpanProcessor buffers spans and flushes on an interval. This is the
|
|
59
|
-
// right default for production — simple span processor is one HTTP round
|
|
60
|
-
// trip per span, which is fine for tests and dev but nasty at scale.
|
|
61
|
-
const processor = new BatchSpanProcessor(exporter, {
|
|
62
|
-
scheduledDelayMillis: config.batchDelayMs ?? 5_000,
|
|
63
|
-
maxExportBatchSize: config.maxBatchSize ?? 100,
|
|
64
|
-
maxQueueSize: 2048,
|
|
65
|
-
});
|
|
66
|
-
provider.addSpanProcessor(processor);
|
|
67
|
-
// Register as the global OTel tracer provider. After this call,
|
|
68
|
-
// `trace.getTracer('anything')` returns a tracer from our provider,
|
|
69
|
-
// which routes spans to SightSpanExporter.
|
|
70
|
-
provider.register();
|
|
71
|
-
return {
|
|
72
|
-
provider,
|
|
73
|
-
shutdown: async () => {
|
|
74
|
-
await provider.shutdown();
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=init.js.map
|
package/dist/init.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","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