Skip to content

[chore] Address TODO to migrate to VCRpy and remove bespoke RequestMocker code in Google GenAI SDK instrumentation #3344

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

Merged

Conversation

michaelsafyan
Copy link
Contributor

@michaelsafyan michaelsafyan commented Mar 6, 2025

Description

Revises the tests to split up into two different categories:

  1. A majority of tests that fully mock out the GenAI SDK (and do not need any request-level mocking).
  2. An end-to-end ("e2e") test that uses VCRpy to test with a non-mocked GenAI SDK to sanity-check the system.

This addresses prior pull request feedback expressing concern regarding bespoke request mocking and deviation from typical pattern elsewhere of using the VCRpy component. This also addresses the original underlying concerns regarding velocity; since most tests do not use VCRpy and directly mock the underlying GenAI SDK, most feature changes can be tested with much simpler mocks of the GenAI SDK outputs.

Type of change

  • Code cleanup

How Has This Been Tested?

  • Recorded with:

  • tox -e py312-test-instrumentation-google-genai-oldest --vcr-record=all

  • Ran the tests with:

  • tox -e py312-test-instrumentation-google-genai-oldest

Does This PR Require a Core Repo Change?

  • No

@michaelsafyan michaelsafyan marked this pull request as ready for review March 7, 2025 22:26
@michaelsafyan
Copy link
Contributor Author

Friendly ping.... is it possible to get this reviewed?

@nirga
Copy link
Contributor

nirga commented Mar 13, 2025

@michaelsafyan note the failing CI

@michaelsafyan
Copy link
Contributor Author

Thanks. I had missed those failing checks.

Notes for myself for addressing this:

  1. First fix is in relation to lint (tox -e lint-instrumentation-google-genai).
  2. Second is in relation to tests on Python 3.9 (tox -e py39-test-instrumentation-google-genai-oldest, py39-test-instrumentation-google-genai-latest). It looks like VCRpy reports content-encoding: gzip even when it isn't gzipped, and this is causing it to fail in earlier version of Python... I'm guessing more stringent validation compared to later versions.

@michaelsafyan
Copy link
Contributor Author

@xrmx sorry for bothering you, but since you commented with a rocket emoji earlier and are one of the maintainers, I'm wondering if I might be able to ask you to get this merged?

@aabmass aabmass merged commit e43e8c9 into open-telemetry:main Mar 19, 2025
712 checks passed
@michaelsafyan michaelsafyan deleted the google_genai_test_improvements branch March 19, 2025 19:23
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.

9 participants