fix(observability): address PR review + SonarCloud findings
Reviewer findings: - Fix double-count of exhausted-retry failures: the inner final-retry branch and the outer except both recorded a processing error. Consolidate to the outer handler (single call site); inner branch keeps only the Qdrant-upsert error metric. Regression test added. - Deletes are no longer counted as indexing events: the delete success path drops doc_type so astrolabe_documents_indexed_total is not inflated. Regression test added. - Reuse the already-resolved `settings` in _index_document instead of a second get_settings() call. - Use explicit `> 0` guards in record_document_parse / record_embedding instead of truthiness checks. SonarCloud: - S1244 (BUG): replace float `==` equality in metric tests with pytest.approx. - S5332 (hotspot): use https in the gateway-URL test fixture. - S1192: extract the repeated "vector_sync.chunk_count" span-attribute literal into a module constant. Review nit: move the duplicated `_sample` test helper into a shared `metric_sample` fixture in tests/unit/conftest.py. Refs Deck #175, PR #831. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
5d205fcaab
commit
2e49e442f4
@@ -534,15 +534,15 @@ def record_document_parse(
|
||||
).observe(duration)
|
||||
document_parse_total.labels(processor=processor, tier=tier, status=status).inc()
|
||||
if status == "success":
|
||||
if pages:
|
||||
if pages > 0:
|
||||
document_pages_processed_total.labels(processor=processor, tier=tier).inc(
|
||||
pages
|
||||
)
|
||||
if chars:
|
||||
if chars > 0:
|
||||
document_chars_processed_total.labels(processor=processor, tier=tier).inc(
|
||||
chars
|
||||
)
|
||||
if byte_size:
|
||||
if byte_size > 0:
|
||||
document_bytes_processed_total.labels(processor=processor, tier=tier).inc(
|
||||
byte_size
|
||||
)
|
||||
@@ -587,9 +587,9 @@ def record_embedding(
|
||||
).observe(duration)
|
||||
embedding_requests_total.labels(kind=kind, provider=provider, status=status).inc()
|
||||
if status == "success":
|
||||
if chunks:
|
||||
if chunks > 0:
|
||||
embedding_chunks_total.labels(kind=kind, provider=provider).inc(chunks)
|
||||
if chars:
|
||||
if chars > 0:
|
||||
embedding_chars_total.labels(kind=kind, provider=provider).inc(chars)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user