Logging unknown operations for persisted queries should include the "operationName" field, or emit some metrics

Forgive me if this is the wrong place for this. Happy to make this a GH issue/feature request if that’s better.

I’d like to start rolling out persisted queries on my supergraph, with an eye towards safe-listing them in the future.

I see that the operation body is emitted in the structured log from router, but for the purposes of building a useful dashboard in Grafana I’d like to either include the operation name as a field, or emit a metric for unknown operations that includes the operation name. That way we can see at a glance which operations still need to be published without looking at the entire operation body, which can be quite large.

Thoughts?

1 Like

Hey @jmccall For any net new feature requests, if you want them shared publicly you can create a GitHub issue but then if you have a GraphOS account you can also use that same issue to file a feature request with our support team here: https://support.apollographql.com/

That being said you could have some variation of this today with a few features…

You can include the operation name in traces with custom events

telemetry:
  instrumentation:
    instruments:
      default_requirement_level: recommended

    spans:
      mode: spec_compliant
      router:
        attributes:
          "my-custom-attribute":
            operation_name: hash # or string is option

    events:
      router:
        "my.custom.event":
          on: request
          level: info
          message: "No operation name"
          condition:
            not:
              exists:
                operation_name: string

Using Rhai scripts or Coprocessor you could look at the operation name your self request.body.operation_name and if it is not set, then do more advanced things

1 Like

That seems like it could work, but I don’t see any reference to persisted operations.

By my read your example would emit an event when operation name is missing.

I’m more concerned with the “audit” mode of safe-listed persisted queries, as documented here:

Right now it looks like my only option is to scrape logs.

Ah yes, I would enable the audit mode and scrape logs but adding this info into the context so you could trigger customizations could be a feature request if you would like to file that

https://support.apollographql.com/

Done, I’ve raised the issue here and in our support portal.