setaur 0.1.0__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.
setaur-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
setaur-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,373 @@
1
+ Metadata-Version: 2.4
2
+ Name: setaur
3
+ Version: 0.1.0
4
+ Summary: Robotics telemetry SDK — publish sensor streams, structured events, and distributed traces to the Setaur observability platform
5
+ Keywords: robotics,telemetry,observability,tracing,distributed-tracing,sensors,events,ros,autonomous,setaur
6
+ Author: Noah Shibley
7
+ Author-email: Noah Shibley <noah@calque.ai>
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Scientific/Engineering
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Classifier: Typing :: Typed
18
+ Requires-Dist: cbor2>=6.1.2
19
+ Requires-Dist: nats-py>=2.15.0
20
+ Requires-Python: >=3.11
21
+ Project-URL: Homepage, https://setaur.ai
22
+ Project-URL: Documentation, https://setaur.ai/docs/python-sdk
23
+ Project-URL: Repository, https://github.com/calque-ai/setaur-sdk-python
24
+ Project-URL: Bug Tracker, https://github.com/calque-ai/setaur-sdk-python/issues
25
+ Description-Content-Type: text/markdown
26
+
27
+ # setaur-sdk-python
28
+
29
+ Python SDK for publishing telemetry from a robot to the **setaur-edge** agent. Send sensor readings, structured events, and distributed traces with a single import.
30
+
31
+ ---
32
+
33
+ ## What is this?
34
+
35
+ Setaur is a telemetry SDK for robotics. It gives every component on your robot a consistent way to emit three kinds of data:
36
+
37
+ | Kind | Use for | API |
38
+ | ---------- | --------------------------------------------------------------------------- | --------------------------------------- |
39
+ | **Sensor** | High-rate, continuous measurements (IMU, lidar, encoders) | `setaur.sensor()` |
40
+ | **Event** | Sparse, discrete occurrences (state changes, faults, commands) | `setaur.info()` / `setaur.error()` / … |
41
+ | **Span** | Timed operations with a start, end, and duration (path planning, arm moves) | `setaur.span()` / `setaur.get_tracer()` |
42
+
43
+ All three are published to a local **setaur-edge** agent, which forwards them to the Setaur platform.
44
+
45
+ ---
46
+
47
+ ## Prerequisites
48
+
49
+ ### 1. Create a Setaur account
50
+
51
+ Sign up at **[setaur.ai](https://setaur.ai)**.
52
+
53
+ ### 2. Add a robot
54
+
55
+ In the Setaur platform, add a robot. This generates a unique **robot key** (`rbt-…`) and a **credentials file** (`.creds`) that the SDK uses to authenticate with setaur-edge.
56
+
57
+ Download both from the add/edit robot configuration page, you'll need them in the steps below.
58
+
59
+ ### 3. Install and run setaur-edge on the robot
60
+
61
+ **setaur-edge** is the local agent that receives telemetry from the SDK and forwards it to the Setaur platform. Download it from the add/edit robot configuration page in the Setaur platform.
62
+
63
+ Run it on the same machine as your robot code before calling `setaur.init()`:
64
+
65
+ ```bash
66
+ ./setaur-edge --creds /etc/robot/robot.creds
67
+ ```
68
+
69
+ Setaur-edge must be running before `setaur.init()` is called or it will raise a `RuntimeError`. See the [setaur-edge documentation](https://setaur.ai/docs/setauredge) for installation options, configuration flags, and running as a system service.
70
+
71
+ ---
72
+
73
+ ## Installation
74
+
75
+ ```bash
76
+ pip install setaur
77
+ ```
78
+
79
+ Or with [uv](https://docs.astral.sh/uv/):
80
+
81
+ ```bash
82
+ uv add setaur
83
+ ```
84
+
85
+ ---
86
+
87
+ ## Quick start
88
+
89
+ ```python
90
+ import time
91
+ import setaur
92
+ from setaur import SourceType
93
+
94
+ # Robot key and credentials are generated on the add/edit robot page at setaur.ai.
95
+ setaur.init("rbt-yourrobotkey")
96
+
97
+ # Publish one IMU reading
98
+ setaur.sensor(
99
+ source_id = "imu_main",
100
+ source_type = SourceType.SENSOR,
101
+ timestamp_ns = time.time_ns(),
102
+ data = {"accel": {"x": 0.01, "y": -0.02, "z": 9.81}},
103
+ )
104
+
105
+ setaur.shutdown()
106
+ ```
107
+
108
+ ---
109
+
110
+ ## Initialisation and shutdown
111
+
112
+ ```python
113
+ import setaur
114
+
115
+ # Connect to setaur-edge. Blocks until connected or raises RuntimeError on failure.
116
+ # Returns the client, store it if you need direct access to flush() or close().
117
+ client = setaur.init("rbt-yourrobotkey")
118
+
119
+ # Optional: pass an explicit credentials file path.
120
+ # Falls back to the SETAUR_CREDS_FILE environment variable when omitted.
121
+ setaur.init("rbt-yourrobotkey", creds_file="/etc/robot/robot.creds")
122
+
123
+ # At process exit, flush all queued messages then close the connection.
124
+ setaur.shutdown()
125
+
126
+ # Mid-run flush (e.g. before a reboot) without stopping the client.
127
+ setaur.flush(timeout=3.0)
128
+ ```
129
+
130
+ The `SETAUR_CREDS_FILE` environment variable is the recommended way to supply credentials in production:
131
+
132
+ ```bash
133
+ SETAUR_CREDS_FILE=/etc/robot/robot.creds python my_robot.py
134
+ ```
135
+
136
+ ---
137
+
138
+ ## Sensors
139
+
140
+ Use `sensor()` for continuous, high-rate streams. Capture the timestamp immediately after the hardware read, before any processing, so it reflects true acquisition time.
141
+
142
+ ```python
143
+ import time
144
+ import setaur
145
+ from setaur import SourceType
146
+
147
+ setaur.init("rbt-yourrobotkey")
148
+
149
+ data, timestamp_ns = read_imu() # your driver call
150
+
151
+ seq = setaur.sensor(
152
+ source_id = "imu_main",
153
+ source_type = SourceType.SENSOR,
154
+ timestamp_ns = timestamp_ns,
155
+ data = data, # any CBOR-serializable dict
156
+ )
157
+ # seq is a monotonically increasing counter per source_id.
158
+ # A gap on the receiving side means a message was dropped.
159
+ ```
160
+
161
+ **Source types**
162
+
163
+ | Value | Meaning |
164
+ | -------------------------- | ------------------------------------- |
165
+ | `SourceType.SENSOR` | Physical sensor (IMU, lidar, camera) |
166
+ | `SourceType.STATE_MACHINE` | State machine or planner output |
167
+ | `SourceType.METADATA` | Configuration or descriptive metadata |
168
+
169
+ ---
170
+
171
+ ## Events
172
+
173
+ Use events for sparse, discrete occurrences, state transitions, faults, commands, milestones. Each event carries a machine-readable `event_type`, a human-readable `message`, a severity level, and optional structured `attrs`.
174
+
175
+ ### Severity shortcuts
176
+
177
+ ```python
178
+ setaur.info("nav", "startup", "Navigation system ready")
179
+
180
+ setaur.warning("battery_monitor", "battery_low", "Battery at 18%",
181
+ attrs={"battery_pct": 18, "voltage_v": 11.2})
182
+
183
+ setaur.error("motor_controller", "motor_fault", "Motor 2 overcurrent",
184
+ attrs={"motor_id": "motor_2", "current_amps": 12.5})
185
+
186
+ setaur.critical("safety_controller", "emergency_stop", "E-stop triggered",
187
+ attrs={"trigger_source": "lidar", "distance_cm": 12})
188
+ ```
189
+
190
+ ### Generic event
191
+
192
+ ```python
193
+ from setaur import EventSeverity
194
+
195
+ setaur.event(
196
+ source_id = "navigation_controller",
197
+ event_type = "state_transition",
198
+ message = "Switched to AUTONOMOUS mode",
199
+ severity = EventSeverity.INFO,
200
+ attrs = {"from_state": "MANUAL", "to_state": "AUTONOMOUS"},
201
+ data = {"extra_blob": ...}, # optional: unstructured payload
202
+ )
203
+ ```
204
+
205
+ `event_type` is a machine-readable label used for filtering and aggregation (e.g. `"motor_fault"`). `message` is the human-readable description shown in the UI.
206
+
207
+ **Severity levels**
208
+
209
+ | Level | When to use |
210
+ | ---------- | ------------------------------------------------ |
211
+ | `INFO` | Normal operational events |
212
+ | `WARNING` | Something worth watching but not yet broken |
213
+ | `ERROR` | Something went wrong; intervention may be needed |
214
+ | `CRITICAL` | Immediate action required (e.g. safety stop) |
215
+
216
+ ---
217
+
218
+ ## Spans
219
+
220
+ Use spans to time operations, path planning, actuator moves, perception pipelines. A span records a start time, end time, and duration automatically. Nested spans form a distributed trace with no manual ID wiring.
221
+
222
+ ### Simple span
223
+
224
+ ```python
225
+ with setaur.span("nav", "path_planning", "Plan route to dock") as s:
226
+ s.set_attr("goal", "charging_dock")
227
+ waypoints = plan_path()
228
+ s.set_attr("waypoint_count", len(waypoints))
229
+
230
+ # After the with block:
231
+ print(s.sequence_num) # published sequence number
232
+ print(s.trace_id) # 32-char hex trace ID
233
+ print(s.span_id) # 16-char hex span ID
234
+ ```
235
+
236
+ ### Nested spans automatic trace propagation
237
+
238
+ Spans opened inside an active span automatically inherit the enclosing `trace_id` and set `parent_id` without any manual wiring:
239
+
240
+ ```python
241
+ with setaur.span("mission_executor", "mission_leg", "Execute leg") as mission:
242
+ for wp in waypoints:
243
+ with setaur.span("drive_controller", "waypoint_exec", f"Drive to {wp}") as s:
244
+ success = drive_to(wp)
245
+ s.set_attr("success", success)
246
+
247
+ if not success:
248
+ # This event is also linked to the active trace automatically.
249
+ setaur.error("drive_controller", "waypoint_failed", f"Failed at {wp}",
250
+ attrs={"waypoint": wp})
251
+ ```
252
+
253
+ If an exception propagates out of a span, `span.error` is recorded in `attrs` automatically and the span is published normally.
254
+
255
+ ### Span options
256
+
257
+ ```python
258
+ from setaur import SpanKind
259
+
260
+ with setaur.span(
261
+ "arm_controller",
262
+ "joint_move",
263
+ "Move joint 3 to 45°",
264
+ kind = SpanKind.ACTUATOR, # hint to the visualiser
265
+ ) as s:
266
+ move_joint(3, 45)
267
+ ```
268
+
269
+ **Span kinds**
270
+
271
+ | Value | Meaning |
272
+ | ---------------------- | ------------------------------------------ |
273
+ | `SpanKind.UNSPECIFIED` | Default |
274
+ | `SpanKind.INTERNAL` | Internal computation (planning, inference) |
275
+ | `SpanKind.SENSOR` | Sensor acquisition |
276
+ | `SpanKind.ACTUATOR` | Actuator command or motion |
277
+ | `SpanKind.PRODUCER` | Publishes work to a queue |
278
+ | `SpanKind.CONSUMER` | Consumes work from a queue |
279
+
280
+ ---
281
+
282
+ ## Tracer component-scoped handle
283
+
284
+ If a component emits many spans and events, use `get_tracer()` to bind `source_id` once and avoid repeating it at every call site:
285
+
286
+ ```python
287
+ nav = setaur.get_tracer("nav")
288
+ drive = setaur.get_tracer("drive_controller")
289
+
290
+ with nav.span("mission_leg", "Execute leg") as mission:
291
+ for wp in waypoints:
292
+ with drive.span("waypoint_exec", f"Drive to {wp}") as s:
293
+ success = drive_to(wp)
294
+ s.set_attr("success", success)
295
+
296
+ if not success:
297
+ drive.error("waypoint_failed", f"Failed at {wp}",
298
+ attrs={"waypoint": wp})
299
+
300
+ nav.info("mission_complete", "Leg finished")
301
+ ```
302
+
303
+ Tracers are lightweight handles, create them at module level and reuse freely. Trace context propagates identically to the module-level functions.
304
+
305
+ ---
306
+
307
+ ## Log correlation
308
+
309
+ Get the current trace ID for attaching to structured log lines:
310
+
311
+ ```python
312
+ import logging
313
+ logger = logging.getLogger(__name__)
314
+
315
+ with setaur.span("nav", "planning", "Plan route"):
316
+ logger.info("starting planner", extra={"trace_id": setaur.get_active_trace_id()})
317
+ plan()
318
+ ```
319
+
320
+ `get_active_trace_id()` returns `None` when called outside a span context.
321
+
322
+ ---
323
+
324
+ ## API reference
325
+
326
+ ### Init and lifecycle
327
+
328
+ | Function | Description |
329
+ | ------------------------------------------------------- | ------------------------------------------------------------------- |
330
+ | `setaur.init(robot_key, *, creds_file=None) -> _Client` | Connect to setaur-edge. Blocks until connected. |
331
+ | `setaur.shutdown(timeout=5.0)` | Flush queued messages then close the connection. |
332
+ | `setaur.flush(timeout=5.0) -> bool` | Drain the queue without closing. Returns `True` if drained in time. |
333
+
334
+ ### Sensors
335
+
336
+ | Function | Description |
337
+ | ------------------------------------------------------------------ | -------------------------------------------------- |
338
+ | `setaur.sensor(source_id, source_type, timestamp_ns, data) -> int` | Publish a sensor reading. Returns sequence number. |
339
+
340
+ ### Events
341
+
342
+ | Function | Description |
343
+ | ----------------------------------------------------------------------- | ---------------------------------------- |
344
+ | `setaur.event(source_id, event_type, message, severity, *, ...) -> int` | Publish an event with explicit severity. |
345
+ | `setaur.info(source_id, event_type, message, *, ...) -> int` | Shorthand for INFO severity. |
346
+ | `setaur.warning(source_id, event_type, message, *, ...) -> int` | Shorthand for WARNING severity. |
347
+ | `setaur.error(source_id, event_type, message, *, ...) -> int` | Shorthand for ERROR severity. |
348
+ | `setaur.critical(source_id, event_type, message, *, ...) -> int` | Shorthand for CRITICAL severity. |
349
+
350
+ ### Spans and tracing
351
+
352
+ | Function | Description |
353
+ | ---------------------------------------------------------------------------- | ------------------------------------------------------ |
354
+ | `setaur.span(source_id, event_type, message, severity=INFO, *, ...) -> Span` | Return a timed span context manager. |
355
+ | `setaur.get_tracer(source_id) -> Tracer` | Return a component-scoped tracer. |
356
+ | `setaur.get_active_span() -> Span \| None` | Return the innermost active span for this thread/task. |
357
+ | `setaur.get_active_trace_id() -> str \| None` | Return the current trace ID, or `None` outside a span. |
358
+
359
+ ### Return values
360
+
361
+ Every publish call returns a **sequence number** a monotonically increasing integer per `source_id`. A gap in sequence numbers on the receiving side means at least one message was dropped by the publish queue.
362
+
363
+ ---
364
+
365
+ ## Examples
366
+
367
+ Full working examples are in the [`examples/`](examples/) directory:
368
+
369
+ | File | Demonstrates |
370
+ | ----------------------------------------------------- | --------------------------------------------------- |
371
+ | [`sensor_example.py`](examples/sensor_example.py) | IMU at 100 Hz with accurate hardware timestamps |
372
+ | [`event_example.py`](examples/event_example.py) | All four severity levels with structured attrs |
373
+ | [`advanced_example.py`](examples/advanced_example.py) | Nested spans, automatic trace propagation, `Tracer` |