Pure C lib for python3 (or C if u wanna) to analyze traces and check for compliance with the OpenTelemetry standard.
Example:
from otelanalyzer import *
import json
def testTrace(a: Analyzer, t: str):
tr = Trace()
tr.traceString = t
tr.traceId = "1" * 32
tr.serviceName = "some-name"
a.analyze_btrace(tr)
r = a.get_counters('some-name')
print(json.dumps(r, indent=4))
if __name__ == '__main__':
t = "[{'spanId': '0000000000000000', 'serviceName': 'some-name', 'traceId': '00000000000000000000000000000000', 'project': 'some-project', 'service': 'some-service'}]"
a = Analyzer()
testTrace(a, t)
Result
$ python3 test_lib.py
{
"UndefTraceStatus": 0,
"myMissingParent": 0,
"notmyMissingParent": 0,
"myNoParentInTrace": 0,
"notmyNoParentInTrace": 0,
"myDuplicateSpan": 0,
"notmyDuplicateSpan": 0,
"myBadSpanIdSize": 0,
"notmyBadSpanIdSize": 0,
"myBadTraceIdSize": 0,
"notmyBadTraceIdSize": 0,
"myExamples": [],
"notmyExamples": [],
"badTraceCount": 0,
"mySpanCount": 1,
"traceCount": 1
}
$ valgrind --tool=memcheck --leak-check=full python3 test_lib.py
==374573== HEAP SUMMARY:
==374573== in use at exit: 397,058 bytes in 11 blocks
==374573== total heap usage: 3,462 allocs, 3,451 frees, 4,881,009 bytes allocated
==374573==
==374573== LEAK SUMMARY:
==374573== definitely lost: 0 bytes in 0 blocks
==374573== indirectly lost: 0 bytes in 0 blocks
==374573== possibly lost: 0 bytes in 0 blocks
==374573== still reachable: 397,058 bytes in 11 blocks
==374573== suppressed: 0 bytes in 0 blocks
Plugins
Plugins for this package can add more robust trace analysis and edge case management. They will be called after splitting traces into spans, so you can work more comfortably. The motivation for this feature is to be able to add NDA-protected features without forking the project.
They are called during traceString analyzation. Steps are as follows:
- Split
traceStringinto spans, add span statuses, and increase error counters accordingly - Call all plugins
- Free the trace object for optimization reasons
C plugins
You can add your C analysis plugins in the src/plugin_manager.c file. Their source files should be placed in the src/plugins/ folder. A plugin should have a function with Analyzer* and Trace* parameters and should return void. There is an example plugin in src/plugins/example_plugin.*
You are strongly encouraged to write your plugins with header files, as demonstrated in example_plugin.
Your function will be called after parsing the trace into separate spans. Please keep in mind that trace.traceString will be freed at this point for optimization reasons.
Python plugins
You can add your own Python plugin to modify the existing behavior of the analyzer. To do this, create a function that takes dict[str, Counter] and Trace as input parameters. Then, pass a pointer (just the function's name without brackets or parameters) to Analyzer.plg_manager.add_plugin(your_func). Plugins will be executed in a first-in, first-out order.
Your function's behaviour is not restricted in any way except for input-output types: feel free to call your custom classes, write raw data right into DB and whatever.
dict[str, Counter] contains service names as keys and their corresponding ErrorCounter values. Only services that appear at least once in the trace spans are included.
Trace is the current trace object being analyzed. See the plugin execution steps for reference.
IF YOU WANT TO MODIFY the Counter value corresponding to your service, YOU MUST return the updated dict[str, Counter] object. Keep in mind that the Trace object is read-only, so your changes will not be applied directly.
If you want to modify the examples property of a counter, YOU MUST also update ExamplesCount, or your changes will not take effect.
Plugin example:
def example_plugin(d: dict[str, Counter], t: Trace):
d["some-name"].mySpanCount = 9999999
d["some-name"].myBadTraceExamples.append("pipa")
d["some-name"].myExamplesCount += 1
return d
def test_plugin(a: Analyzer, t: str):
a.plg_manager.add_plugin(lambda_func)
Installation
$ pip install otelanalyzer
or
$ python3 setup.py build_ext --inplace && mv ./otelanalyzer.so ./otelanalyzer
Dependencies
The package has no dependencies.
Planned features
- Python unit tests
- Wheels for Python 3.13 (you can already build it locally, check installation)
Metadata
Release files for otelanalyzer 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| otelanalyzer-1.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.17+ x86-64 | Details for otelanalyzer-1.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| otelanalyzer-1.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.11 | CPython 3.11 | Linux glibc 2.17+ x86-64 | Details for otelanalyzer-1.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| otelanalyzer-1.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | CPython 3.10 | Linux glibc 2.17+ x86-64 | Details for otelanalyzer-1.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
Total release size: 247.4 kB
Release files / otelanalyzer-1.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | otelanalyzer-1.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 83.9 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
563f76f41e89e990e4df0fabe6a30b36703f4f5c6bf3a324464c78f5e983d605
|
|
BLAKE2b-256 checksum How to use checksums |
349dbd689c3f75ca427489091d0d1a0ab9369a22c0c00326d760011dc4655116
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / otelanalyzer-1.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | otelanalyzer-1.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 82.7 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
f75c0c02c5d4302d3928854995f7f596fcaee6cd366b6bcf20f8212926d103dd
|
|
BLAKE2b-256 checksum How to use checksums |
e3175baff9ba385c093eaa67fb8e8a5b18578bb4ba03188ecdddd27995880009
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / otelanalyzer-1.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | otelanalyzer-1.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 80.8 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
7a67ce515657ece61d61f88af11bdaef07e896daa01b2dd76d20aae47eaa9c73
|
|
BLAKE2b-256 checksum How to use checksums |
fc2baf56991c1bec801a3c9c2c34976ce9b3ec85341de26183f3b824afbebbf6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Security for otelanalyzer 1.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.