Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(langchain): add support for chain metadata in spans #175

Merged
merged 6 commits into from
Feb 8, 2024

Conversation

mikeldking
Copy link
Contributor

@mikeldking mikeldking commented Feb 7, 2024

Adds the ability to serialize langchain metadata into the traces via a metadata semantic conventions

Screenshot 2024-02-07 at 11 36 42 PM Screenshot 2024-02-07 at 11 36 07 PM Screenshot 2024-02-07 at 11 35 50 PM

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 7, 2024
assert isinstance(metadata, Mapping), f"expected Mapping, found {type(metadata)}"
# Yield out each metadata key and value
for key, value in metadata.items():
yield f"{LC_METADATA_PREFIX}.{key}", value
Copy link
Contributor Author

@mikeldking mikeldking Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I should do a dump here if it's not a primative?

@@ -0,0 +1,8 @@
# LangChain specific span attributes

LC_METADATA_PREFIX = "langchain.metadata"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively could make this a semcov... Might be somewhat unifying.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding to semcov in #176

Copy link
Contributor

@RogerHYang RogerHYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just be mindful of how the dot partitioning (i.e. dict nesting) works when the attribute key is not a semconv string.
Screenshot 2024-02-07 at 3 35 07 PM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants