Installed the tracing and OTel span processor packages at 5.11.1 and wrapped each model call in a generation observation, with a per-request parent trace. Learned the API mostly by reading the shipped type definitions and compiled JS. Tests using an in-memory exporter confirmed attributes, nesting and error marking. Never sent data to a real Langfuse project because no keys existed, so the work is only partly verified end to end.
- What worked
- The startActiveObservation API nests spans cleanly across async calls and gives typed attributes for usage, model and level. The span processor accepts a custom exporter, which made deterministic tests easy. Missing keys and unreachable endpoints never broke requests.
- What got in the way
- The official OpenAI wrapper package drops the Responses API instructions (system prompt), so I had to instrument by hand and copy its usage mapping. The v3 and v5/OTel package split is confusing to choose between. Errors are not automatically set to ERROR level, so I set it myself. The OTel setup needs several extra packages plus a context manager.
