log-foundry 0.10.2.dev4__tar.gz → 0.10.2.dev5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/PKG-INFO +1 -1
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/pyproject.toml +1 -1
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/__init__.py +5 -2
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/context.py +33 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/LICENSE +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/README.md +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/api.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/config.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/console.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/decorator.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/ids.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/model.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/py.typed +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sanitize.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/__init__.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/_batch.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/_chunk.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/_socket.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/_time.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/base.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/callback.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/clickhouse.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/datadog.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/elasticsearch.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/eventhubs.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/file.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/filtering.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/firehose.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/honeycomb.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/http.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/kafka.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/kinesis.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/logging_sink.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/logstash.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/loki.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/mongodb.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/multi.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/nats.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/newrelic.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/postgres.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/pubsub.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/rabbitmq.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/redis.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/sentry.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/sns.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/splunk.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/sqlite.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/sqs.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/stdout.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/syslog.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/transform.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/sinks/util.py +0 -0
- {log_foundry-0.10.2.dev4 → log_foundry-0.10.2.dev5}/src/log_foundry/worker.py +0 -0
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Public façade (module-function shape). Exposes configuration, the ``@trace`` decorator, the
|
|
4
4
|
``debug/info/warning/error/critical`` emitters, ``set_baggage``, the cross-process propagation
|
|
5
5
|
pair (``continue_trace`` to adopt an inbound context; ``current_traceparent`` /
|
|
6
|
-
``current_trace_context`` / ``current_baggage_header`` to publish this one), ``
|
|
7
|
-
|
|
6
|
+
``current_trace_context`` / ``current_baggage_header`` to publish this one), ``reset_context``
|
|
7
|
+
(clear both for a caller who opens no span), ``flush`` (drain and keep logging) and ``shutdown``
|
|
8
|
+
(drain, close the sink, and stop).
|
|
8
9
|
"""
|
|
9
10
|
|
|
10
11
|
from importlib.metadata import PackageNotFoundError
|
|
@@ -16,6 +17,7 @@ from log_foundry.context import (
|
|
|
16
17
|
current_baggage_header,
|
|
17
18
|
current_trace_context,
|
|
18
19
|
current_traceparent,
|
|
20
|
+
reset_context,
|
|
19
21
|
)
|
|
20
22
|
from log_foundry.decorator import continue_trace, trace
|
|
21
23
|
from log_foundry.worker import Health
|
|
@@ -107,6 +109,7 @@ __all__ = [
|
|
|
107
109
|
"get_config",
|
|
108
110
|
"health",
|
|
109
111
|
"info",
|
|
112
|
+
"reset_context",
|
|
110
113
|
"set_baggage",
|
|
111
114
|
"shutdown",
|
|
112
115
|
"trace",
|
|
@@ -33,6 +33,7 @@ __all__ = [
|
|
|
33
33
|
"pop_span",
|
|
34
34
|
"push_baggage_scope",
|
|
35
35
|
"push_span",
|
|
36
|
+
"reset_context",
|
|
36
37
|
"set_baggage",
|
|
37
38
|
]
|
|
38
39
|
|
|
@@ -133,6 +134,38 @@ def pop_baggage_scope(token: contextvars.Token[dict[str, object]]) -> None:
|
|
|
133
134
|
_baggage.set(old if isinstance(old, dict) else {})
|
|
134
135
|
|
|
135
136
|
|
|
137
|
+
def reset_context() -> None:
|
|
138
|
+
"""Clear baggage and any adopted trace context outright (SPEC-024 FR-003).
|
|
139
|
+
|
|
140
|
+
For the caller who uses the emitters **without** ``@trace``: the orphan path opens no span,
|
|
141
|
+
so there is no root-span exit to hang the release on, and both values would otherwise live
|
|
142
|
+
as long as the context does. A ``@trace`` user does not need this —
|
|
143
|
+
:func:`pop_baggage_scope` already runs at every root span's exit.
|
|
144
|
+
|
|
145
|
+
It is also the remedy for the one case that scope cannot reach: an adoption made outside a
|
|
146
|
+
span whose root span then runs in a child context, where the clear lands in the copy. Call
|
|
147
|
+
this in the context that made the adoption.
|
|
148
|
+
|
|
149
|
+
One function rather than two because the two values have the same lifetime and the same
|
|
150
|
+
failure mode, and a caller who wants one almost always wants the other.
|
|
151
|
+
|
|
152
|
+
Unlike the scope release this **clears** rather than restores — a process-level baggage
|
|
153
|
+
default set before any span is erased too, which is the point of an explicit reset. Safe
|
|
154
|
+
with nothing ever set, with no span open, and inside an open span. Never raises, like every
|
|
155
|
+
other entry point on this path (arch §4).
|
|
156
|
+
|
|
157
|
+
Prefer calling it **outside** a span. Inside one it does the obvious thing to the events
|
|
158
|
+
that follow, but SPEC-015 backfills ``span.start`` and ``span.end`` from the baggage live at
|
|
159
|
+
*close*, so a mid-span reset also empties the two boundary events — which describe the whole
|
|
160
|
+
span and carry ``duration_ms``/``status`` — of baggage that was live for most of it. That
|
|
161
|
+
span's exit then restores the baggage from before the span, as it always does.
|
|
162
|
+
"""
|
|
163
|
+
# Cleared in the same order as `pop_baggage_scope`, for the reason given there: a stale
|
|
164
|
+
# trace id is wrong data, a stale baggage field is only stale.
|
|
165
|
+
_adopted.set(None)
|
|
166
|
+
_baggage.set({})
|
|
167
|
+
|
|
168
|
+
|
|
136
169
|
# -- adopted inbound context (SPEC-014) --------------------------------------------------
|
|
137
170
|
|
|
138
171
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|