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
Add support for async and streaming responses in the Google GenAI instrumentation (#3298)
* Begin instrumentation of GenAI SDK.
* Snapshot current state.
* Created minimal tests and got first test to pass.
* Added test for span attributes.
* Ensure that token counts work.
* Add more tests.
* Make it easy to turn off instrumentation for streaming and async to allow for rapid iteration.
* Add licenses and fill out main README.rst.
* Add a changelog file.
* Fill out 'requirements.txt' and 'README.rst' for the manual instrumentation example.
* Add missing exporter dependency for the manual instrumentation example.
* Fill out rest of the zero-code example.
* Add minimal tests for async, streaming cases.
* Update sync test to use indirection on top of 'client.models.generate_content' to simplify test reuse.
* Fix ruff check issues.
* Add subproject to top-level project build mechanism.
* Simplify invocation of pylint.
* Fix 'make test' command and lint issues.
* Add '.dev' suffix to version per feedback on pull request #3256
* Fix README.rst files for the examples.
* Add specific versions for the examples.
* Revamp 'make test' to not require local 'tox.ini' configuration.
* Extend separators per review comment.
Co-authored-by: Riccardo Magliocchetti <[email protected]>
* Fix version conflict caused by non-hermetic requirements.
* Fix typo on the comment line.
* Add test for the use of the 'vertex_ai' system, and improve how this system is determined.
* Factor out testing logic to enable sharing with the async code.
* Addressed minor lint issues.
* Make it clearer that nonstreaming_base is a helper module that is not invoked directly.
* Integrate feedback from related pull request #3268.
* Update workflows with 'tox -e generate-workflows'.
* Improve data model and add some rudimentary type checking.
* Accept only 'true' for a true value to align with other code.
* Update the scope name used.
* Add **kwargs to patched methods to prevent future breakage due to the addition of future keyword arguments.
* Remove redundant list conversion in call to "sorted".
Co-authored-by: Aaron Abbott <[email protected]>
* Reformat with 'tox -e ruff'.
* Fix failing lint workflow.
* Fix failing lint workflow.
* Exclude Google GenAI instrumentation from the bootstrap code for now.
* Minor improvements to the tooling shell files.
* Fix typo flagged by codespell spellchecker.
* Increase alignment with broader repo practices.
* Add more TODOs and documentation to clarify the intended work scope.
* Remove unneeded accessor from OTelWrapper.
* Add more comments to the tests.
* Reformat with ruff.
* Change 'desireable' to 'desirable' per codespell spellchecker.
* Make tests pass without pythonpath
* Fix new lint errors showing up after change
* Revert "Fix new lint errors showing up after change"
This reverts commit 567adc6.
pylint ignore instead
* Add TODO item required/requested from code review.
Co-authored-by: Aaron Abbott <[email protected]>
* Simplify changelog per PR feedback.
* Remove square brackets from model name in span name per PR feedback.
* Checkpoint current state.
* Misc test cleanup. Now that scripts are invoked solely through pytest via tox, remove main functions and hash bang lines.
* Improve quality of event logging.
* Implement streaming support in RequestsMocker, get tests passing again.
* Add test with multiple responses.
* Remove support for async and streaming from TODOs, since this is now addressed.
* Increase testing coverage for streaming.
* Reformat with ruff.
* Add minor version bump with changelog.
* Change TODOs to bulleted list.
* Update per PR feedback
Co-authored-by: Aaron Abbott <[email protected]>
* Restructure streaming async logic to begin execution earlier.
* Reformat with ruff.
* Disable pylint check for catching broad exception. Should be allowed given exception is re-raised.
* Simplify async streaming solution per PR comment.
---------
Co-authored-by: Riccardo Magliocchetti <[email protected]>
Co-authored-by: Aaron Abbott <[email protected]>
Copy file name to clipboardexpand all lines: instrumentation-genai/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/generate_content.py
+36-32
Original file line number
Diff line number
Diff line change
@@ -45,15 +45,11 @@
45
45
_logger=logging.getLogger(__name__)
46
46
47
47
48
-
# Constant used for the value of 'gen_ai.operation.name".
49
-
_GENERATE_CONTENT_OP_NAME="generate_content"
50
-
51
48
# Constant used to make the absence of content more understandable.
52
49
_CONTENT_ELIDED="<elided>"
53
50
54
-
# Enable these after these cases are fully vetted and tested
55
-
_INSTRUMENT_STREAMING=False
56
-
_INSTRUMENT_ASYNC=False
51
+
# Constant used for the value of 'gen_ai.operation.name".
Copy file name to clipboardexpand all lines: instrumentation-genai/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/version.py
+1-1
Original file line number
Diff line number
Diff line change
@@ -17,4 +17,4 @@
17
17
# This version should stay below "1.0" until the fundamentals
18
18
# in "TODOS.md" have been addressed. Please revisit the TODOs
19
19
# listed there before bumping to a stable version.
Copy file name to clipboardexpand all lines: instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/generate_content/nonstreaming_base.py
+4-38
Original file line number
Diff line number
Diff line change
@@ -17,31 +17,7 @@
17
17
importunittest
18
18
19
19
from ..common.baseimportTestCase
20
-
21
-
22
-
defcreate_valid_response(
23
-
response_text="The model response", input_tokens=10, output_tokens=20
0 commit comments