@arizeai/phoenix-client 6.11.2 → 6.12.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 CHANGED
@@ -544,6 +544,32 @@ const rootSpans = await getSpans({
544
544
  | `spanKind` | `SpanKindFilter \| SpanKindFilter[]` | Filter by span kind (`LLM`, `CHAIN`, `TOOL`, `RETRIEVER`, etc.) |
545
545
  | `statusCode` | `SpanStatusCode \| SpanStatusCode[]` | Filter by status code (`OK`, `ERROR`, `UNSET`) |
546
546
 
547
+ ### Logging Spans
548
+
549
+ Use `logSpans` to submit spans directly to a project using Phoenix's simplified span structure — the same shape returned by `getSpans`. This is useful for backfilling or migrating spans without going through OpenTelemetry. If your application is already instrumented with OpenTelemetry, export spans via `@arizeai/phoenix-otel` instead.
550
+
551
+ ```ts
552
+ import { logSpans } from "@arizeai/phoenix-client/spans";
553
+
554
+ const result = await logSpans({
555
+ project: { projectName: "my-project" },
556
+ spans: [
557
+ {
558
+ name: "chat_completion",
559
+ context: { trace_id: "abc123", span_id: "def456" },
560
+ span_kind: "LLM",
561
+ start_time: "2024-01-01T00:00:00Z",
562
+ end_time: "2024-01-01T00:00:01Z",
563
+ status_code: "OK",
564
+ attributes: { "llm.model_name": "gpt-4" },
565
+ },
566
+ ],
567
+ });
568
+ console.log(`Queued ${result.totalQueued} of ${result.totalReceived} spans`);
569
+ ```
570
+
571
+ If any span in the request is invalid or a duplicate of a span that already exists, none of the spans are queued and `logSpans` throws a `SpanCreationError` with `invalidSpans` and `duplicateSpans` details.
572
+
547
573
  ## Span Annotations
548
574
 
549
575
  The `spans` export also provides functions for managing span annotations — adding evaluations, feedback, and labels to spans.