Skip to content

Commit

Permalink
CF Metrics, Tests, and Fixes (#33)
Browse files Browse the repository at this point in the history
* direct port of cf server PoC from tx5 repo

* make test

* update deps

* integrate with server-o-bahn suite

* fix windows ts runner

* ci fix

* try through node itself

* do we need to resume?

* only run cf test on linux

* protocol update

* ensure message ordering through batching

* concurrency fixes

* rate limiting

* cleanup

* fmt

* cleanup and comments

* test2 different behavior

* Update ts/sbd-server/server-o-bahn-runner.mjs

Co-authored-by: Jost Schulte <jost.schulte@protonmail.com>

* Update ts/sbd-server/src/index.ts

Co-authored-by: Jost Schulte <jost.schulte@protonmail.com>

* bad sig test

* test 4 & 5

* msg-too-big

* order stress

* tweaks

* address code review comments

* cloudflare metrics

* new test style

* checkpoint

* add dead state tracking to signal DO

* cleanup

* docs

* Update ts/sbd-server/src/prom.ts

* update

* npm --verbose ci

* npm install

* older node

---------

Co-authored-by: Jost Schulte <jost.schulte@protonmail.com>
  • Loading branch information
neonphog and jost-s authored Jul 18, 2024
1 parent 72db08f commit 4de593c
Show file tree
Hide file tree
Showing 23 changed files with 1,639 additions and 1,131 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: NodeJS Setup
uses: actions/setup-node@v4
with:
node-version: latest
node-version: '20.x'
cache: 'npm'
cache-dependency-path: ts/sbd-server/package-lock.json

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: NodeJS Setup
uses: actions/setup-node@v4
with:
node-version: latest
node-version: '20.x'
cache: 'npm'
cache-dependency-path: ts/sbd-server/package-lock.json

Expand Down
45 changes: 45 additions & 0 deletions ts/sbd-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Cloudflare SbdServer

## Metrics

It's hard to get a sense of what is going on with distributed durable objects. To mitigate this, we are writing metrics to a KV called `SBD_COORDINATION`. These metrics can be enumerated from a central metrics http endpoint. However, as these metrics list IP addresses, and cause billable load on our worker kv endpoint, they will be guarded by an api key.

### Set Api Key

Set these api keys via worker secrets in the form: `METRIC_API_$(whoami)="$(uuidgen)"`.

E.g. `METRIC_API_NEONPHOG=d6d38e16-9fe2-4cbf-b66d-e49775064d59`

If doing this through the cloudflare dashboard, don't forget to click `encrypt`!

Or you can use `wrangler secret put METRIC_API_NEONPHOG` and then paste in the uuidgen result.

### Access the Metrics Endpoint

`$(url)/metris/$(whoami)/$(uuidgen)`

E.g. `https://sbd.holo.host/metrics/NEONPHOG/d6d38e16-9fe2-4cbf-b66d-e49775064d59`

Should give you something like:

```
# HELP client.count active client count
# TYPE client.count guage
client.count 4
# HELP client.recv.byte.count bytes received from client
# TYPE client.recv.byte.count guage
client.recv.byte.count{name="AqpAUD6QBb8lOfSBGna4C3tGAbI7E5slQ0MKkjm28kQ",opened=1720728911,active=1720728911,ip="no-ip"} 96
# HELP client.recv.byte.count bytes received from client
# TYPE client.recv.byte.count guage
client.recv.byte.count{name="R2qUfRVFfBhGGyxC4i_MorG48Ptk3JXwWvkIsh9mtRo",opened=1720728935,active=1720728935,ip="no-ip"} 96
# HELP client.recv.byte.count bytes received from client
# TYPE client.recv.byte.count guage
client.recv.byte.count{name="ia6EqgbobPhVrOdqlqZtL7v8EK5uDj5vlV4uTMB6vsY",opened=1720728936,active=1720728936,ip="no-ip"} 96
# HELP client.recv.byte.count bytes received from client
# TYPE client.recv.byte.count guage
client.recv.byte.count{name="u-JEHfSU6hArnHSjf9KA5W_ABH37go3Cm453UagScI8",opened=1720728911,active=1720728911,ip="no-ip"} 96
```
Loading

0 comments on commit 4de593c

Please sign in to comment.