snowflakedb / snowflakedb/snowflake-connector-python

SNOW-2146179: opentelemetry fails to import when not installed, even when setting telemetry off

Open
#2,352 1 comment 0 reactions 1 assignee View on GitHub

@sfc-gh-snow-drivers-warsaw-dl is already working on this.

Since Jun 16, 2025.

enhancement status-triage_done
Dominant language
Python
Stars
730
Forks
574
Avg merge
5h 45m
Merged PRs (30d)
16

Description

Python version

Python 3.8.5

Operating system and processor architecture

macOS-10.16-x86_64-i386-64bit

Installed packages
aioboto3==12.3.0
aiobotocore==2.11.2
aiodns==3.0.0
aiohttp==3.9.3
aioitertools==0.11.0
aiosignal==1.3.1
aioslacker==0.0.11
aniso8601==9.0.1
annotated-types==0.7.0
anyio==4.5.2
asgiref==3.8.1
asn1crypto==1.5.1
astroid==2.11.7
async-generator==1.10
async-timeout==4.0.3
attrs==22.1.0
backports.zoneinfo==0.2.1
bcrypt==4.0.1
boto3==1.34.34
botocore==1.34.34
capsolver==1.0.7
cchardet==2.1.7
certifi==2022.9.24
cffi==1.15.1
chardet==3.0.4
charset-normalizer==2.1.1
click==8.1.3
colorama==0.4.5
configparser==3.5.0
croniter==6.0.0
cryptography==38.0.1
cycler==0.11.0
Cython==0.29.30
decorator==5.1.1
dill==0.3.6
elasticsearch==7.17.5
et-xmlfile==1.1.0
exceptiongroup==1.2.2
fastapi==0.115.6
filelock==3.8.0
Flask==2.1.3
Flask-RESTful==0.3.9
fonttools==4.38.0
frozenlist==1.4.0
fsspec==2024.10.0
future==0.18.3
fuzzywuzzy==0.18.0
greenlet==3.0.1
gtin-validator==1.0.3
guppy3==3.1.2
h11==0.14.0
html-testRunner==1.2.1
httpcore==1.0.7
httpx==0.28.1
humanize==3.12.0
idna==3.3
importlib-metadata==5.0.0
iniconfig==1.1.1
isort==5.10.1
itsdangerous==2.1.2
Jinja2==3.1.2
jmespath==1.0.1
joblib==1.2.0
jsonpickle==2.2.0
kiwisolver==1.4.4
lazy-object-proxy==1.8.0
Levenshtein==0.21.1
lxml==5.2.2
MarkupSafe==2.1.1
matplotlib==3.5.2
mccabe==0.7.0
multi-key-dict==2.0.3
multidict==4.7.6
networkx==3.1
numpy==1.22.4
openpyxl==3.0.9
outcome==1.2.0
packaging==21.3
pandas==1.4.3
paramiko==2.11.0
passlib==1.7.4
pbr==5.11.0
Pillow==9.2.0
platformdirs==4.3.6
playwright==1.40.0
pluggy==1.0.0
prometheus-client==0.14.1
psutil==5.9.0
py==1.11.0
pyarrow==8.0.0
pyathena==2.11.0
pycares==4.2.2
pycparser==2.21
pydantic==2.10.4
pydantic_core==2.27.2
pyee==11.0.1
PyHive==0.6.5
PyJWT==2.9.0
pylint==2.14.5
Pympler==1.0.1
PyNaCl==1.5.0
pyobjc-core==9.0
pyobjc-framework-Cocoa==9.0
pyodbc==4.0.34
pyOpenSSL==22.1.0
pyotp==2.6.0
pyparsing==3.0.9
pypdf==4.0.1
PySocks==1.7.1
pytest==7.1.2
pytest-asyncio==0.19.0
pytest-timeout==2.1.0
pytest-timestamper==0.0.9
python-dateutil==2.8.2
python-http-client==3.3.7
python-jenkins==1.7.0
python-xlib==0.32
pytz==2022.1
pyxhook==1.0.0
rapidfuzz==3.2.0
redis==5.0.1
requests==2.31.0
requests-file==1.5.1
retry==0.9.2
s3fs==2024.10.0
s3transfer==0.10.0
scikit-learn==1.1.1
scipy==1.7.2
selenium==4.3.0
sendgrid==6.11.0
six==1.16.0
slack-sdk==3.18.1
slacker==0.9.42
snakeviz==2.2.1
sniffio==1.3.0
snowflake-connector-python==3.14.0
sortedcontainers==2.4.0
SQLAlchemy==1.3.18
starkbank-ecdsa==2.2.0
starlette==0.41.3
tabulate==0.9.0
tenacity==8.1.0
threadpoolctl==3.1.0
tldextract==3.3.1
tomli==2.0.1
tomlkit==0.11.6
tornado==6.4.2
tqdm==4.66.4
trino==0.326.0
trio==0.22.0
trio-websocket==0.9.2
typing_extensions==4.12.2
tzlocal==5.0.1
urllib3==1.26.11
uvicorn==0.17.4
Werkzeug==2.2.2
wrapt==1.14.1
wsproto==1.2.0
xlrd==2.0.1
yarl==1.8.1
zipp==3.10.0
What did you do?
completely disabled otel as suggested here
https://github.com/snowflakedb/snowflake-connector-python?tab=readme-ov-file#disable-telemetry


            self.connection: SnowflakeConnection = snowflake.connector.connect(
                user=snowflake_credentials['username'],
                private_key=private_key,
                account=snowflake_credentials['account'],
                database=snowflake_credentials['database'],
                warehouse=snowflake_credentials['warehouse'],
                keep_alive=keep_alive,
                session_parameters={
                    "CLIENT_TELEMETRY_ENABLED": False
                }
            )
            self.connection.telemetry_enabled = False


and even added explicitly

            self.connection._server_param_telemetry_enabled = False



but I keep getting this debug error message

10-06-2025 12:47:09 snowflake.connector.network DEBUG    Opentelemtry otel injection failed
Traceback (most recent call last):
  File "/Users/liranc/Bright/goodreports/venv/lib/python3.8/site-packages/snowflake/connector/network.py", line 489, in request
    from opentelemetry.trace.propagation.tracecontext import (
ModuleNotFoundError: No module named 'opentelemetry'


because apparently no one ever check the parameters before importing otel, see network.py lines 485-498:


        try:
            # SNOW-1763555: inject OpenTelemetry headers if available specifically in WC3 format
            #  into our request headers in case tracing is enabled. This should make sure that
            #  our requests are accounted for properly if OpenTelemetry is used by users.
            from opentelemetry.trace.propagation.tracecontext import (
                TraceContextTextMapPropagator,
            )

            TraceContextTextMapPropagator().inject(headers)
        except Exception:
            logger.debug(
                "Opentelemtry otel injection failed",
                exc_info=True,
            )
What did you expect to see?

no debug error

Can you set logging to DEBUG and collect the logs?
import logging
import os

for logger_name in ('snowflake.connector',):
    logger = logging.getLogger(logger_name)
    logger.setLevel(logging.DEBUG)
    ch = logging.StreamHandler()
    ch.setLevel(logging.DEBUG)
    ch.setFormatter(logging.Formatter('%(asctime)s - %(threadName)s %(filename)s:%(lineno)d - %(funcName)s() - %(levelname)s - %(message)s'))
    logger.addHandler(ch)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.