traceai-cognee 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.
@@ -0,0 +1,87 @@
1
+ *.py[cod]
2
+
3
+ # C extensions
4
+ *.so
5
+
6
+ # IDEs
7
+ .idea/
8
+ .vscode/
9
+
10
+ # Packages
11
+ *.egg
12
+ *.egg-info
13
+ .eggs/
14
+ # build
15
+ parts
16
+ bin
17
+ var
18
+ sdist
19
+ dist
20
+ develop-eggs
21
+ .installed.cfg
22
+ lib
23
+ lib64
24
+
25
+ # Installer logs
26
+ pip-log.txt
27
+
28
+ # Unit test / coverage reports
29
+ .coverage
30
+ .tox
31
+ nosetests.xml
32
+
33
+ # Complexity
34
+ output/*.html
35
+ output/*/index.html
36
+
37
+ # Sphinx
38
+ docs/_build
39
+
40
+ # Cookiecutter
41
+ output/
42
+
43
+ .workon
44
+
45
+ **.wav
46
+ **.joblib
47
+
48
+ **/__pycache__
49
+
50
+ #Excel files
51
+ *.xlsx
52
+ #csv files
53
+ *.csv
54
+ #virtual environments
55
+ **/.venv
56
+ **/env
57
+ **/.env
58
+ *.DS_Store
59
+ *.pdf
60
+ **/node_modules
61
+ **/dist
62
+ *.log
63
+ .DS_Store
64
+ **/package-lock.json
65
+ # Standalone npm example (outside the pnpm workspace): its lockfile pins the tested dependency set.
66
+ !typescript/examples/tanstack-ai/package-lock.json
67
+ **/tsconfig.tsbuildinfo
68
+ **/.fi
69
+ **/.pytest_cache
70
+ planning/
71
+
72
+ # Java build artifacts
73
+ **/target/
74
+ **/.settings/
75
+ **/.project
76
+ **/.classpath
77
+ **/.factorypath
78
+ *.class
79
+ *.jar
80
+ *.war
81
+
82
+ # C# build artifacts
83
+ **/bin/
84
+ **/obj/
85
+
86
+ # Python
87
+ **/uv.lock
@@ -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,55 @@
1
+ Metadata-Version: 2.5
2
+ Name: traceai-cognee
3
+ Version: 0.1.0
4
+ Summary: Future AGI exporter for Cognee native OpenTelemetry spans
5
+ Project-URL: Repository, https://github.com/future-agi/traceAI
6
+ Project-URL: Documentation, https://docs.futureagi.com/docs/integrations/traceai/cognee
7
+ Author-email: Future AGI <no-reply@futureagi.com>
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Requires-Python: <3.14,>=3.10
11
+ Requires-Dist: fi-instrumentation-otel<2,>=1.2.2
12
+ Requires-Dist: opentelemetry-sdk<2,>=1.27
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest<9,>=8; extra == 'dev'
15
+ Description-Content-Type: text/markdown
16
+
17
+ # traceai-cognee
18
+
19
+ Send Cognee's native OpenTelemetry spans to Future AGI without additional instrumentation. Enable `COGNEE_TRACING_ENABLED=true` before your first Cognee operation and configure once before that operation.
20
+
21
+ Requires Python 3.10–3.13 and `fi-instrumentation-otel>=1.2.2,<2`.
22
+
23
+ ```bash
24
+ pip install "cognee[tracing]==1.6.5" "traceai-cognee==0.1.0"
25
+ export COGNEE_TRACING_ENABLED=true
26
+ export FI_API_KEY="YOUR_FI_API_KEY"
27
+ export FI_SECRET_KEY="YOUR_FI_SECRET_KEY"
28
+ export FI_PROJECT_NAME="my-cognee-app"
29
+ ```
30
+
31
+ Configure your model and embedding providers using the [Cognee documentation](https://docs.cognee.ai/), then run your operations with the adapter attached:
32
+
33
+ ```python
34
+ import os
35
+ from traceai_cognee import configure
36
+
37
+ handle = configure(project_name=os.environ['FI_PROJECT_NAME'])
38
+ # Run cognee.add, cognee.cognify and cognee.search here.
39
+ handle.force_flush()
40
+ handle.shutdown()
41
+ ```
42
+
43
+ Set `FI_API_KEY` and `FI_SECRET_KEY` for the Future AGI exporter. `FI_BASE_URL` selects a different Future AGI origin. Alternatively supply an OTLP HTTP `endpoint` and `headers`, or an injected OpenTelemetry exporter. A supplied exporter is owned by the handle. `provider` can be the global SDK provider Cognee will use. Existing processors are not shut down; a provider whose default processor would be replaced on add is rejected.
44
+
45
+ A repeated `configure` with the same options returns the active handle; different options require shutting it down first. Shutdown detaches the handle immediately and closes the exporter asynchronously, after in-flight callbacks return; it does not wait for exporter closure. Flush before shutdown when the queue must be drained. Each span is exported by the configuration that was active when it started: end spans and flush before shutdown, because a span still open at shutdown is not exported, and a later configuration does not adopt it. The adapter tracks at most 65,536 open spans; beyond that the oldest open span is dropped when it ends. Spans that share a trace ID, span ID and start time with another tracked span are not exported; such reuse only happens with a faulty ID generator, and once the limit evicts the earlier span's entry the protection no longer applies to it. If a custom provider raises from `add_span_processor` after attaching the processor, a retry reuses it; a provider that hides its processor list can keep an inactive extra processor for each failed attempt. Closure uses a non-daemon thread, so a stuck exporter can delay interpreter exit. An old handle cannot flush or shut down a later configuration. Shutting down the provider closes the adapter too and prevents reuse of that provider. Overlapping `configure` calls fail fast with `RuntimeError`; retry after the first call finishes. A successful `force_flush` drains the processor queue, not an acknowledgement of remote delivery.
46
+
47
+ By default only allowlisted operational attributes are sent. `capture_content=True` includes recognized Cognee input/output fields. Error details and stack traces remain excluded. Span names are retained; keep sensitive data out of them. Other processors on the provider receive unmodified native spans and need their own privacy controls.
48
+
49
+ ### Structured content redaction
50
+
51
+ With content capture enabled, the adapter redacts recognized credential field names in nested objects, arrays, JSON-serialized objects, and flattened paths. These include API keys, authorization headers, access/refresh/auth/bearer/ID/session/security tokens, client secrets, secret/private keys, passwords, credentials, and AWS access-key IDs and secret access keys. Common snake-case, camel-case, and dotted/bracketed path forms are recognized. Fields such as `input_tokens`, `token_count`, and `request_id` remain available.
52
+
53
+ This is a field-name policy, not a universal secret detector. Free text and unknown encodings are not scanned for credentials; enable content capture only for approved application data. The adapter does not mutate the original content or inspect opaque runtime objects. Numeric attributes outside the OTLP signed 64-bit integer range, or non-finite floating-point values, are omitted before encoding.
54
+
55
+ For a complete add/cognify/search application, see the [Cognee example](../../examples/cognee/). Search spans are mapped to `RETRIEVER` and structured-output model calls to `LLM`. Native span IDs, parent relationships and status codes are preserved, including Cognee's missing-collection probe errors.
@@ -0,0 +1,39 @@
1
+ # traceai-cognee
2
+
3
+ Send Cognee's native OpenTelemetry spans to Future AGI without additional instrumentation. Enable `COGNEE_TRACING_ENABLED=true` before your first Cognee operation and configure once before that operation.
4
+
5
+ Requires Python 3.10–3.13 and `fi-instrumentation-otel>=1.2.2,<2`.
6
+
7
+ ```bash
8
+ pip install "cognee[tracing]==1.6.5" "traceai-cognee==0.1.0"
9
+ export COGNEE_TRACING_ENABLED=true
10
+ export FI_API_KEY="YOUR_FI_API_KEY"
11
+ export FI_SECRET_KEY="YOUR_FI_SECRET_KEY"
12
+ export FI_PROJECT_NAME="my-cognee-app"
13
+ ```
14
+
15
+ Configure your model and embedding providers using the [Cognee documentation](https://docs.cognee.ai/), then run your operations with the adapter attached:
16
+
17
+ ```python
18
+ import os
19
+ from traceai_cognee import configure
20
+
21
+ handle = configure(project_name=os.environ['FI_PROJECT_NAME'])
22
+ # Run cognee.add, cognee.cognify and cognee.search here.
23
+ handle.force_flush()
24
+ handle.shutdown()
25
+ ```
26
+
27
+ Set `FI_API_KEY` and `FI_SECRET_KEY` for the Future AGI exporter. `FI_BASE_URL` selects a different Future AGI origin. Alternatively supply an OTLP HTTP `endpoint` and `headers`, or an injected OpenTelemetry exporter. A supplied exporter is owned by the handle. `provider` can be the global SDK provider Cognee will use. Existing processors are not shut down; a provider whose default processor would be replaced on add is rejected.
28
+
29
+ A repeated `configure` with the same options returns the active handle; different options require shutting it down first. Shutdown detaches the handle immediately and closes the exporter asynchronously, after in-flight callbacks return; it does not wait for exporter closure. Flush before shutdown when the queue must be drained. Each span is exported by the configuration that was active when it started: end spans and flush before shutdown, because a span still open at shutdown is not exported, and a later configuration does not adopt it. The adapter tracks at most 65,536 open spans; beyond that the oldest open span is dropped when it ends. Spans that share a trace ID, span ID and start time with another tracked span are not exported; such reuse only happens with a faulty ID generator, and once the limit evicts the earlier span's entry the protection no longer applies to it. If a custom provider raises from `add_span_processor` after attaching the processor, a retry reuses it; a provider that hides its processor list can keep an inactive extra processor for each failed attempt. Closure uses a non-daemon thread, so a stuck exporter can delay interpreter exit. An old handle cannot flush or shut down a later configuration. Shutting down the provider closes the adapter too and prevents reuse of that provider. Overlapping `configure` calls fail fast with `RuntimeError`; retry after the first call finishes. A successful `force_flush` drains the processor queue, not an acknowledgement of remote delivery.
30
+
31
+ By default only allowlisted operational attributes are sent. `capture_content=True` includes recognized Cognee input/output fields. Error details and stack traces remain excluded. Span names are retained; keep sensitive data out of them. Other processors on the provider receive unmodified native spans and need their own privacy controls.
32
+
33
+ ### Structured content redaction
34
+
35
+ With content capture enabled, the adapter redacts recognized credential field names in nested objects, arrays, JSON-serialized objects, and flattened paths. These include API keys, authorization headers, access/refresh/auth/bearer/ID/session/security tokens, client secrets, secret/private keys, passwords, credentials, and AWS access-key IDs and secret access keys. Common snake-case, camel-case, and dotted/bracketed path forms are recognized. Fields such as `input_tokens`, `token_count`, and `request_id` remain available.
36
+
37
+ This is a field-name policy, not a universal secret detector. Free text and unknown encodings are not scanned for credentials; enable content capture only for approved application data. The adapter does not mutate the original content or inspect opaque runtime objects. Numeric attributes outside the OTLP signed 64-bit integer range, or non-finite floating-point values, are omitted before encoding.
38
+
39
+ For a complete add/cognify/search application, see the [Cognee example](../../examples/cognee/). Search spans are mapped to `RETRIEVER` and structured-output model calls to `LLM`. Native span IDs, parent relationships and status codes are preserved, including Cognee's missing-collection probe errors.
@@ -0,0 +1,26 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27,<2"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "traceai-cognee"
7
+ version = "0.1.0"
8
+ description = "Future AGI exporter for Cognee native OpenTelemetry spans"
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ authors = [{name = "Future AGI", email = "no-reply@futureagi.com"}]
12
+ requires-python = ">=3.10,<3.14"
13
+ dependencies = ["fi-instrumentation-otel>=1.2.2,<2", "opentelemetry-sdk>=1.27,<2"]
14
+
15
+ [project.optional-dependencies]
16
+ dev = ["pytest>=8,<9"]
17
+
18
+ [project.urls]
19
+ Repository = "https://github.com/future-agi/traceAI"
20
+ Documentation = "https://docs.futureagi.com/docs/integrations/traceai/cognee"
21
+
22
+ [tool.hatch.build.targets.wheel]
23
+ packages = ["traceai_cognee"]
24
+
25
+ [tool.pytest.ini_options]
26
+ testpaths = ["tests"]
@@ -0,0 +1,96 @@
1
+ import json
2
+ import unittest
3
+ from opentelemetry import trace
4
+ from opentelemetry.sdk.trace import TracerProvider
5
+ from opentelemetry.sdk.trace.export import SimpleSpanProcessor
6
+ from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter
7
+ from opentelemetry.trace import Status, StatusCode
8
+ from traceai_cognee import configure, __version__
9
+
10
+ class TestAdapter(unittest.TestCase):
11
+ @classmethod
12
+ def setUpClass(cls):
13
+ cls.provider = TracerProvider()
14
+ trace.set_tracer_provider(cls.provider)
15
+
16
+ def setUp(self):
17
+ self.other = InMemorySpanExporter()
18
+ self.provider.add_span_processor(SimpleSpanProcessor(self.other))
19
+ self.sink = InMemorySpanExporter()
20
+
21
+ def emit(self, name, attrs):
22
+ with self.provider.get_tracer('test').start_as_current_span(name) as span:
23
+ for key, value in attrs.items(): span.set_attribute(key, value)
24
+ span.record_exception(ValueError('fake-private-error'))
25
+ span.set_status(Status(StatusCode.ERROR, 'fake-private-error'))
26
+
27
+ def test_projection_copy_and_status(self):
28
+ handle = configure(project_name='sample', exporter=self.sink)
29
+ self.assertIs(handle, configure(project_name='sample', exporter=self.sink))
30
+ with self.assertRaises(ValueError): configure(project_name='different', exporter=self.sink)
31
+ self.emit('cognee.search.query', {'cognee.search.query':'fake-private-query', 'custom.secret':'fake-secret', 'gen_ai.usage.input_tokens':7})
32
+ self.assertTrue(handle.force_flush())
33
+ src = self.other.get_finished_spans()[-1]; dst = self.sink.get_finished_spans()[-1]
34
+ self.assertEqual(src.attributes['cognee.search.query'], 'fake-private-query')
35
+ self.assertNotIn('cognee.search.query', dst.attributes)
36
+ self.assertNotIn('custom.secret', dst.attributes)
37
+ self.assertEqual(dst.attributes['gen_ai.usage.input_tokens'], 7)
38
+ self.assertEqual(dst.attributes['fi.span.kind'], 'RETRIEVER')
39
+ self.assertEqual(dst.status.status_code, StatusCode.ERROR)
40
+ self.assertIsNone(dst.status.description)
41
+ self.assertEqual(dst.context, src.context); self.assertEqual(dst.parent, src.parent)
42
+ self.assertEqual(dst.start_time, src.start_time); self.assertEqual(dst.end_time, src.end_time)
43
+ self.assertEqual(dst.resource.attributes['project_name'], 'sample')
44
+ self.assertNotIn('fake-private-error', str(dst.events))
45
+ handle.shutdown()
46
+ self.emit('after', {})
47
+ self.assertEqual(self.other.get_finished_spans()[-1].name, 'after')
48
+
49
+ def test_content_redaction_and_llm(self):
50
+ handle = configure(project_name='sample', exporter=self.sink, capture_content=True)
51
+ value = json.dumps({'api_key':'fake-secret', 'question':'hello'})
52
+ self.emit('cognee.observe.acreate_structured_output', {'langfuse.observation.input':value, 'langfuse.observation.output':'answer'})
53
+ handle.force_flush(); out = self.sink.get_finished_spans()[-1]
54
+ self.assertEqual(out.attributes['fi.span.kind'], 'LLM')
55
+ self.assertEqual(json.loads(out.attributes['input.value'])['api_key'], '[REDACTED]')
56
+ self.assertEqual(out.attributes['output.value'], 'answer')
57
+ self.assertNotIn('fake-secret', str(out.attributes))
58
+ handle.shutdown()
59
+
60
+ def test_additional_processor_and_lifecycle(self):
61
+ handle = configure(project_name='sample', exporter=self.sink)
62
+ native_buffer = InMemorySpanExporter()
63
+ self.provider.add_span_processor(SimpleSpanProcessor(native_buffer))
64
+ self.emit('memory.retrieve', {'memory.query.text': 'question'})
65
+ self.assertTrue(handle.force_flush())
66
+ self.assertEqual(len(self.sink.get_finished_spans()), 1)
67
+ self.assertEqual(native_buffer.get_finished_spans()[-1].attributes['memory.query.text'], 'question')
68
+ handle.shutdown()
69
+ handle.shutdown()
70
+ self.emit('later', {})
71
+ self.assertTrue(self.provider.force_flush())
72
+ self.assertEqual(native_buffer.get_finished_spans()[-1].name, 'later')
73
+ second = InMemorySpanExporter()
74
+ next_handle = configure(project_name='sample', exporter=second)
75
+ self.emit('reconfigured', {})
76
+ self.assertTrue(self.provider.force_flush())
77
+ self.assertEqual([span.name for span in second.get_finished_spans()], ['reconfigured'])
78
+ next_handle.shutdown()
79
+ self.assertTrue(self.provider.force_flush())
80
+
81
+ def test_replaceable_default_refused_without_replacement(self):
82
+ self.provider._default_processor = True
83
+ try:
84
+ before = self.provider._active_span_processor._span_processors
85
+ with self.assertRaisesRegex(RuntimeError, 'replaceable default'):
86
+ configure(project_name='sample', exporter=self.sink)
87
+ self.assertEqual(before, self.provider._active_span_processor._span_processors)
88
+ finally:
89
+ del self.provider._default_processor
90
+
91
+ def test_default_exporter_constructs_without_sending(self):
92
+ handle = configure(project_name='sample', endpoint='http://127.0.0.1:1/v1/traces', headers={'x-api-key': 'synthetic'})
93
+ self.assertTrue(handle.force_flush())
94
+ handle.shutdown()
95
+
96
+ def test_version(self): self.assertEqual(__version__, '0.1.0')