From eab090f35175e2897bb706642f297b52ccbecb01 Mon Sep 17 00:00:00 2001 From: Chris Coutinho Date: Thu, 11 Jun 2026 05:37:07 +0200 Subject: [PATCH] fix(worker): clear Sonar S5332 hotspot + address review nits - tests: use https in the OTLP endpoint fixture to clear the S5332 "http protocol is insecure" security hotspot (quality gate: new_security_hotspots_reviewed). - cli: add the "tracing disabled" else branch in _init_worker_observability so the worker logs parity with app.py when no OTLP endpoint is set. - cli: trim the verbose inline comment in worker() (the WHY lives in the helper docstring), per review. Co-Authored-By: Claude Opus 4.8 (1M context) --- nextcloud_mcp_server/cli.py | 14 +++++++------- tests/test_cli.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/nextcloud_mcp_server/cli.py b/nextcloud_mcp_server/cli.py index a787fdeb..f247a1cd 100644 --- a/nextcloud_mcp_server/cli.py +++ b/nextcloud_mcp_server/cli.py @@ -326,6 +326,10 @@ def _init_worker_observability(settings: Settings) -> None: "OpenTelemetry tracing enabled (endpoint: %s)", settings.otel_exporter_otlp_endpoint, ) + else: + logger.info( + "OpenTelemetry tracing disabled (set OTEL_EXPORTER_OTLP_ENDPOINT to enable)" + ) @click.command() @@ -363,13 +367,9 @@ def worker(concurrency: int | None): f"resolved INGEST_QUEUE={settings.ingest_queue!r}" ) - # Initialize observability once the config is known to be runnable. The - # always-on API pod does this in its lifespan (app.py); the worker has its - # own entrypoint, so without this it emits plain-text logs and exposes no - # /metrics — leaving the ingest workload (which does the real - # parse/embed/upsert work, and where the astrolabe_* pipeline metrics + - # document_processor.parse spans are recorded) invisible in external - # split-worker mode (Deck #310, unblocks #175). + # Initialize observability here, not in a lifespan — the worker never runs + # uvicorn, so it skips app.py's bootstrap (the WHY lives in the helper's + # docstring). Done after the queue check so a misconfig fails fast. _init_worker_observability(settings) from nextcloud_mcp_server.vector.queue.procrastinate import ( # noqa: PLC0415 diff --git a/tests/test_cli.py b/tests/test_cli.py index c54fcc60..638e62ae 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -406,14 +406,14 @@ def test_init_worker_observability_sets_up_tracing_when_endpoint( """An OTLP endpoint enables tracing so worker spans (parse/embed) export.""" _init_worker_observability( _fake_settings( - otel_exporter_otlp_endpoint="http://otel:4317", + otel_exporter_otlp_endpoint="https://otel:4317", otel_traces_sampler_arg=0.5, ) ) assert patched_observability["tracing"] == { "service_name": "nextcloud-mcp-server", - "otlp_endpoint": "http://otel:4317", + "otlp_endpoint": "https://otel:4317", "otlp_verify_ssl": False, "sampling_rate": 0.5, }