Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/codespace-review-up.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ on:
# - auto_merge_enabled
- auto_merge_disabled
# - enqueued
- dequeued
# - dequeued -- When merge queue completes, it triggers this event
workflow_dispatch:

permissions:
Expand All @@ -51,7 +51,6 @@ jobs:
echo "github.event_name: ${{ github.event_name }}"
echo "github.event.action: ${{ github.event.action }}"
echo "github.actor: ${{ github.actor }}"
echo "github.event.pull_request.auto_merge: ${{ github.event.pull_request.auto_merge }}"
echo "github.triggering_actor: ${{ github.triggering_actor }}"

- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down
2 changes: 2 additions & 0 deletions data/reusables/dependabot/dependabot-alerts-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ You can sort and filter {% data variables.product.prodname_dependabot_alerts %}

| Option | Description | Example |
|:---|:---|:---|
| `CVE-ID`| Displays alerts associated with this `CVE-ID` | `CVE-2020-28482` will show any alerts whose underlying advisory has this CVE ID number. |
| `ecosystem` | Displays alerts for the selected ecosystem | Use `ecosystem:npm` to show {% data variables.product.prodname_dependabot_alerts %} for npm |
| `GHSA-ID`| Displays alerts associated with this `GHSA-ID` | `GHSA-49wp-qq6x-g2rf` will show any alerts whose underlying advisory has this {% data variables.product.prodname_advisory_database %} ID. |
| `has` | Displays alerts meeting the selected filter criteria | Use `has:patch` to show alerts related to advisories that have a patch |
| `is` | Displays alerts based on their state | Use `is:open` to show open alerts |
| `manifest` | Displays alerts for the selected manifest | Use `manifest:webwolf/pom.xml` to show alerts on the pom.xml file of the webwolf application |
Expand Down
26 changes: 26 additions & 0 deletions src/article-api/middleware/article.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import catchMiddlewareError from '@/observability/middleware/catch-middleware-er
import { ExtendedRequestWithPageInfo } from '../types'
import { pageValidationMiddleware, pathValidationMiddleware } from './validation'
import contextualize from '#src/frame/middleware/context/context.js'
import statsd from '#src/observability/lib/statsd.js'

/** START helper functions */

Expand Down Expand Up @@ -59,6 +60,23 @@ async function getArticleBody(req: ExtendedRequestWithPageInfo) {
return await page.render(renderingReq.context)
}

function incrementArticleLookup(
pathname: string,
language: string,
type: 'full' | 'body' | 'meta',
) {
const tags = [
// According to https://docs.datadoghq.com/getting_started/tagging/#define-tags
// the max length of a tag is 200 characters. Most of ours are less than
// that but we truncate just to be safe.
`pathname:${pathname}`.slice(0, 200),
`language:${language}`,
`type:${type}`,
]

statsd.increment('api.article.lookup', 1, tags)
}

/** END helper functions */

/** START routes */
Expand All @@ -82,6 +100,8 @@ router.get(
return res.status(403).json({ error: (error as Error).message })
}

incrementArticleLookup(req.pageinfo.pathname, req.pageinfo.page.languageCode, 'full')

defaultCacheControl(res)
return res.json({
meta: metaData,
Expand All @@ -101,6 +121,9 @@ router.get(
} catch (error) {
return res.status(403).json({ error: (error as Error).message })
}

incrementArticleLookup(req.pageinfo.pathname, req.pageinfo.page.languageCode, 'body')

defaultCacheControl(res)
return res.type('text/markdown').send(bodyContent)
}),
Expand All @@ -112,6 +135,9 @@ router.get(
pageValidationMiddleware as RequestHandler,
catchMiddlewareError(async function (req: ExtendedRequestWithPageInfo, res: Response) {
const metaData = await getArticleMetadata(req)

incrementArticleLookup(req.pageinfo.pathname, req.pageinfo.page.languageCode, 'meta')

defaultCacheControl(res)
return res.json(metaData)
}),
Expand Down
8 changes: 8 additions & 0 deletions src/article-api/middleware/pagelist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getProductStringFromPath, getVersionStringFromPath } from '#src/frame/l
import { getLanguageCodeFromPath } from '#src/languages/middleware/detect-language.js'
import { pagelistValidationMiddleware } from './validation'
import catchMiddlewareError from '#src/observability/middleware/catch-middleware-error.js'
import statsd from '#src/observability/lib/statsd.js'

const router = express.Router()

Expand Down Expand Up @@ -78,6 +79,7 @@ router.get(
return
}

incrementPagelistLookup(req.context!.currentVersion!, req.context!.currentLanguage!)
defaultCacheControl(res)

// new line added at the end so `wc` works as expected with `-l` and `-w`.
Expand All @@ -101,4 +103,10 @@ function versionMatcher(key: string, targetVersion: string, targetLang: string)
if (versionFromPermalink === targetVersion && langFromPermalink === targetLang) return key
}

function incrementPagelistLookup(version: string, language: string) {
const tags = [`version:${version}`, `language:${language}`]

statsd.increment('api.pagelist.lookup', 1, tags)
}

export default router