|
1 | 1 | import * as Sentry from "@sentry/bun"; |
2 | 2 |
|
3 | | -export const Metrics = { |
| 3 | +const billing = { |
| 4 | + billingSync: (success: boolean, eventType: string) => { |
| 5 | + Sentry.metrics.count("billing.sync", 1, { |
| 6 | + attributes: { success: String(success), event_type: eventType }, |
| 7 | + }); |
| 8 | + }, |
| 9 | +}; |
| 10 | + |
| 11 | +const stt = { |
4 | 12 | websocketConnected: (provider: string) => { |
5 | 13 | Sentry.metrics.count("websocket.connected", 1, { |
6 | 14 | attributes: { provider }, |
7 | 15 | }); |
8 | 16 | }, |
9 | | - |
10 | 17 | websocketDisconnected: (provider: string, durationMs: number) => { |
11 | 18 | Sentry.metrics.distribution("websocket.duration", durationMs, { |
12 | 19 | unit: "millisecond", |
13 | 20 | attributes: { provider }, |
14 | 21 | }); |
15 | 22 | }, |
| 23 | +}; |
16 | 24 |
|
17 | | - billingSync: (success: boolean, eventType: string) => { |
18 | | - Sentry.metrics.count("billing.sync", 1, { |
19 | | - attributes: { success: String(success), event_type: eventType }, |
20 | | - }); |
21 | | - }, |
22 | | - |
| 25 | +const llm = { |
23 | 26 | chatCompletion: (streaming: boolean, statusCode: number) => { |
24 | 27 | Sentry.metrics.count("chat.completion", 1, { |
25 | 28 | attributes: { streaming: String(streaming), status: String(statusCode) }, |
26 | 29 | }); |
27 | 30 | }, |
| 31 | +}; |
28 | 32 |
|
| 33 | +export const Metrics = { |
| 34 | + ...stt, |
| 35 | + ...llm, |
29 | 36 | upstreamLatency: (provider: string, durationMs: number) => { |
30 | 37 | Sentry.metrics.distribution("upstream.latency", durationMs, { |
31 | 38 | unit: "millisecond", |
32 | 39 | attributes: { provider }, |
33 | 40 | }); |
34 | 41 | }, |
| 42 | + ...billing, |
35 | 43 | }; |
0 commit comments