-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Feature/disable telemetry #4032
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
Open
mportdata
wants to merge
43
commits into
google:main
Choose a base branch
from
mportdata:feature/disable-telemetry
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+546
−25
Open
Changes from 37 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
5883369
added flags for enabling and disabling all telemetry - test_spans cur…
mportdata 8aa526c
test(telemetry): cover disable flags
mportdata 541be5f
test(telemetry): cover disable paths
mportdata 6965880
fix(telemetry): restore cache helper
mportdata ba0ce7a
fixed examples in docstring for is_telemetry_enabled which previously…
mportdata 849b281
moved docstring to 1 line for conciseness
mportdata 181a4fd
Merge branch 'main' into feature/disable-telemetry
mportdata f272712
Merge branch 'main' into feature/disable-telemetry
mportdata a6a70be
refactor(agents): simplify span handling
mportdata 8435ad5
refactor(agents): align run_live span handling
mportdata 231c2f2
refactor(telemetry): align span contexts
mportdata 628658b
refactor(flows): simplify call_llm tracing
mportdata 2a2c7f2
refactor(flows): simplify execute_tool tracing
mportdata 75b375c
refactor(telemetry): unify cache span handling
mportdata 6a3a388
chore(samples): revert GEPA formatting
mportdata 276c5ba
refactor(agents): reduce telemetry boilerplate
mportdata ea1d30c
refactor(agents): keep telemetry flag in validator
mportdata cfca1f3
refactor(flows): gate tracing on telemetry
mportdata 6e8c2fa
refactor(core): gate telemetry spans
mportdata a097fcf
refactor(models): rename cache helper
mportdata de5ac88
removed unnecessary formatting change for easier code review
mportdata a4026e7
removed unnecessary formatting change for easier code review
mportdata cafe5e1
reordered the lines on changes to base_agent to minimise diffs for re…
mportdata 7905c89
reordered the lines on changes to base_agent to minimise diffs for re…
mportdata eee9b47
reordered lines to make review easier - now closer to original code
mportdata 9fe906d
removed abstraction _create_gemini_cache_body as this is only used on…
mportdata aedf35f
removed _run_callbacks_and_impl to keep diffs at a minimum per PR
mportdata bdea88f
tidied up diffs that aren't needed
mportdata 1d79472
tidied up diffs that aren't needed
mportdata eaf028b
used nullcontext in google_llm for more efficient span handling when …
mportdata 149c736
tidied up diffs that aren't needed
mportdata 5449dff
made diffs smaller on runners using contextlib
mportdata a309268
tidied up diffs that aren't needed
mportdata ed8e613
tidied up diffs that aren't needed
mportdata 8a601da
tidied up diffs that aren't needed
mportdata 350006c
tidied up diffs that aren't needed
mportdata 8f30332
tidied up diffs that aren't needed
mportdata 0bdf44e
fixed typo telemetryare in docstring
mportdata 6ee7c24
corrected return examples in is_telemetry_enabled
mportdata c7c8cf4
ran autoformat.sh
mportdata 7100e48
fixed is_telemetry_disabled so type checking does not cause issues
mportdata 314cbf0
fixed typing import so the type Any is imported
mportdata 27527f2
Merge branch 'main' into feature/disable-telemetry
mportdata File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Copyright 2025 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Utilities for telemetry. | ||
|
|
||
| This module is for ADK internal use only. | ||
| Please do not rely on the implementation details. | ||
| """ | ||
|
|
||
| from typing import TYPE_CHECKING | ||
|
|
||
| from .env_utils import is_env_enabled | ||
|
|
||
| if TYPE_CHECKING: | ||
| from ..agents.base_agent import BaseAgent | ||
|
|
||
|
|
||
| def is_telemetry_enabled(agent: "BaseAgent") -> bool: | ||
| """Check if telemetry is enabled for the given agent. | ||
|
|
||
| By default telemetry is enabled for an agent unless any of the variables to disable telemetry are set to true. | ||
|
|
||
| Args: | ||
| agent: The agent to check if telemetry is enabled for. | ||
|
|
||
| Returns: | ||
| False if any of the environment variables or attributes to disable telemetryare set to True, 'true' or 1, False otherwise. | ||
|
|
||
| Examples: | ||
| >>> os.environ['OTEL_SDK_DISABLED'] = 'true' | ||
| >>> is_telemetry_enabled(my_agent) | ||
| True | ||
|
|
||
| >>> os.environ['ADK_TELEMETRY_DISABLED'] = 1 | ||
| >>> is_telemetry_enabled(my_agent) | ||
| True | ||
|
|
||
| >>> my_agent.disable_telemetry = True | ||
| >>> is_telemetry_enabled(my_agent) | ||
| True | ||
|
|
||
| >>> os.environ['OTEL_SDK_DISABLED'] = 1 | ||
| >>> os.environ['ADK_TELEMETRY_DISABLED'] = 'false' | ||
| >>> my_agent.disable_telemetry = False | ||
| >>> is_telemetry_enabled(my_agent) | ||
| False | ||
| """ | ||
| telemetry_disabled = ( | ||
| is_env_enabled("OTEL_SDK_DISABLED") | ||
| or is_env_enabled("ADK_TELEMETRY_DISABLED") | ||
| or getattr(agent, "disable_telemetry", False) | ||
| ) | ||
| return not telemetry_disabled | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Copyright 2025 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.