Skip to content

Commit d466426

Browse files
authored
Merge pull request #128 from community-of-python/feature/generate-spans-for-health-checks
Generate spans for healthcheck
2 parents 1f8da77 + c84170d commit d466426

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ Parameters description:
429429
- `opentelemetry_instrumentors` - a list of extra instrumentors.
430430
- `opentelemetry_exclude_urls` - list of ignored urls.
431431
- `opentelemetry_log_traces` - traces will be logged to stdout.
432+
- `opentelemetry_generate_health_check_spans` - generate spans for health check handlers if `True`
432433

433434
These settings are subsequently passed to [opentelemetry](https://opentelemetry.io/), finalizing your Opentelemetry integration.
434435

microbootstrap/instruments/opentelemetry_instrument.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class OpentelemetryConfig(BaseInstrumentConfig):
6666
],
6767
)
6868
opentelemetry_log_traces: bool = False
69+
opentelemetry_generate_health_check_spans: bool = True
6970

7071

7172
@typing.runtime_checkable
@@ -169,7 +170,11 @@ def bootstrap(self) -> None:
169170
class OpentelemetryInstrument(BaseOpentelemetryInstrument[OpentelemetryConfig]):
170171
def define_exclude_urls(self) -> list[str]:
171172
exclude_urls = [*self.instrument_config.opentelemetry_exclude_urls]
172-
if self.instrument_config.health_checks_path and self.instrument_config.health_checks_path not in exclude_urls:
173+
if (
174+
not self.instrument_config.opentelemetry_generate_health_check_spans
175+
and self.instrument_config.health_checks_path
176+
and self.instrument_config.health_checks_path not in exclude_urls
177+
):
173178
exclude_urls.append(self.instrument_config.health_checks_path)
174179
return exclude_urls
175180

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def minimal_opentelemetry_config() -> OpentelemetryConfig:
102102
opentelemetry_endpoint="/my-engdpoint",
103103
opentelemetry_namespace="namespace",
104104
opentelemetry_container_name="container-name",
105+
opentelemetry_generate_health_check_spans=False,
105106
)
106107

107108

0 commit comments

Comments
 (0)