fix(otel): complete diagnostics-otel OpenTelemetry v2 API migration#12897
Conversation
|
@greptileai the one issue you raised was outdated, this PR is ready to merge please update the score. |
|
Hi @vincentkoc, have u tested this plugin e2e with a real backend (like Jaeger or a standard OTel collector) to ensure data exported as expected? |
@feng-95 was working in my logs but collector is not working (as you point out), i think i know the issue so will switch this branch PR to draft to avoid noise as im testing from branch on a live instance. |
|
Hi @vincentkoc , I wanted to check in on the current status of this PR—do you consider it fully ready for review and merge at this stage? Additionally, since the openclaw repository can sometimes be quite slow with reviewing and merging large PRs, have you considered submitting this to the openclaw-cn community: https://github.com/jiulingyun/openclaw-cn as well? The maintainers there tend to merge faster. Getting it live in openclaw-cn would be an excellent way to validate these new capabilities in the wild, which could provide the proof-of-stability needed to accelerate the review and merge process here in the main openclaw repo. |
|
@feng-95 yes this has been 100% tested by hand and coded by hand with some AI assistance (hence the screenshots), all other PRs are broken. Just rebasing the conflicts and formatting which broke after some merge conflicts. I dont feel comfortable commiting to a fork, your welcomed to sync my branch manually if you wish. |
|
Rebased branch and resolved merge conflicts, ready to merge again. |
|
hi @vincentkoc - amazing, thanks for the patch! tried it, too and works! unfortunately the OTel spans are missing the input / output data. |
|
@nimarb that is a seperate issue and will be follow-up PRs, feel free to raise an issue and mention this PR and we can go from there. For the interest of the openclaw team small mergable PRs will help move things along faster. |
|
@nimarb @vincentkoc - Hey, folks! I'm setting up an observability ecosystem for OpenClaw and have been tracking this issue for a while; I'm very interested in getting this working. Just wanted to let you know that I'm open to and interested in working in the follow up tasks for the OpenTelemetry instrumentation. |
|
Hi @vincentkoc, congrats on getting this merged! Thanks for the hard work on this issue. I’m currently trying to verify this on my end, but I’m running into an issue. After enabling the diagnostics-otel plugin and configuring the reporting endpoint, I’m not seeing any traces or metrics arriving at my server. Could I be missing something in the setup, or is there a specific configuration format required Here is the configuration I'm using: Is there any additional logging I can enable to debug why the export might be failing silently? Thanks a lot! |
@feng-95 you can start gateway in debug mode and see the diagnostics for OTEL, secondly disable metrics and logs and just use traces first and see, thirdly it could be networking/endpoint related issue. |
It seems that the diagnostics-otel plugin currently uses And I just wonder would it be possible to add support for Protocol Buffers or make the encoding format configurable in a future update? |

Summary
This PR completes the OpenTelemetry v2 compatibility fix for the
diagnostics-otelextension with a tightly scoped patch. It addresses the runtime API breaks without pulling in unrelated changes from other subsystems.This is part of a broader set of improvements I'm personally working on uplifting telemetry in OpenClaw (work started in an earlier umbrella PR #9761) to bring Opik and first-class native AI observability into OpenClaw which includes OTel and hook upgrades.
This has been tested by me on a live instance, output of an OTel trace showing its working

Motivation
The current OTel plugin can fail during startup on current OTel package versions (#3201). lobster-biscuit
Changes
extensions/diagnostics-oteland excludes unrelated cross-module edits.Resourceusage withresourceFromAttributesandATTR_SERVICE_NAMEfor v2-compatible resource initialization.LoggerProvider.addLogRecordProcessor(...)with constructorprocessorswiring required by current@opentelemetry/sdk-logs.diagnostics-otelunit-test mocks to match the current OTel APIs (resourceFromAttributes,ATTR_SERVICE_NAME, constructor processors).diagnostics-otelbreakages are covered: https://github.com/open-telemetry/opentelemetry-js/blob/main/doc/upgrade-to-2.x.mdRelated and Resolves
Greptile Overview
Greptile Summary
Completes OpenTelemetry v2 API migration for the
diagnostics-otelextension, addressing runtime compatibility issues with current OTel packages. Key changes include:SemanticResourceAttributeswithATTR_SERVICE_NAMEandResourcewithresourceFromAttributesfor v2-compatible resource initializationLoggerProviderinstantiation to use constructor-basedprocessorswiring instead of deprecatedaddLogRecordProcessor()methodglobalThisto ensure consistent state across module instancesThe changes are tightly scoped to the diagnostics-otel extension and diagnostic event infrastructure, following the official OpenTelemetry JS v2 migration guide.
Confidence Score: 4/5
sdk.start()(line 135) has been addressed with try-catch and await, which is good. The recursion guard implementation is solid with a depth limit of 100. The global state pattern for diagnostic events correctly addresses multi-instance scenarios. All v2 API changes align with OpenTelemetry documentation.