xiaohongshu
xiaohongshu
langfuse-extraction
Extracts traces, observations, and metrics from Langfuse Cloud (EU) API for debugging, telemetry analysis, and regulatory audit trails. Generates ALCOA+ compliant reports, exports to pandas DataFrame, and supports time-range/user/session filtering. Use when investigating production issues, genera...
Full skill instructions
Purpose: Extract observability data from Langfuse Cloud API for analysis, debugging, and compliance reporting.
✅ Use when:
❌ Do NOT use when:
langfuse-integration skill)langfuse-dashboard skill)Use case: Get last 24 hours of traces for monitoring/debugging.
# scripts/extract_traces.py --hours 24 --output recent_traces.json
from langfuse import Langfuse
from datetime import datetime, timedelta
import json
langfuse = Langfuse()
from_time = datetime.now() - timedelta(hours=24)
traces = langfuse.api.trace.list(
from_timestamp=from_time.isoformat(),
tags=["pharmaceutical", "gamp5"],
limit=100
)
# Export to JSON
with open("recent_traces.json", "w") as f:
json.dump([{
"trace_id": t.id,
"timestamp": t.timestamp,
"user_id": t.user_id,
"session_id": t.session_id,
"duration_ms": t.duration,
"status": t.status
} for t in traces.data], f, indent=2)
Use case: Investigate specific trace with all span details.
# scripts/extract_traces.py --trace-id <id> --detailed
trace = langfuse.api.trace.get("trace_id_here")
observations = []
for obs in trace.observations:
observations.append({
"id": obs.id,
"type": obs.type, # "SPAN", "GENERATION", "EVENT"
"name": obs.name,
"latency_ms": obs.latency,
"input_tokens": obs.usage.input if obs.usage else 0,
"output_tokens": obs.usage.output if obs.usage else 0,
"cost": obs.calculated_total_cost or 0.0,
"metadata": obs.metadata
})
Use case: Regulatory compliance reporting.
# scripts/generate_audit_trail.py --user-id <clerk_id> --session-id <job_id>
def generate_audit_trail(user_id: str, session_id: str = None):
traces = langfuse.api.trace.list(
user_id=user_id,
session_id=session_id
)
audit_trail = []
for trace in traces.data:
audit_entry = {
"timestamp": trace.timestamp,
"user_id": trace.user_id,
"session_id": trace.session_id,
"trace_id": trace.id,
"compliance": {
"attributable": bool(trace.user_id),
"contemporaneous": True,
"complete": trace.status == "COMPLETED",
"gamp5_category": trace.metadata.get("compliance.gamp5.category")
},
"operations": [
{"name": obs.name, "duration_ms": obs.latency}
for obs in trace.observations
]
}
audit_trail.append(audit_entry)
return audit_trail
Use case: Statistical analysis, cost tracking, performance metrics.
# scripts/export_to_dataframe.py --output traces.csv
import pandas as pd
traces = langfuse.api.trace.list(limit=1000)
records = []
for trace in traces.data:
records.append({
"trace_id": trace.id,
"timestamp": trace.timestamp,
"duration_ms": trace.duration,
"user_id": trace.user_id,
"session_id": trace.session_id,
"total_cost": trace.total_cost or 0.0,
"input_tokens": trace.usage.input if trace.usage else 0,
"output_tokens": trace.usage.output if trace.usage else 0,
"status": trace.status,
"gamp5_category": trace.metadata.get("compliance.gamp5.category")
})
df = pd.DataFrame(records)
df.to_csv("traces.csv", index=False)
Skill Version: 1.0.0 Last Updated: 2025-01-17 API Version: Langfuse REST API v1 EU Data Residency: cloud.langfuse.com
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience