-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from guardrails-ai/anonymous-telem
trace on server start
- Loading branch information
Showing
5 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.0.1" | ||
__version__ = "0.0.2" |
This file contains 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 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,10 @@ | ||
import requests | ||
|
||
|
||
def has_internet_connection() -> bool: | ||
try: | ||
res = requests.get("https://www.guardrailsai.com/") | ||
res.raise_for_status() | ||
return True | ||
except requests.ConnectionError: | ||
return False |
This file contains 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,24 @@ | ||
import platform | ||
from guardrails.classes.credentials import Credentials | ||
from guardrails.version import GUARDRAILS_VERSION | ||
from guardrails_api.utils.has_internet_connection import has_internet_connection | ||
|
||
|
||
def trace_server_start_if_enabled(): | ||
config = Credentials.from_rc_file() | ||
if config.enable_metrics is True and has_internet_connection(): | ||
from guardrails.utils.hub_telemetry_utils import HubTelemetry | ||
HubTelemetry().create_new_span( | ||
"guardrails-api/start", | ||
[ | ||
("guardrails-version", GUARDRAILS_VERSION), | ||
("python-version", platform.python_version()), | ||
("system", platform.system()), | ||
("platform", platform.platform()), | ||
("arch", platform.architecture()[0]), | ||
("machine", platform.machine()), | ||
("processor", platform.processor()), | ||
], | ||
True, | ||
False, | ||
) |
This file contains 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