Skip to content

Commit 3d0d13d

Browse files
authored
repo sync
2 parents 96e4736 + 02f2883 commit 3d0d13d

File tree

6 files changed

+46
-6
lines changed

6 files changed

+46
-6
lines changed

layouts/product-landing.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ <h3 class="f4 text-normal text-mono text-uppercase color-gray-5">{% data ui.toc.
3535
<ul class="list-style-none">
3636
{% for link in featuredLinks.guides %}
3737
<li class="border-top">
38-
<a class="link-with-intro Bump-link--hover no-underline d-block py-4" href="{{ link.href }}">
39-
<h4 class="link-with-intro-title link-gray-dark mb-1">{{ link.title }}<span class="Bump-link-symbol"></span></h4>
38+
<a class="link-with-intro Bump-link--hover no-underline d-block py-3" href="{{ link.href }}">
39+
<h4 class="link-with-intro-title mb-1">{{ link.title }}<span class="Bump-link-symbol"></span></h4>
4040
<p class="link-with-intro-intro color-gray-5 mb-0">{{ link.intro | truncatewords: 12 }}</p>
4141
</a>
4242
</li>
@@ -52,7 +52,7 @@ <h3 class="f4 text-normal text-mono text-uppercase color-gray-5">{% data ui.toc.
5252
{% for link in featuredLinks.popular %}
5353
<li class="border-top">
5454
<a class="link-with-intro Bump-link--hover no-underline d-block py-3" href="{{ link.href }}">
55-
<h4 class="link-with-intro-title link-gray-dark">{{ link.title }}<span class="Bump-link-symbol"></span></h4>
55+
<h4 class="link-with-intro-title">{{ link.title }}<span class="Bump-link-symbol"></span></h4>
5656
</a>
5757
</li>
5858
{% endfor %}
@@ -68,11 +68,11 @@ <h3 class="f4 text-normal text-mono text-uppercase color-gray-5">{% data ui.toc.
6868
{% for link in page.changelog %}
6969
<li class="border-top">
7070
<a href="{{ link.href }}" class="d-block text-gray-dark Bump-link--hover py-3 no-underline">
71+
<h4>{{ link.title }} <span class="Bump-link-symbol"></span></h4>
7172
<time
72-
class="tooltipped tooltipped-n text-gray-light text-mono mb-1"
73+
class="tooltipped tooltipped-n text-gray-light text-mono mt-1"
7374
aria-label="{{ link.date | date: '%B %d, %Y' }}"
7475
>{{ link.date | date: "%B %d" }}</time>
75-
<h4>{{ link.title }} <span class="Bump-link-symbol"></span></h4>
7676
</a>
7777
</li>
7878
{% endfor %}

lib/page.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const renderContent = require('./render-content')
1919
const frontmatter = require('./frontmatter')
2020
const products = require('./all-products')
2121
const slash = require('slash')
22+
const statsd = require('./statsd')
2223

2324
class Page {
2425
constructor (opts) {
@@ -84,6 +85,10 @@ class Page {
8485
: true
8586
}
8687

88+
// Instrument the `_render` method, so externally we call #render
89+
// but it's wrapped in a timer that reports to Datadog
90+
this.render = statsd.asyncTimer(this._render.bind(this), 'page.render')
91+
8792
return this
8893
}
8994

@@ -116,7 +121,7 @@ class Page {
116121
: this.renderProp('title', context, opts)
117122
}
118123

119-
async render (context) {
124+
async _render (context) {
120125
this.intro = await renderContent(this.rawIntro, context)
121126
this.introPlainText = await renderContent(this.rawIntro, context, { textOnly: true })
122127
this.title = await renderContent(this.rawTitle, context, { textOnly: true, encodeEntities: true })

lib/statsd.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const StatsD = require('hot-shots')
2+
3+
const mock = Boolean(process.env.NODE_ENV === 'test' || !process.env.DATADOG_API_KEY)
4+
5+
/**
6+
* @type {import('hot-shots').StatsD}
7+
*/
8+
module.exports = new StatsD({
9+
prefix: 'docs.',
10+
mock,
11+
globalTags: {
12+
app: 'docs'
13+
}
14+
})

middleware/render-page.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const patterns = require('../lib/patterns')
55
const layouts = require('../lib/layouts')
66
const getMiniTocItems = require('../lib/get-mini-toc-items')
77
const Page = require('../lib/page')
8+
const statsd = require('../lib/statsd')
89

910
// We've got lots of memory, let's use it
1011
// We can eventually throw this into redis
@@ -18,6 +19,7 @@ module.exports = async function renderPage (req, res, next) {
1819
if (!process.env.CI && process.env.NODE_ENV !== 'test') {
1920
if (req.method === 'GET' && pageCache[originalUrl]) {
2021
console.log(`Serving from cached version of ${originalUrl}`)
22+
statsd.increment('page.sent_from_cache')
2123
return res.send(pageCache[originalUrl])
2224
}
2325
}

package-lock.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"got": "^9.6.0",
4343
"gray-matter": "^4.0.1",
4444
"helmet": "^3.21.2",
45+
"hot-shots": "^8.2.0",
4546
"html-entities": "^1.2.1",
4647
"html-truncate": "^1.2.2",
4748
"imurmurhash": "^0.1.4",

0 commit comments

Comments
 (0)