open-telemetry / open-telemetry/opentelemetry-python-contrib
[redis] Redis-sentinel not working
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
The Redis auto instrumentation is not working with redis-sentinel
Steps to reproduce
Setup a redis-sentinel and a redis instance, run an application with sentinel configurations.
What is the expected behavior?
Information for sentinel connections
What is the actual behavior?
"Traceback (most recent call last):
File "/home/vutuandat/.local/share/project_name-tNQ0Wzfa/lib/python3.8/site-packages/opentelemetry/instrumentation/redis/util.py", line 29, in _extract_conn_attributes
attributes["net.peer.name"] = conn_kwargs["host"]
KeyError: 'host'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/vutuandat/.local/share/project_name-tNQ0Wzfa/lib/python3.8/site-packages/opentelemetry/sdk/trace/__init__.py", line 861, in use_span
yield span
File "/home/vutuandat/.local/share/project_name-tNQ0Wzfa/lib/python3.8/site-packages/opentelemetry/sdk/trace/__init__.py", line 774, in start_as_current_span
yield span_context
File "/home/vutuandat/.local/share/project_name-tNQ0Wzfa/lib/python3.8/site-packages/opentelemetry/instrumentation/redis/__init__.py", line 84, in _traced_execute_command
_set_connection_attributes(span, instance)
File "/home/vutuandat/.local/share/project_name-tNQ0Wzfa/lib/python3.8/site-packages/opentelemetry/instrumentation/redis/__init__.py", line 64, in _set_connection_attributes
for key, value in _extract_conn_attributes(
File "/home/vutuandat/.local/share/project_name-tNQ0Wzfa/lib/python3.8/site-packages/opentelemetry/instrumentation/redis/util.py", line 33, in _extract_conn_attributes
attributes["net.peer.name"] = conn_kwargs["path"]
KeyError: 'path'
"
Additional context
python 3.8.5
opentelemetry-sdk 0.17b0
opentelemetry-instrumentation-redis 0.17b0
I did manage to make it run by adding
try:
attributes["net.peer.name"] = conn_kwargs["path"]
attributes["net.transport"] = "Unix"
except KeyError:
# just a quick workaround
attributes["net.peer.name"] = conn_kwargs["connection_pool"].service_name
...
however, I'm not sure which information we want to put in span tags.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/util.py, especially _extract_conn_attributes, and reproduce the failure using Redis Sentinel and a Redis instance. Inspect the Sentinel connection kwargs and determine which span attributes should represent the connection; done means Sentinel instrumentation runs without the reported KeyError and emits the agreed information.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, redis
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100