[AUR-401] Disable Haystack telemetry with monkey patching (#1)
Sample Haystack log when running a pipeline. Note: the `pipeline.classname` can leak company information.
```json
{
"hardware.cpus": 16,
"hardware.gpus": 0,
"libraries.colab": false,
"libraries.cuda": false,
"libraries.haystack": "1.20.0rc0",
"libraries.ipython": false,
"libraries.pytest": false,
"libraries.ray": false,
"libraries.torch": false,
"libraries.transformers": "4.31.0",
"os.containerized": false,
"os.family": "Linux",
"os.machine": "x86_64",
"os.version": "6.2.0-26-generic",
"pipeline.classname": "TempPipeline",
"pipeline.config_hash": "07a8eddd5a6e512c0d898c6d9f445ed9",
"pipeline.nodes.PromptNode": 1,
"pipeline.nodes.Shaper": 1,
"pipeline.nodes.WebRetriever": 1,
"pipeline.run_parameters.debug": false,
"pipeline.run_parameters.documents": [
0
],
"pipeline.run_parameters.file_paths": 0,
"pipeline.run_parameters.labels": 0,
"pipeline.run_parameters.meta": 1,
"pipeline.run_parameters.params": false,
"pipeline.run_parameters.queries": true,
"pipeline.runs": 1,
"pipeline.type": "Query",
"python.version": "3.10.12"
}
```
Solution: Haystack telemetry uses the `telemetry` variable, `posthog` library and `HAYSTACK_TELEMETRY_ENABLED` envar. We set the envar to False and make sure the relevant objects are disabled.
This commit is contained in:
committed by
GitHub
parent
043209fda7
commit
e9d1d5c118
@@ -0,0 +1,25 @@
|
||||
# Disable telemetry with monkey patching
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
try:
|
||||
import posthog
|
||||
|
||||
def capture(*args, **kwargs):
|
||||
logger.info("posthog.capture called with args: %s, kwargs: %s", args, kwargs)
|
||||
|
||||
posthog.capture = capture
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
try:
|
||||
import os
|
||||
|
||||
os.environ["HAYSTACK_TELEMETRY_ENABLED"] = "False"
|
||||
import haystack.telemetry
|
||||
|
||||
haystack.telemetry.telemetry = None
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
__version__ = "0.0.1"
|
||||
|
||||
Reference in New Issue
Block a user