Skip to content

Conversation

@xBlaz3kx
Copy link
Contributor

@xBlaz3kx xBlaz3kx commented Feb 2, 2025

Proposed changes

Based on my feature request in #334, I added support for OCPP-J and Websocket server metrics.

Caution

Watch out for a breaking change: Go version updated to 1.22, because the OTel SDKs require at least 1.22.

  • Metrics support via OpenTelemetry SDK
  • Added OCPPJ server metrics
    • Dispatcher metrics (inflight and per client queue sizes)
    • Inbound/outbound requests
    • (WIP) ping-pong duration per client
  • Added websocket metrics
    • Connected clients
    • Message rate (per client)
  • Updated examples, so observabilty/metrics can be configured via env variables
  • Updated docker-compose files for both TLS and non-tls examples so observability can be configured
  • Added makefile commands so deploying examples is easier

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of
them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before
merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Further comments

List of things that should be noted/addressed in the future:

  1. In the example, OpenTelemetry SDK exports metrics via insecure GRPC only
  2. Havent added websocket request rate metric, which could be useful
  3. Potential Tracing integration? Out of scope for now
  4. ~~Currently, OCPPJ and websocket error metrics are not handled properly, as this is a proof of concept. ~~
  5. Documentation update

@xBlaz3kx xBlaz3kx changed the title Feature: OCPP-J and Websocket server observability Feature: OCPP-J and Websocket server metrics Feb 2, 2025
@xBlaz3kx xBlaz3kx force-pushed the feature/observability branch from 7a1d09a to a624578 Compare February 2, 2025 17:18
@xBlaz3kx
Copy link
Contributor Author

xBlaz3kx commented Feb 2, 2025

I'll need some help with this PR to capture metrics at points where it makes most sense and since Im not that familiar with the flows right now, Im open to suggestions.

Copy link
Owner

@lorenzodonini lorenzodonini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the great work. I think this is a very good start, we can fine-tune more metrics down the road and/or accept requests.

I recommend waiting to improve on this until #347 is merged, since it includes some structural changes in the websocket package. Sorry about that but it's been long due.

@xBlaz3kx
Copy link
Contributor Author

Thanks a lot for the great work. I think this is a very good start, we can fine-tune more metrics down the road and/or accept requests.

I recommend waiting to improve on this until #347 is merged, since it includes some structural changes in the websocket package. Sorry about that but it's been long due.

Hey,

no problem!

I'll wait for the PR to be merged, meanwhile I will address all the comments and add the missing error handling.

What do you think about adding tracing?

@lorenzodonini
Copy link
Owner

I'll wait for the PR to be merged, meanwhile I will address all the comments and add the missing error handling.

It's merged now, feel free to rebase. Sorry about the conflicts.

What do you think about adding tracing?

Both metric and tracing have on my TODO list for a while, so thanks for getting this started. If you wish to add tracing as well, I'd love it, but would recommend a separate PR for that.

@xBlaz3kx xBlaz3kx force-pushed the feature/observability branch from 87af54b to 5723667 Compare March 1, 2025 21:19
@xBlaz3kx xBlaz3kx requested a review from lorenzodonini March 1, 2025 21:32
@xBlaz3kx xBlaz3kx force-pushed the feature/observability branch from 901d39a to fa622e0 Compare April 7, 2025 20:05
@xBlaz3kx
Copy link
Contributor Author

Since a lot of people have issues with the callback queue/reconnection, we should also probably add additional metrics for dispatcher and message queues.

@xBlaz3kx xBlaz3kx force-pushed the feature/observability branch from fa622e0 to 44085f8 Compare June 18, 2025 20:38
@xBlaz3kx
Copy link
Contributor Author

@lorenzodonini mind rereviewing? I think the PR is good enough for an initial version/PoC, definitely need to add more server metrics.

@xBlaz3kx xBlaz3kx changed the title Feature: OCPP-J and Websocket server metrics Feature: OCPP server observability Aug 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants