-
Notifications
You must be signed in to change notification settings - Fork 994
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add basic anonymous telemetry Signed-off-by: Jacob Klegar <jacob@tecton.ai> * add telemetry docs Signed-off-by: Jacob Klegar <jacob@tecton.ai> * add testing Signed-off-by: Jacob Klegar <jacob@tecton.ai> * fix test Signed-off-by: Jacob Klegar <jacob@tecton.ai> * lint Signed-off-by: Jacob Klegar <jacob@tecton.ai> * fix prow job Signed-off-by: Jacob Klegar <jacob@tecton.ai> * bugfix Signed-off-by: Jacob Klegar <jacob@tecton.ai> * fix env var setting Signed-off-by: Jacob Klegar <jacob@tecton.ai> * lint Signed-off-by: Jacob Klegar <jacob@tecton.ai> * address comments and fix unit test Signed-off-by: Jacob Klegar <jacob@tecton.ai> * lint Signed-off-by: Jacob Klegar <jacob@tecton.ai>
- Loading branch information
Showing
15 changed files
with
232 additions
and
5 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
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
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 @@ | ||
# Telemetry | ||
|
||
### How telemetry is used | ||
|
||
The Feast maintainers use anonymous usage statistics to help shape the Feast roadmap. Several client methods are tracked, beginning in Feast 0.9. Users are assigned a UUID which is sent along with the name of the method, the Feast version, the OS (using `sys.platform`), and the current time. For more detailed information see [the source code](https://github.com/feast-dev/feast/blob/master/sdk/python/feast/telemetry.py). | ||
|
||
### How to disable telemetry | ||
|
||
To opt out of telemetry, simply set the environment variable `FEAST_TELEMETRY` to `False` in the environment in which the Feast client is run. | ||
|
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
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
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
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,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# Default artifact location setting in Prow jobs | ||
LOGS_ARTIFACT_PATH=/logs/artifacts | ||
|
||
pip install -r sdk/python/requirements-ci.txt | ||
make compile-protos-python | ||
make lint-python | ||
|
||
cd sdk/python/ | ||
pip install -e . | ||
cd telemetry_tests/ | ||
pytest --junitxml=${LOGS_ARTIFACT_PATH}/python-sdk-test-report.xml |
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
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,45 @@ | ||
# Copyright 2019 The Feast Authors | ||
# | ||
# 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 | ||
# | ||
# https://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. | ||
|
||
import os | ||
import sys | ||
from datetime import datetime | ||
from typing import Dict | ||
|
||
import requests | ||
|
||
TELEMETRY_ENDPOINT = ( | ||
"https://us-central1-kf-feast.cloudfunctions.net/bq_telemetry_logger" | ||
) | ||
|
||
|
||
def log_usage( | ||
function_name: str, | ||
telemetry_id: str, | ||
timestamp: datetime, | ||
version: Dict[str, Dict[str, str]], | ||
): | ||
json = { | ||
"function_name": function_name, | ||
"telemetry_id": telemetry_id, | ||
"timestamp": timestamp.isoformat(), | ||
"version": version, | ||
"os": sys.platform, | ||
"is_test": os.getenv("FEAST_IS_TELEMETRY_TEST", "False"), | ||
} | ||
try: | ||
requests.post(TELEMETRY_ENDPOINT, json=json) | ||
except Exception: | ||
pass | ||
return |
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,70 @@ | ||
# Copyright 2020 The Feast Authors | ||
# | ||
# 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 | ||
# | ||
# https://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. | ||
|
||
from datetime import datetime | ||
from feast.client import Client | ||
from feast.entity import Entity | ||
from feast.value_type import ValueType | ||
from google.cloud import bigquery | ||
import os | ||
import pytest | ||
from time import sleep | ||
|
||
def test_telemetry_on(): | ||
os.environ["FEAST_IS_TELEMETRY_TEST"] = 'True' | ||
test_client = Client(serving_url=None, core_url=None) | ||
test_client.set_project("project1") | ||
entity = Entity( | ||
name="driver_car_id", | ||
description="Car driver id", | ||
value_type=ValueType.STRING, | ||
labels={"team": "matchmaking"}, | ||
) | ||
|
||
timestamp = datetime.utcnow() | ||
try: | ||
test_client.apply(entity) | ||
except Exception: | ||
pass | ||
|
||
sleep(30) | ||
bq_client = bigquery.Client() | ||
query = f"select * from `kf-feast.feast_telemetry.cloudfunctions_googleapis_com_cloud_functions` where timestamp >= TIMESTAMP(\"{timestamp.date().isoformat()}\") and JSON_EXTRACT(textPayload, '$.is_test')='\"True\"' and JSON_EXTRACT(textPayload, '$.timestamp')>'\"{timestamp.isoformat()}\"'" | ||
query_job = bq_client.query(query) | ||
rows = query_job.result() | ||
assert(rows.total_rows == 1) | ||
|
||
def test_telemetry_off(): | ||
os.environ["FEAST_IS_TELEMETRY_TEST"] = 'True' | ||
test_client = Client(serving_url=None, core_url=None, telemetry=False) | ||
test_client.set_project("project1") | ||
entity = Entity( | ||
name="driver_car_id", | ||
description="Car driver id", | ||
value_type=ValueType.STRING, | ||
labels={"team": "matchmaking"}, | ||
) | ||
|
||
timestamp = datetime.utcnow() | ||
try: | ||
test_client.apply(entity) | ||
except Exception: | ||
pass | ||
|
||
sleep(30) | ||
bq_client = bigquery.Client() | ||
query = f"select * from `kf-feast.feast_telemetry.cloudfunctions_googleapis_com_cloud_functions` where timestamp >= TIMESTAMP(\"{timestamp.date().isoformat()}\") and JSON_EXTRACT(textPayload, '$.is_test')='\"True\"' and JSON_EXTRACT(textPayload, '$.timestamp')>'\"{timestamp.isoformat()}\"'" | ||
query_job = bq_client.query(query) | ||
rows = query_job.result() | ||
assert(rows.total_rows == 0) |