crewAI: [BUG] Cannot connect to telemetry.crewai.com

Description Cannot connect to telemetry.crewai.com.

Steps to Reproduce Provide a step-by-step process to reproduce the behavior: Make any stub code for a crew completing a task. Your console will be flooded with errors saying it can’t connect to telemetry.crewai.com. It seems like this error logging should be suppressed as its not essential to the program, and it obfuscates the actual valuable console output.

Expected behavior No logging when there’s a failure to connect to the (optional) telemetry server. My code and deployments should not suffer because the crewai.com site is down.

Screenshots/Code snippets Here’s the simple code I’m running:

from crewai import Crew, Task, Agent
from crewai_tools import tool

@tool("Add tool")
def add(a: int, b: int) -> int:
    """
    Adds two numbers together

    :param a: First number to add
    :param b: Second number to add
    :return: The sum of the two numbers `a` and `b`.
    """
    return a + b
math_agent = Agent(
    role="Math",
    goal="Add numbers",
    backstory="I am an agent that can add 2 numbers together.",
    tools=[add],
    allow_delegation=False,
)
add_task = Task(
    description="Add numbers {a} and {b}",
    expected_output="The sum of 3 and 5 is 8.",
    agent=math_agent,
)
crew = Crew(agents=[math_agent], tasks=[add_task], max_rpm=100)
result = crew.kickoff(inputs={ "a": 10, "b": 20 })

It seems the error may be occurring because crewai.com is down. When I access crewai.com, it redirects to some firewall from my ISP saying crewai.com’s certificate is invalid. image

Environment Details:

  • Operating System: macOS Sonoma
  • Python Version: 3.11
  • crewAI Version: 0.41.1
  • crewAI Tools Version: 0.4.26

Logs

Here’s what gets printed in my console when I run the stub code above.

It does print the correct answer of 30 (albeit not with the correct format…) but then it dumps a bunch of errors involving failed connections to the telemetry server.

30

2024-08-10 23:57:47,791 - 11391905792 - __init__.py-__init__:369 - ERROR: Exception while exporting Span batch.
Traceback (most recent call last):
  File "/Users/shrey/code/lambdas/venv/lib/python3.11/site-packages/urllib3/connection.py", line 198, in _new_conn
    sock = connection.create_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/shrey/code/lambdas/venv/lib/python3.11/site-packages/urllib3/util/connection.py", line 85, in create_connection
    raise err
  File "/Users/shrey/code/lambdas/venv/lib/python3.11/site-packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/shrey/code/lambdas/venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 793, in urlopen
    response = self._make_request(
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/shrey/code/lambdas/venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 491, in _make_request
    raise new_e
  File "/Users/shrey/code/lambdas/venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 467, in _make_request
    self._validate_conn(conn)
  File "/Users/shrey/code/lambdas/venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 1099, in _validate_conn
    conn.connect()
  File "/Users/shrey/code/lambdas/venv/lib/python3.11/site-packages/urllib3/connection.py", line 616, in connect
    self.sock = sock = self._new_conn()
                       ^^^^^^^^^^^^^^^^
  File "/Users/shrey/code/lambdas/venv/lib/python3.11/site-packages/urllib3/connection.py", line 213, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x2a24c0590>: Failed to establish a new connection: [Errno 61] Connection refused

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/shrey/code/lambdas/venv/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/Users/shrey/code/lambdas/venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 847, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/Users/shrey/code/lambdas/venv/lib/python3.11/site-packages/urllib3/util/retry.py", line 515, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='telemetry.crewai.com', port=4319): Max retries exceeded with url: /v1/traces (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x2a24c0590>: Failed to establish a new connection: [Errno 61] Connection refused'))

(It’ll keep printing this for each retry and on each action that triggers CrewAI telemetry – I’ve omitted the excess logs here.)

Possible Solution Suppress logging output when the telemetry server connections fail. Telemetry is nonessential for end users of crewai libraries; it’s understandable to have invisible telemetry to improve the library, but it’s not good to have it hamper the developer experience here (or, for anyone using crewai in production, blow up someone’s cloud logging bill and maybe even their Slack/PagerDuty).

Additional context Add any other context about the problem here.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

I’ve seen previous discussions that there are two ways to turn this off.

From what I understand, telemetry is currently hardwired into the system. If this is incorrect, please let me know.

You are correct, but you can (or at least could) disable telemetry by adding the following code snippet:

from crewai.telemetry import Telemetry

def noop(*args, **kwargs):
print("Telemetry method called and noop'd\n")
pass

for attr in dir(Telemetry):
if callable(getattr(Telemetry, attr)) and not attr.startswith("__"):
setattr(Telemetry, attr, noop)

Now add the environment variable at the top of the script:

import os
from crewai import Agent, Task, Crew, Process
from crewai_tools import SerperDevTool

os.environ["OTEL_SDK_DISABLED"] = "true"