mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
Fix #2536: Add CREWAI_DISABLE_TELEMETRY environment variable
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -22,7 +22,7 @@ usage of tools, API calls, responses, any data processed by the agents, or secre
|
|||||||
When the `share_crew` feature is enabled, detailed data including task descriptions, agents' backstories or goals, and other specific attributes are collected
|
When the `share_crew` feature is enabled, detailed data including task descriptions, agents' backstories or goals, and other specific attributes are collected
|
||||||
to provide deeper insights. This expanded data collection may include personal information if users have incorporated it into their crews or tasks.
|
to provide deeper insights. This expanded data collection may include personal information if users have incorporated it into their crews or tasks.
|
||||||
Users should carefully consider the content of their crews and tasks before enabling `share_crew`.
|
Users should carefully consider the content of their crews and tasks before enabling `share_crew`.
|
||||||
Users can disable telemetry by setting the environment variable `OTEL_SDK_DISABLED` to `true`.
|
Users can disable telemetry by setting the environment variable `CREWAI_DISABLE_TELEMETRY` to `true` or by setting `OTEL_SDK_DISABLED` to `true` (note that the latter disables all OpenTelemetry instrumentation globally).
|
||||||
|
|
||||||
### Data Explanation:
|
### Data Explanation:
|
||||||
| Defaulted | Data | Reason and Specifics |
|
| Defaulted | Data | Reason and Specifics |
|
||||||
@@ -55,4 +55,4 @@ This enables a deeper insight into usage patterns.
|
|||||||
<Warning>
|
<Warning>
|
||||||
If you enable `share_crew`, the collected data may include personal information if it has been incorporated into crew configurations, task descriptions, or outputs.
|
If you enable `share_crew`, the collected data may include personal information if it has been incorporated into crew configurations, task descriptions, or outputs.
|
||||||
Users should carefully review their data and ensure compliance with GDPR and other applicable privacy regulations before enabling this feature.
|
Users should carefully review their data and ensure compliance with GDPR and other applicable privacy regulations before enabling this feature.
|
||||||
</Warning>
|
</Warning>
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ class Telemetry:
|
|||||||
self.ready = False
|
self.ready = False
|
||||||
self.trace_set = False
|
self.trace_set = False
|
||||||
|
|
||||||
if os.getenv("OTEL_SDK_DISABLED", "false").lower() == "true":
|
if (os.getenv("OTEL_SDK_DISABLED", "false").lower() == "true" or
|
||||||
|
os.getenv("CREWAI_DISABLE_TELEMETRY", "false").lower() == "true"):
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
0
tests/telemetry/__init__.py
Normal file
0
tests/telemetry/__init__.py
Normal file
27
tests/telemetry/test_telemetry_disable.py
Normal file
27
tests/telemetry/test_telemetry_disable.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import os
|
||||||
|
import pytest
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
from crewai.telemetry import Telemetry
|
||||||
|
|
||||||
|
|
||||||
|
def test_telemetry_disabled_with_otel_sdk_disabled():
|
||||||
|
"""Test that telemetry is disabled when OTEL_SDK_DISABLED is set to true."""
|
||||||
|
with patch.dict(os.environ, {"OTEL_SDK_DISABLED": "true"}):
|
||||||
|
telemetry = Telemetry()
|
||||||
|
assert telemetry.ready is False
|
||||||
|
|
||||||
|
|
||||||
|
def test_telemetry_disabled_with_crewai_disable_telemetry():
|
||||||
|
"""Test that telemetry is disabled when CREWAI_DISABLE_TELEMETRY is set to true."""
|
||||||
|
with patch.dict(os.environ, {"CREWAI_DISABLE_TELEMETRY": "true"}):
|
||||||
|
telemetry = Telemetry()
|
||||||
|
assert telemetry.ready is False
|
||||||
|
|
||||||
|
|
||||||
|
def test_telemetry_enabled_by_default():
|
||||||
|
"""Test that telemetry is enabled by default."""
|
||||||
|
with patch.dict(os.environ, {}, clear=True):
|
||||||
|
with patch("crewai.telemetry.telemetry.TracerProvider"):
|
||||||
|
telemetry = Telemetry()
|
||||||
|
assert telemetry.ready is True
|
||||||
Reference in New Issue
Block a user