Skip to content

Selective Debug Logging for Credentials Fetch Errors in Botocore #3439

@psnilesh

Description

@psnilesh

Describe the bug

The botocore.utils.py file currently has debug logs enabled for both the IMDS (Instance Metadata Service) fetcher and S3 operations. This is causing performance issues when trying to debug NoCredentialsFound errors, as the debug logs from S3 operations are also being generated, which can significantly impact application performance.

This is what I did to enable debug logs from credentials fetchers,

    boto3.set_stream_logger('botocore.utils', logging.DEBUG)
    boto3.set_stream_logger('botocore.credentials', logging.DEBUG)

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

I would like to have a way to selectively enable debug logs only for the credentials fetch process, without enabling debug logs for other parts of the botocore library, such as S3 operations. This would allow me to effectively debug NoCredentialsFound errors without the performance impact of excessive debug logging.

Current Behavior

Too many logs

Reproduction Steps

Run below program and observe the amount of logs generated,

import boto3
import logging

boto3.set_stream_logger('botocore.utils', logging.DEBUG)
boto3.set_stream_logger('botocore.credentials', logging.DEBUG)

boto3.Session().client('s3').get_object(...) # 

Possible Solution

Introduce a new configuration option or a logging filter that would allow users to enable debug logging specifically for the credentials fetch process, without affecting the logging behavior of other parts of the botocore library.

Additional Information/Context

No response

SDK version used

Latest

Environment details (OS name and version, etc.)

Amazon Linux

Metadata

Metadata

Assignees

Labels

bugThis issue is a confirmed bug.p3This is a minor priority issues3

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions