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.1.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.1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: forge_observe-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 efa35a75fc94eb6f6e78d7fe27103a2d210c1db885df065cba1b59749fc124f5
MD5 198adbd1a5f9241c1726128b2aa3a1a0
BLAKE2b-256 64193308e55f6d4d3f4ad388ca93c7dcf0f862a69c3d499ccf129a1d1fc5e6ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for forge_observe-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: forge_observe-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cdb6269e360ec00f47554d00ce0dae6da70107123e113f1830a446d116e1ab85
MD5 22ef7f6cd707ec88f5b0137470e5bed7
BLAKE2b-256 f405787e15a99e46a78f62c2dd9a65c46efcb9dccf199bc36d1f449aa914056b

See more details on using hashes here.

Provenance

The following attestation bundles were made for forge_observe-0.1.1-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