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), with set_usage() for gen_ai.usage.* input (inclusive), output, cache-read, cache-write (under both cache_write and the released cache_creation name) and reasoning tokens, and gen_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() takes call_id, skill_name/skill_version and transfer_target (delegation to another agent); agents.invoke_agent() takes agent_id.
  • ai.metrics.record_tool_failure(tool=, error_type=) feeds the existing gen_ai.tool.failures counter, 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 ai package.

Changed

  • record_token_usage() (histograms labelled provider/model) is kept for existing callers; new code uses record_inference_usage().

0.2.1

Fixed

  • The semantic-convention opt-in now takes effect. It was set inside start(), but OpenTelemetry reads OTEL_SEMCONV_STABILITY_OPT_IN once, at the first instrumentation, and services call instrument_fastapi() at import, before start(). The GenAI opt-in was therefore silently ignored. start(), instrument_fastapi(), instrument_flask() and instrument_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 LoggingHandler from 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, and code.* attributes are still exported.
  • HTTP instrumentation defaults to http/dup: the stable HTTP metrics are emitted next to the legacy ones. http.server.request.duration carries http.route, so latency and errors can be broken down per endpoint; the legacy http.server.duration never could. HTTP spans carry both attribute sets. An operator value for a signal in OTEL_SEMCONV_STABILITY_OPT_IN is 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 standard OTEL_* environment variables. OTEL_SERVICE_NAME, when set, overrides .service(name) and is enough on its own for .start(). OTEL_EXPORTER_OTLP_HEADERS values 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() and instrument_flask() must run before the app serves its first request, and don't need .start() first.
  • aice_observability.propagation: inject_context(), extract_context() and continue_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() (with extra_attributes) and ai.metrics.record_budget_event(kind) (gen_ai.budget.events counter).

On this page