Skip to content

Commit 78f8a62

Browse files
authored
Merge pull request #92 from modern-python/fix/des-4-5-small-cleanups
fix: strip skip_sentry from Sentry context; drop dead is_X_installed conjuncts
2 parents 19283e6 + e440b5a commit 78f8a62

5 files changed

Lines changed: 15 additions & 8 deletions

File tree

‎lite_bootstrap/instruments/logging_instrument.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def structlog_pre_chain_processors(self) -> list[typing.Any]:
137137
]
138138

139139
def is_ready(self) -> bool:
140-
return self.bootstrap_config.logging_enabled and import_checker.is_structlog_installed
140+
return self.bootstrap_config.logging_enabled
141141

142142
@staticmethod
143143
def check_dependencies() -> bool:

‎lite_bootstrap/instruments/opentelemetry_instrument.py‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ class OpenTelemetryInstrument(BaseInstrument):
8383
)
8484

8585
def is_ready(self) -> bool:
86-
return (
87-
bool(self.bootstrap_config.opentelemetry_endpoint or self.bootstrap_config.opentelemetry_log_traces)
88-
and import_checker.is_opentelemetry_installed
89-
)
86+
return bool(self.bootstrap_config.opentelemetry_endpoint or self.bootstrap_config.opentelemetry_log_traces)
9087

9188
@staticmethod
9289
def check_dependencies() -> bool:

‎lite_bootstrap/instruments/pyroscope_instrument.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class PyroscopeInstrument(BaseInstrument):
2626
missing_dependency_message = "pyroscope is not installed"
2727

2828
def is_ready(self) -> bool:
29-
return bool(self.bootstrap_config.pyroscope_endpoint) and import_checker.is_pyroscope_installed
29+
return bool(self.bootstrap_config.pyroscope_endpoint)
3030

3131
@staticmethod
3232
def check_dependencies() -> bool:

‎lite_bootstrap/instruments/sentry_instrument.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
IGNORED_STRUCTLOG_ATTRIBUTES: typing.Final = frozenset(
20-
{"event", "level", "logger", "tracing", "timestamp", "exception"}
20+
{"event", "level", "logger", "tracing", "timestamp", "exception", "skip_sentry"}
2121
)
2222

2323

@@ -98,7 +98,7 @@ class SentryInstrument(BaseInstrument):
9898
missing_dependency_message = "sentry_sdk is not installed"
9999

100100
def is_ready(self) -> bool:
101-
return bool(self.bootstrap_config.sentry_dsn) and import_checker.is_sentry_installed
101+
return bool(self.bootstrap_config.sentry_dsn)
102102

103103
@staticmethod
104104
def check_dependencies() -> bool:

‎tests/instruments/test_sentry_instrument.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ def test_skip(self, event: "sentry_types.Event") -> None:
108108
"contexts": {"structlog": {"foo": "bar"}},
109109
},
110110
),
111+
(
112+
{
113+
"logentry": {"formatted": '{"event": "event name", "skip_sentry": false, "foo": "bar"}'},
114+
"contexts": {},
115+
},
116+
{
117+
"logentry": {"formatted": "event name"},
118+
"contexts": {"structlog": {"foo": "bar"}},
119+
},
120+
),
111121
],
112122
)
113123
def test_modify(self, event_before: "sentry_types.Event", event_after: "sentry_types.Event") -> None:

0 commit comments

Comments
 (0)