Skip to content

Commit

Permalink
log request domains in quota aggregation (#15)
Browse files Browse the repository at this point in the history
* report domain on quota reporting

* add changeset

* update uhttp-lib
  • Loading branch information
esterlus authored Aug 14, 2024
1 parent 4fa238b commit 64a9362
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-houses-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'uhttp-exit-app': patch
---

Log domain no quota reporting
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"typescript": "^5.4.5"
},
"dependencies": {
"@hoprnet/uhttp-lib": "^3.0.2",
"@hoprnet/uhttp-lib": "^3.3.0",
"debug": "^4.3.4",
"sqlite3": "^5.1.7",
"ws": "^8.18.0"
Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,12 +545,16 @@ async function reportToDiscoveryPlatform({
}) {
const lastReqSeg = cacheEntry.segments.get(cacheEntry.count - 1) as Segment.Segment;
const rpcMethod = determineRPCmethod(reqPayload.body);
const url = new URL(reqPayload.endpoint);
const domain = url.hostname;

const quotaRequest: DpApi.QuotaParams = {
clientId: reqPayload.clientId,
rpcMethod,
segmentCount: cacheEntry.count,
lastSegmentLength: lastReqSeg.body.length,
chainId: reqPayload.chainId,
domain,
type: 'request',
};

Expand All @@ -561,6 +565,7 @@ async function reportToDiscoveryPlatform({
segmentCount: segments.length,
lastSegmentLength: lastRespSeg.body.length,
chainId: reqPayload.chainId,
domain,
type: 'response',
};

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,10 @@
"@noble/curves" "^1.3.0"
"@noble/hashes" "^1.3.3"

"@hoprnet/uhttp-lib@^3.0.2":
version "3.0.2"
resolved "https://registry.yarnpkg.com/@hoprnet/uhttp-lib/-/uhttp-lib-3.0.2.tgz#5ad0f5fd0771cb1b1ff895d23fe3c5678c5a1b43"
integrity sha512-J2LDSH0Fu7DlH/e3Iv1NKW9JTb7Y7xXD1LxkuHI9hyDm3cePSG3g1f6DR1p+rJLldRFgVqnuJENOaz/kRPmx6g==
"@hoprnet/uhttp-lib@^3.3.0":
version "3.3.0"
resolved "https://registry.yarnpkg.com/@hoprnet/uhttp-lib/-/uhttp-lib-3.3.0.tgz#11ab38f3da1bd6dca6ecc93e19e582fc827ab313"
integrity sha512-oFw+eCSO2uyaCmp48JazzyilPSZ8Z2SW7JAoq40YpKbiilG7rqWW+sdVWHegjqdN2RNJJnNFonXT+7UWdE0mSw==
dependencies:
"@hoprnet/uhttp-crypto" "^1.0.1"
debug "^4.3.4"
Expand Down

0 comments on commit 64a9362

Please sign in to comment.