Skip to content

RFC 306: Instrument GraphQL costs

Created by: ryanslade

Before introducing GraphQL rate limiting we need to instrument current costs so that we have an idea of what level to set our limits at.

We need to copy our rate limit cost function from here as we don't want to alter the existing one that is specific to GitHub: https://github.com/sourcegraph/sourcegraph/blob/bdc08921f7cd178eb3648b31b30e10d7b56184b8/internal/extsvc/github/v4.go#L169

Per GraphQL request we should estimate the cost and instrument it with the following labels:

  1. Whether the query is authenticated or not (anonymous=true/false)
  2. The query / mutation name, eg. LogEvent or unknown. We currently track this based on https://github.com/sourcegraph/sourcegraph/blob/main/internal/trace/httptrace.go#L68

We'll use a histogram and bucket values can be decided once we've done https://github.com/sourcegraph/sourcegraph/issues/18099