// Function accepting any observation type
function logObservation(obs: LangfuseObservation) {
console.log(`Observation ${obs.id} in trace ${obs.traceId}`);
// All observations have common methods
obs.updateTrace({ tags: ['logged'] });
obs.end();
}
// Works with any observation type
const span = startObservation('test-span');
const generation = startObservation('llm-call', {}, { asType: 'generation' });
const agent = startObservation('ai-agent', {}, { asType: 'agent' });
logObservation(span);
logObservation(generation);
logObservation(agent);
Union type representing any Langfuse observation wrapper.
This type encompasses all observation types supported by Langfuse, providing a unified interface for handling different kinds of traced operations. It's particularly useful for generic functions that work with any observation type.
Included Types