Skip to content

Commit

Permalink
Revert "Try adding express's ip address"
Browse files Browse the repository at this point in the history
This reverts commit 0568556.
  • Loading branch information
IanPhilips committed Oct 23, 2024
1 parent d3af9f4 commit 7936a46
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions backend/api/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,20 +215,12 @@ const ignoredEndpoints = [
'/get-channel-seen-time',
]

const getCleanIp = (ip: string) => {
return ip.startsWith('::ffff:') ? ip.substring(7) : ip
}

const requestMonitoring: RequestHandler = (req, res, next) => {
const traceContext = req.get('X-Cloud-Trace-Context')
const traceId = traceContext ? traceContext.split('/')[0] : randomString(12)
const { method, path: endpoint, url } = req
const baseEndpoint = getBaseName(endpoint)

// Get clean IP address
const ip = getCleanIp(req.ip)

const context = { endpoint, traceId, baseEndpoint, ip }
const context = { endpoint, traceId, baseEndpoint }
withMonitoringContext(context, () => {
if (method == 'OPTIONS') {
next()
Expand All @@ -242,7 +234,7 @@ const requestMonitoring: RequestHandler = (req, res, next) => {
) {
log(`${method} ${url}`)
}
metrics.inc('http/request_count', { endpoint, baseEndpoint, method, ip })
metrics.inc('http/request_count', { endpoint, baseEndpoint, method })
res.on('close', () => {
const endTs = hrtime.bigint()
const latencyMs = Number(endTs - startTs) / 1e6 // Convert to milliseconds
Expand Down

0 comments on commit 7936a46

Please sign in to comment.