open-telemetry / open-telemetry/opentelemetry-python-contrib
Non existing object in botocore boto3.client("s3").head_object() records an exception
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
Describe your environment
OS: (e.g, Ubuntu 22.04)
Python version: (e.g., Python 3.12.6)
Package version: (e.g., 0.48b0)
What happened?
When the object doesn't exist it records an exception. I'm using Uptrace as frontend which raises alarm on all exceptions.
In Sentry.io it doesn't record an exception as example.
Steps to Reproduce
def clean():
import boto3
from botocore.exceptions import ClientError
from opentelemetry.trace import get_tracer
s3 = boto3.client(
"s3",
endpoint_url="host",
aws_access_key_id="aws_access_key_id",
aws_secret_access_key="aws_secret_access_key",
region_name="region",
)
otel_spawn_tracer = get_tracer("spawn")
with otel_spawn_tracer.start_as_current_span("mytrace"):
try:
response = s3.head_object(Bucket="bucket", Key="non_existing_key.txt")
except ClientError as exc:
# Not found
if exc.response.get("ResponseMetadata", {}).get("HTTPStatusCode", -1) == 404:
return False
raise
else:
return bool(response["ContentLength"])
# todo fix the config according to your s3 config
clean()
Expected Result
I didn't expect it to record an exception. Since this is a normal workflow to check if object exists. It's not an exceptional workflow.
Actual Result
I didn't expect it to record an exception since this is the normal workflow to check if objects exists in S3. Maybe we need a way to exclude some cases like this one from recording exceptions?
Additional context
No response
Would you like to implement a fix?
None
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 the supplied Python reproduction and locate the instrumentation path that records exceptions for boto3 S3 head_object(). Reproduce the 404 case and compare it with other ClientError responses. Done means a normal missing-object check is not recorded as an exception while genuinely unexpected errors remain recorded.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- cloud, observability-sre
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100