Changelog
Observability
Release notes for aice-observability.
Python: aice-observability
0.2.2 (unreleased)
Added
ai.tracing.inference(): one model call as a CLIENT span named{operation} {model}(semantic-conventions-genai), withset_usage()forgen_ai.usage.*input (inclusive), output, cache-read, cache-write (under bothcache_writeand the releasedcache_creationname) and reasoning tokens, andgen_ai.response.id/.model.ai.metrics.record_inference_usage(): five monotonic counters,gen_ai.client.inference.usage.{input_tokens, output_tokens, cache_read.input_tokens, cache_write.input_tokens, reasoning.output_tokens}, so a window's tokens sum exactly.- A View on those counters keeps only bounded labels (provider, request
model, operation,
gen_ai.agent.name,aice.key_source); a thread, run or tenant id passed as a label is dropped instead of minting a series per id. agents.execute_tool()takescall_id,skill_name/skill_versionandtransfer_target(delegation to another agent);agents.invoke_agent()takesagent_id.ai.metrics.record_tool_failure(tool=, error_type=)feeds the existinggen_ai.tool.failurescounter, which had no recorder.ai.metrics.record_unrecorded_usage():aice.usage.unrecorded_tokens, the tokens a model call spent that the caller's usage ledger failed to store, for alerting on lost billing data.- First tests for the
aipackage.
Changed
record_token_usage()(histograms labelledprovider/model) is kept for existing callers; new code usesrecord_inference_usage().
0.2.1
Fixed
- The semantic-convention opt-in now takes effect. It was set inside
start(), but OpenTelemetry readsOTEL_SEMCONV_STABILITY_OPT_INonce, at the first instrumentation, and services callinstrument_fastapi()at import, beforestart(). The GenAI opt-in was therefore silently ignored.start(),instrument_fastapi(),instrument_flask()andinstrument_django()now all apply it first, and a warning names the problem if some other instrumentation got there earlier. - Log export no longer sends a record's private (
_-prefixed) attributes. structlog's stdlib integration (ProcessorFormatter) puts the logger object on every record as_logger; with opentelemetry-sdk 1.45 each record logged an "Invalid type" warning, doubling log output. start()no longer leaves a second log handler on the root logger. Since opentelemetry-instrumentation-logging 0.61,LoggingInstrumentor(used for trace-id injection) also installs an exporting handler of its own by default; it is now opted out.
Changed
- Log export uses
LoggingHandlerfrom opentelemetry-instrumentation-logging (now>=0.61b0, the first release with it) instead of the SDK's deprecated one. Log lines look the same: a dict message (structlog's event dict) is sent as JSON text, andcode.*attributes are still exported. - HTTP instrumentation defaults to
http/dup: the stable HTTP metrics are emitted next to the legacy ones.http.server.request.durationcarrieshttp.route, so latency and errors can be broken down per endpoint; the legacyhttp.server.durationnever could. HTTP spans carry both attribute sets. An operator value for a signal inOTEL_SEMCONV_STABILITY_OPT_INis kept; defaults fill in only the signals it leaves out.
0.2.0
First release on PyPI. Earlier 0.1.x uploads were withdrawn and are not available.
Added
Observability, an OpenTelemetry bootstrap for Python services: traces, metrics and logs over OTLP/HTTP, configured with.service(name)and the standardOTEL_*environment variables.OTEL_SERVICE_NAME, when set, overrides.service(name)and is enough on its own for.start().OTEL_EXPORTER_OTLP_HEADERSvalues are percent-decoded, as the OTel spec requires.- Instrumentation for FastAPI, Flask, Django, SQLAlchemy, httpx, Redis,
psycopg2, Psycopg 3, asyncpg, botocore (boto3 / S3 / MinIO), Celery,
logging and system metrics. Each integration skips quietly when the library
it instruments is absent.
instrument_fastapi()andinstrument_flask()must run before the app serves its first request, and don't need.start()first. aice_observability.propagation:inject_context(),extract_context()andcontinue_trace()for carrying a trace across a hand-rolled queue (a Postgres job table, pgmq). A missing or malformed carrier starts a new trace.- AI telemetry:
ai.agents.invoke_agent()/execute_tool()(withextra_attributes) andai.metrics.record_budget_event(kind)(gen_ai.budget.eventscounter).