@rivetkit/traces 2.1.0-rc.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.
Files changed (56) hide show
  1. package/LICENSE +203 -0
  2. package/dist/schemas/v1.ts +653 -0
  3. package/dist/tsup/chunk-2D7JND4Z.js +63 -0
  4. package/dist/tsup/chunk-2D7JND4Z.js.map +1 -0
  5. package/dist/tsup/chunk-7RQXHEKZ.js +541 -0
  6. package/dist/tsup/chunk-7RQXHEKZ.js.map +1 -0
  7. package/dist/tsup/chunk-DXS2HLRN.cjs +63 -0
  8. package/dist/tsup/chunk-DXS2HLRN.cjs.map +1 -0
  9. package/dist/tsup/chunk-QOSSO6CN.cjs +541 -0
  10. package/dist/tsup/chunk-QOSSO6CN.cjs.map +1 -0
  11. package/dist/tsup/chunk-UNGPFJ4C.js +417 -0
  12. package/dist/tsup/chunk-UNGPFJ4C.js.map +1 -0
  13. package/dist/tsup/chunk-ZTVH74GC.cjs +417 -0
  14. package/dist/tsup/chunk-ZTVH74GC.cjs.map +1 -0
  15. package/dist/tsup/encoding.cjs +20 -0
  16. package/dist/tsup/encoding.cjs.map +1 -0
  17. package/dist/tsup/encoding.d.cts +6 -0
  18. package/dist/tsup/encoding.d.ts +6 -0
  19. package/dist/tsup/encoding.js +20 -0
  20. package/dist/tsup/encoding.js.map +1 -0
  21. package/dist/tsup/index.browser.cjs +15 -0
  22. package/dist/tsup/index.browser.cjs.map +1 -0
  23. package/dist/tsup/index.browser.d.cts +7 -0
  24. package/dist/tsup/index.browser.d.ts +7 -0
  25. package/dist/tsup/index.browser.js +15 -0
  26. package/dist/tsup/index.browser.js.map +1 -0
  27. package/dist/tsup/index.cjs +921 -0
  28. package/dist/tsup/index.cjs.map +1 -0
  29. package/dist/tsup/index.d.cts +9 -0
  30. package/dist/tsup/index.d.ts +9 -0
  31. package/dist/tsup/index.js +921 -0
  32. package/dist/tsup/index.js.map +1 -0
  33. package/dist/tsup/noop-CcgjEgCu.d.cts +99 -0
  34. package/dist/tsup/noop-D-YAZiGa.d.ts +99 -0
  35. package/dist/tsup/otlp-Da4Yz0xC.d.cts +81 -0
  36. package/dist/tsup/otlp-Da4Yz0xC.d.ts +81 -0
  37. package/dist/tsup/otlp-entry.cjs +16 -0
  38. package/dist/tsup/otlp-entry.cjs.map +1 -0
  39. package/dist/tsup/otlp-entry.d.cts +10 -0
  40. package/dist/tsup/otlp-entry.d.ts +10 -0
  41. package/dist/tsup/otlp-entry.js +16 -0
  42. package/dist/tsup/otlp-entry.js.map +1 -0
  43. package/dist/tsup/v1-DovAIc7f.d.cts +118 -0
  44. package/dist/tsup/v1-DovAIc7f.d.ts +118 -0
  45. package/package.json +74 -0
  46. package/schemas/v1.bare +177 -0
  47. package/schemas/versioned.ts +99 -0
  48. package/src/encoding.ts +18 -0
  49. package/src/index.browser.ts +13 -0
  50. package/src/index.ts +31 -0
  51. package/src/noop.ts +81 -0
  52. package/src/otlp-entry.ts +18 -0
  53. package/src/otlp.ts +158 -0
  54. package/src/read-range.ts +502 -0
  55. package/src/traces.ts +1186 -0
  56. package/src/types.ts +94 -0
package/src/types.ts ADDED
@@ -0,0 +1,94 @@
1
+ import type { ReadRangeWire as SchemaReadRangeWire } from "../schemas/versioned.js";
2
+
3
+ export interface TracesDriver {
4
+ get(key: Uint8Array): Promise<Uint8Array | null>;
5
+ set(key: Uint8Array, value: Uint8Array): Promise<void>;
6
+ delete(key: Uint8Array): Promise<void>;
7
+ deletePrefix(prefix: Uint8Array): Promise<void>;
8
+ list(prefix: Uint8Array): Promise<Array<{ key: Uint8Array; value: Uint8Array }>>;
9
+ listRange(
10
+ start: Uint8Array,
11
+ end: Uint8Array,
12
+ options?: { reverse?: boolean; limit?: number },
13
+ ): Promise<Array<{ key: Uint8Array; value: Uint8Array }>>;
14
+ batch(writes: Array<{ key: Uint8Array; value: Uint8Array }>): Promise<void>;
15
+ }
16
+
17
+ export interface SpanHandle {
18
+ spanId: Uint8Array;
19
+ traceId: Uint8Array;
20
+ isActive(): boolean;
21
+ }
22
+
23
+ export interface StartSpanOptions {
24
+ parent?: SpanHandle;
25
+ attributes?: Record<string, unknown>;
26
+ links?: Array<{
27
+ traceId: Uint8Array;
28
+ spanId: Uint8Array;
29
+ traceState?: string;
30
+ attributes?: Record<string, unknown>;
31
+ }>;
32
+ kind?: number;
33
+ traceState?: string;
34
+ flags?: number;
35
+ }
36
+
37
+ export interface UpdateSpanOptions {
38
+ attributes?: Record<string, unknown>;
39
+ status?: SpanStatusInput;
40
+ }
41
+
42
+ export interface SpanStatusInput {
43
+ code: "UNSET" | "OK" | "ERROR";
44
+ message?: string;
45
+ }
46
+
47
+ export interface EndSpanOptions {
48
+ status?: SpanStatusInput;
49
+ }
50
+
51
+ export interface EventOptions {
52
+ attributes?: Record<string, unknown>;
53
+ timeUnixMs?: number;
54
+ }
55
+
56
+ export interface ReadRangeOptions {
57
+ startMs: number;
58
+ endMs: number;
59
+ limit: number;
60
+ }
61
+
62
+ export type ReadRangeWire = SchemaReadRangeWire;
63
+
64
+ export interface ReadRangeResult<TExport> {
65
+ otlp: TExport;
66
+ clamped: boolean;
67
+ }
68
+
69
+ export interface TracesOptions<TResource> {
70
+ driver: TracesDriver;
71
+ resource?: TResource;
72
+ bucketSizeSec?: number;
73
+ targetChunkBytes?: number;
74
+ maxChunkBytes?: number;
75
+ maxChunkAgeMs?: number;
76
+ snapshotIntervalMs?: number;
77
+ snapshotBytesThreshold?: number;
78
+ maxActiveSpans?: number;
79
+ maxReadLimit?: number;
80
+ }
81
+
82
+ export interface Traces<TExport> {
83
+ startSpan(name: string, options?: StartSpanOptions): SpanHandle;
84
+ updateSpan(handle: SpanHandle, options: UpdateSpanOptions): void;
85
+ setAttributes(handle: SpanHandle, attributes: Record<string, unknown>): void;
86
+ setStatus(handle: SpanHandle, status: SpanStatusInput): void;
87
+ endSpan(handle: SpanHandle, options?: EndSpanOptions): void;
88
+ emitEvent(handle: SpanHandle, name: string, options?: EventOptions): void;
89
+ withSpan<T>(handle: SpanHandle, fn: () => T): T;
90
+ getCurrentSpan(): SpanHandle | null;
91
+ flush(): Promise<boolean>;
92
+ readRange(options: ReadRangeOptions): Promise<ReadRangeResult<TExport>>;
93
+ readRangeWire(options: ReadRangeOptions): Promise<ReadRangeWire>;
94
+ }