You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
🚀 Feature: use metadata from invoke calls in Langchain to populate span attributes #3213
I'd like to add arbitrary data as an attribute for my events and extract it from metadata when using batch and abatch methods. However, currently it doesn't work: attributes do not get populated from metadata.
🎤 Why is this feature needed ?
Otherwise, when using batch, I have no way to correlate errors to data if I disabled prompts. I disable prompts in some places because the data there is sensitive but if an error happens -- we need to be able to at least get an identifier of this data.
✌️ How do you aim to achieve this?
Not sure yet, let's discuss.
🔄️ Additional Information
I tried using callbacks but they are applied outside of traceloop per-workflow span, not inside of it :(
👀 Have you spent some time to check if this feature request has been raised before?
It just attaches context but I am not sure that context is automatically added as attributes to spans. That would require you to register a custom span processor that adds these attributes to it during span creation such as what this package does but with baggage.
The commit_id is 100% serializable: I tried to add the following code to the instrumentor just as a test and everything worked successfully: commit_id appeared in otel.
Activity
nirga commentedon Aug 2, 2025
Hey @zmievsa-semasoftware - can you give an example of how you pass those attributes?
zmievsa commentedon Aug 2, 2025
Like so
nirga commentedon Aug 2, 2025
I believe we are adding the metadata to the trace as association properties. Is there a chance
commit_idisn't serializable? Can you screenshot the span attributes of the span / trace you're getting?zmievsa commentedon Aug 2, 2025
It just attaches context but I am not sure that context is automatically added as attributes to spans. That would require you to register a custom span processor that adds these attributes to it during span creation such as what this package does but with baggage.
The commit_id is 100% serializable: I tried to add the following code to the instrumentor just as a test and everything worked successfully: commit_id appeared in otel.
nirga commentedon Aug 2, 2025
Oh I see now - we use the context to propagate the metadata to all spans - but we do that in the SDK - are you using the instrumentation directly?
zmievsa commentedon Aug 2, 2025
Yup, I am :(
fix(langchain): populate metadata as span attributes in batch operations
zmievsa-semasoftware commentedon Aug 3, 2025
@nirga you are a rockstar! Thank you very much!