traceAI-livekit 0.1.3__tar.gz → 0.2.1__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.
- traceai_livekit-0.2.1/LICENSE +201 -0
- traceai_livekit-0.2.1/PKG-INFO +222 -0
- traceai_livekit-0.2.1/README.md +190 -0
- {traceai_livekit-0.1.3 → traceai_livekit-0.2.1}/pyproject.toml +3 -4
- {traceai_livekit-0.1.3 → traceai_livekit-0.2.1}/traceai_livekit/__init__.py +5 -1
- traceai_livekit-0.2.1/traceai_livekit/_recording_attributes.py +316 -0
- traceai_livekit-0.2.1/traceai_livekit/_recording_boundary.py +100 -0
- {traceai_livekit-0.1.3 → traceai_livekit-0.2.1}/traceai_livekit/exporters/base_exporter.py +76 -27
- {traceai_livekit-0.1.3 → traceai_livekit-0.2.1}/traceai_livekit/exporters/grpc_exporter.py +3 -3
- {traceai_livekit-0.1.3 → traceai_livekit-0.2.1}/traceai_livekit/exporters/http_exporter.py +3 -3
- traceai_livekit-0.2.1/traceai_livekit/recording.py +227 -0
- traceai_livekit-0.1.3/PKG-INFO +0 -144
- traceai_livekit-0.1.3/README.md +0 -112
- {traceai_livekit-0.1.3 → traceai_livekit-0.2.1}/traceai_livekit/exporters/__init__.py +0 -0
- {traceai_livekit-0.1.3 → traceai_livekit-0.2.1}/traceai_livekit/integration.py +0 -0
|
@@ -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 describing the origin of the Work and
|
|
141
|
+
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 accept and charge a
|
|
167
|
+
fee for acceptance of support, warranty, indemnity, or other liability
|
|
168
|
+
obligations and/or rights consistent with this License. However, in
|
|
169
|
+
accepting such obligations, You may act only on Your own behalf and on
|
|
170
|
+
Your sole responsibility, not on behalf of any other Contributor, and
|
|
171
|
+
only if You agree to indemnify, defend, and hold each Contributor
|
|
172
|
+
harmless for any liability incurred by, or claims asserted against,
|
|
173
|
+
such Contributor by reason of your accepting any such warranty or
|
|
174
|
+
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 2024-2026 Future AGI, Inc.
|
|
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.
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: traceAI-livekit
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: OpenTelemetry instrumentation for LiveKit
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: traceai,futureagi,opentelemetry,tracing,observability,llm,livekit
|
|
8
|
+
Author: Future AGI
|
|
9
|
+
Author-email: no-reply@futureagi.com
|
|
10
|
+
Requires-Python: >=3.10,<3.14
|
|
11
|
+
Classifier: Framework :: OpenTelemetry
|
|
12
|
+
Classifier: Framework :: OpenTelemetry :: Instrumentations
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Programming Language :: Python
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Classifier: Topic :: System :: Monitoring
|
|
24
|
+
Requires-Dist: fi-instrumentation-otel (>=1.3.0)
|
|
25
|
+
Project-URL: Changelog, https://github.com/future-agi/traceAI/blob/dev/python/frameworks/livekit/CHANGELOG.md
|
|
26
|
+
Project-URL: Documentation, https://docs.futureagi.com/docs/integrations/traceai/livekit
|
|
27
|
+
Project-URL: Homepage, https://futureagi.com
|
|
28
|
+
Project-URL: Issues, https://github.com/future-agi/traceAI/issues
|
|
29
|
+
Project-URL: Repository, https://github.com/future-agi/traceAI/tree/dev/python/frameworks/livekit
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# traceAI-livekit
|
|
33
|
+
|
|
34
|
+
OpenTelemetry instrumentation for LiveKit agents integrated with Future AGI.
|
|
35
|
+
|
|
36
|
+
This package provides automatic attribute mapping from LiveKit's native OpenTelemetry instrumentation to Future AGI's semantic conventions, ensuring rich and structured traces in your dashboard.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install traceai-livekit
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
To instrument your LiveKit agent, simply initialize `fi-instrumentation` and enable the attribute mapping **inside your agent's entrypoint**.
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from livekit.agents import AgentServer, JobContext
|
|
50
|
+
from fi_instrumentation.otel import register, ProjectType
|
|
51
|
+
from traceai_livekit import enable_http_attribute_mapping
|
|
52
|
+
|
|
53
|
+
server = AgentServer()
|
|
54
|
+
|
|
55
|
+
@server.rtc_session()
|
|
56
|
+
async def entrypoint(ctx: JobContext):
|
|
57
|
+
# 1. Initialize TraceAI (inside entrypoint for multiprocessing safety)
|
|
58
|
+
register(
|
|
59
|
+
project_name="My LiveKit Agent",
|
|
60
|
+
project_type=ProjectType.OBSERVE,
|
|
61
|
+
set_global_tracer_provider=True,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
# 2. Enable LiveKit attribute mapping
|
|
65
|
+
# This automatically hooks into LiveKit's telemetry system
|
|
66
|
+
enable_http_attribute_mapping()
|
|
67
|
+
|
|
68
|
+
# ... rest of your agent logic ...
|
|
69
|
+
await ctx.connect()
|
|
70
|
+
|
|
71
|
+
if __name__ == "__main__":
|
|
72
|
+
server.run()
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`enable_http_attribute_mapping()` (or `enable_grpc_attribute_mapping()`) hands the provider to LiveKit for you. If you call
|
|
76
|
+
LiveKit's `set_tracer_provider` yourself on the provider `register()` returned, call it after `enable_*`: before it, the call
|
|
77
|
+
drops the Future AGI exporter. LiveKit installs its privacy filter once per provider, so an `allow_pii` passed in a later call is
|
|
78
|
+
ignored. To keep conversation content out of your traces, set `LIVEKIT_TELEMETRY_ALLOW_PII=false` before calling `enable_*`
|
|
79
|
+
(livekit-agents 1.8 and later).
|
|
80
|
+
|
|
81
|
+
### Flushing at the end of a job
|
|
82
|
+
|
|
83
|
+
On Linux a LiveKit job process ends without running `atexit`, and LiveKit flushes only its own processors, so the spans
|
|
84
|
+
still queued when a job ends, such as the root `agent_session` span, used to never reach Future AGI. `enable_*` now sends
|
|
85
|
+
them twice over:
|
|
86
|
+
|
|
87
|
+
- **When the job shuts down**, if `enable_*` runs inside a job (the usual place, the entrypoint): this sends the voice
|
|
88
|
+
trace, `agent_session` included, as soon as the call ends.
|
|
89
|
+
- **When the process exits**, just before it stops: this sends what LiveKit ends after the shutdown callbacks, its own
|
|
90
|
+
`job_shutdown` span, and the job's root `job_entrypoint` span when tracing is set up before the job starts. With
|
|
91
|
+
set-up inside the entrypoint, LiveKit starts `job_entrypoint` before tracing is on, so it is never recorded and the
|
|
92
|
+
job trace arrives rooted at `job_shutdown`.
|
|
93
|
+
|
|
94
|
+
Each waits at most 3 seconds for the collector, well inside the 10 seconds LiveKit gives a job process to exit, so its own
|
|
95
|
+
clean-up still runs when the collector is slow.
|
|
96
|
+
|
|
97
|
+
If you set tracing up outside a job (for example at import time, in the job process), only the process-exit flush runs.
|
|
98
|
+
To also send each call's trace as soon as the call ends, call `flush_on_job_shutdown()` in each job entrypoint:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
from traceai_livekit import flush_on_job_shutdown
|
|
102
|
+
|
|
103
|
+
@server.rtc_session()
|
|
104
|
+
async def entrypoint(ctx: JobContext):
|
|
105
|
+
flush_on_job_shutdown()
|
|
106
|
+
...
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Do not pass `provider.force_flush` to `ctx.add_shutdown_callback`: LiveKit calls it with the shutdown reason, which
|
|
110
|
+
`force_flush` takes as its timeout, so it fails and nothing is flushed.
|
|
111
|
+
|
|
112
|
+
Limits:
|
|
113
|
+
- A process LiveKit kills (for example when a worker drains and the job overruns its exit time) sends nothing more.
|
|
114
|
+
- Before livekit-agents 1.3, LiveKit closes the session at the same time as the job-shutdown flush, so that flush can miss
|
|
115
|
+
`agent_session`; the process-exit flush still sends it.
|
|
116
|
+
- A second `AgentSession` in one job that is still closing when the shutdown callbacks run is sent by the process-exit
|
|
117
|
+
flush, not the job-shutdown one.
|
|
118
|
+
- In LiveKit Cloud observability mode the session's parent span is recorded on LiveKit's own provider and never reaches
|
|
119
|
+
Future AGI, so the trace has no stored root there.
|
|
120
|
+
|
|
121
|
+
## Recording metadata on a session trace
|
|
122
|
+
|
|
123
|
+
`record_egress` records metadata only: it never records, opens, downloads or uploads media. Each call creates and promptly ends one INTERNAL `livekit.recording.snapshot` span with FI kind `CHAIN`, parented to the supplied session span. Multiple recordings and start/stop/update responses remain separate snapshots instead of overwriting a root.
|
|
124
|
+
|
|
125
|
+
Use an explicitly owned session root/envelope before starting recording. An ended span or a `NonRecordingSpan` holding its saved context is valid for later callbacks. Without `session_span`, the helper uses the current valid OTel span; it does not discover the native LiveKit root or search ancestors. Without a valid parent it returns `False` and creates no orphan recording trace.
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
from fi_instrumentation import FITracer, TraceConfig
|
|
129
|
+
from opentelemetry import trace
|
|
130
|
+
from traceai_livekit import record_egress, wrap_egress_client
|
|
131
|
+
|
|
132
|
+
# provider is the provider from register(); enable_* has already configured mapping.
|
|
133
|
+
policy = TraceConfig()
|
|
134
|
+
tracer = provider.get_tracer("my-agent-recordings")
|
|
135
|
+
root = FITracer(tracer, config=policy).start_span(
|
|
136
|
+
"LiveKit Agent Session", fi_span_kind="agent"
|
|
137
|
+
)
|
|
138
|
+
saved_parent = trace.NonRecordingSpan(root.get_span_context())
|
|
139
|
+
|
|
140
|
+
# Bind the egress SERVICE, not the owning API context manager. Requests and
|
|
141
|
+
# response objects are forwarded unchanged; only successful responses are read.
|
|
142
|
+
egress = wrap_egress_client(
|
|
143
|
+
api_owner.egress, session_span=saved_parent, room_name=room_name,
|
|
144
|
+
conversation_id=conversation_id, # optional: may differ from room_name
|
|
145
|
+
tracer=tracer, trace_config=policy,
|
|
146
|
+
)
|
|
147
|
+
with trace.use_span(root, end_on_exit=False):
|
|
148
|
+
info = await egress.start_room_composite_egress(start_request)
|
|
149
|
+
# Start AgentSession under this context too, where the LiveKit mode supports it.
|
|
150
|
+
|
|
151
|
+
# Later, for a final EgressInfo-like response ALREADY received by your application:
|
|
152
|
+
recorded_locally = record_egress(
|
|
153
|
+
final_info, session_span=saved_parent, room_name=room_name,
|
|
154
|
+
conversation_id=conversation_id, tracer=tracer, trace_config=policy,
|
|
155
|
+
)
|
|
156
|
+
# End root at actual session shutdown; the application owns API stop/close.
|
|
157
|
+
# See examples/egress_agent.py for a bounded, idempotent shutdown callback.
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
`True` means a snapshot was locally created and ended. It does **not** confirm collector delivery, recording completion, an available final file, or a playable URL. `False` also covers tracing suppression, unsampled children, invalid/missing ids, room mismatch and instrumentation failure. Delegate failures/cancellation are not swallowed or logged by the proxy. A failed or cancelled start with no returned id can leave server-side state unknown; the adapter does not retry or discover that state.
|
|
161
|
+
|
|
162
|
+
### Metadata contract
|
|
163
|
+
|
|
164
|
+
These are package-local custom attributes, not standardized recording semantics or a dashboard-player API:
|
|
165
|
+
|
|
166
|
+
| FI export-copy attribute | Meaning |
|
|
167
|
+
| --- | --- |
|
|
168
|
+
| `livekit.recording.operation` | `snapshot` or a fixed captured method name |
|
|
169
|
+
| `livekit.recording.egress_id` | Bounded nonempty response id |
|
|
170
|
+
| `livekit.recording.status` | Recognized `EGRESS_*` label or decimal enum number; zero is retained, numbers are not interpreted |
|
|
171
|
+
| `livekit.recording.started_at_unix_nano`, `livekit.recording.ended_at_unix_nano` | Positive int64 Unix nanoseconds, only when supplied |
|
|
172
|
+
| `livekit.recording.room_name` | Explicit room, otherwise response room |
|
|
173
|
+
| `gen_ai.conversation.id` | Explicit conversation id, independently masked; otherwise the fully masked room passed through conversation masks. A withheld room supplies no implicit conversation; a redacted room supplies only its replacement |
|
|
174
|
+
| `livekit.recording.file_locations` | At most eight credential-free object locators or safe relative filenames |
|
|
175
|
+
| `livekit.recording.stream_locations` | At most eight stream origins; paths may be bearer keys and are omitted |
|
|
176
|
+
|
|
177
|
+
The helper's EgressInfo-like contract reads only `egress_id`, `room_name`, `status`, `started_at`, `ended_at`, `file_results` (`location`, or `filename` only when location is absent) and `stream_results` (`url`). Use a caller-normalized response if your SDK differs. Timestamps must already be Unix nanoseconds; there is no magnitude-based conversion. Missing/zero/invalid timestamps, unknown status text, unsupported legacy singular/segment/image results and absent locations are omitted. A successful start/stop may still be STARTING/ENDING with no final location; no duration or completion is inferred.
|
|
178
|
+
|
|
179
|
+
Ids/room/conversation are at most 256 characters; locations at most 2048. Oversize values are omitted, not truncated. Only the first eight elements of each results collection are examined. A nonempty explicit room that differs from the response room refuses capture. No request, upload configuration, auth header, protobuf serialization or media bytes are inspected.
|
|
180
|
+
|
|
181
|
+
### Privacy and adapter limits
|
|
182
|
+
|
|
183
|
+
The recording helper controls only the metadata it writes. Attributes, events or links that your own samplers, span processors or code add are exported as written; the recording policy does not filter them, except the helper's reserved keys, which export always re-checks.
|
|
184
|
+
|
|
185
|
+
- Helper-authored values pass existing FI `TraceConfig.mask` gates for both the destination alias and source key **before** span creation. Locations also pass the `output.value` policy, so output hiding applies. Both the helper policy and any supplied FITracer policy apply. A withheld helper value is not placed into attributes, events, links, exception text, logs, baggage, context keys, resources or the helper's boolean result.
|
|
186
|
+
- FI export re-applies those policies by **key name**, not writer provenance, to the nine source/alias pairs in the metadata table (including `lk.pii.room_name` and `gen_ai.conversation.id`) and `session.id`. This also covers reserved attribute keys in application-created events and links; unrelated keys, event names, exception text and link targets are not filtered by the recording policy. Missing sources do not recreate aliases. A masking `Exception` replaces the affected value with `__REDACTED__` rather than exporting raw metadata or exception text. Export rechecking may transform an already-masked value again: custom masks should be idempotent.
|
|
187
|
+
- Capture uses a per-call copy of the ordinary OTel SDK tracer without changing the supplied tracer/provider, sampler, or application callbacks. A lifecycle adapter retains the started child for `finally` cleanup and carries the policy tuple on a local instrumentation-scope copy for delayed/batched FI export. Normal scope fields and attributes are unchanged; no response values, policy data or identity registry are serialized. Application samplers/processors are not sandboxed or restricted. Unknown/custom tracers, subclasses, nested tracer proxies or inaccessible FI configuration fail closed before starting a span. Minimum-FI/SDK and LiveKit-copy compatibility still require verification.
|
|
188
|
+
- Through creation **and ending**, the helper attaches a fresh context containing only the selected parent, including its trace state. It does not inherit ambient FI session/user/metadata attributes or baggage. Suppression is checked first; child termination and restoration of the caller context run in `finally`, including when `start_span` fails after SDK allocation. Initial extraction/masking failures still create no child.
|
|
189
|
+
- The helper writes sensitive live-span values only under `lk.pii.*`; its aliases are created on the FI export copy. LiveKit PII opt-out and Cloud redaction can therefore remove helper-authored ids, room, conversation and locations before aliasing. The exact `livekit.recording.snapshot` and supported `livekit.recording.<method>` names remain reserved across tracer scopes: loss of the operation attribute to sampling or SDK limits cannot enable generic room-to-conversation fallback. Ordinary non-recording spans keep their existing mapping.
|
|
190
|
+
- File locations allow `http`, `https`, `s3`, `gs` or safe relative names. Stream locations allow `http`, `https`, `rtmp`, `rtmps`, `rtsp`, `rtsps`, but only their origin survives. Malformed/unsupported locations, controls, backslashes and unsafe relative paths are omitted. All query parameters, fragments and userinfo are dropped. Credential-free locators are intentionally **not usable presigned playback links**. This stricter local projection supplements FI masks; it does not claim reuse of an independently verified shared URL/credential sanitizer.
|
|
191
|
+
- The opt-in proxy recognizes coroutine functions named `start_room_composite_egress`, `start_web_egress`, `start_participant_egress`, `start_track_composite_egress`, `start_track_egress`, `stop_egress`, `update_stream`, and `update_layout`. This is a structural service contract, not a verified SDK-version matrix. Non-coroutine/decorated methods and unrelated attributes pass through; non-info responses produce no snapshot. Use the manual helper when recognition is unsupported.
|
|
192
|
+
- The wrapper freezes its parent at creation; an unbound wrapper stays capture-disabled even if a different task later has a current span. Rewrapping with omitted/identical options is idempotent; conflicting supplied bindings raise a value-free `ValueError`. No global room registry or response history is kept.
|
|
193
|
+
- Calls on the original service, other processes and server-side completion events are not intercepted. There is no polling or webhook server. Your application supplies final updates and distributed trace-context propagation. The API owner remains responsible for shutdown; special-method/context-manager protocols are not proxied.
|
|
194
|
+
- The envelope is not a promise that FI receives LiveKit Cloud's native root. The earlier Cloud-root limitation still applies. Native `AgentSession` parent inheritance and real SDK compatibility must be validated for the deployed mode.
|
|
195
|
+
|
|
196
|
+
The pinned development lock contains LiveKit Agents 1.8.6, API 1.2.1, protocol 1.1.27, FI 1.3.0 and OpenTelemetry SDK 1.44.0. Those pins are **verification targets, not executed compatibility results for this feature**. Fake-service tests do not establish SDK schemas, timestamp semantics, native-session linkage or a playback UI.
|
|
197
|
+
|
|
198
|
+
## Compatibility
|
|
199
|
+
|
|
200
|
+
* **livekit-agents**: 1.x. 1.8 is the tested version (it needs Python 3.10 or later). Since 1.7, LiveKit names its content
|
|
201
|
+
attributes `lk.pii.*` (for example `lk.pii.user_input`); both those names and the earlier ones are mapped to `input.value`
|
|
202
|
+
and `output.value`.
|
|
203
|
+
* **Python**: 3.10 to 3.13.
|
|
204
|
+
* **fi-instrumentation-otel**: 1.3.0 or later; the recording helpers' privacy tests fail with 1.1.0. 1.3.0 needs Python 3.10
|
|
205
|
+
or later and sets the default base64 image cap to 0 (see its changelog). 1.0 moved span attributes from the `llm.*` names to the OpenTelemetry GenAI `gen_ai.*` names, and
|
|
206
|
+
renamed the `SpanAttributes` constants with them. Code that only calls `register()` is unaffected; if your code sets or reads
|
|
207
|
+
those attributes directly, see the
|
|
208
|
+
[mapping from the old names](https://github.com/future-agi/traceAI/blob/main/docs/OTEL_GENAI_SEMANTIC_CONVENTIONS.md#migration-from-openinference-llm).
|
|
209
|
+
|
|
210
|
+
## Features
|
|
211
|
+
|
|
212
|
+
* **Automatic Attribute Mapping**: Converts LiveKit attributes (like `lk.user_input`, `gen_ai.usage.input_tokens`) to Future AGI standard attributes (`input.value`, `llm.tokenCount.prompt`).
|
|
213
|
+
* **Raw Data Preservation**: Keeps original LiveKit attributes and adds `raw.input` / `raw.output` for full debugging context.
|
|
214
|
+
* **Multiprocessing Support**: Designed to work with LiveKit's worker process model.
|
|
215
|
+
* **Event Parsing**: Extracts LLM outputs from `gen_ai.choice` events when available.
|
|
216
|
+
|
|
217
|
+
## Examples
|
|
218
|
+
|
|
219
|
+
Check the `examples/` directory for agent examples (validate recording SDK compatibility before deployment):
|
|
220
|
+
* `simple_agent.py`: A basic voice assistant agent.
|
|
221
|
+
* `egress_agent.py`: An agent with opt-in Egress metadata capture, an explicit session envelope and bounded stop/close cleanup. The modern `LiveKitAPI().egress` request shape and native-session linkage require the deployment's SDK/mode validation.
|
|
222
|
+
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# traceAI-livekit
|
|
2
|
+
|
|
3
|
+
OpenTelemetry instrumentation for LiveKit agents integrated with Future AGI.
|
|
4
|
+
|
|
5
|
+
This package provides automatic attribute mapping from LiveKit's native OpenTelemetry instrumentation to Future AGI's semantic conventions, ensuring rich and structured traces in your dashboard.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install traceai-livekit
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
To instrument your LiveKit agent, simply initialize `fi-instrumentation` and enable the attribute mapping **inside your agent's entrypoint**.
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from livekit.agents import AgentServer, JobContext
|
|
19
|
+
from fi_instrumentation.otel import register, ProjectType
|
|
20
|
+
from traceai_livekit import enable_http_attribute_mapping
|
|
21
|
+
|
|
22
|
+
server = AgentServer()
|
|
23
|
+
|
|
24
|
+
@server.rtc_session()
|
|
25
|
+
async def entrypoint(ctx: JobContext):
|
|
26
|
+
# 1. Initialize TraceAI (inside entrypoint for multiprocessing safety)
|
|
27
|
+
register(
|
|
28
|
+
project_name="My LiveKit Agent",
|
|
29
|
+
project_type=ProjectType.OBSERVE,
|
|
30
|
+
set_global_tracer_provider=True,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
# 2. Enable LiveKit attribute mapping
|
|
34
|
+
# This automatically hooks into LiveKit's telemetry system
|
|
35
|
+
enable_http_attribute_mapping()
|
|
36
|
+
|
|
37
|
+
# ... rest of your agent logic ...
|
|
38
|
+
await ctx.connect()
|
|
39
|
+
|
|
40
|
+
if __name__ == "__main__":
|
|
41
|
+
server.run()
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`enable_http_attribute_mapping()` (or `enable_grpc_attribute_mapping()`) hands the provider to LiveKit for you. If you call
|
|
45
|
+
LiveKit's `set_tracer_provider` yourself on the provider `register()` returned, call it after `enable_*`: before it, the call
|
|
46
|
+
drops the Future AGI exporter. LiveKit installs its privacy filter once per provider, so an `allow_pii` passed in a later call is
|
|
47
|
+
ignored. To keep conversation content out of your traces, set `LIVEKIT_TELEMETRY_ALLOW_PII=false` before calling `enable_*`
|
|
48
|
+
(livekit-agents 1.8 and later).
|
|
49
|
+
|
|
50
|
+
### Flushing at the end of a job
|
|
51
|
+
|
|
52
|
+
On Linux a LiveKit job process ends without running `atexit`, and LiveKit flushes only its own processors, so the spans
|
|
53
|
+
still queued when a job ends, such as the root `agent_session` span, used to never reach Future AGI. `enable_*` now sends
|
|
54
|
+
them twice over:
|
|
55
|
+
|
|
56
|
+
- **When the job shuts down**, if `enable_*` runs inside a job (the usual place, the entrypoint): this sends the voice
|
|
57
|
+
trace, `agent_session` included, as soon as the call ends.
|
|
58
|
+
- **When the process exits**, just before it stops: this sends what LiveKit ends after the shutdown callbacks, its own
|
|
59
|
+
`job_shutdown` span, and the job's root `job_entrypoint` span when tracing is set up before the job starts. With
|
|
60
|
+
set-up inside the entrypoint, LiveKit starts `job_entrypoint` before tracing is on, so it is never recorded and the
|
|
61
|
+
job trace arrives rooted at `job_shutdown`.
|
|
62
|
+
|
|
63
|
+
Each waits at most 3 seconds for the collector, well inside the 10 seconds LiveKit gives a job process to exit, so its own
|
|
64
|
+
clean-up still runs when the collector is slow.
|
|
65
|
+
|
|
66
|
+
If you set tracing up outside a job (for example at import time, in the job process), only the process-exit flush runs.
|
|
67
|
+
To also send each call's trace as soon as the call ends, call `flush_on_job_shutdown()` in each job entrypoint:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from traceai_livekit import flush_on_job_shutdown
|
|
71
|
+
|
|
72
|
+
@server.rtc_session()
|
|
73
|
+
async def entrypoint(ctx: JobContext):
|
|
74
|
+
flush_on_job_shutdown()
|
|
75
|
+
...
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Do not pass `provider.force_flush` to `ctx.add_shutdown_callback`: LiveKit calls it with the shutdown reason, which
|
|
79
|
+
`force_flush` takes as its timeout, so it fails and nothing is flushed.
|
|
80
|
+
|
|
81
|
+
Limits:
|
|
82
|
+
- A process LiveKit kills (for example when a worker drains and the job overruns its exit time) sends nothing more.
|
|
83
|
+
- Before livekit-agents 1.3, LiveKit closes the session at the same time as the job-shutdown flush, so that flush can miss
|
|
84
|
+
`agent_session`; the process-exit flush still sends it.
|
|
85
|
+
- A second `AgentSession` in one job that is still closing when the shutdown callbacks run is sent by the process-exit
|
|
86
|
+
flush, not the job-shutdown one.
|
|
87
|
+
- In LiveKit Cloud observability mode the session's parent span is recorded on LiveKit's own provider and never reaches
|
|
88
|
+
Future AGI, so the trace has no stored root there.
|
|
89
|
+
|
|
90
|
+
## Recording metadata on a session trace
|
|
91
|
+
|
|
92
|
+
`record_egress` records metadata only: it never records, opens, downloads or uploads media. Each call creates and promptly ends one INTERNAL `livekit.recording.snapshot` span with FI kind `CHAIN`, parented to the supplied session span. Multiple recordings and start/stop/update responses remain separate snapshots instead of overwriting a root.
|
|
93
|
+
|
|
94
|
+
Use an explicitly owned session root/envelope before starting recording. An ended span or a `NonRecordingSpan` holding its saved context is valid for later callbacks. Without `session_span`, the helper uses the current valid OTel span; it does not discover the native LiveKit root or search ancestors. Without a valid parent it returns `False` and creates no orphan recording trace.
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from fi_instrumentation import FITracer, TraceConfig
|
|
98
|
+
from opentelemetry import trace
|
|
99
|
+
from traceai_livekit import record_egress, wrap_egress_client
|
|
100
|
+
|
|
101
|
+
# provider is the provider from register(); enable_* has already configured mapping.
|
|
102
|
+
policy = TraceConfig()
|
|
103
|
+
tracer = provider.get_tracer("my-agent-recordings")
|
|
104
|
+
root = FITracer(tracer, config=policy).start_span(
|
|
105
|
+
"LiveKit Agent Session", fi_span_kind="agent"
|
|
106
|
+
)
|
|
107
|
+
saved_parent = trace.NonRecordingSpan(root.get_span_context())
|
|
108
|
+
|
|
109
|
+
# Bind the egress SERVICE, not the owning API context manager. Requests and
|
|
110
|
+
# response objects are forwarded unchanged; only successful responses are read.
|
|
111
|
+
egress = wrap_egress_client(
|
|
112
|
+
api_owner.egress, session_span=saved_parent, room_name=room_name,
|
|
113
|
+
conversation_id=conversation_id, # optional: may differ from room_name
|
|
114
|
+
tracer=tracer, trace_config=policy,
|
|
115
|
+
)
|
|
116
|
+
with trace.use_span(root, end_on_exit=False):
|
|
117
|
+
info = await egress.start_room_composite_egress(start_request)
|
|
118
|
+
# Start AgentSession under this context too, where the LiveKit mode supports it.
|
|
119
|
+
|
|
120
|
+
# Later, for a final EgressInfo-like response ALREADY received by your application:
|
|
121
|
+
recorded_locally = record_egress(
|
|
122
|
+
final_info, session_span=saved_parent, room_name=room_name,
|
|
123
|
+
conversation_id=conversation_id, tracer=tracer, trace_config=policy,
|
|
124
|
+
)
|
|
125
|
+
# End root at actual session shutdown; the application owns API stop/close.
|
|
126
|
+
# See examples/egress_agent.py for a bounded, idempotent shutdown callback.
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
`True` means a snapshot was locally created and ended. It does **not** confirm collector delivery, recording completion, an available final file, or a playable URL. `False` also covers tracing suppression, unsampled children, invalid/missing ids, room mismatch and instrumentation failure. Delegate failures/cancellation are not swallowed or logged by the proxy. A failed or cancelled start with no returned id can leave server-side state unknown; the adapter does not retry or discover that state.
|
|
130
|
+
|
|
131
|
+
### Metadata contract
|
|
132
|
+
|
|
133
|
+
These are package-local custom attributes, not standardized recording semantics or a dashboard-player API:
|
|
134
|
+
|
|
135
|
+
| FI export-copy attribute | Meaning |
|
|
136
|
+
| --- | --- |
|
|
137
|
+
| `livekit.recording.operation` | `snapshot` or a fixed captured method name |
|
|
138
|
+
| `livekit.recording.egress_id` | Bounded nonempty response id |
|
|
139
|
+
| `livekit.recording.status` | Recognized `EGRESS_*` label or decimal enum number; zero is retained, numbers are not interpreted |
|
|
140
|
+
| `livekit.recording.started_at_unix_nano`, `livekit.recording.ended_at_unix_nano` | Positive int64 Unix nanoseconds, only when supplied |
|
|
141
|
+
| `livekit.recording.room_name` | Explicit room, otherwise response room |
|
|
142
|
+
| `gen_ai.conversation.id` | Explicit conversation id, independently masked; otherwise the fully masked room passed through conversation masks. A withheld room supplies no implicit conversation; a redacted room supplies only its replacement |
|
|
143
|
+
| `livekit.recording.file_locations` | At most eight credential-free object locators or safe relative filenames |
|
|
144
|
+
| `livekit.recording.stream_locations` | At most eight stream origins; paths may be bearer keys and are omitted |
|
|
145
|
+
|
|
146
|
+
The helper's EgressInfo-like contract reads only `egress_id`, `room_name`, `status`, `started_at`, `ended_at`, `file_results` (`location`, or `filename` only when location is absent) and `stream_results` (`url`). Use a caller-normalized response if your SDK differs. Timestamps must already be Unix nanoseconds; there is no magnitude-based conversion. Missing/zero/invalid timestamps, unknown status text, unsupported legacy singular/segment/image results and absent locations are omitted. A successful start/stop may still be STARTING/ENDING with no final location; no duration or completion is inferred.
|
|
147
|
+
|
|
148
|
+
Ids/room/conversation are at most 256 characters; locations at most 2048. Oversize values are omitted, not truncated. Only the first eight elements of each results collection are examined. A nonempty explicit room that differs from the response room refuses capture. No request, upload configuration, auth header, protobuf serialization or media bytes are inspected.
|
|
149
|
+
|
|
150
|
+
### Privacy and adapter limits
|
|
151
|
+
|
|
152
|
+
The recording helper controls only the metadata it writes. Attributes, events or links that your own samplers, span processors or code add are exported as written; the recording policy does not filter them, except the helper's reserved keys, which export always re-checks.
|
|
153
|
+
|
|
154
|
+
- Helper-authored values pass existing FI `TraceConfig.mask` gates for both the destination alias and source key **before** span creation. Locations also pass the `output.value` policy, so output hiding applies. Both the helper policy and any supplied FITracer policy apply. A withheld helper value is not placed into attributes, events, links, exception text, logs, baggage, context keys, resources or the helper's boolean result.
|
|
155
|
+
- FI export re-applies those policies by **key name**, not writer provenance, to the nine source/alias pairs in the metadata table (including `lk.pii.room_name` and `gen_ai.conversation.id`) and `session.id`. This also covers reserved attribute keys in application-created events and links; unrelated keys, event names, exception text and link targets are not filtered by the recording policy. Missing sources do not recreate aliases. A masking `Exception` replaces the affected value with `__REDACTED__` rather than exporting raw metadata or exception text. Export rechecking may transform an already-masked value again: custom masks should be idempotent.
|
|
156
|
+
- Capture uses a per-call copy of the ordinary OTel SDK tracer without changing the supplied tracer/provider, sampler, or application callbacks. A lifecycle adapter retains the started child for `finally` cleanup and carries the policy tuple on a local instrumentation-scope copy for delayed/batched FI export. Normal scope fields and attributes are unchanged; no response values, policy data or identity registry are serialized. Application samplers/processors are not sandboxed or restricted. Unknown/custom tracers, subclasses, nested tracer proxies or inaccessible FI configuration fail closed before starting a span. Minimum-FI/SDK and LiveKit-copy compatibility still require verification.
|
|
157
|
+
- Through creation **and ending**, the helper attaches a fresh context containing only the selected parent, including its trace state. It does not inherit ambient FI session/user/metadata attributes or baggage. Suppression is checked first; child termination and restoration of the caller context run in `finally`, including when `start_span` fails after SDK allocation. Initial extraction/masking failures still create no child.
|
|
158
|
+
- The helper writes sensitive live-span values only under `lk.pii.*`; its aliases are created on the FI export copy. LiveKit PII opt-out and Cloud redaction can therefore remove helper-authored ids, room, conversation and locations before aliasing. The exact `livekit.recording.snapshot` and supported `livekit.recording.<method>` names remain reserved across tracer scopes: loss of the operation attribute to sampling or SDK limits cannot enable generic room-to-conversation fallback. Ordinary non-recording spans keep their existing mapping.
|
|
159
|
+
- File locations allow `http`, `https`, `s3`, `gs` or safe relative names. Stream locations allow `http`, `https`, `rtmp`, `rtmps`, `rtsp`, `rtsps`, but only their origin survives. Malformed/unsupported locations, controls, backslashes and unsafe relative paths are omitted. All query parameters, fragments and userinfo are dropped. Credential-free locators are intentionally **not usable presigned playback links**. This stricter local projection supplements FI masks; it does not claim reuse of an independently verified shared URL/credential sanitizer.
|
|
160
|
+
- The opt-in proxy recognizes coroutine functions named `start_room_composite_egress`, `start_web_egress`, `start_participant_egress`, `start_track_composite_egress`, `start_track_egress`, `stop_egress`, `update_stream`, and `update_layout`. This is a structural service contract, not a verified SDK-version matrix. Non-coroutine/decorated methods and unrelated attributes pass through; non-info responses produce no snapshot. Use the manual helper when recognition is unsupported.
|
|
161
|
+
- The wrapper freezes its parent at creation; an unbound wrapper stays capture-disabled even if a different task later has a current span. Rewrapping with omitted/identical options is idempotent; conflicting supplied bindings raise a value-free `ValueError`. No global room registry or response history is kept.
|
|
162
|
+
- Calls on the original service, other processes and server-side completion events are not intercepted. There is no polling or webhook server. Your application supplies final updates and distributed trace-context propagation. The API owner remains responsible for shutdown; special-method/context-manager protocols are not proxied.
|
|
163
|
+
- The envelope is not a promise that FI receives LiveKit Cloud's native root. The earlier Cloud-root limitation still applies. Native `AgentSession` parent inheritance and real SDK compatibility must be validated for the deployed mode.
|
|
164
|
+
|
|
165
|
+
The pinned development lock contains LiveKit Agents 1.8.6, API 1.2.1, protocol 1.1.27, FI 1.3.0 and OpenTelemetry SDK 1.44.0. Those pins are **verification targets, not executed compatibility results for this feature**. Fake-service tests do not establish SDK schemas, timestamp semantics, native-session linkage or a playback UI.
|
|
166
|
+
|
|
167
|
+
## Compatibility
|
|
168
|
+
|
|
169
|
+
* **livekit-agents**: 1.x. 1.8 is the tested version (it needs Python 3.10 or later). Since 1.7, LiveKit names its content
|
|
170
|
+
attributes `lk.pii.*` (for example `lk.pii.user_input`); both those names and the earlier ones are mapped to `input.value`
|
|
171
|
+
and `output.value`.
|
|
172
|
+
* **Python**: 3.10 to 3.13.
|
|
173
|
+
* **fi-instrumentation-otel**: 1.3.0 or later; the recording helpers' privacy tests fail with 1.1.0. 1.3.0 needs Python 3.10
|
|
174
|
+
or later and sets the default base64 image cap to 0 (see its changelog). 1.0 moved span attributes from the `llm.*` names to the OpenTelemetry GenAI `gen_ai.*` names, and
|
|
175
|
+
renamed the `SpanAttributes` constants with them. Code that only calls `register()` is unaffected; if your code sets or reads
|
|
176
|
+
those attributes directly, see the
|
|
177
|
+
[mapping from the old names](https://github.com/future-agi/traceAI/blob/main/docs/OTEL_GENAI_SEMANTIC_CONVENTIONS.md#migration-from-openinference-llm).
|
|
178
|
+
|
|
179
|
+
## Features
|
|
180
|
+
|
|
181
|
+
* **Automatic Attribute Mapping**: Converts LiveKit attributes (like `lk.user_input`, `gen_ai.usage.input_tokens`) to Future AGI standard attributes (`input.value`, `llm.tokenCount.prompt`).
|
|
182
|
+
* **Raw Data Preservation**: Keeps original LiveKit attributes and adds `raw.input` / `raw.output` for full debugging context.
|
|
183
|
+
* **Multiprocessing Support**: Designed to work with LiveKit's worker process model.
|
|
184
|
+
* **Event Parsing**: Extracts LLM outputs from `gen_ai.choice` events when available.
|
|
185
|
+
|
|
186
|
+
## Examples
|
|
187
|
+
|
|
188
|
+
Check the `examples/` directory for agent examples (validate recording SDK compatibility before deployment):
|
|
189
|
+
* `simple_agent.py`: A basic voice assistant agent.
|
|
190
|
+
* `egress_agent.py`: An agent with opt-in Egress metadata capture, an explicit session envelope and bounded stop/close cleanup. The modern `LiveKitAPI().egress` request shape and native-session linkage require the deployment's SDK/mode validation.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "traceAI-livekit"
|
|
3
|
-
version = "0.1
|
|
3
|
+
version = "0.2.1"
|
|
4
4
|
description = "OpenTelemetry instrumentation for LiveKit"
|
|
5
5
|
authors = ["Future AGI <no-reply@futureagi.com>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -15,7 +15,6 @@ classifiers = [
|
|
|
15
15
|
"Programming Language :: Python",
|
|
16
16
|
"Programming Language :: Python :: 3",
|
|
17
17
|
"Programming Language :: Python :: 3 :: Only",
|
|
18
|
-
"Programming Language :: Python :: 3.9",
|
|
19
18
|
"Programming Language :: Python :: 3.10",
|
|
20
19
|
"Programming Language :: Python :: 3.11",
|
|
21
20
|
"Programming Language :: Python :: 3.12",
|
|
@@ -27,8 +26,8 @@ classifiers = [
|
|
|
27
26
|
]
|
|
28
27
|
|
|
29
28
|
[tool.poetry.dependencies]
|
|
30
|
-
python = "
|
|
31
|
-
fi-instrumentation-otel = ">=1.
|
|
29
|
+
python = ">=3.10,<3.14"
|
|
30
|
+
fi-instrumentation-otel = ">=1.3.0"
|
|
32
31
|
|
|
33
32
|
[tool.poetry.group.dev.dependencies]
|
|
34
33
|
# livekit-agents 1.8 is the version whose privacy filter the tests cover; it needs Python 3.10+.
|