Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

feat/enterpriseportal: define GetCodyGatewayUsage RPC, use uint64 for rate limits#63531

Merged
bobheadxi merged 3 commits intomainfrom
rp-cody-gateway-usage-rpc
Jul 2, 2024
Merged

feat/enterpriseportal: define GetCodyGatewayUsage RPC, use uint64 for rate limits#63531
bobheadxi merged 3 commits intomainfrom
rp-cody-gateway-usage-rpc

Conversation

@bobheadxi
Copy link
Member

@bobheadxi bobheadxi commented Jun 27, 2024

Part of https://linear.app/sourcegraph/issue/CORE-201. The RPC will be backed by https://github.com/sourcegraph/sourcegraph/pull/63528

The uint64 for ratelimits is a backwards-compatible change, per proto docs:

int32, uint32, int64, uint64, and bool are all compatible – this means you can change a field from one of these types to another without breaking forwards- or backwards-compatibility.

Test plan

CI

@cla-bot cla-bot bot added the cla-signed label Jun 27, 2024
@bobheadxi bobheadxi requested review from a team and eseliger June 27, 2024 20:42
bobheadxi referenced this pull request Jun 28, 2024
…plit up internal/codygateway (#63528)

Allows us to directly reuse the Cody Gateway usage queries so that they
can be served directly from Enterprise Portal
(https://github.com/sourcegraph/sourcegraph/pull/63531). To enable this
we also need to split up the monolithic `internal/codygateway` package
so that not all roads lead back to `conf`:

- `internal/codygateway`: Client mechanisms
- `internal/codygateway/codygatewayevents`: Cody Gateway events service
+ related consts
- `internal/codygateway/codygatewayactor`: Cody Gateway actor types

Part of https://linear.app/sourcegraph/issue/CORE-201

## Test plan

n/a
@bobheadxi bobheadxi force-pushed the rp-cody-gateway-usage-rpc branch from bc3ad3c to 3dfb7af Compare June 28, 2024 21:05
Copy link
Member Author

Copy link
Member

@eseliger eseliger left a comment

Choose a reason for hiding this comment

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

kool

Copy link
Member

Choose a reason for hiding this comment

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

Should this be IDEMPOTENT or NO_SIDE_EFFECTS? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, fixed!

@bobheadxi bobheadxi force-pushed the rp-cody-gateway-usage-rpc branch from 3dfb7af to 9ef8c09 Compare July 2, 2024 16:01
@bobheadxi bobheadxi merged commit e24464b into main Jul 2, 2024
Copy link
Member Author

Merge activity

@bobheadxi bobheadxi deleted the rp-cody-gateway-usage-rpc branch July 2, 2024 16:25
bobheadxi added a commit that referenced this pull request Jul 2, 2024
Uses the refactors from #63528 and the new RPC proposed in #63531 to
implement the existing GraphQL query for getting Cody Gateway usage
stats using Enterprise Portal. Also adds some basic instrumentation on
`codygatewayevents.Service`.

Closes https://linear.app/sourcegraph/issue/CORE-201
Requires sourcegraph/managed-services#1685

## Test plan

Without setting any new vars:

```sh
$ sg run enterprise-portal
# ...
[enterprise-...l] WARN service.codygatewayevents service/codygatewayevents.go:11 CodyGatewayEvents service is not configured
```

Add to `sg.config.overwrite.yaml`:

```yaml
  enterprise-portal:
    env:
      CODY_GATEWAY_EVENTS_PROJECT_ID: telligentsourcegraph
```

The client auths by default credentials, so if you have access to the
dataset everything will "just work". Request S2 data by subscription ID
at `:6081/debug/grpcui/`:

<img width="1065" alt="Screenshot 2024-06-28 at 1 55 49 PM"
src="https://github.com/sourcegraph/sourcegraph/assets/23356519/29549807-c3e1-4a2a-a6e6-a2414687f3bc">

---------

Co-authored-by: Erik Seliger <erikseliger@me.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants