{"id":26681169,"url":"https://github.com/zkh-dot/oteltraceanalyzer","last_synced_at":"2026-03-05T06:02:07.489Z","repository":{"id":282256556,"uuid":"947928111","full_name":"Zkh-dot/otelTraceAnalyzer","owner":"Zkh-dot","description":"Pure C lib for python3 (or C if u wanna) to analyze traces check for compliance with the OpenTelemetry standard.","archived":false,"fork":false,"pushed_at":"2025-07-08T17:31:50.000Z","size":2559,"stargazers_count":5,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-08T18:51:32.735Z","etag":null,"topics":["c","opentelemetry","python"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zkh-dot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-13T13:22:25.000Z","updated_at":"2025-05-02T13:50:28.000Z","dependencies_parsed_at":"2025-04-12T12:36:17.815Z","dependency_job_id":"f0d225d0-159f-4aa8-ae4d-d5341133eea7","html_url":"https://github.com/Zkh-dot/otelTraceAnalyzer","commit_stats":null,"previous_names":["zkh-dot/oteltraceanalyzer"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Zkh-dot/otelTraceAnalyzer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zkh-dot%2FotelTraceAnalyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zkh-dot%2FotelTraceAnalyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zkh-dot%2FotelTraceAnalyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zkh-dot%2FotelTraceAnalyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zkh-dot","download_url":"https://codeload.github.com/Zkh-dot/otelTraceAnalyzer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zkh-dot%2FotelTraceAnalyzer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30111779,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T03:40:26.266Z","status":"ssl_error","status_checked_at":"2026-03-05T03:39:15.902Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","opentelemetry","python"],"created_at":"2025-03-26T07:14:28.545Z","updated_at":"2026-03-05T06:02:07.477Z","avatar_url":"https://github.com/Zkh-dot.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Pure C lib for python3 (or C if u wanna) to analyze traces and check for compliance with the [OpenTelemetry](https://opentelemetry.io/) standard.\n\n# Example:\n\n```python\nfrom otelanalyzer import *\nimport json\n\ndef testTrace(a: Analyzer, t: str):\n    tr = Trace()\n    tr.traceString = t\n    tr.traceId = \"1\" * 32\n    tr.serviceName = \"some-name\"\n    a.analyze_btrace(tr)\n    r = a.get_counters('some-name')\n    print(json.dumps(r, indent=4))\n\nif __name__ == '__main__':\n    t = \"[{'spanId': '0000000000000000', 'serviceName': 'some-name', 'traceId': '00000000000000000000000000000000', 'project': 'some-project', 'service': 'some-service'}]\"\n    a = Analyzer()\n    testTrace(a, t)\n```\n\n## Result\n```\n$ python3 test_lib.py\n{\n    \"UndefTraceStatus\": 0,\n    \"myMissingParent\": 0,\n    \"notmyMissingParent\": 0,\n    \"myNoParentInTrace\": 0,\n    \"notmyNoParentInTrace\": 0,\n    \"myDuplicateSpan\": 0,\n    \"notmyDuplicateSpan\": 0,\n    \"myBadSpanIdSize\": 0,\n    \"notmyBadSpanIdSize\": 0,\n    \"myBadTraceIdSize\": 0,\n    \"notmyBadTraceIdSize\": 0,\n    \"myExamples\": [],\n    \"notmyExamples\": [],\n    \"badTraceCount\": 0,\n    \"mySpanCount\": 1,\n    \"traceCount\": 1\n}\n```\n```\n$ valgrind --tool=memcheck --leak-check=full python3 test_lib.py\n\n==374573== HEAP SUMMARY:\n\n==374573==     in use at exit: 397,058 bytes in 11 blocks\n==374573==   total heap usage: 3,462 allocs, 3,451 frees, 4,881,009 bytes allocated\n==374573==\n==374573== LEAK SUMMARY:\n==374573==    definitely lost: 0 bytes in 0 blocks\n==374573==    indirectly lost: 0 bytes in 0 blocks\n==374573==      possibly lost: 0 bytes in 0 blocks\n==374573==    still reachable: 397,058 bytes in 11 blocks\n==374573==         suppressed: 0 bytes in 0 blocks\n```\n\n# Plugins\n\nPlugins 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.\n\nThey are called during traceString analyzation. Steps are as follows:\n\n1. Split `traceString` into spans, add span statuses, and increase error counters accordingly\n2. Call all plugins\n3. Free the trace object for optimization reasons\n\n## C plugins\n\nYou 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.*`\n\nYou are strongly encouraged to write your plugins with header files, as demonstrated in `example_plugin`.\n\nYour 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.\n\n## Python plugins\n\nYou 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.\n\nYour 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.\n\n`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.\n\n`Trace` is the current trace object being analyzed. See the plugin execution steps for reference.\n\nIF 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.\n\nIf you want to modify the `examples` property of a counter, YOU MUST also update `ExamplesCount`, or your changes will not take effect.\n\nPlugin example:\n\n```python\ndef example_plugin(d: dict[str, Counter], t: Trace):\n    d[\"some-name\"].mySpanCount = 9999999\n    d[\"some-name\"].myBadTraceExamples.append(\"pipa\")\n    d[\"some-name\"].myExamplesCount += 1\n    return d\n\ndef test_plugin(a: Analyzer, t: str):\n    a.plg_manager.add_plugin(lambda_func)\n```\n\n# Installation\n\n```$ pip install otelanalyzer```\n\nor\n\n```$ python3 setup.py build_ext --inplace \u0026\u0026 mv ./otelanalyzer.so ./otelanalyzer```\n\n# Dependencies\n\nThe package has no dependencies.\n\n# Planned features\n\n* Python unit tests\n* Wheels for Python 3.13 (you can already build it locally, check installation)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzkh-dot%2Foteltraceanalyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzkh-dot%2Foteltraceanalyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzkh-dot%2Foteltraceanalyzer/lists"}