Skip to content

Commit aee8c81

Browse files
authored
Merge pull request #521 from vtex/chore/clean-metrics-backport
Chore backport socket metrics cleanup
2 parents 848a2dc + ae2cfb4 commit aee8c81

3 files changed

Lines changed: 15 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10+
## [3.77.8] - 2022-12-15
11+
### Changed
12+
- Remove socket metrics per origin
13+
1014
## [3.77.7] - 2022-04-14
1115

1216
### Fixed
@@ -1013,3 +1017,7 @@ instead
10131017
## [0.48.0] - 2018-09-21
10141018
### Changed
10151019
- `HttpClient` now adds `'Accept-Encoding': 'gzip'` header by default.
1020+
1021+
1022+
[Unreleased]: https://github.com/vtex/node-vtex-api/compare/v3.77.8...HEAD
1023+
[3.77.8]: https://github.com/vtex/node-vtex-api/compare/v3.77.7...v3.77.8

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vtex/api",
3-
"version": "3.77.7",
3+
"version": "3.77.8",
44
"description": "VTEX I/O API client",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",

src/HttpClient/middlewares/request.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,28 +92,22 @@ export const requestMiddleware = (limit?: Limit) => async (ctx: MiddlewareContex
9292
ctx.response = await (limit ? limit(makeRequest) : makeRequest())
9393
}
9494

95-
function countPerOrigin (obj: { [key: string]: any[] }) {
95+
function count (obj: { [key: string]: any[] }) {
9696
try {
97-
return mapObjIndexed(val => val.length, obj)
97+
return Object.values(obj).reduce((acc, val) => acc += val.length, 0)
9898
} catch (_) {
99-
return {}
99+
return 0
100100
}
101101
}
102102

103103
export function httpAgentStats () {
104-
const socketsPerOrigin = countPerOrigin(httpAgent.sockets)
105-
const sockets = sum(values(socketsPerOrigin))
106-
const freeSocketsPerOrigin = countPerOrigin((httpAgent as any).freeSockets)
107-
const freeSockets = sum(values(freeSocketsPerOrigin))
108-
const pendingRequestsPerOrigin = countPerOrigin(httpAgent.requests)
109-
const pendingRequests = sum(values(pendingRequestsPerOrigin))
104+
const sockets = count(httpAgent.sockets)
105+
const freeSockets = count((httpAgent as any).freeSockets)
106+
const pendingRequests = count(httpAgent.requests)
110107

111108
return {
112109
freeSockets,
113-
freeSocketsPerOrigin,
114110
pendingRequests,
115-
pendingRequestsPerOrigin,
116111
sockets,
117-
socketsPerOrigin,
118112
}
119113
}

0 commit comments

Comments
 (0)