Skip to content

JSON RPC: define attributes on invalid requests #2228

@louis-cl

Description

@louis-cl

The jsonrpc conventions require the presence of rpc.method.

In some invalid request scenarios, it is impossible to determine the method trying to be invoked.
Like from the jsonrpc specification examples:

--> {"jsonrpc": "2.0", "method": "foobar, "params": "bar", "baz]
<-- {"jsonrpc": "2.0", "error": {"code": -32700, "message": "Parse error"}, "id": null}

Should there be a convention for the telemetry in this scenario?

I can imagine a few options:

  1. Don't generate metrics for this scenario
  2. Break convention and don't send rpc.method
  3. Send a special value for rpc.method like ""
  4. Make rpc.method conditionally required

I see value in counting how many jsonrpc errors with code -32700 my server returns.
I would be erring on option 3 to respect the convention.

Extra thoughts on option 3

Why "" ? the jsonspec requires a null on these errors:

If there was an error in detecting the id in the Request object (e.g. Parse error/Invalid Request), it MUST be Null.

And the semantic convention maps it to empty string

Use empty string in case of null value

It felt reasonable to follow the same results for when rpc.method can't be detected.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions