Skip to main content

OpenTelemetry instrumentation for qwen-think reasoning sessions.

Project description

forge-observe

OpenTelemetry instrumentation for qwen-think reasoning sessions.

Emits traces and metrics for thinking budget consumption, mode switches, token splits, preserve_thinking utilization, and backend flag normalization. Works with any OTel-compatible backend (Jaeger, Grafana Tempo, Datadog, etc.).

Install

pip install forge-observe

# For OTLP export (Jaeger, Tempo, Datadog):
pip install forge-observe[otlp]

Quick start

Auto-instrumentation (recommended)

from forge_observe import instrument
instrument()

# Now use qwen-think as normal -- spans and metrics are emitted automatically.
from qwen_think import ThinkingSession
session = ThinkingSession(client=your_client)
response = session.chat("Implement a binary search tree")

Manual tracing

from forge_observe import ForgeTracer

tracer = ForgeTracer()
with tracer.session(attributes={"model": "Qwen3.6-35B"}) as span:
    with tracer.think_decision(mode="think", reason="coding task"):
        pass
    with tracer.budget_check(
        total_tokens=200000, used_tokens=50000,
        available_tokens=150000, action="ok",
    ):
        pass

Configuration

from forge_observe import configure, instrument

configure(
    service_name="my-app",
    otlp_endpoint="http://localhost:4317",
    otlp_protocol="grpc",
)
instrument()

All settings can be overridden via environment variables:

Variable Default Description
FORGE_OBSERVE_SERVICE_NAME forge-observe OTel service name
FORGE_OBSERVE_OTLP_ENDPOINT http://localhost:4317 OTLP collector endpoint
FORGE_OBSERVE_OTLP_PROTOCOL grpc grpc or http
FORGE_OBSERVE_ENABLED true Kill switch
FORGE_OBSERVE_CONSOLE_EXPORT false Print spans to stdout

What it instruments

Spans (auto-instrumented)

forge.session
  |-- forge.session.think_decision    router chose think/instruct, with reason
  |-- forge.session.param_swap        sampling params changed
  |-- forge.session.budget_check      budget evaluated, remaining tokens logged
  |-- forge.backend.normalize         flag normalization applied
  |-- forge.backend.response          response received, thinking/response split
  |-- forge.session.preserve_check    preserve_thinking reuse evaluated

Spans (manual via ForgeTracer)

forge.session.backend_call            wraps a backend API call
forge.mtp.config_decision             MTP config selected or disabled, with reason

Metrics

Name Type Description
forge.session.budget_remaining Gauge Tokens remaining in budget
forge.session.thinking_tokens Counter Total thinking tokens emitted
forge.session.response_tokens Counter Total response tokens emitted
forge.session.mode_switches Counter Think/instruct mode flips
forge.session.preserve_reuse_rate Gauge Fraction of turns reusing prior thinking
forge.mtp.acceptance_rate Gauge Speculative token acceptance rate

Examples

See examples/ for setups targeting Jaeger, Grafana Tempo, and Datadog.

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

forge_observe-0.1.0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

forge_observe-0.1.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file forge_observe-0.1.0.tar.gz.

File metadata

  • Download URL: forge_observe-0.1.0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for forge_observe-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c7b8f7718d5514497676192068425bf7b2595b7932c7c1e04daa3649d884c4df
MD5 d766f4af95a0c5b16db4e32ddced0e45
BLAKE2b-256 dbe270c902f5eff3c42e1ff7c1617d0d71570b0f2370e2ff4dd50b5dbd4c1c1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for forge_observe-0.1.0.tar.gz:

Publisher: publish.yml on ArkaD171717/forge-observe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file forge_observe-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: forge_observe-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for forge_observe-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2357306e03c4ed34161d553c61e04dce19c45dec9fb96020372547dca28ccfac
MD5 5936e5df844c541e9db2b631ab13b85a
BLAKE2b-256 55dce8ca9087703896e6c9a89661797a6cbf36a21ebec8e9cab1da4bdbfd0101

See more details on using hashes here.

Provenance

The following attestation bundles were made for forge_observe-0.1.0-py3-none-any.whl:

Publisher: publish.yml on ArkaD171717/forge-observe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page