@heystack/otel 0.0.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/README.md +15 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +21 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @heystack/otel
|
|
2
|
+
|
|
3
|
+
One-call OpenTelemetry tracing that exports to Heystack.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @heystack/otel
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
At the very top of your app's entry file:
|
|
10
|
+
```ts
|
|
11
|
+
import { initHeystack } from "@heystack/otel";
|
|
12
|
+
initHeystack({ apiKey: process.env.HEYSTACK_KEY!, service: "my-app" });
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then run your app and make a request — traces appear in your Heystack dashboard within seconds.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
2
|
+
export interface HeystackOptions {
|
|
3
|
+
/** Your Heystack ingest key (sk_live_...). */
|
|
4
|
+
apiKey: string;
|
|
5
|
+
/** The OTel service.name this app reports as (must match the app's service in Heystack). */
|
|
6
|
+
service: string;
|
|
7
|
+
/** Override the ingest endpoint (defaults to Heystack production). */
|
|
8
|
+
endpoint?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ExporterConfig {
|
|
11
|
+
url: string;
|
|
12
|
+
headers: {
|
|
13
|
+
Authorization: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** Pure: derive the OTLP/HTTP exporter URL + auth header. Unit-tested. */
|
|
17
|
+
export declare function buildExporterConfig(o: HeystackOptions): ExporterConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Initialise Heystack OpenTelemetry tracing. Call once, as early as possible in
|
|
20
|
+
* your app's entry point. Returns the started NodeSDK.
|
|
21
|
+
*/
|
|
22
|
+
export declare function initHeystack(o: HeystackOptions): NodeSDK;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
2
|
+
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
3
|
+
const DEFAULT_ENDPOINT = "https://ingest.heystack.dev";
|
|
4
|
+
/** Pure: derive the OTLP/HTTP exporter URL + auth header. Unit-tested. */
|
|
5
|
+
export function buildExporterConfig(o) {
|
|
6
|
+
const base = (o.endpoint ?? DEFAULT_ENDPOINT).replace(/\/+$/, "");
|
|
7
|
+
return { url: `${base}/v1/traces`, headers: { Authorization: `Bearer ${o.apiKey}` } };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Initialise Heystack OpenTelemetry tracing. Call once, as early as possible in
|
|
11
|
+
* your app's entry point. Returns the started NodeSDK.
|
|
12
|
+
*/
|
|
13
|
+
export function initHeystack(o) {
|
|
14
|
+
const cfg = buildExporterConfig(o);
|
|
15
|
+
const sdk = new NodeSDK({
|
|
16
|
+
serviceName: o.service,
|
|
17
|
+
traceExporter: new OTLPTraceExporter({ url: cfg.url, headers: cfg.headers }),
|
|
18
|
+
});
|
|
19
|
+
sdk.start();
|
|
20
|
+
return sdk;
|
|
21
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@heystack/otel",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "One-call OpenTelemetry tracing that exports to Heystack.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } },
|
|
10
|
+
"files": ["dist", "README.md"],
|
|
11
|
+
"publishConfig": { "access": "public" },
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc -p tsconfig.build.json",
|
|
14
|
+
"test": "vitest run",
|
|
15
|
+
"typecheck": "tsc --noEmit",
|
|
16
|
+
"prepublishOnly": "pnpm build"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@opentelemetry/sdk-node": "^0.57.0",
|
|
20
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.57.0",
|
|
21
|
+
"@opentelemetry/resources": "^1.30.0",
|
|
22
|
+
"@opentelemetry/semantic-conventions": "^1.30.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"vitest": "^2.1.0",
|
|
26
|
+
"typescript": "^5.7.0",
|
|
27
|
+
"@types/node": "^22.0.0"
|
|
28
|
+
}
|
|
29
|
+
}
|