fix: ADDON-85914 findings fixes#458
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…loading Make solnlib.observability importable without grpcio by deferring grpc and OTLPMetricExporter imports to the point where they are actually used inside _create_otlp_exporter. This allows modules to import StanzaObservabilityRecorder in environments where grpcio is not installed. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Implements a stanza-scoped observability recorder backed by a shared ObservabilityService singleton cache, enabling efficient per-stanza event metrics collection with automatic flush-on-exit lifecycle management. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…bservabilityRecorder
extra_attrs is now merged first and stanza_name is applied last, so the stanza-scoped guarantee is always preserved. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
artemrys
approved these changes
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix DELTA temporality on
OTLPMetricExporter— bothCounterandHistogramnow explicitly declareAggregationTemporality.DELTA, matchingthe existing
LoggerMetricExporterbehaviour and ensuring each exportinterval reports only the delta, not a cumulative total.
Add
ObservabilityService.flush()— public method that callsMeterProvider.force_flush()via the OTel SDK's public API. Replaces theprevious pattern of reaching into private SDK internals to drain metric
readers before process exit.
Safe lazy import of
grpcio—import grpcandOTLPMetricExporterare moved from module top-level into
_create_otlp_exporter().from solnlib.observability import StanzaObservabilityRecordernow succeedsin environments where
grpciois not installed.Add
StanzaObservabilityRecorder— stanza-scoped recorder that wrapsObservabilityServicewith a per-process singleton cache (one service permodinput_type). Key design decisions:ClassVaron the class itself, making itstraightforward to reset in tests.
register_instrument(callback)delegates toObservabilityService.register_instrument()— no need to access theunderlying service directly.
ATTR_MODINPUT_NAMEis always applied last inrecord()and cannot beoverridden by
extra_attrs, preserving the stanza-scoped guarantee.__exit__callsflush()automatically.
_emit_zero_baseline()recordsadd(0, 0)on construction so the metricseries is visible from the first collection cycle even when no events were
ingested.