([]);
const spans = openTelemetrySpanAdapter.convertRawDocumentsToSpans(traceData);
return (
{/* Traces sidebar */}
{}}
onTraceSelect={setSelectedTrace}
selectedTrace={selectedTrace}
/>
{/* Tree view */}
{/* Details panel */}
{selectedSpan && }
);
}
```
--------------------------------
### Import AgentPrism Types and Constants
Source: https://github.com/evilmartians/agent-prism/blob/main/packages/types/readme.md
Demonstrates how to import core TypeScript types such as TraceSpan, TraceSpanAttribute, and TraceSpanCategory, as well as OpenTelemetry and Langfuse related types. It also shows importing constants for OpenInference semantic conventions.
```typescript
// Import types
import type {
TraceSpan,
TraceSpanAttribute,
TraceSpanCategory,
OpenTelemetrySpan,
OpenTelemetryDocument,
} from "@evilmartians/agent-prism-types";
// Import constants for OpenInference semantic conventions
import {
OPENINFERENCE_ATTRIBUTES,
OPENINFERENCE_MAPPINGS,
OPENTELEMETRY_GENAI_MAPPINGS,
} from "@evilmartians/agent-prism-types";
```
--------------------------------
### Conditional Class Styling with Classnames
Source: https://github.com/evilmartians/agent-prism/blob/main/CONTRIBUTING.md
Demonstrates how to use the 'classnames' library for conditionally applying CSS classes based on component state or props. This is recommended for managing complex styling logic.
```jsx
import cn from "classnames";
...
...
```
--------------------------------
### Adapt Langfuse Traces to Spans with AgentPrism
Source: https://github.com/evilmartians/agent-prism/blob/main/readme.md
Converts raw Langfuse trace documents into a standardized span format using the `langfuseSpanAdapter` from `@evilmartians/agent-prism-data`. This facilitates the use of Langfuse traces within the AgentPrism TraceViewer.
```typescript
import { langfuseSpanAdapter } from "@evilmartians/agent-prism-data";
const spans = langfuseSpanAdapter.convertRawDocumentsToSpans(langfuseDocument);
```
--------------------------------
### TraceViewer Data Structure Interface
Source: https://github.com/evilmartians/agent-prism/blob/main/readme.md
Defines the expected data structure for AgentPrism's TraceViewer component. It includes trace metadata, a hierarchical span tree, and optional badges, ensuring compatibility with UI components.
```typescript
interface TraceViewerData {
traceRecord: TraceRecord; // Trace metadata (id, timestamp, status)
spans: TraceSpan[]; // Hierarchical span tree
badges?: BadgeProps[]; // Optional trace badges
}
```
--------------------------------
### Data Integration Adapters in JavaScript/TypeScript
Source: https://github.com/evilmartians/agent-prism/blob/main/readme.md
Shows how to use data adapters provided by AgentPrism to normalize trace data from different sources like OpenTelemetry and Langfuse into a format suitable for UI rendering. These adapters offer methods for converting raw data and extracting specific span information.
```tsx
import {
openTelemetrySpanAdapter,
langfuseSpanAdapter,
} from "@evilmartians/agent-prism-data";
// convert whole documents to TraceSpans (normalized view)
openTelemetrySpanAdapter.convertRawDocumentsToSpans(otlpData);
// convert single span (a.k.a. record, a.k.a. Langfuse observation)
openTelemetrySpanAdapter.convertRawSpanToTraceSpan(otlpData);
// in case you want to use TreeView component
openTelemetrySpanAdapter.convertRawSpansToSpanTree(otlpData);
// get some data for a particular observation/span (e.g. when you loaded one record)
langfuseSpanAdapter.getSpanCategory(observationData);
langfuseSpanAdapter.getSpanCost(observationData);
langfuseSpanAdapter.getSpanDuration(observationData);
langfuseSpanAdapter.getSpanInputOutput(observationData);
langfuseSpanAdapter.getSpanStatus(observationData);
langfuseSpanAdapter.getSpanTokensCount(observationData);
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.