Skip to content

Commit 2c5ffd6

Browse files
committed
fix lint checks
1 parent 0581402 commit 2c5ffd6

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ def get_aws_region() -> str:
4949
# This will automatically check AWS CLI config, instance metadata, etc.
5050
if is_installed("botocore"):
5151
try:
52-
from botocore import session
52+
from botocore import session # pylint: disable=import-outside-toplevel
5353

5454
botocore_session = session.Session()
55-
if botocore_session.region_name:
55+
if hasattr(botocore_session, "region_name") and botocore_session.region_name:
5656
return botocore_session.region_name
57-
except Exception:
57+
except (ImportError, AttributeError):
5858
# botocore failed to determine region
5959
pass
6060

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/aws_opentelemetry_distro.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ def _configure(self, **kwargs):
107107
# Set disabled instrumentations default
108108
os.environ.setdefault(
109109
OTEL_PYTHON_DISABLED_INSTRUMENTATIONS,
110-
"http,sqlalchemy,psycopg2,pymysql,sqlite3,aiopg,asyncpg,mysql_connector,botocore,boto3,urllib3,requests,starlette",
110+
"http,sqlalchemy,psycopg2,pymysql,sqlite3,aiopg,asyncpg,mysql_connector,"
111+
"botocore,boto3,urllib3,requests,starlette",
111112
)
112113

113114
# Set logging auto instrumentation default

aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_aws_opentelemetry_distro.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
from pkg_resources import DistributionNotFound, require
88

9+
from amazon.opentelemetry.distro.aws_opentelemetry_distro import AwsOpenTelemetryDistro
10+
911

1012
class TestAwsOpenTelemetryDistro(TestCase):
1113
def test_package_available(self):
@@ -41,8 +43,6 @@ def test_agent_observability_sets_new_defaults(self):
4143
os.environ["AGENT_OBSERVABILITY_ENABLED"] = "true"
4244

4345
# Import and configure
44-
from amazon.opentelemetry.distro.aws_opentelemetry_distro import AwsOpenTelemetryDistro
45-
4646
with patch("amazon.opentelemetry.distro.aws_opentelemetry_distro.apply_instrumentation_patches"):
4747
with patch("amazon.opentelemetry.distro.aws_opentelemetry_distro.get_aws_region", return_value="us-west-2"):
4848
# We need to mock the parent class to avoid its side effects
@@ -54,7 +54,8 @@ def test_agent_observability_sets_new_defaults(self):
5454
self.assertEqual(os.environ.get("OTEL_TRACES_SAMPLER"), "parentbased_always_on")
5555
self.assertEqual(
5656
os.environ.get("OTEL_PYTHON_DISABLED_INSTRUMENTATIONS"),
57-
"http,sqlalchemy,psycopg2,pymysql,sqlite3,aiopg,asyncpg,mysql_connector,botocore,boto3,urllib3,requests,starlette",
57+
"http,sqlalchemy,psycopg2,pymysql,sqlite3,aiopg,asyncpg,mysql_connector,"
58+
"botocore,boto3,urllib3,requests,starlette",
5859
)
5960
self.assertEqual(os.environ.get("OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED"), "true")
6061
self.assertEqual(os.environ.get("OTEL_AWS_APPLICATION_SIGNALS_ENABLED"), "false")
@@ -63,8 +64,6 @@ def test_new_defaults_not_set_when_agent_observability_disabled(self):
6364
# Don't set AGENT_OBSERVABILITY_ENABLED or set it to false
6465
os.environ.pop("AGENT_OBSERVABILITY_ENABLED", None)
6566

66-
from amazon.opentelemetry.distro.aws_opentelemetry_distro import AwsOpenTelemetryDistro
67-
6867
with patch("amazon.opentelemetry.distro.aws_opentelemetry_distro.apply_instrumentation_patches"):
6968
with patch("opentelemetry.distro.OpenTelemetryDistro._configure"):
7069
distro = AwsOpenTelemetryDistro()

0 commit comments

Comments
 (0)