mirascope 2.2.0-alpha.2 → 2.2.2-alpha.4
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 +168 -0
- package/dist/index.cjs +420 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +212 -5
- package/dist/index.d.ts +212 -5
- package/dist/index.js +420 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -338,6 +338,173 @@ try {
|
|
|
338
338
|
}
|
|
339
339
|
```
|
|
340
340
|
|
|
341
|
+
## Ops: Instrumentation, Tracing & Versioning
|
|
342
|
+
|
|
343
|
+
The `ops` module provides observability and versioning for your LLM applications, with automatic integration to Mirascope Cloud or any OpenTelemetry-compatible backend.
|
|
344
|
+
|
|
345
|
+
### Configuration
|
|
346
|
+
|
|
347
|
+
```typescript
|
|
348
|
+
import { ops } from "mirascope";
|
|
349
|
+
|
|
350
|
+
// Uses MIRASCOPE_API_KEY environment variable
|
|
351
|
+
ops.configure();
|
|
352
|
+
|
|
353
|
+
// Or explicit API key
|
|
354
|
+
ops.configure({ apiKey: "your-api-key" });
|
|
355
|
+
|
|
356
|
+
// Or custom OpenTelemetry provider
|
|
357
|
+
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
|
|
358
|
+
ops.configure({ tracerProvider: new NodeTracerProvider() });
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Tracing
|
|
362
|
+
|
|
363
|
+
Wrap functions or calls with `trace()` to create spans:
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
import { llm, ops } from "mirascope";
|
|
367
|
+
|
|
368
|
+
const recommendBook = llm.defineCall<{ genre: string }>({
|
|
369
|
+
model: "anthropic/claude-haiku-4-5",
|
|
370
|
+
template: ({ genre }) => `Recommend a ${genre} book.`,
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
// Trace a call
|
|
374
|
+
const tracedRecommendBook = ops.trace(recommendBook, {
|
|
375
|
+
name: "recommend-book",
|
|
376
|
+
tags: ["recommendation", "books"],
|
|
377
|
+
metadata: { source: "example" },
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
const response = await tracedRecommendBook({ genre: "fantasy" });
|
|
381
|
+
|
|
382
|
+
// Access span metadata
|
|
383
|
+
const result = await tracedRecommendBook.wrapped({ genre: "sci-fi" });
|
|
384
|
+
console.log(result.traceId, result.spanId);
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### Versioning
|
|
388
|
+
|
|
389
|
+
Track function versions based on closure analysis. Changes to your function code or its dependencies automatically create new versions:
|
|
390
|
+
|
|
391
|
+
```typescript
|
|
392
|
+
import { ops } from "mirascope";
|
|
393
|
+
|
|
394
|
+
const computeEmbedding = ops.version(
|
|
395
|
+
async (text: string) => {
|
|
396
|
+
// Your embedding logic
|
|
397
|
+
return [0.1, 0.2, 0.3];
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
name: "embedding-v1",
|
|
401
|
+
tags: ["embedding", "production"],
|
|
402
|
+
}
|
|
403
|
+
);
|
|
404
|
+
|
|
405
|
+
// Access version info (hash, signatureHash, name, version, tags, metadata)
|
|
406
|
+
console.log(computeEmbedding.versionInfo);
|
|
407
|
+
|
|
408
|
+
// Get wrapped result with span info and annotation support
|
|
409
|
+
const result = await computeEmbedding.wrapped("hello");
|
|
410
|
+
await result.annotate({ label: "pass" }); // or "fail"
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
> [!NOTE]
|
|
414
|
+
> For accurate source-level versioning, use the [Transform Plugin](#transform-plugin). Without it, versioning uses compiled JavaScript via `fn.toString()`.
|
|
415
|
+
|
|
416
|
+
### Sessions
|
|
417
|
+
|
|
418
|
+
Group related traces under a session ID:
|
|
419
|
+
|
|
420
|
+
```typescript
|
|
421
|
+
import { ops } from "mirascope";
|
|
422
|
+
|
|
423
|
+
await ops.session({ id: "user-123-conversation-1" }, async () => {
|
|
424
|
+
const response = await tracedChat({ message: "Hello!" });
|
|
425
|
+
console.log(ops.currentSession()?.id); // "user-123-conversation-1"
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
// With attributes
|
|
429
|
+
await ops.session(
|
|
430
|
+
{
|
|
431
|
+
id: "session-2",
|
|
432
|
+
attributes: { userId: "user-456", channel: "web" },
|
|
433
|
+
},
|
|
434
|
+
async () => {
|
|
435
|
+
// Attributes are propagated to spans
|
|
436
|
+
}
|
|
437
|
+
);
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
### Spans
|
|
441
|
+
|
|
442
|
+
Create custom spans for non-LLM operations:
|
|
443
|
+
|
|
444
|
+
```typescript
|
|
445
|
+
import { ops } from "mirascope";
|
|
446
|
+
|
|
447
|
+
await ops.span("data-processing", async (span) => {
|
|
448
|
+
span.info("Starting processing");
|
|
449
|
+
span.set({ "app.batch_size": 100 });
|
|
450
|
+
|
|
451
|
+
// Nested spans
|
|
452
|
+
await ops.span("validation", async (child) => {
|
|
453
|
+
child.debug("Validating input");
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
span.info("Complete", { records: 100 });
|
|
457
|
+
});
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
### LLM Instrumentation
|
|
461
|
+
|
|
462
|
+
Automatically instrument all LLM calls with OpenTelemetry GenAI semantic conventions:
|
|
463
|
+
|
|
464
|
+
```typescript
|
|
465
|
+
import { ops } from "mirascope";
|
|
466
|
+
|
|
467
|
+
ops.instrumentLLM();
|
|
468
|
+
|
|
469
|
+
// Now all Model calls automatically create spans with:
|
|
470
|
+
// - gen_ai.system: "anthropic"
|
|
471
|
+
// - gen_ai.request.model: "claude-haiku-4-5"
|
|
472
|
+
// - gen_ai.usage.input_tokens / output_tokens
|
|
473
|
+
const response = await recommendBook({ genre: "mystery" });
|
|
474
|
+
|
|
475
|
+
// Check status
|
|
476
|
+
console.log(ops.isLLMInstrumented()); // true
|
|
477
|
+
ops.uninstrumentLLM();
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
### Context Propagation
|
|
481
|
+
|
|
482
|
+
Propagate trace context across service boundaries:
|
|
483
|
+
|
|
484
|
+
```typescript
|
|
485
|
+
import { ops } from "mirascope";
|
|
486
|
+
|
|
487
|
+
// Inject context into outgoing HTTP headers
|
|
488
|
+
const headers: Record<string, string> = {};
|
|
489
|
+
ops.injectContext(headers);
|
|
490
|
+
await fetch(url, { headers });
|
|
491
|
+
|
|
492
|
+
// Extract context on receiving side
|
|
493
|
+
await ops.propagatedContext(incomingHeaders, async () => {
|
|
494
|
+
await ops.span("downstream-work", async (span) => {
|
|
495
|
+
// Linked to upstream trace
|
|
496
|
+
});
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
// Session propagation
|
|
500
|
+
const sessionId = ops.extractSessionId(incomingHeaders);
|
|
501
|
+
if (sessionId) {
|
|
502
|
+
await ops.session({ id: sessionId }, async () => {
|
|
503
|
+
// Continue session from upstream
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
```
|
|
507
|
+
|
|
341
508
|
## Supported Providers
|
|
342
509
|
|
|
343
510
|
- **Anthropic**: `anthropic/claude-sonnet-4-5`, `anthropic/claude-haiku-4-5`, etc.
|
|
@@ -380,6 +547,7 @@ See the [`examples/`](./examples) directory for more examples:
|
|
|
380
547
|
- `context/` - Sharing dependencies with context
|
|
381
548
|
- `chaining/` - Chaining and parallel calls
|
|
382
549
|
- `reliability/` - Retry and fallback patterns
|
|
550
|
+
- `ops/` - Tracing, versioning, sessions, and instrumentation
|
|
383
551
|
|
|
384
552
|
Run an example:
|
|
385
553
|
```bash
|
package/dist/index.cjs
CHANGED
|
@@ -13184,11 +13184,216 @@ var TokenCostCalculateResponse = schemas_exports.object({
|
|
|
13184
13184
|
totalCostDollars: schemas_exports.number()
|
|
13185
13185
|
});
|
|
13186
13186
|
|
|
13187
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemResourceAttributesItemValueArrayValue.ts
|
|
13188
|
+
var TracesCreateOtelRequestResourceSpansItemResourceAttributesItemValueArrayValue = schemas_exports.object({
|
|
13189
|
+
values: schemas_exports.list(schemas_exports.unknown())
|
|
13190
|
+
});
|
|
13191
|
+
|
|
13192
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemResourceAttributesItemValueIntValue.ts
|
|
13193
|
+
var TracesCreateOtelRequestResourceSpansItemResourceAttributesItemValueIntValue = schemas_exports.undiscriminatedUnion([
|
|
13194
|
+
schemas_exports.string(),
|
|
13195
|
+
schemas_exports.number()
|
|
13196
|
+
]);
|
|
13197
|
+
|
|
13198
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemResourceAttributesItemValueKvlistValueValuesItem.ts
|
|
13199
|
+
var TracesCreateOtelRequestResourceSpansItemResourceAttributesItemValueKvlistValueValuesItem = schemas_exports.object({
|
|
13200
|
+
key: schemas_exports.string(),
|
|
13201
|
+
value: schemas_exports.unknown()
|
|
13202
|
+
});
|
|
13203
|
+
|
|
13204
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemResourceAttributesItemValueKvlistValue.ts
|
|
13205
|
+
var TracesCreateOtelRequestResourceSpansItemResourceAttributesItemValueKvlistValue = schemas_exports.object({
|
|
13206
|
+
values: schemas_exports.list(
|
|
13207
|
+
TracesCreateOtelRequestResourceSpansItemResourceAttributesItemValueKvlistValueValuesItem
|
|
13208
|
+
)
|
|
13209
|
+
});
|
|
13210
|
+
|
|
13211
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemResourceAttributesItemValue.ts
|
|
13212
|
+
var TracesCreateOtelRequestResourceSpansItemResourceAttributesItemValue = schemas_exports.object({
|
|
13213
|
+
stringValue: schemas_exports.string().optional(),
|
|
13214
|
+
intValue: TracesCreateOtelRequestResourceSpansItemResourceAttributesItemValueIntValue.optional(),
|
|
13215
|
+
doubleValue: schemas_exports.number().optional(),
|
|
13216
|
+
boolValue: schemas_exports.boolean().optional(),
|
|
13217
|
+
arrayValue: TracesCreateOtelRequestResourceSpansItemResourceAttributesItemValueArrayValue.optional(),
|
|
13218
|
+
kvlistValue: TracesCreateOtelRequestResourceSpansItemResourceAttributesItemValueKvlistValue.optional()
|
|
13219
|
+
});
|
|
13220
|
+
|
|
13221
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemResourceAttributesItem.ts
|
|
13222
|
+
var TracesCreateOtelRequestResourceSpansItemResourceAttributesItem = schemas_exports.object({
|
|
13223
|
+
key: schemas_exports.string(),
|
|
13224
|
+
value: TracesCreateOtelRequestResourceSpansItemResourceAttributesItemValue
|
|
13225
|
+
});
|
|
13226
|
+
|
|
13227
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemResource.ts
|
|
13228
|
+
var TracesCreateOtelRequestResourceSpansItemResource = schemas_exports.object({
|
|
13229
|
+
attributes: schemas_exports.list(TracesCreateOtelRequestResourceSpansItemResourceAttributesItem).optional(),
|
|
13230
|
+
droppedAttributesCount: schemas_exports.number().optional()
|
|
13231
|
+
});
|
|
13232
|
+
|
|
13233
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueArrayValue.ts
|
|
13234
|
+
var TracesCreateOtelRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueArrayValue = schemas_exports.object({
|
|
13235
|
+
values: schemas_exports.list(schemas_exports.unknown())
|
|
13236
|
+
});
|
|
13237
|
+
|
|
13238
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueIntValue.ts
|
|
13239
|
+
var TracesCreateOtelRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueIntValue = schemas_exports.undiscriminatedUnion([
|
|
13240
|
+
schemas_exports.string(),
|
|
13241
|
+
schemas_exports.number()
|
|
13242
|
+
]);
|
|
13243
|
+
|
|
13244
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueKvlistValueValuesItem.ts
|
|
13245
|
+
var TracesCreateOtelRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueKvlistValueValuesItem = schemas_exports.object({
|
|
13246
|
+
key: schemas_exports.string(),
|
|
13247
|
+
value: schemas_exports.unknown()
|
|
13248
|
+
});
|
|
13249
|
+
|
|
13250
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueKvlistValue.ts
|
|
13251
|
+
var TracesCreateOtelRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueKvlistValue = schemas_exports.object({
|
|
13252
|
+
values: schemas_exports.list(
|
|
13253
|
+
TracesCreateOtelRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueKvlistValueValuesItem
|
|
13254
|
+
)
|
|
13255
|
+
});
|
|
13256
|
+
|
|
13257
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemScopeSpansItemScopeAttributesItemValue.ts
|
|
13258
|
+
var TracesCreateOtelRequestResourceSpansItemScopeSpansItemScopeAttributesItemValue = schemas_exports.object({
|
|
13259
|
+
stringValue: schemas_exports.string().optional(),
|
|
13260
|
+
intValue: TracesCreateOtelRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueIntValue.optional(),
|
|
13261
|
+
doubleValue: schemas_exports.number().optional(),
|
|
13262
|
+
boolValue: schemas_exports.boolean().optional(),
|
|
13263
|
+
arrayValue: TracesCreateOtelRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueArrayValue.optional(),
|
|
13264
|
+
kvlistValue: TracesCreateOtelRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueKvlistValue.optional()
|
|
13265
|
+
});
|
|
13266
|
+
|
|
13267
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemScopeSpansItemScopeAttributesItem.ts
|
|
13268
|
+
var TracesCreateOtelRequestResourceSpansItemScopeSpansItemScopeAttributesItem = schemas_exports.object({
|
|
13269
|
+
key: schemas_exports.string(),
|
|
13270
|
+
value: TracesCreateOtelRequestResourceSpansItemScopeSpansItemScopeAttributesItemValue
|
|
13271
|
+
});
|
|
13272
|
+
|
|
13273
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemScopeSpansItemScope.ts
|
|
13274
|
+
var TracesCreateOtelRequestResourceSpansItemScopeSpansItemScope = schemas_exports.object({
|
|
13275
|
+
name: schemas_exports.string(),
|
|
13276
|
+
version: schemas_exports.string().optional(),
|
|
13277
|
+
attributes: schemas_exports.list(
|
|
13278
|
+
TracesCreateOtelRequestResourceSpansItemScopeSpansItemScopeAttributesItem
|
|
13279
|
+
).optional(),
|
|
13280
|
+
droppedAttributesCount: schemas_exports.number().optional()
|
|
13281
|
+
});
|
|
13282
|
+
|
|
13283
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueArrayValue.ts
|
|
13284
|
+
var TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueArrayValue = schemas_exports.object({
|
|
13285
|
+
values: schemas_exports.list(schemas_exports.unknown())
|
|
13286
|
+
});
|
|
13287
|
+
|
|
13288
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueIntValue.ts
|
|
13289
|
+
var TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueIntValue = schemas_exports.undiscriminatedUnion([
|
|
13290
|
+
schemas_exports.string(),
|
|
13291
|
+
schemas_exports.number()
|
|
13292
|
+
]);
|
|
13293
|
+
|
|
13294
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueKvlistValueValuesItem.ts
|
|
13295
|
+
var TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueKvlistValueValuesItem = schemas_exports.object({
|
|
13296
|
+
key: schemas_exports.string(),
|
|
13297
|
+
value: schemas_exports.unknown()
|
|
13298
|
+
});
|
|
13299
|
+
|
|
13300
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueKvlistValue.ts
|
|
13301
|
+
var TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueKvlistValue = schemas_exports.object({
|
|
13302
|
+
values: schemas_exports.list(
|
|
13303
|
+
TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueKvlistValueValuesItem
|
|
13304
|
+
)
|
|
13305
|
+
});
|
|
13306
|
+
|
|
13307
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValue.ts
|
|
13308
|
+
var TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValue = schemas_exports.object({
|
|
13309
|
+
stringValue: schemas_exports.string().optional(),
|
|
13310
|
+
intValue: TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueIntValue.optional(),
|
|
13311
|
+
doubleValue: schemas_exports.number().optional(),
|
|
13312
|
+
boolValue: schemas_exports.boolean().optional(),
|
|
13313
|
+
arrayValue: TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueArrayValue.optional(),
|
|
13314
|
+
kvlistValue: TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueKvlistValue.optional()
|
|
13315
|
+
});
|
|
13316
|
+
|
|
13317
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemAttributesItem.ts
|
|
13318
|
+
var TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemAttributesItem = schemas_exports.object({
|
|
13319
|
+
key: schemas_exports.string(),
|
|
13320
|
+
value: TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValue
|
|
13321
|
+
});
|
|
13322
|
+
|
|
13323
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemEndTimeUnixNano.ts
|
|
13324
|
+
var TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemEndTimeUnixNano = schemas_exports.undiscriminatedUnion([
|
|
13325
|
+
schemas_exports.string(),
|
|
13326
|
+
schemas_exports.number()
|
|
13327
|
+
]);
|
|
13328
|
+
|
|
13329
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemStartTimeUnixNano.ts
|
|
13330
|
+
var TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemStartTimeUnixNano = schemas_exports.undiscriminatedUnion([
|
|
13331
|
+
schemas_exports.string(),
|
|
13332
|
+
schemas_exports.number()
|
|
13333
|
+
]);
|
|
13334
|
+
|
|
13335
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemStatus.ts
|
|
13336
|
+
var TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemStatus = schemas_exports.object({
|
|
13337
|
+
code: schemas_exports.number().optional(),
|
|
13338
|
+
message: schemas_exports.string().optional()
|
|
13339
|
+
});
|
|
13340
|
+
|
|
13341
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItem.ts
|
|
13342
|
+
var TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItem = schemas_exports.object({
|
|
13343
|
+
traceId: schemas_exports.string(),
|
|
13344
|
+
spanId: schemas_exports.string(),
|
|
13345
|
+
parentSpanId: schemas_exports.string().optionalNullable(),
|
|
13346
|
+
name: schemas_exports.string(),
|
|
13347
|
+
kind: schemas_exports.number().optional(),
|
|
13348
|
+
startTimeUnixNano: TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemStartTimeUnixNano,
|
|
13349
|
+
endTimeUnixNano: TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemEndTimeUnixNano,
|
|
13350
|
+
attributes: schemas_exports.list(
|
|
13351
|
+
TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemAttributesItem
|
|
13352
|
+
).optional(),
|
|
13353
|
+
droppedAttributesCount: schemas_exports.number().optional(),
|
|
13354
|
+
events: schemas_exports.list(schemas_exports.unknown()).optional(),
|
|
13355
|
+
droppedEventsCount: schemas_exports.number().optional(),
|
|
13356
|
+
status: TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItemStatus.optional(),
|
|
13357
|
+
links: schemas_exports.list(schemas_exports.unknown()).optional(),
|
|
13358
|
+
droppedLinksCount: schemas_exports.number().optional()
|
|
13359
|
+
});
|
|
13360
|
+
|
|
13361
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItemScopeSpansItem.ts
|
|
13362
|
+
var TracesCreateOtelRequestResourceSpansItemScopeSpansItem = schemas_exports.object({
|
|
13363
|
+
scope: TracesCreateOtelRequestResourceSpansItemScopeSpansItemScope.optional(),
|
|
13364
|
+
spans: schemas_exports.list(
|
|
13365
|
+
TracesCreateOtelRequestResourceSpansItemScopeSpansItemSpansItem
|
|
13366
|
+
),
|
|
13367
|
+
schemaUrl: schemas_exports.string().optional()
|
|
13368
|
+
});
|
|
13369
|
+
|
|
13370
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelRequestResourceSpansItem.ts
|
|
13371
|
+
var TracesCreateOtelRequestResourceSpansItem = schemas_exports.object({
|
|
13372
|
+
resource: TracesCreateOtelRequestResourceSpansItemResource.optional(),
|
|
13373
|
+
scopeSpans: schemas_exports.list(
|
|
13374
|
+
TracesCreateOtelRequestResourceSpansItemScopeSpansItem
|
|
13375
|
+
),
|
|
13376
|
+
schemaUrl: schemas_exports.string().optional()
|
|
13377
|
+
});
|
|
13378
|
+
|
|
13379
|
+
// src/api/_generated/serialization/resources/traces/client/requests/TracesCreateOtelRequest.ts
|
|
13380
|
+
var TracesCreateOtelRequest = schemas_exports.object({
|
|
13381
|
+
resourceSpans: schemas_exports.list(
|
|
13382
|
+
TracesCreateOtelRequestResourceSpansItem
|
|
13383
|
+
)
|
|
13384
|
+
});
|
|
13385
|
+
|
|
13187
13386
|
// src/api/_generated/serialization/resources/traces/types/TracesCreateRequestResourceSpansItemResourceAttributesItemValueArrayValue.ts
|
|
13188
13387
|
var TracesCreateRequestResourceSpansItemResourceAttributesItemValueArrayValue = schemas_exports.object({
|
|
13189
13388
|
values: schemas_exports.list(schemas_exports.unknown())
|
|
13190
13389
|
});
|
|
13191
13390
|
|
|
13391
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateRequestResourceSpansItemResourceAttributesItemValueIntValue.ts
|
|
13392
|
+
var TracesCreateRequestResourceSpansItemResourceAttributesItemValueIntValue = schemas_exports.undiscriminatedUnion([
|
|
13393
|
+
schemas_exports.string(),
|
|
13394
|
+
schemas_exports.number()
|
|
13395
|
+
]);
|
|
13396
|
+
|
|
13192
13397
|
// src/api/_generated/serialization/resources/traces/types/TracesCreateRequestResourceSpansItemResourceAttributesItemValueKvlistValueValuesItem.ts
|
|
13193
13398
|
var TracesCreateRequestResourceSpansItemResourceAttributesItemValueKvlistValueValuesItem = schemas_exports.object({
|
|
13194
13399
|
key: schemas_exports.string(),
|
|
@@ -13205,7 +13410,7 @@ var TracesCreateRequestResourceSpansItemResourceAttributesItemValueKvlistValue =
|
|
|
13205
13410
|
// src/api/_generated/serialization/resources/traces/types/TracesCreateRequestResourceSpansItemResourceAttributesItemValue.ts
|
|
13206
13411
|
var TracesCreateRequestResourceSpansItemResourceAttributesItemValue = schemas_exports.object({
|
|
13207
13412
|
stringValue: schemas_exports.string().optional(),
|
|
13208
|
-
intValue:
|
|
13413
|
+
intValue: TracesCreateRequestResourceSpansItemResourceAttributesItemValueIntValue.optional(),
|
|
13209
13414
|
doubleValue: schemas_exports.number().optional(),
|
|
13210
13415
|
boolValue: schemas_exports.boolean().optional(),
|
|
13211
13416
|
arrayValue: TracesCreateRequestResourceSpansItemResourceAttributesItemValueArrayValue.optional(),
|
|
@@ -13229,6 +13434,12 @@ var TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueAr
|
|
|
13229
13434
|
values: schemas_exports.list(schemas_exports.unknown())
|
|
13230
13435
|
});
|
|
13231
13436
|
|
|
13437
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueIntValue.ts
|
|
13438
|
+
var TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueIntValue = schemas_exports.undiscriminatedUnion([
|
|
13439
|
+
schemas_exports.string(),
|
|
13440
|
+
schemas_exports.number()
|
|
13441
|
+
]);
|
|
13442
|
+
|
|
13232
13443
|
// src/api/_generated/serialization/resources/traces/types/TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueKvlistValueValuesItem.ts
|
|
13233
13444
|
var TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueKvlistValueValuesItem = schemas_exports.object({
|
|
13234
13445
|
key: schemas_exports.string(),
|
|
@@ -13245,7 +13456,7 @@ var TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueKv
|
|
|
13245
13456
|
// src/api/_generated/serialization/resources/traces/types/TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItemValue.ts
|
|
13246
13457
|
var TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItemValue = schemas_exports.object({
|
|
13247
13458
|
stringValue: schemas_exports.string().optional(),
|
|
13248
|
-
intValue:
|
|
13459
|
+
intValue: TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueIntValue.optional(),
|
|
13249
13460
|
doubleValue: schemas_exports.number().optional(),
|
|
13250
13461
|
boolValue: schemas_exports.boolean().optional(),
|
|
13251
13462
|
arrayValue: TracesCreateRequestResourceSpansItemScopeSpansItemScopeAttributesItemValueArrayValue.optional(),
|
|
@@ -13271,6 +13482,12 @@ var TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemVal
|
|
|
13271
13482
|
values: schemas_exports.list(schemas_exports.unknown())
|
|
13272
13483
|
});
|
|
13273
13484
|
|
|
13485
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueIntValue.ts
|
|
13486
|
+
var TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueIntValue = schemas_exports.undiscriminatedUnion([
|
|
13487
|
+
schemas_exports.string(),
|
|
13488
|
+
schemas_exports.number()
|
|
13489
|
+
]);
|
|
13490
|
+
|
|
13274
13491
|
// src/api/_generated/serialization/resources/traces/types/TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueKvlistValueValuesItem.ts
|
|
13275
13492
|
var TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueKvlistValueValuesItem = schemas_exports.object({
|
|
13276
13493
|
key: schemas_exports.string(),
|
|
@@ -13287,7 +13504,7 @@ var TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemVal
|
|
|
13287
13504
|
// src/api/_generated/serialization/resources/traces/types/TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValue.ts
|
|
13288
13505
|
var TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValue = schemas_exports.object({
|
|
13289
13506
|
stringValue: schemas_exports.string().optional(),
|
|
13290
|
-
intValue:
|
|
13507
|
+
intValue: TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueIntValue.optional(),
|
|
13291
13508
|
doubleValue: schemas_exports.number().optional(),
|
|
13292
13509
|
boolValue: schemas_exports.boolean().optional(),
|
|
13293
13510
|
arrayValue: TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValueArrayValue.optional(),
|
|
@@ -13300,6 +13517,18 @@ var TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItem =
|
|
|
13300
13517
|
value: TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItemValue
|
|
13301
13518
|
});
|
|
13302
13519
|
|
|
13520
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemEndTimeUnixNano.ts
|
|
13521
|
+
var TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemEndTimeUnixNano = schemas_exports.undiscriminatedUnion([
|
|
13522
|
+
schemas_exports.string(),
|
|
13523
|
+
schemas_exports.number()
|
|
13524
|
+
]);
|
|
13525
|
+
|
|
13526
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemStartTimeUnixNano.ts
|
|
13527
|
+
var TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemStartTimeUnixNano = schemas_exports.undiscriminatedUnion([
|
|
13528
|
+
schemas_exports.string(),
|
|
13529
|
+
schemas_exports.number()
|
|
13530
|
+
]);
|
|
13531
|
+
|
|
13303
13532
|
// src/api/_generated/serialization/resources/traces/types/TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemStatus.ts
|
|
13304
13533
|
var TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemStatus = schemas_exports.object({
|
|
13305
13534
|
code: schemas_exports.number().optional(),
|
|
@@ -13313,8 +13542,8 @@ var TracesCreateRequestResourceSpansItemScopeSpansItemSpansItem = schemas_export
|
|
|
13313
13542
|
parentSpanId: schemas_exports.string().optionalNullable(),
|
|
13314
13543
|
name: schemas_exports.string(),
|
|
13315
13544
|
kind: schemas_exports.number().optional(),
|
|
13316
|
-
startTimeUnixNano:
|
|
13317
|
-
endTimeUnixNano:
|
|
13545
|
+
startTimeUnixNano: TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemStartTimeUnixNano,
|
|
13546
|
+
endTimeUnixNano: TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemEndTimeUnixNano,
|
|
13318
13547
|
attributes: schemas_exports.list(
|
|
13319
13548
|
TracesCreateRequestResourceSpansItemScopeSpansItemSpansItemAttributesItem
|
|
13320
13549
|
).optional(),
|
|
@@ -13437,6 +13666,17 @@ var TracesSearchRequest = schemas_exports.object({
|
|
|
13437
13666
|
rootSpansOnly: schemas_exports.boolean().optional()
|
|
13438
13667
|
});
|
|
13439
13668
|
|
|
13669
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelResponsePartialSuccess.ts
|
|
13670
|
+
var TracesCreateOtelResponsePartialSuccess = schemas_exports.object({
|
|
13671
|
+
rejectedSpans: schemas_exports.number().optional(),
|
|
13672
|
+
errorMessage: schemas_exports.string().optional()
|
|
13673
|
+
});
|
|
13674
|
+
|
|
13675
|
+
// src/api/_generated/serialization/resources/traces/types/TracesCreateOtelResponse.ts
|
|
13676
|
+
var TracesCreateOtelResponse = schemas_exports.object({
|
|
13677
|
+
partialSuccess: TracesCreateOtelResponsePartialSuccess.optional()
|
|
13678
|
+
});
|
|
13679
|
+
|
|
13440
13680
|
// src/api/_generated/serialization/resources/traces/types/TracesCreateResponsePartialSuccess.ts
|
|
13441
13681
|
var TracesCreateResponsePartialSuccess = schemas_exports.object({
|
|
13442
13682
|
rejectedSpans: schemas_exports.number().optional(),
|
|
@@ -21869,6 +22109,181 @@ var TracesClient = class {
|
|
|
21869
22109
|
"/traces"
|
|
21870
22110
|
);
|
|
21871
22111
|
}
|
|
22112
|
+
/**
|
|
22113
|
+
* @param {Mirascope.TracesCreateOtelRequest} request
|
|
22114
|
+
* @param {TracesClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
22115
|
+
*
|
|
22116
|
+
* @throws {@link Mirascope.BadRequestError}
|
|
22117
|
+
* @throws {@link Mirascope.UnauthorizedError}
|
|
22118
|
+
* @throws {@link Mirascope.PaymentRequiredError}
|
|
22119
|
+
* @throws {@link Mirascope.ForbiddenError}
|
|
22120
|
+
* @throws {@link Mirascope.NotFoundError}
|
|
22121
|
+
* @throws {@link Mirascope.ConflictError}
|
|
22122
|
+
* @throws {@link Mirascope.TooManyRequestsError}
|
|
22123
|
+
* @throws {@link Mirascope.InternalServerError}
|
|
22124
|
+
* @throws {@link Mirascope.ServiceUnavailableError}
|
|
22125
|
+
*
|
|
22126
|
+
* @example
|
|
22127
|
+
* await client.traces.createotel({
|
|
22128
|
+
* resourceSpans: [{
|
|
22129
|
+
* scopeSpans: [{
|
|
22130
|
+
* spans: [{
|
|
22131
|
+
* traceId: "traceId",
|
|
22132
|
+
* spanId: "spanId",
|
|
22133
|
+
* name: "name",
|
|
22134
|
+
* startTimeUnixNano: "startTimeUnixNano",
|
|
22135
|
+
* endTimeUnixNano: "endTimeUnixNano"
|
|
22136
|
+
* }]
|
|
22137
|
+
* }]
|
|
22138
|
+
* }]
|
|
22139
|
+
* })
|
|
22140
|
+
*/
|
|
22141
|
+
createotel(request, requestOptions) {
|
|
22142
|
+
return HttpResponsePromise.fromPromise(
|
|
22143
|
+
this.__createotel(request, requestOptions)
|
|
22144
|
+
);
|
|
22145
|
+
}
|
|
22146
|
+
async __createotel(request, requestOptions) {
|
|
22147
|
+
const _headers = mergeHeaders(
|
|
22148
|
+
this._options?.headers,
|
|
22149
|
+
requestOptions?.headers
|
|
22150
|
+
);
|
|
22151
|
+
const _response = await fetcher({
|
|
22152
|
+
url: url_exports.join(
|
|
22153
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment) ?? MirascopeEnvironment.Production,
|
|
22154
|
+
"v1/traces"
|
|
22155
|
+
),
|
|
22156
|
+
method: "POST",
|
|
22157
|
+
headers: _headers,
|
|
22158
|
+
contentType: "application/json",
|
|
22159
|
+
queryParameters: requestOptions?.queryParams,
|
|
22160
|
+
requestType: "json",
|
|
22161
|
+
body: TracesCreateOtelRequest.jsonOrThrow(request, {
|
|
22162
|
+
unrecognizedObjectKeys: "strip",
|
|
22163
|
+
omitUndefined: true
|
|
22164
|
+
}),
|
|
22165
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 180) * 1e3,
|
|
22166
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
22167
|
+
abortSignal: requestOptions?.abortSignal,
|
|
22168
|
+
fetchFn: this._options?.fetch,
|
|
22169
|
+
logging: this._options.logging
|
|
22170
|
+
});
|
|
22171
|
+
if (_response.ok) {
|
|
22172
|
+
return {
|
|
22173
|
+
data: TracesCreateOtelResponse.parseOrThrow(
|
|
22174
|
+
_response.body,
|
|
22175
|
+
{
|
|
22176
|
+
unrecognizedObjectKeys: "passthrough",
|
|
22177
|
+
allowUnrecognizedUnionMembers: true,
|
|
22178
|
+
allowUnrecognizedEnumValues: true,
|
|
22179
|
+
skipValidation: true,
|
|
22180
|
+
breadcrumbsPrefix: ["response"]
|
|
22181
|
+
}
|
|
22182
|
+
),
|
|
22183
|
+
rawResponse: _response.rawResponse
|
|
22184
|
+
};
|
|
22185
|
+
}
|
|
22186
|
+
if (_response.error.reason === "status-code") {
|
|
22187
|
+
switch (_response.error.statusCode) {
|
|
22188
|
+
case 400:
|
|
22189
|
+
throw new BadRequestError2(
|
|
22190
|
+
_response.error.body,
|
|
22191
|
+
_response.rawResponse
|
|
22192
|
+
);
|
|
22193
|
+
case 401:
|
|
22194
|
+
throw new UnauthorizedError(
|
|
22195
|
+
UnauthorizedErrorBody.parseOrThrow(
|
|
22196
|
+
_response.error.body,
|
|
22197
|
+
{
|
|
22198
|
+
unrecognizedObjectKeys: "passthrough",
|
|
22199
|
+
allowUnrecognizedUnionMembers: true,
|
|
22200
|
+
allowUnrecognizedEnumValues: true,
|
|
22201
|
+
skipValidation: true,
|
|
22202
|
+
breadcrumbsPrefix: ["response"]
|
|
22203
|
+
}
|
|
22204
|
+
),
|
|
22205
|
+
_response.rawResponse
|
|
22206
|
+
);
|
|
22207
|
+
case 402:
|
|
22208
|
+
throw new PaymentRequiredError(
|
|
22209
|
+
PlanLimitExceededError.parseOrThrow(
|
|
22210
|
+
_response.error.body,
|
|
22211
|
+
{
|
|
22212
|
+
unrecognizedObjectKeys: "passthrough",
|
|
22213
|
+
allowUnrecognizedUnionMembers: true,
|
|
22214
|
+
allowUnrecognizedEnumValues: true,
|
|
22215
|
+
skipValidation: true,
|
|
22216
|
+
breadcrumbsPrefix: ["response"]
|
|
22217
|
+
}
|
|
22218
|
+
),
|
|
22219
|
+
_response.rawResponse
|
|
22220
|
+
);
|
|
22221
|
+
case 403:
|
|
22222
|
+
throw new ForbiddenError(
|
|
22223
|
+
PermissionDeniedError.parseOrThrow(
|
|
22224
|
+
_response.error.body,
|
|
22225
|
+
{
|
|
22226
|
+
unrecognizedObjectKeys: "passthrough",
|
|
22227
|
+
allowUnrecognizedUnionMembers: true,
|
|
22228
|
+
allowUnrecognizedEnumValues: true,
|
|
22229
|
+
skipValidation: true,
|
|
22230
|
+
breadcrumbsPrefix: ["response"]
|
|
22231
|
+
}
|
|
22232
|
+
),
|
|
22233
|
+
_response.rawResponse
|
|
22234
|
+
);
|
|
22235
|
+
case 404:
|
|
22236
|
+
throw new NotFoundError2(
|
|
22237
|
+
NotFoundErrorBody.parseOrThrow(_response.error.body, {
|
|
22238
|
+
unrecognizedObjectKeys: "passthrough",
|
|
22239
|
+
allowUnrecognizedUnionMembers: true,
|
|
22240
|
+
allowUnrecognizedEnumValues: true,
|
|
22241
|
+
skipValidation: true,
|
|
22242
|
+
breadcrumbsPrefix: ["response"]
|
|
22243
|
+
}),
|
|
22244
|
+
_response.rawResponse
|
|
22245
|
+
);
|
|
22246
|
+
case 409:
|
|
22247
|
+
throw new ConflictError(
|
|
22248
|
+
_response.error.body,
|
|
22249
|
+
_response.rawResponse
|
|
22250
|
+
);
|
|
22251
|
+
case 429:
|
|
22252
|
+
throw new TooManyRequestsError(
|
|
22253
|
+
RateLimitError2.parseOrThrow(_response.error.body, {
|
|
22254
|
+
unrecognizedObjectKeys: "passthrough",
|
|
22255
|
+
allowUnrecognizedUnionMembers: true,
|
|
22256
|
+
allowUnrecognizedEnumValues: true,
|
|
22257
|
+
skipValidation: true,
|
|
22258
|
+
breadcrumbsPrefix: ["response"]
|
|
22259
|
+
}),
|
|
22260
|
+
_response.rawResponse
|
|
22261
|
+
);
|
|
22262
|
+
case 500:
|
|
22263
|
+
throw new InternalServerError(
|
|
22264
|
+
_response.error.body,
|
|
22265
|
+
_response.rawResponse
|
|
22266
|
+
);
|
|
22267
|
+
case 503:
|
|
22268
|
+
throw new ServiceUnavailableError(
|
|
22269
|
+
_response.error.body,
|
|
22270
|
+
_response.rawResponse
|
|
22271
|
+
);
|
|
22272
|
+
default:
|
|
22273
|
+
throw new MirascopeError2({
|
|
22274
|
+
statusCode: _response.error.statusCode,
|
|
22275
|
+
body: _response.error.body,
|
|
22276
|
+
rawResponse: _response.rawResponse
|
|
22277
|
+
});
|
|
22278
|
+
}
|
|
22279
|
+
}
|
|
22280
|
+
return handleNonStatusCodeError(
|
|
22281
|
+
_response.error,
|
|
22282
|
+
_response.rawResponse,
|
|
22283
|
+
"POST",
|
|
22284
|
+
"/v1/traces"
|
|
22285
|
+
);
|
|
22286
|
+
}
|
|
21872
22287
|
/**
|
|
21873
22288
|
* @param {Mirascope.TracesSearchRequest} request
|
|
21874
22289
|
* @param {TracesClient.RequestOptions} requestOptions - Request-specific configuration.
|