Telemetry¶
The restgdf[telemetry] extra integrates with
OpenTelemetry for distributed tracing and
log correlation. Install it alongside the base package:
pip install "restgdf[telemetry]"
See Observability with OpenTelemetry for a practical integration guide.
restgdf.telemetry¶
restgdf.telemetry — optional OpenTelemetry integration (BL-32).
This package is importable on a base install (no OTel). Functions that
need OTel at runtime raise OptionalDependencyError
when the SDK is absent and telemetry is enabled.
Quick-start:
pip install restgdf[telemetry]
from restgdf.telemetry import RestgdfInstrumentor, feature_layer_stream_span
- exception restgdf.telemetry.OptionalDependencyError[source]¶
Bases:
ConfigurationError,ModuleNotFoundErrorRaised when an optional dependency (pandas/geopandas/pyogrio) is absent.
Multi-inherits
ModuleNotFoundErrorso existingexcept ImportError/except ModuleNotFoundErrorcall sites keep working whenrestgdf[geo]is not installed.
- class restgdf.telemetry.RestgdfInstrumentor(*args, **kwargs)[source]¶
Bases:
objectThin restgdf-specific wrapper around
AioHttpClientInstrumentor.Dynamically rebuilds itself as a subclass of
opentelemetry.instrumentation.aiohttp_client.AioHttpClientInstrumentorat construction time. This deferred approach avoids import-time failures on a base install that has no OTel packages.
- restgdf.telemetry.feature_layer_stream_span(*, layer_url, layer_id=None, out_fields=None, where=None, order=None, extra_attrs=None)[source]¶
Open an INTERNAL
feature_layer.streamspan (R-21).- Parameters:
layer_url – Full service URL (will be scrubbed).
layer_id – ArcGIS layer ID.
out_fields – Value of the
outFieldsparameter, if any.where – Value of the
whereparameter, if any.order – Pagination order hint (
"request"or"completion").extra_attrs – Additional span attributes (must already be namespaced).
- Yields:
span | None– The openedSpan, orNonewhen telemetry is disabled.
Notes
This helper attaches the span to the current asyncio Context via
start_as_current_span. It is not safe to wrap an async-generator body whoseyieldcan suspend across the__aexit__boundary — usestart_feature_layer_stream_span()+ manualspan.end()in those callers instead.