Skip to content

Commit 75a85da

Browse files
author
Peter Bengtsson
authored
insight into which page has what page.render statsd timer (#23747)
1 parent bc16b52 commit 75a85da

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

lib/page.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import renderContent from './render-content/index.js'
1313
import processLearningTracks from './process-learning-tracks.js'
1414
import { productMap } from './all-products.js'
1515
import slash from 'slash'
16-
import statsd from './statsd.js'
1716
import readFileContents from './read-file-contents.js'
1817
import getLinkData from './get-link-data.js'
1918
import getDocumentType from './get-document-type.js'
@@ -114,9 +113,7 @@ class Page {
114113
this.showMiniToc = this.showMiniToc === false ? this.showMiniToc : true
115114
}
116115

117-
// Instrument the `_render` method, so externally we call #render
118-
// but it's wrapped in a timer that reports to Datadog
119-
this.render = statsd.asyncTimer(this._render.bind(this), 'page.render')
116+
this.render = this._render.bind(this)
120117

121118
return this
122119
}

middleware/render-page.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { get } from 'lodash-es'
22
import patterns from '../lib/patterns.js'
33
import getMiniTocItems from '../lib/get-mini-toc-items.js'
44
import Page from '../lib/page.js'
5+
import statsd from '../lib/statsd.js'
56
import { isConnectionDropped } from './halt-on-dropped-connection.js'
67
import { nextApp, nextHandleRequest } from './next.js'
78

@@ -47,7 +48,10 @@ export default async function renderPage(req, res, next) {
4748
if (isConnectionDropped(req, res)) return
4849

4950
// render page
50-
context.renderedPage = await page.render(context)
51+
const pageRenderTimed = statsd.asyncTimer(page.render, 'middleware.render_page', [
52+
`path:${req.pagePath || req.path}`,
53+
])
54+
context.renderedPage = await pageRenderTimed(context)
5155

5256
// Stop processing if the connection was already dropped
5357
if (isConnectionDropped(req, res)) return

0 commit comments

Comments
 (0)