Skip to content

Add API spec for logger client integration into cdp-client#25

Open
stefanrammo wants to merge 1 commit intomainfrom
spec/logger-integration
Open

Add API spec for logger client integration into cdp-client#25
stefanrammo wants to merge 1 commit intomainfrom
spec/logger-integration

Conversation

@stefanrammo
Copy link
Copy Markdown
Collaborator

Specifies two changes to integrate the CDP Logger Client into the main JavaScript CDP Client package:

  1. Bundle logger client as studio.logger — move the cdplogger-client code into the cdp-client package so users only need one require()

  2. Add client.logger(path) method — auto-discovers the logger's WebSocket endpoint by reading ServerPort and ServerIP from the node's children, then creates and caches a logger client connection

Uses ServerPort tree navigation for discovery (works with all CDP versions). Service-based discovery and proxy transport via ServicesNotification are documented as future work for CDP 5.1+.

Includes 5 use case examples, failure/timeout semantics, caching and lifecycle behavior, and migration notes.

Specifies two changes to integrate the CDP Logger Client into the
main JavaScript CDP Client package:

1. Bundle logger client as studio.logger — move the cdplogger-client
   code into the cdp-client package so users only need one require()

2. Add client.logger(path) method — auto-discovers the logger's
   WebSocket endpoint by reading ServerPort and ServerIP from the
   node's children, then creates and caches a logger client connection

Uses ServerPort tree navigation for discovery (works with all CDP
versions). Service-based discovery and proxy transport via
ServicesNotification are documented as future work for CDP 5.1+.

Includes 5 use case examples, failure/timeout semantics, caching
and lifecycle behavior, and migration notes.
@Karmo7
Copy link
Copy Markdown

Karmo7 commented Apr 1, 2026

"Uses ServerPort tree navigation for discovery (works with all CDP versions). Service-based discovery and proxy transport via ServicesNotification are documented as future work for CDP 5.1+."

The reason CDP Studio moved to service-based discovery is that this tree scanning to find loggers and the ServerPort property caused performance issues for larger projects. Also, this here is a new feature, so I think it is fine if it only works with CDP 5.1+. People can use the existing logger client for old versions if needed.

All in all, in my opinion cdp-client logger support should only use service-based discovery without any tree scanning.

});
```

This requires knowing the `ServerPort` child convention, extracting the hostname, and managing two independent client lifecycles. The logger client (`cdplogger-client`) is a separate npm package with its own protobuf schema and WebSocket connection, making the setup even more cumbersome.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Also, one must know "App.CDPLogger" is the path and this must be updated when CDP project is restructured.


Instead of opening a direct WebSocket to the logger port, the logger connection could tunnel through the existing StudioAPI WebSocket — the same way sibling app connections work via `connectViaProxy()`. This avoids firewall and port-opening issues when the logger port is not directly reachable from the client.

Service-based discovery and proxy transport are the preferred approach for CDP 5.1+ and should be added in a follow-up. The `ServerPort` approach is implemented first for backward compatibility with all CDP versions.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would enable proxy transport by default because browser security settings often reject connections to other ports, especially when using https. And I think supporting only CDP 5.1 is fine

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

And if it makes implementation easier, I don't think we need to support direct connection. The proxy performance is quite good.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

And one more reason the direct connection is not so useful - the logger server api does not support authentication, so it is recommended to block that port with firewall. This proxy thing allows to serve logged data behind studioapi authentication.

@Karmo7
Copy link
Copy Markdown

Karmo7 commented Apr 1, 2026

"Uses ServerPort tree navigation for discovery (works with all CDP versions). Service-based discovery and proxy transport via ServicesNotification are documented as future work for CDP 5.1+."

The reason CDP Studio moved to service-based discovery is that this tree scanning to find loggers and the ServerPort property caused performance issues for larger projects. Also, this here is a new feature, so I think it is fine if it only works with CDP 5.1+. People can use the existing logger client for old versions if needed.

All in all, in my opinion cdp-client logger support should only use service-based discovery without any tree scanning.

Ok, I now read the rest of the spec and there is no tree scanning. User must hard-code the path, e.g. "App.CDPLogger". Still, I don't think this is useful enough at the moment. If one hard-codes the path to logger, they might as well hard-code the ServerPort. Better to not think about older CDP versions and directly move to implementing service-based discovery.

@Karmo7
Copy link
Copy Markdown

Karmo7 commented Apr 1, 2026

Something to consider for the future (I think not needed for the first step) is to make it easier to ask historic data for a real-time value. Kind of like CDP Studio Analyze mode auto-discovers if added node has historic data available and lists the history sources when right-clicking on the legend.


```javascript
const loggers = await client.loggers(); // returns all discovered logger services
const logger = loggers[0]; // or find by name/metadata
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

"or find by name/metadata" - yes, as the metadata includes the logger path in the metadata name field, should allow to refer to logger using that as well .

@Karmo7
Copy link
Copy Markdown

Karmo7 commented Apr 1, 2026

Spec reviews should also have 2 reviewers

@stefanrammo stefanrammo requested a review from nuubik April 1, 2026 13:27
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