Skip to content

Commit 5ea0a71

Browse files
authored
Check LRU cache before acquiring the semaphore/thread to upload a file (open-telemetry#3907)
* initial commit * Add changelog * Respond to comments
1 parent 447aac2 commit 5ea0a71

File tree

2 files changed

+5
-0
lines changed
  • instrumentation-genai/opentelemetry-instrumentation-google-genai
  • util/opentelemetry-util-genai/src/opentelemetry/util/genai/_upload

2 files changed

+5
-0
lines changed

instrumentation-genai/opentelemetry-instrumentation-google-genai/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
- Minor change to check LRU cache in Completion Hook before acquiring semaphore/thread ([#3907](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3907)).
11+
1012
## Version 0.4b0 (2025-10-16)
1113

1214
- Implement the new semantic convention changes made in https://github.com/open-telemetry/semantic-conventions/pull/2179.

util/opentelemetry-util-genai/src/opentelemetry/util/genai/_upload/completion_hook.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ def done(future: Future[None]) -> None:
149149
path,
150150
contents_hashed_to_filename,
151151
), json_encodeable in upload_data.items():
152+
if contents_hashed_to_filename and path in self.lru_dict:
153+
self.lru_dict.move_to_end(path)
154+
continue
152155
# could not acquire, drop data
153156
if not self._semaphore.acquire(blocking=False): # pylint: disable=consider-using-with
154157
_logger.warning(

0 commit comments

Comments
 (0)