Skip to content

Commit

Permalink
Print telemetry warning only for developers
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianSosic committed Nov 27, 2024
1 parent ba43352 commit 64f6e7f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions baybe/telemetry/_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __getattribute__(self, name: str, /) -> Any:
try:
self._initialize()
except Exception:
if is_enabled():
if is_enabled() and user_is_developer():
warnings.warn(
"Opentelemetry could not be imported. Potentially it is "
"not installed. Disabling BayBE telemetry.",
Expand Down Expand Up @@ -182,7 +182,7 @@ def daemon_task() -> None:

# Telemetry is active but the endpoint is not reachable
if TELEMETRY_VPN_CHECK and (ex := test_connection()) is not None:
if os.environ.get(VARNAME_TELEMETRY_USERNAME, "").startswith("DEV_"):
if user_is_developer():
# Only printed for developers to make them aware of potential issues
warnings.warn(
f"WARNING: BayBE Telemetry endpoint '{ENDPOINT_URL}' cannot be "
Expand Down Expand Up @@ -217,6 +217,11 @@ def get_user_details() -> dict[str, str]:
return {"host": hostname_hash, "user": username_hash, "version": __version__}


def user_is_developer() -> bool:
"""Determine if the user is a developer."""
return os.environ.get(VARNAME_TELEMETRY_USERNAME, "").startswith("DEV_")


def submit_scalar_value(instrument_name: str, value: int | float) -> None:
"""See :func:`baybe.telemetry.api.telemetry_record_value`."""
if instrument_name in tools.instruments:
Expand Down

0 comments on commit 64f6e7f

Please sign in to comment.