mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-25 19:15:18 +02:00
feat(observability): integrate OpenTelemetry collector and configuration for enhanced telemetry
This commit is contained in:
parent
51e4d8b489
commit
df698e0216
6 changed files with 160 additions and 7 deletions
|
|
@ -113,12 +113,37 @@ class TestBootstrapConfig:
|
|||
resource = bootstrap._build_resource()
|
||||
attrs = dict(resource.attributes)
|
||||
assert attrs["service.name"] == "custom-backend"
|
||||
assert attrs["deployment.environment"] == "test"
|
||||
assert attrs["deployment.environment.name"] == "test"
|
||||
assert attrs["service.instance.id"]
|
||||
|
||||
def test_shutdown_is_safe_without_providers(self) -> None:
|
||||
bootstrap.shutdown_otel()
|
||||
|
||||
def test_init_logs_enables_log_correlation(
|
||||
self, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
calls: list[dict[str, object]] = []
|
||||
|
||||
class FakeLoggingInstrumentor:
|
||||
def instrument(self, **kwargs: object) -> None:
|
||||
calls.append(kwargs)
|
||||
|
||||
def fake_safe_instrument(name: str, callback):
|
||||
assert name == "logging"
|
||||
monkeypatch.setattr(
|
||||
"opentelemetry.instrumentation.logging.LoggingInstrumentor",
|
||||
FakeLoggingInstrumentor,
|
||||
)
|
||||
callback()
|
||||
return True
|
||||
|
||||
monkeypatch.setattr(bootstrap, "_LOGS_INITIALIZED", False)
|
||||
monkeypatch.setattr(bootstrap, "_safe_instrument", fake_safe_instrument)
|
||||
|
||||
bootstrap.init_logs()
|
||||
|
||||
assert calls == [{"set_logging_format": True}]
|
||||
|
||||
|
||||
class TestMetricHelpers:
|
||||
def test_all_metric_helpers_noop_safely_when_disabled(self) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue