Add support for custom serialization of observation fields #2781
ashamlian-roadway
started this conversation in
Ideas
Replies: 2 comments 2 replies
-
|
The input and and output of each observation are completely customizable. Just set the capture_input and capture_output args in the observe() decorator to False. Then specify the the desired format of your observation using the 'input' and 'output' params of langfuse_context.update_current_observation(). |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Agree that a custom serializer would be helpful here as overriding the input/output for each and every function adds a lot of instrumentation code which is not necessary. @hassiebp what do you think about this? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
-
Describe the feature or potential improvement
Currently (and if I'm not mistaken), observation data is serialized with
EventSerializer. This class supports relatively robust serialization out of the box, but I think it would be nice to allow users to specify how to serialize objects within the observation. As an example, an observation may have an input with args:(str, pd.DataFrame)object as function input or output.The default logic here assumes that this input is serializable, but in fact we need to specify how to serialize the DataFrame. Additionally, it is possible that the order of checks in the
EventSerializer.default()method should be altered such that serialization ofSequences comes before that oflists ortuples (though I can appreciate there being a LOT of edge cases here...hence the request for general, custom serialization).A
CustomEventSerializercould be injected as an arg toLangfuse()to allow clients to specify how to handle arbitrary types, which is extremely useful when tracking observation inputs and outputs from span to span in conjunction with generation observations (practically speaking, I'm referring to agentic tool-calling scenarios)Additional information
No response
Beta Was this translation helpful? Give feedback.
All reactions