Instrument Haystack
Recipe — instrument a Haystack pipeline using manual trace upload.
import json, uuid
from pathlib import Path
from layerlens import Stratix
client = Stratix()
# Run your Haystack pipeline
result = pipeline.run({"text_embedder": {"text": query}, "prompt_builder": {"query": query}})
# Build a trace record (data is flexible Dict[str, Any])
trace_record = {
"id": str(uuid.uuid4()),
"input": query,
"output": result["llm"]["replies"][0] if "llm" in result else None,
"data": {
"haystack_pipeline_outputs": result,
},
}
Path("haystack_trace.jsonl").write_text(json.dumps(trace_record))
client.traces.upload("haystack_trace.jsonl")See also
Last updated
Was this helpful?