toad-eye 1.1.0 → 2.1.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 +132 -87
- package/dist/agent.d.ts +41 -0
- package/dist/agent.js +91 -0
- package/dist/alerts/channels.d.ts +2 -0
- package/dist/alerts/channels.js +81 -0
- package/dist/alerts/conditions.d.ts +29 -0
- package/dist/alerts/conditions.js +147 -0
- package/dist/alerts/grafana.d.ts +5 -0
- package/dist/alerts/grafana.js +19 -0
- package/dist/alerts/index.d.ts +5 -0
- package/dist/alerts/index.js +12 -0
- package/dist/alerts/manager.d.ts +13 -0
- package/dist/alerts/manager.js +87 -0
- package/dist/alerts/types.d.ts +46 -0
- package/dist/alerts/types.js +1 -0
- package/dist/budget/error.d.ts +10 -0
- package/dist/budget/error.js +22 -0
- package/dist/budget/index.d.ts +3 -0
- package/dist/budget/index.js +2 -0
- package/dist/budget/tracker.d.ts +35 -0
- package/dist/budget/tracker.js +121 -0
- package/dist/budget/types.d.ts +34 -0
- package/dist/budget/types.js +1 -0
- package/dist/cli.js +127 -18
- package/dist/core/metrics.d.ts +14 -0
- package/dist/core/metrics.js +119 -0
- package/dist/core/pricing.d.ts +24 -0
- package/dist/core/pricing.js +52 -0
- package/dist/{spans.d.ts → core/spans.d.ts} +3 -1
- package/dist/core/spans.js +143 -0
- package/dist/core/tracer.d.ts +9 -0
- package/dist/core/tracer.js +93 -0
- package/dist/drift/baseline.d.ts +16 -0
- package/dist/drift/baseline.js +16 -0
- package/dist/drift/cosine.d.ts +13 -0
- package/dist/drift/cosine.js +39 -0
- package/dist/drift/embedding-provider.d.ts +21 -0
- package/dist/drift/embedding-provider.js +8 -0
- package/dist/drift/index.d.ts +9 -0
- package/dist/drift/index.js +8 -0
- package/dist/drift/monitor.d.ts +29 -0
- package/dist/drift/monitor.js +47 -0
- package/dist/drift/openai-embeddings.d.ts +6 -0
- package/dist/drift/openai-embeddings.js +26 -0
- package/dist/export.d.ts +46 -0
- package/dist/export.js +108 -0
- package/dist/guard.d.ts +26 -0
- package/dist/guard.js +45 -0
- package/dist/index.d.ts +17 -5
- package/dist/index.js +10 -3
- package/dist/instrumentations/anthropic.d.ts +1 -0
- package/dist/instrumentations/anthropic.js +73 -0
- package/dist/instrumentations/create.d.ts +11 -0
- package/dist/instrumentations/create.js +165 -0
- package/dist/instrumentations/gemini.d.ts +1 -0
- package/dist/instrumentations/gemini.js +48 -0
- package/dist/instrumentations/openai.d.ts +1 -0
- package/dist/instrumentations/openai.js +94 -0
- package/dist/instrumentations/registry.d.ts +5 -0
- package/dist/instrumentations/registry.js +31 -0
- package/dist/instrumentations/types.d.ts +37 -0
- package/dist/instrumentations/types.js +1 -0
- package/dist/types/attributes.d.ts +48 -0
- package/dist/types/attributes.js +53 -0
- package/dist/types/config.d.ts +34 -0
- package/dist/types/config.js +1 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/index.js +13 -0
- package/dist/types/metrics.d.ts +33 -0
- package/dist/types/metrics.js +35 -0
- package/dist/types/providers.d.ts +5 -0
- package/dist/types/providers.js +1 -0
- package/dist/types/spans.d.ts +40 -0
- package/dist/types/spans.js +1 -0
- package/package.json +38 -4
- package/templates/alerts.example.yml +54 -0
- package/templates/docker-compose.yml +1 -2
- package/templates/grafana/dashboards/cost-breakdown.json +208 -0
- package/templates/grafana/dashboards/error-drilldown.json +188 -0
- package/templates/grafana/dashboards/finops-attribution.json +278 -0
- package/templates/grafana/dashboards/latency-analysis.json +134 -0
- package/templates/grafana/dashboards/llm-overview.json +161 -30
- package/templates/grafana/dashboards/model-comparison.json +143 -0
- package/dist/metrics.d.ts +0 -6
- package/dist/metrics.js +0 -46
- package/dist/spans.js +0 -61
- package/dist/tracer.d.ts +0 -4
- package/dist/tracer.js +0 -46
- package/dist/types.d.ts +0 -69
- package/dist/types.js +0 -32
package/dist/tracer.d.ts
DELETED
package/dist/tracer.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
2
|
-
import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
3
|
-
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
4
|
-
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
|
|
5
|
-
import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
|
|
6
|
-
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
|
|
7
|
-
import { initMetrics } from "./metrics.js";
|
|
8
|
-
const DEFAULT_ENDPOINT = "http://localhost:4318";
|
|
9
|
-
let sdk = null;
|
|
10
|
-
let currentConfig = null;
|
|
11
|
-
export function getConfig() {
|
|
12
|
-
return currentConfig;
|
|
13
|
-
}
|
|
14
|
-
export function initObservability(config) {
|
|
15
|
-
if (sdk)
|
|
16
|
-
return;
|
|
17
|
-
const endpoint = config.endpoint ?? DEFAULT_ENDPOINT;
|
|
18
|
-
const resource = resourceFromAttributes({
|
|
19
|
-
[ATTR_SERVICE_NAME]: config.serviceName,
|
|
20
|
-
});
|
|
21
|
-
const traceExporter = new OTLPTraceExporter({
|
|
22
|
-
url: `${endpoint}/v1/traces`,
|
|
23
|
-
});
|
|
24
|
-
const metricExporter = new OTLPMetricExporter({
|
|
25
|
-
url: `${endpoint}/v1/metrics`,
|
|
26
|
-
});
|
|
27
|
-
const metricReader = new PeriodicExportingMetricReader({
|
|
28
|
-
exporter: metricExporter,
|
|
29
|
-
exportIntervalMillis: 5000,
|
|
30
|
-
});
|
|
31
|
-
sdk = new NodeSDK({
|
|
32
|
-
resource,
|
|
33
|
-
traceExporter,
|
|
34
|
-
metricReader,
|
|
35
|
-
});
|
|
36
|
-
sdk.start();
|
|
37
|
-
currentConfig = config;
|
|
38
|
-
initMetrics();
|
|
39
|
-
}
|
|
40
|
-
export async function shutdown() {
|
|
41
|
-
if (!sdk)
|
|
42
|
-
return;
|
|
43
|
-
await sdk.shutdown();
|
|
44
|
-
sdk = null;
|
|
45
|
-
currentConfig = null;
|
|
46
|
-
}
|
package/dist/types.d.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
export declare const INSTRUMENTATION_NAME = "toad-eye";
|
|
2
|
-
/**
|
|
3
|
-
* LLM providers supported by toad-eye
|
|
4
|
-
*/
|
|
5
|
-
export type LLMProvider = "anthropic" | "gemini" | "openai";
|
|
6
|
-
/**
|
|
7
|
-
* Span status
|
|
8
|
-
*/
|
|
9
|
-
export type SpanStatus = "success" | "error";
|
|
10
|
-
/**
|
|
11
|
-
* Attributes attached to every LLM span (trace).
|
|
12
|
-
* These become searchable fields in Jaeger and filterable dimensions in Grafana.
|
|
13
|
-
*/
|
|
14
|
-
export interface LLMSpanAttributes {
|
|
15
|
-
readonly provider: LLMProvider;
|
|
16
|
-
readonly model: string;
|
|
17
|
-
readonly prompt: string;
|
|
18
|
-
readonly completion: string;
|
|
19
|
-
readonly inputTokens: number;
|
|
20
|
-
readonly outputTokens: number;
|
|
21
|
-
readonly cost: number;
|
|
22
|
-
readonly temperature: number;
|
|
23
|
-
readonly status: SpanStatus;
|
|
24
|
-
readonly error?: string | undefined;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Metric names exported to Prometheus.
|
|
28
|
-
*
|
|
29
|
-
* Naming convention follows OpenTelemetry semantic conventions:
|
|
30
|
-
* - dots as separators: "llm.request.duration"
|
|
31
|
-
* - Prometheus auto-converts dots to underscores: llm_request_duration
|
|
32
|
-
* - Prometheus adds _total suffix to counters automatically — do NOT include it in the name
|
|
33
|
-
*/
|
|
34
|
-
export declare const LLM_METRICS: {
|
|
35
|
-
readonly REQUEST_DURATION: "llm.request.duration";
|
|
36
|
-
readonly REQUEST_COST: "llm.request.cost";
|
|
37
|
-
readonly TOKENS: "llm.tokens";
|
|
38
|
-
readonly REQUESTS: "llm.requests";
|
|
39
|
-
readonly ERRORS: "llm.errors";
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Span attribute keys attached to every LLM span.
|
|
43
|
-
* Using constants prevents typos and enables rename-refactoring.
|
|
44
|
-
*/
|
|
45
|
-
export declare const LLM_ATTRS: {
|
|
46
|
-
readonly PROVIDER: "llm.provider";
|
|
47
|
-
readonly MODEL: "llm.model";
|
|
48
|
-
readonly PROMPT: "llm.prompt";
|
|
49
|
-
readonly COMPLETION: "llm.completion";
|
|
50
|
-
readonly INPUT_TOKENS: "llm.input_tokens";
|
|
51
|
-
readonly OUTPUT_TOKENS: "llm.output_tokens";
|
|
52
|
-
readonly COST: "llm.cost";
|
|
53
|
-
readonly TEMPERATURE: "llm.temperature";
|
|
54
|
-
readonly STATUS: "llm.status";
|
|
55
|
-
readonly ERROR: "llm.error";
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Type-safe metric name — only values from LLM_METRICS are allowed
|
|
59
|
-
*/
|
|
60
|
-
export type MetricName = (typeof LLM_METRICS)[keyof typeof LLM_METRICS];
|
|
61
|
-
/**
|
|
62
|
-
* Configuration for initObservability().
|
|
63
|
-
* This is what the user passes when connecting toad-eye to their service.
|
|
64
|
-
*/
|
|
65
|
-
export interface ToadEyeConfig {
|
|
66
|
-
readonly serviceName: string;
|
|
67
|
-
readonly endpoint?: string | undefined;
|
|
68
|
-
readonly recordContent?: boolean | undefined;
|
|
69
|
-
}
|
package/dist/types.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export const INSTRUMENTATION_NAME = "toad-eye";
|
|
2
|
-
/**
|
|
3
|
-
* Metric names exported to Prometheus.
|
|
4
|
-
*
|
|
5
|
-
* Naming convention follows OpenTelemetry semantic conventions:
|
|
6
|
-
* - dots as separators: "llm.request.duration"
|
|
7
|
-
* - Prometheus auto-converts dots to underscores: llm_request_duration
|
|
8
|
-
* - Prometheus adds _total suffix to counters automatically — do NOT include it in the name
|
|
9
|
-
*/
|
|
10
|
-
export const LLM_METRICS = {
|
|
11
|
-
REQUEST_DURATION: "llm.request.duration",
|
|
12
|
-
REQUEST_COST: "llm.request.cost",
|
|
13
|
-
TOKENS: "llm.tokens",
|
|
14
|
-
REQUESTS: "llm.requests",
|
|
15
|
-
ERRORS: "llm.errors",
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Span attribute keys attached to every LLM span.
|
|
19
|
-
* Using constants prevents typos and enables rename-refactoring.
|
|
20
|
-
*/
|
|
21
|
-
export const LLM_ATTRS = {
|
|
22
|
-
PROVIDER: "llm.provider",
|
|
23
|
-
MODEL: "llm.model",
|
|
24
|
-
PROMPT: "llm.prompt",
|
|
25
|
-
COMPLETION: "llm.completion",
|
|
26
|
-
INPUT_TOKENS: "llm.input_tokens",
|
|
27
|
-
OUTPUT_TOKENS: "llm.output_tokens",
|
|
28
|
-
COST: "llm.cost",
|
|
29
|
-
TEMPERATURE: "llm.temperature",
|
|
30
|
-
STATUS: "llm.status",
|
|
31
|
-
ERROR: "llm.error",
|
|
32
|
-
};
|