Skip to content

Conversation

@epinault
Copy link
Contributor

@epinault epinault commented Mar 26, 2025

This is an attempt to add some basic telemetry. This will be useful to then create an OTEL package to automatically get tracing from this telemetry setup.

I am happy to add tests as well but the setup is currently difficult in this project to run outside of CI. Is that the intent to not be able to run them locally? Is there way to make them run locally?

@brainlid
Copy link
Owner

Hi @epinault! The test should be easy to run locally. The main challenge is that some tests are "live", meaning they hit a server and test the responses. Those require an API key for the service being tested. I typically run the tests locally and focus on the live tests for the service I'm working with currently.

Otherwise, running mix test runs all the non-live tests locally. In general, I try to have most of the important parsing logic run using non-live tests.

@epinault
Copy link
Contributor Author

I think because it require the API key and I don t have any, thats where the challenge was. The test_helper does a fetch_env! . I ll just put fake value and see what happens. Just feels we could make it a little easier so we dont even need them in test for local test?

@brainlid
Copy link
Owner

There's a file .envrc_template in the root of the project. Rename it to .envrc and if you're using something like direnv, then the dummy API keys get loaded for you.

If there's something else needed in the Testing section of the README, I'm happy to update it.

@epinault epinault force-pushed the epinault/adds-telemetry branch from a716045 to 910bc8a Compare March 27, 2025 03:57
@epinault
Copy link
Contributor Author

@brainlid thanks! that helped! I updated the README and added tests. what do you think about the MR?

@epinault
Copy link
Contributor Author

@brainlid any chance we could merge this in?

@brainlid
Copy link
Owner

brainlid commented Apr 12, 2025

Hi @epinault!

I tried to update the PR, but failed and gave up after about 30 minutes. I'm guessing the PR/branch isn't setup to "Allow edits from maintainers", either that or I was just having a bad day.

It looks good! I like the telemetry module with the event docs and examples.

Here's what I was trying to do:

  • Merged master in
  • Fix merge errors
  • Fix variable names in ChatMistralAI (openai -> mistralai)
  • Run formatter

There are about 5 tests failing in test/chat_models/telemetry_test.exs. It appears that they are running as "live" tests and failing with bad API credentials, which makes me think the mocking isn't setup as expected for the tests?

Once we get this fixed up I'll be happy to merge it!

@epinault
Copy link
Contributor Author

sounds good! I ll take a look this week and try to fix it up

@epinault epinault force-pushed the epinault/adds-telemetry branch from 910bc8a to e1f1aaa Compare April 16, 2025 03:38
@epinault
Copy link
Contributor Author

rebased, fixed up the merge error, and the variable name. Also reformatted with 1.18

Looking at the 5 tests now

@epinault epinault force-pushed the epinault/adds-telemetry branch from f062ebb to 5ac6ebc Compare April 16, 2025 03:59
@epinault
Copy link
Contributor Author

ok hopefully test are passing for you now too! I used a bit of "AI" to get the tests fixed up. 😅

@brainlid brainlid merged commit 3f8d32e into brainlid:main Apr 16, 2025
2 checks passed
@brainlid
Copy link
Owner

Awesome @epinault! Thanks! This is a valuable addition.
❤️💛💙💜

@epinault
Copy link
Contributor Author

thank you for merging this! Now I just need to make an opentelemetry version of that for tracing 🫠

brainlid added a commit that referenced this pull request Apr 19, 2025
* 'main' of github.com:brainlid/langchain:
  adds telemetry (#284)
  check that the requested tool_name exists - return an error if it does not exist in the chain
  added LLMChain.run_until_tool_used/3 (#292)
brainlid added a commit that referenced this pull request Apr 23, 2025
* main:
  updated readme for version install
  updated mix.exs version for release
  updated changelog for v0.3.3
  added content part description to OpenAI module doc for file uploads
  fixed doc typo
  adds telemetry (#284)
  check that the requested tool_name exists - return an error if it does not exist in the chain
  added LLMChain.run_until_tool_used/3 (#292)
  Support for file with file_id in ChatOpenAI (#283)
  Fix options being passed to the ollama chat api (#179)
  Support for json_response in ChatModels.ChatGoogleAI (#277)
  support streaming responses from mistral (#287)
  feat: File urls for Google (#286)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants