diff --git a/.github/workflows/auto-add-ready-for-doc-review.yml b/.github/workflows/auto-add-ready-for-doc-review.yml index 3d556a58d65a..14f91163d2e7 100644 --- a/.github/workflows/auto-add-ready-for-doc-review.yml +++ b/.github/workflows/auto-add-ready-for-doc-review.yml @@ -29,7 +29,7 @@ jobs: - name: Check team membership id: membership_check - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 with: github-token: ${{ secrets.DOCS_BOT_PAT_BASE }} script: | diff --git a/.github/workflows/auto-close-dependencies.yml b/.github/workflows/auto-close-dependencies.yml index 280ef8f07f79..a073fa3328fa 100644 --- a/.github/workflows/auto-close-dependencies.yml +++ b/.github/workflows/auto-close-dependencies.yml @@ -50,7 +50,7 @@ jobs: # Because we get far too much spam ;_; - name: Lock conversations - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 env: PR_NUMBER: ${{ github.event.pull_request.number }} with: diff --git a/.github/workflows/changelog-prompt.yml b/.github/workflows/changelog-prompt.yml index 5a02ff82876e..bb65d8ab79d9 100644 --- a/.github/workflows/changelog-prompt.yml +++ b/.github/workflows/changelog-prompt.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Check if PR author is in docs-content team id: check_team - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 with: github-token: ${{ secrets.DOCS_BOT_PAT_BASE }} script: | @@ -41,7 +41,7 @@ jobs: if: env.CONTINUE_WORKFLOW == 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 with: github-token: ${{ secrets.DOCS_BOT_PAT_BASE }} script: | diff --git a/.github/workflows/check-for-spammy-issues.yml b/.github/workflows/check-for-spammy-issues.yml index 24a11a3cad69..9ef657e21967 100644 --- a/.github/workflows/check-for-spammy-issues.yml +++ b/.github/workflows/check-for-spammy-issues.yml @@ -17,7 +17,7 @@ jobs: if: github.repository == 'github/docs' runs-on: ubuntu-latest steps: - - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd + - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 with: github-token: ${{ secrets.DOCS_BOT_PAT_BASE }} script: | diff --git a/.github/workflows/close-bad-repo-sync-prs.yml b/.github/workflows/close-bad-repo-sync-prs.yml index 391422e27313..507b8596f2da 100644 --- a/.github/workflows/close-bad-repo-sync-prs.yml +++ b/.github/workflows/close-bad-repo-sync-prs.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Close pull request if unwanted - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 with: github-token: ${{ secrets.DOCS_BOT_PAT_BASE }} script: | diff --git a/.github/workflows/confirm-internal-staff-work-in-docs.yml b/.github/workflows/confirm-internal-staff-work-in-docs.yml index 00dd5c555a6a..8551eadf2970 100644 --- a/.github/workflows/confirm-internal-staff-work-in-docs.yml +++ b/.github/workflows/confirm-internal-staff-work-in-docs.yml @@ -24,7 +24,7 @@ jobs: if: github.repository == 'github/docs' && github.actor != 'docs-bot' steps: - id: membership_check - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 env: TEAM_CONTENT_REPO: ${{ secrets.TEAM_CONTENT_REPO }} with: diff --git a/.github/workflows/copy-api-issue-to-internal.yml b/.github/workflows/copy-api-issue-to-internal.yml index df1bf1a31fa9..09adbdb8f066 100644 --- a/.github/workflows/copy-api-issue-to-internal.yml +++ b/.github/workflows/copy-api-issue-to-internal.yml @@ -19,7 +19,7 @@ jobs: if: github.event.label.name == 'fix-internally' && github.repository == 'github/docs' steps: - name: Check if this run was triggered by a member of the docs team - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 id: triggered-by-member with: github-token: ${{secrets.DOCS_BOT_PAT_BASE}} diff --git a/.github/workflows/create-changelog-pr.yml b/.github/workflows/create-changelog-pr.yml index 7cf90c1472b4..e211f2ed0f91 100644 --- a/.github/workflows/create-changelog-pr.yml +++ b/.github/workflows/create-changelog-pr.yml @@ -34,7 +34,7 @@ jobs: - name: Check that the user belongs to the github org id: hubber_check - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 with: github-token: ${{ secrets.DOCS_BOT_PAT_BASE }} script: | @@ -105,7 +105,7 @@ jobs: - name: Create a pull request if: env.CONTINUE_WORKFLOW == 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 id: create_pull_request with: github-token: ${{ secrets.DOCS_BOT_PAT_BASE }} @@ -124,7 +124,7 @@ jobs: - name: Add 'ready-for-doc-review' and 'skip FR board' labels to PR if: env.CONTINUE_WORKFLOW == 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 env: # Get the number of the PR that was just created: PULL_REQUEST_NUMBER: ${{ steps.create_pull_request.outputs.pull-request-number }} @@ -140,7 +140,7 @@ jobs: - name: Assign PR to commenter if: env.CONTINUE_WORKFLOW == 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 env: # Reuse the PR number captured earlier PULL_REQUEST_NUMBER: ${{ steps.create_pull_request.outputs.pull-request-number }} diff --git a/.github/workflows/feedback-prompt.yml b/.github/workflows/feedback-prompt.yml index 5cb1a6bdab99..8c3c0d1e3a8e 100644 --- a/.github/workflows/feedback-prompt.yml +++ b/.github/workflows/feedback-prompt.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Check if PR author is in docs-content team id: check_team - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 with: github-token: ${{ secrets.DOCS_BOT_PAT_BASE }} script: | @@ -41,7 +41,7 @@ jobs: if: env.NON_DOCS_HUBBER == 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 with: github-token: ${{ secrets.DOCS_BOT_PAT_BASE }} script: | diff --git a/.github/workflows/hubber-contribution-help.yml b/.github/workflows/hubber-contribution-help.yml index aa0f3b6d0164..67f711caaa53 100644 --- a/.github/workflows/hubber-contribution-help.yml +++ b/.github/workflows/hubber-contribution-help.yml @@ -26,7 +26,7 @@ jobs: uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - id: membership_check - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 with: github-token: ${{ secrets.DOCS_BOT_PAT_BASE }} script: | diff --git a/.github/workflows/index-general-search.yml b/.github/workflows/index-general-search.yml index 139c34cb6ab0..de6eefd0e1b2 100644 --- a/.github/workflows/index-general-search.yml +++ b/.github/workflows/index-general-search.yml @@ -49,7 +49,7 @@ jobs: outputs: matrix: ${{ steps.set-matrix.outputs.result }} steps: - - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 id: set-matrix with: script: | diff --git a/.github/workflows/merged-notification.yml b/.github/workflows/merged-notification.yml index 225d9a3bbe1f..c650e765ee94 100644 --- a/.github/workflows/merged-notification.yml +++ b/.github/workflows/merged-notification.yml @@ -20,7 +20,7 @@ jobs: if: github.repository == 'github/docs' && github.event.pull_request.merged && github.event.pull_request.base.ref == github.event.repository.default_branch && github.event.pull_request.user.login != 'docs-bot' runs-on: ubuntu-latest steps: - - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd + - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 with: script: | github.rest.issues.createComment({ diff --git a/.github/workflows/move-existing-issues-to-the-correct-repo.yml b/.github/workflows/move-existing-issues-to-the-correct-repo.yml index de50f7af274c..12de61fa20c1 100644 --- a/.github/workflows/move-existing-issues-to-the-correct-repo.yml +++ b/.github/workflows/move-existing-issues-to-the-correct-repo.yml @@ -16,7 +16,7 @@ jobs: if: github.repository == 'github/docs-internal' steps: - id: move_to_correct_repo - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 env: TEAM_ENGINEERING_REPO: ${{ secrets.TEAM_ENGINEERING_REPO }} TEAM_CONTENT_REPO: ${{ secrets.TEAM_CONTENT_REPO }} diff --git a/.github/workflows/move-reopened-issues-to-triage.yaml b/.github/workflows/move-reopened-issues-to-triage.yaml index e14ea8d31f8c..04b3e6e8c9c7 100644 --- a/.github/workflows/move-reopened-issues-to-triage.yaml +++ b/.github/workflows/move-reopened-issues-to-triage.yaml @@ -18,7 +18,7 @@ jobs: if: github.repository == 'github/docs' runs-on: ubuntu-latest steps: - - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd + - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 with: script: | const issueNumber = context.issue.number; diff --git a/.github/workflows/notify-when-maintainers-cannot-edit.yaml b/.github/workflows/notify-when-maintainers-cannot-edit.yaml index 8e93e6dcea11..69a2298edb6b 100644 --- a/.github/workflows/notify-when-maintainers-cannot-edit.yaml +++ b/.github/workflows/notify-when-maintainers-cannot-edit.yaml @@ -19,7 +19,7 @@ jobs: if: github.repository == 'github/docs' runs-on: ubuntu-latest steps: - - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd + - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 with: script: | const query = ` diff --git a/.github/workflows/os-ready-for-review.yml b/.github/workflows/os-ready-for-review.yml index 37c9881b9963..0d15785ecbaa 100644 --- a/.github/workflows/os-ready-for-review.yml +++ b/.github/workflows/os-ready-for-review.yml @@ -23,7 +23,7 @@ jobs: uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Check if this run was triggered by a member of the docs team - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 id: triggered-by-member with: github-token: ${{secrets.DOCS_BOT_PAT_BASE}} diff --git a/.github/workflows/repo-sync.yml b/.github/workflows/repo-sync.yml index 94e195f4d35a..4a90652f1e55 100644 --- a/.github/workflows/repo-sync.yml +++ b/.github/workflows/repo-sync.yml @@ -36,7 +36,7 @@ jobs: github_token: ${{ secrets.DOCS_BOT_PAT_REPO_SYNC }} - name: Ship pull request - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 with: github-token: ${{ secrets.DOCS_BOT_PAT_REPO_SYNC }} result-encoding: string diff --git a/.github/workflows/sme-review-tracking-issue.yml b/.github/workflows/sme-review-tracking-issue.yml index f619c060c631..c8725ca73d52 100644 --- a/.github/workflows/sme-review-tracking-issue.yml +++ b/.github/workflows/sme-review-tracking-issue.yml @@ -24,7 +24,7 @@ jobs: - id: create-issue env: URL: ${{ github.event.pull_request.html_url || github.event.issue.html_url }} - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 with: github-token: ${{ secrets.DOCS_BOT_PAT_BASE }} script: |- diff --git a/.github/workflows/triage-issue-comments.yml b/.github/workflows/triage-issue-comments.yml index f9bfc823db93..56921b3663ac 100644 --- a/.github/workflows/triage-issue-comments.yml +++ b/.github/workflows/triage-issue-comments.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Check if the event originated from a team member - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 id: is-internal-contributor with: result-encoding: string diff --git a/content/contributing/style-guide-and-content-model/reference-content-type.md b/content/contributing/style-guide-and-content-model/reference-content-type.md index e1bfb4a5cce0..2ce541c822d8 100644 --- a/content/contributing/style-guide-and-content-model/reference-content-type.md +++ b/content/contributing/style-guide-and-content-model/reference-content-type.md @@ -1,6 +1,8 @@ --- title: Reference content type intro: Reference content provides detailed information that people need while they are actively using a feature. +redirect_from: + - /contributing/style-guide-and-content-model/referential-content-type versions: fpt: '*' ghec: '*' diff --git a/package-lock.json b/package-lock.json index 9a9a2daa6861..d28cdfb9223c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -57,7 +57,7 @@ "helmet": "^8.1.0", "highlight.js": "^11.11.1", "highlightjs-curl": "^1.3.0", - "hot-shots": "^13.2.0", + "hot-shots": "^14.3.1", "html-entities": "^2.5.6", "http-proxy-middleware": "^3.0.5", "imurmurhash": "^0.1.4", @@ -114,7 +114,7 @@ }, "devDependencies": { "@actions/core": "^3.0.0", - "@actions/github": "^8.0.1", + "@actions/github": "^9.1.0", "@axe-core/playwright": "^4.11.1", "@eslint/js": "^9.39.3", "@github/markdownlint-github": "^0.6.3", @@ -237,9 +237,9 @@ } }, "node_modules/@actions/github": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/@actions/github/-/github-8.0.1.tgz", - "integrity": "sha512-cue7mS+kx1/2Dnc/094pitRUm+0uPXVXYVaqOdZwD15BsXATWYHW3idJDYOlyBc5gJlzAQ/w5YLU4LR8D7hjVg==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/@actions/github/-/github-9.1.0.tgz", + "integrity": "sha512-u0hDGQeCS+7VNoLA8hYG65RLdPLMaPGfka0sZ0up7P0AiShqfX6xcuXNteGkQ7X7Tod7AMNwHd4p7DS63i8zzA==", "dev": true, "license": "MIT", "dependencies": { @@ -10677,12 +10677,12 @@ "license": "MIT" }, "node_modules/hot-shots": { - "version": "13.2.0", - "resolved": "https://registry.npmjs.org/hot-shots/-/hot-shots-13.2.0.tgz", - "integrity": "sha512-suQR8U8P2CNcAedwLIaQTQ5OEWhU2rusOmo3gY+H8H1h6bKTBI/xHbq3D9xF6EGgFFjpfLAuB1p2Psc/CYyvOw==", + "version": "14.3.1", + "resolved": "https://registry.npmjs.org/hot-shots/-/hot-shots-14.3.1.tgz", + "integrity": "sha512-2mKuFf3quca37vsT4u4BW9nUZIaz1uuHSpLG0uFQxdg6QAuNU8QnMU6tpEyX/EJe1oEgOrdmFq+DL0NrBIKhkA==", "license": "MIT", "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "optionalDependencies": { "unix-dgram": "2.x" diff --git a/package.json b/package.json index d8e3a9237620..931494d0a070 100644 --- a/package.json +++ b/package.json @@ -217,7 +217,7 @@ "helmet": "^8.1.0", "highlight.js": "^11.11.1", "highlightjs-curl": "^1.3.0", - "hot-shots": "^13.2.0", + "hot-shots": "^14.3.1", "html-entities": "^2.5.6", "http-proxy-middleware": "^3.0.5", "imurmurhash": "^0.1.4", @@ -274,7 +274,7 @@ }, "devDependencies": { "@actions/core": "^3.0.0", - "@actions/github": "^8.0.1", + "@actions/github": "^9.1.0", "@axe-core/playwright": "^4.11.1", "@eslint/js": "^9.39.3", "@github/markdownlint-github": "^0.6.3", diff --git a/src/archives/middleware/archived-enterprise-versions.ts b/src/archives/middleware/archived-enterprise-versions.ts index b3897f12f73c..06e94567563c 100644 --- a/src/archives/middleware/archived-enterprise-versions.ts +++ b/src/archives/middleware/archived-enterprise-versions.ts @@ -1,7 +1,7 @@ import type { Response, NextFunction } from 'express' import { fetchWithRetry } from '@/frame/lib/fetch-utils' -import statsd from '@/observability/lib/statsd' +import statsd, { adaptForTimer } from '@/observability/lib/statsd' import { createLogger } from '@/observability/logger' import { firstVersionDeprecatedOnNewSite, @@ -252,7 +252,7 @@ export default async function archivedEnterpriseVersions( const statsdTags = [`version:${requestedVersion}`] const startTime = Date.now() - const r = await statsd.asyncTimer(doGet, 'archive_enterprise_proxy', [ + const r = await statsd.asyncTimer(adaptForTimer(doGet), 'archive_enterprise_proxy', [ ...statsdTags, `path:${req.path}`, ])() diff --git a/src/assets/scripts/deleted-assets-pr-comment.ts b/src/assets/scripts/deleted-assets-pr-comment.ts index bbe77f96831a..68b425a4def1 100755 --- a/src/assets/scripts/deleted-assets-pr-comment.ts +++ b/src/assets/scripts/deleted-assets-pr-comment.ts @@ -1,8 +1,8 @@ -import github from '@actions/github' +import { context as github_context, getOctokit } from '@actions/github' import { setOutput } from '@actions/core' const { GITHUB_TOKEN } = process.env -const context = github.context +const context = github_context if (!GITHUB_TOKEN) { throw new Error(`GITHUB_TOKEN environment variable not set`) @@ -26,7 +26,7 @@ type MainArgs = { headSHA: string } async function main({ owner, repo, baseSHA, headSHA }: MainArgs) { - const octokit = github.getOctokit(GITHUB_TOKEN as string) + const octokit = getOctokit(GITHUB_TOKEN as string) // get the list of file changes from the PR const response = await octokit.rest.repos.compareCommitsWithBasehead({ owner, diff --git a/src/data-directory/scripts/deleted-features-pr-comment.ts b/src/data-directory/scripts/deleted-features-pr-comment.ts index a29a0b701711..a601190d9c16 100644 --- a/src/data-directory/scripts/deleted-features-pr-comment.ts +++ b/src/data-directory/scripts/deleted-features-pr-comment.ts @@ -8,7 +8,7 @@ * */ -import github from '@actions/github' +import { context as github_context, getOctokit } from '@actions/github' import { setOutput } from '@actions/core' import { program } from 'commander' @@ -19,7 +19,7 @@ if (!GITHUB_TOKEN) { } if (GITHUB_REPOSITORY) { - const context = github.context + const context = github_context const owner = context.repo.owner const repo = context.payload.repository!.name @@ -43,7 +43,7 @@ async function main(owner: string, repo: string, baseSHA: string, headSHA: strin if (!GITHUB_TOKEN) { throw new Error(`GITHUB_TOKEN environment variable not set`) } - const octokit = github.getOctokit(GITHUB_TOKEN) + const octokit = getOctokit(GITHUB_TOKEN) // get the list of file changes from the PR const response = await octokit.rest.repos.compareCommitsWithBasehead({ owner, diff --git a/src/events/lib/hydro.ts b/src/events/lib/hydro.ts index 9bcfffc4f257..105a83edc020 100644 --- a/src/events/lib/hydro.ts +++ b/src/events/lib/hydro.ts @@ -1,7 +1,7 @@ import { createHmac } from 'crypto' import { fetchWithRetry } from '@/frame/lib/fetch-utils' import { isNil } from 'lodash-es' -import statsd from '@/observability/lib/statsd' +import statsd, { adaptForTimer } from '@/observability/lib/statsd' import { report } from '@/observability/lib/failbot' import { MAX_REQUEST_TIMEOUT } from '@/frame/lib/constants' import { createLogger } from '@/observability/logger' @@ -95,4 +95,6 @@ async function _publish( return response } -export const publish = statsd.asyncTimer(_publish, 'hydro.response_time') +const _publishTimed = statsd.asyncTimer(adaptForTimer(_publish), 'hydro.response_time') +export const publish: typeof _publish = (...args) => + _publishTimed(...(args as Parameters)) diff --git a/src/frame/lib/warm-server.ts b/src/frame/lib/warm-server.ts index bfe654d0bad8..71b2b13cb88a 100644 --- a/src/frame/lib/warm-server.ts +++ b/src/frame/lib/warm-server.ts @@ -1,4 +1,4 @@ -import statsd from '@/observability/lib/statsd' +import statsd, { adaptForTimer } from '@/observability/lib/statsd' import { loadUnversionedTree, loadSiteTree, loadPages, loadPageMap } from './page-data' import loadRedirects from '@/redirects/lib/precompile' import { createLogger } from '@/observability/logger' @@ -17,12 +17,15 @@ type WarmServerResult = { // Instrument these functions so that // it's wrapped in a timer that reports to Datadog const dog = { - loadUnversionedTree: statsd.asyncTimer(loadUnversionedTree, 'load_unversioned_tree'), - loadSiteTree: statsd.asyncTimer(loadSiteTree, 'load_site_tree'), - loadPages: statsd.asyncTimer(loadPages, 'load_pages'), - loadPageMap: statsd.asyncTimer(loadPageMap, 'load_page_map'), - loadRedirects: statsd.asyncTimer(loadRedirects, 'load_redirects'), - warmServer: statsd.asyncTimer(warmServer, 'warm_server'), + loadUnversionedTree: statsd.asyncTimer( + adaptForTimer(loadUnversionedTree), + 'load_unversioned_tree', + ), + loadSiteTree: statsd.asyncTimer(adaptForTimer(loadSiteTree), 'load_site_tree'), + loadPages: statsd.asyncTimer(adaptForTimer(loadPages), 'load_pages'), + loadPageMap: statsd.asyncTimer(adaptForTimer(loadPageMap), 'load_page_map'), + loadRedirects: statsd.asyncTimer(adaptForTimer(loadRedirects), 'load_redirects'), + warmServer: statsd.asyncTimer(adaptForTimer(warmServer), 'warm_server'), } // For multiple-triggered Promise sharing @@ -59,7 +62,7 @@ async function warmServer(languagesOnly: string[] = []): Promise { context.collectMiniToc = collectMiniToc } - const pageRenderTimed = statsd.asyncTimer(page.render, STATSD_KEY_RENDER, [`path:${path}`]) + const pageRenderTimed = statsd.asyncTimer(adaptForTimer(page.render), STATSD_KEY_RENDER, [ + `path:${path}`, + ]) return (await pageRenderTimed(context)) as string } diff --git a/src/observability/lib/statsd.ts b/src/observability/lib/statsd.ts index 47d836c1a349..117d5cb6269b 100644 --- a/src/observability/lib/statsd.ts +++ b/src/observability/lib/statsd.ts @@ -1,4 +1,4 @@ -import StatsD from 'hot-shots' +import StatsD, { TimerContext } from 'hot-shots' const { NODE_ENV, @@ -33,3 +33,16 @@ const statsd = new StatsD({ }) export default statsd + +// hot-shots v14 changed asyncTimer/timer to inject a TimerContext as the +// final argument of the wrapped function. This adapter lets callers keep +// passing functions with their original signatures by appending an ignored +// TimerContext parameter. +export function adaptForTimer

( + fn: (...args: P) => Promise, +): (...args: [...P, TimerContext]) => Promise { + return (...args) => { + const original = args.slice(0, -1) as P + return fn(...original) + } +} diff --git a/src/search/middleware/general-search-middleware.ts b/src/search/middleware/general-search-middleware.ts index c9533fcae763..81244fd572c0 100644 --- a/src/search/middleware/general-search-middleware.ts +++ b/src/search/middleware/general-search-middleware.ts @@ -9,7 +9,7 @@ When a user directly hits our API e.g. /api/search/v1?query=foo, they will hit t import { fetchWithRetry } from '@/frame/lib/fetch-utils' import { Request, Response, NextFunction } from 'express' import { errors } from '@elastic/elasticsearch' -import statsd from '@/observability/lib/statsd' +import statsd, { adaptForTimer } from '@/observability/lib/statsd' import { getPathWithoutVersion, getPathWithoutLanguage } from '@/frame/lib/path-utils' import { getGeneralSearchResults } from '@/search/lib/get-elasticsearch-results/general-search' @@ -94,7 +94,11 @@ export default async function contextualizeGeneralSearch( } } else { const tags: string[] = [`indexName:${indexName}`, `toplevels:${searchParams.toplevel.length}`] - const timed = statsd.asyncTimer(getGeneralSearchResults, 'contextualize.search', tags) + const timed = statsd.asyncTimer( + adaptForTimer(getGeneralSearchResults), + 'contextualize.search', + tags, + ) const getGeneralSearchArgs = { indexName, searchParams, diff --git a/src/workflows/content-changes-table-comment.ts b/src/workflows/content-changes-table-comment.ts index c11ddc3a419d..b643c82b6c99 100755 --- a/src/workflows/content-changes-table-comment.ts +++ b/src/workflows/content-changes-table-comment.ts @@ -10,7 +10,7 @@ import fs from 'node:fs' import path from 'node:path' -import github from '@actions/github' +import * as github from '@actions/github' import * as core from '@actions/core' import walk from 'walk-sync'