-
Notifications
You must be signed in to change notification settings - Fork 620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle redis.exceptions.WatchError as a non-error event in instrumentation #2668
Conversation
…9-dev # Conflicts: # instrumentation/opentelemetry-instrumentation-redis/tests/test_redis.py
Bugfix 2639 dev
fetch update
Bugfix 2639 dev
...tion/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/__init__.py
Outdated
Show resolved
Hide resolved
remove fakeredis from tox.ini better code format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we missing a test to check if any other error will have the StatusCode.ERROR
?
Yes, and updated. Thanks for the review |
...tion/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/__init__.py
Outdated
Show resolved
Hide resolved
Hi folks, shouldn't the |
try: | ||
redis_client = FakeRedis() | ||
async with redis_client.pipeline(transaction=False) as pipe: | ||
await pipe.watch("a") | ||
await redis_client.set("a", "bad") | ||
pipe.multi() | ||
await pipe.set("a", "1") | ||
await pipe.execute() | ||
except WatchError: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend this instead, so that we ensure the WatchError
is still raised
try: | |
redis_client = FakeRedis() | |
async with redis_client.pipeline(transaction=False) as pipe: | |
await pipe.watch("a") | |
await redis_client.set("a", "bad") | |
pipe.multi() | |
await pipe.set("a", "1") | |
await pipe.execute() | |
except WatchError: | |
pass | |
with pytest.raises(WatchError): | |
redis_client = FakeRedis() | |
async with redis_client.pipeline(transaction=False) as pipe: | |
await pipe.watch("a") | |
await redis_client.set("a", "bad") | |
pipe.multi() | |
await pipe.set("a", "1") | |
await pipe.execute() |
try: | ||
redis_client = fakeredis.FakeStrictRedis() | ||
pipe = redis_client.pipeline(transaction=True) | ||
pipe.watch("a") | ||
redis_client.set("a", "bad") # This will cause the WatchError | ||
pipe.multi() | ||
pipe.set("a", "1") | ||
pipe.execute() | ||
except WatchError: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try: | |
redis_client = fakeredis.FakeStrictRedis() | |
pipe = redis_client.pipeline(transaction=True) | |
pipe.watch("a") | |
redis_client.set("a", "bad") # This will cause the WatchError | |
pipe.multi() | |
pipe.set("a", "1") | |
pipe.execute() | |
except WatchError: | |
pass | |
with pytest.raises(WatchError): | |
redis_client = fakeredis.FakeStrictRedis() | |
pipe = redis_client.pipeline(transaction=True) | |
pipe.watch("a") | |
redis_client.set("a", "bad") # This will cause the WatchError | |
pipe.multi() | |
pipe.set("a", "1") | |
pipe.execute() |
@chrisguidry please open a new PR with the fix, you're commenting a PR already merged |
In open-telemetry#2668, we started to avoid having the `redis.WatchError` mark the span as having failed, but we were inadvertently suppressing that exception from the calling code. `redis.WatchError` is used for flow-of-control concurrency in many applications, and applications depend on catching the error to handle concurrent changes to keys during redis pipelines. This re-raises the `WatchError` to keep the instrumentation transparent to the application. Fixes open-telemetry#2639
In open-telemetry#2668, we started to avoid having the `redis.WatchError` mark the span as having failed, but we were inadvertently suppressing that exception from the calling code. `redis.WatchError` is used for flow-of-control concurrency in many applications, and applications depend on catching the error to handle concurrent changes to keys during redis pipelines. This re-raises the `WatchError` to keep the instrumentation transparent to the application. Fixes open-telemetry#2639
Description
Fixes # (issue)
When we face the WatchError when running redis instrumentation, Status Code: The status_code should be "UNSET" instead of "ERROR",
#2639
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
py312-test-instrumentation-redis
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.