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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efa35a75fc94eb6f6e78d7fe27103a2d210c1db885df065cba1b59749fc124f5
|
|
| MD5 |
198adbd1a5f9241c1726128b2aa3a1a0
|
|
| BLAKE2b-256 |
64193308e55f6d4d3f4ad388ca93c7dcf0f862a69c3d499ccf129a1d1fc5e6ba
|
Provenance
The following attestation bundles were made for forge_observe-0.1.1.tar.gz:
Publisher:
publish.yml on ArkaD171717/forge-observe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
forge_observe-0.1.1.tar.gz -
Subject digest:
efa35a75fc94eb6f6e78d7fe27103a2d210c1db885df065cba1b59749fc124f5 - Sigstore transparency entry: 1417115231
- Sigstore integration time:
-
Permalink:
ArkaD171717/forge-observe@0b0487714bec9d491534d3ae6e0d483a2c2d0675 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/ArkaD171717
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0b0487714bec9d491534d3ae6e0d483a2c2d0675 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdb6269e360ec00f47554d00ce0dae6da70107123e113f1830a446d116e1ab85
|
|
| MD5 |
22ef7f6cd707ec88f5b0137470e5bed7
|
|
| BLAKE2b-256 |
f405787e15a99e46a78f62c2dd9a65c46efcb9dccf199bc36d1f449aa914056b
|
Provenance
The following attestation bundles were made for forge_observe-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on ArkaD171717/forge-observe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
forge_observe-0.1.1-py3-none-any.whl -
Subject digest:
cdb6269e360ec00f47554d00ce0dae6da70107123e113f1830a446d116e1ab85 - Sigstore transparency entry: 1417115240
- Sigstore integration time:
-
Permalink:
ArkaD171717/forge-observe@0b0487714bec9d491534d3ae6e0d483a2c2d0675 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/ArkaD171717
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0b0487714bec9d491534d3ae6e0d483a2c2d0675 -
Trigger Event:
push
-
Statement type: