Skip to content

Commit f520432

Browse files
authored
Create and migrate observability directory (github#37448)
1 parent be8be7e commit f520432

34 files changed

Lines changed: 1468 additions & 408 deletions

.eslintrc.cjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
node: true,
77
},
88
parser: '@babel/eslint-parser',
9-
extends: ['eslint:recommended', 'standard', 'prettier'],
9+
extends: ['eslint:recommended', 'standard', 'plugin:import/errors', 'prettier'],
1010
parserOptions: {
1111
ecmaVersion: 11,
1212
requireConfigFile: 'false',
@@ -39,4 +39,10 @@ module.exports = {
3939
},
4040
},
4141
],
42+
settings: {
43+
'import/resolver': {
44+
typescript: true,
45+
node: true
46+
}
47+
}
4248
}

.github/workflows/test.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,27 @@ jobs:
4040
// repos.
4141
// You can run multiple paths per suite as space-separated in `path`.
4242
return [
43-
{ name: 'content', path: 'tests/content', },
4443
{ name: 'automated-pipelines', path: 'src/automated-pipelines/tests', },
44+
{ name: 'content', path: 'tests/content', },
45+
// { name: 'content-linter', path: 'src/content-linter/tests', },
4546
{ name: 'events', path: 'src/events/tests', },
4647
{ name: 'ghes-releases', path: 'src/ghes-releases/tests', },
48+
{ name: 'github-apps', path: 'src/github-apps/tests', },
4749
{ name: 'graphql', path: 'src/graphql/tests', },
48-
{ name: 'rest', path: 'src/rest/tests', },
49-
{ name: 'webhooks', path: 'src/webhooks/tests', },
50+
{ name: 'landings', path: 'src/landings/tests', },
5051
{ name: 'linting', path: 'src/content-linter/tests', },
5152
{ name: 'meta', path: 'tests/meta', },
52-
{ name: 'routing', path: 'tests/routing', },
53+
{ name: 'observability', path: 'src/observability/tests' },
54+
{ name: 'pageinfo', path: 'src/pageinfo/tests', },
5355
{ name: 'rendering', path: 'tests/rendering', },
5456
{ name: 'rendering-fixtures', path: 'tests/rendering-fixtures', },
57+
{ name: 'rest', path: 'src/rest/tests', },
58+
{ name: 'routing', path: 'tests/routing', },
5559
{ name: 'search', path: 'src/search/tests', },
56-
{ name: 'pageinfo', path: 'src/pageinfo/tests', },
5760
context.payload.repository.full_name === 'github/docs-internal' &&
5861
{ name: 'translations', path: 'tests/translations', },
5962
{ name: 'unit', path: 'tests/unit', },
63+
{ name: 'webhooks', path: 'src/webhooks/tests', },
6064
].filter(Boolean)
6165
6266
test:

lib/warm-server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import statsd from './statsd.js'
1+
import statsd from '../src/observability/lib/statsd.js'
22
import { loadUnversionedTree, loadSiteTree, loadPages, loadPageMap } from './page-data.js'
33
import loadRedirects from './redirects/precompile.js'
44

middleware/abort.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import statsd from '../lib/statsd.js'
1+
import statsd from '../src/observability/lib/statsd.js'
22

33
export default function abort(req, res, next) {
44
// If the client aborts the connection, send an error

middleware/archived-enterprise-versions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'path'
22
import slash from 'slash'
3-
import statsd from '../lib/statsd.js'
3+
import statsd from '../src/observability/lib/statsd.js'
44
import {
55
firstVersionDeprecatedOnNewSite,
66
lastVersionWithoutArchivedRedirectsFile,

middleware/get-remote-json.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fs from 'fs'
33
import crypto from 'crypto'
44

55
import got from 'got'
6-
import statsd from '../lib/statsd.js'
6+
import statsd from '../src/observability/lib/statsd.js'
77

88
// The only reason this is exported is for the sake of the unit tests'
99
// ability to test in-memory miss after purging this with a mutation

middleware/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import path from 'path'
33

44
import express from 'express'
55

6-
import instrument from '../lib/instrument-middleware.js'
6+
import instrument from '../src/observability/lib/instrument-middleware.js'
77
import haltOnDroppedConnection from './halt-on-dropped-connection.js'
88
import abort from './abort.js'
99
import timeout from './timeout.js'
1010
import morgan from 'morgan'
11-
import datadog from './connect-datadog.js'
11+
import datadog from '../src/observability/middleware/connect-datadog.js'
1212
import helmet from './helmet.js'
1313
import cookieParser from './cookie-parser.js'
1414
import {
1515
setDefaultFastlySurrogateKey,
1616
setLanguageFastlySurrogateKey,
1717
} from './set-fastly-surrogate-key.js'
18-
import handleErrors from './handle-errors.js'
19-
import handleInvalidPaths from './handle-invalid-paths.js'
18+
import handleErrors from '../src/observability/middleware/handle-errors.js'
19+
import handleInvalidPaths from '../src/observability/middleware/handle-invalid-paths.js'
2020
import handleNextDataPath from './handle-next-data-path.js'
2121
import detectLanguage from './detect-language.js'
2222
import reloadTree from './reload-tree.js'
@@ -37,7 +37,7 @@ import archivedEnterpriseVersions from './archived-enterprise-versions.js'
3737
import robots from './robots.js'
3838
import earlyAccessLinks from './contextualizers/early-access-links.js'
3939
import categoriesForSupport from './categories-for-support.js'
40-
import triggerError from './trigger-error.js'
40+
import triggerError from '../src/observability/middleware/trigger-error.js'
4141
import secretScanning from './contextualizers/secret-scanning.js'
4242
import ghesReleaseNotes from './contextualizers/ghes-release-notes.js'
4343
import ghaeReleaseNotes from './contextualizers/ghae-release-notes.js'
@@ -66,7 +66,7 @@ import mockVaPortal from './mock-va-portal.js'
6666
import dynamicAssets from './dynamic-assets.js'
6767
import contextualizeSearch from '../src/search/middleware/contextualize.js'
6868
import rateLimit from './rate-limit.js'
69-
import handleInvalidQuerystrings from './handle-invalid-querystrings.js'
69+
import handleInvalidQuerystrings from '../src/observability/middleware/handle-invalid-query-strings.js'
7070

7171
const { DEPLOYMENT_ENV, NODE_ENV } = process.env
7272
const isTest = NODE_ENV === 'test' || process.env.GITHUB_ACTIONS === 'true'

middleware/rate-limit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import rateLimit from 'express-rate-limit'
22

3-
import statsd from '../lib/statsd.js'
3+
import statsd from '../src/observability/lib/statsd.js'
44
import { noCacheControl } from './cache-control.js'
55

66
const EXPIRES_IN_AS_SECONDS = 60

middleware/render-page.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { get } from 'lodash-es'
22

3-
import FailBot from '../lib/failbot.js'
3+
import FailBot from '../src/observability/lib/failbot.js'
44
import patterns from '../lib/patterns.js'
55
import getMiniTocItems from '../lib/get-mini-toc-items.js'
66
import Page from '../lib/page.js'
7-
import statsd from '../lib/statsd.js'
7+
import statsd from '../src/observability/lib/statsd.js'
88
import { allVersions } from '../lib/all-versions.js'
99
import { isConnectionDropped } from './halt-on-dropped-connection.js'
1010
import { nextApp, nextHandleRequest } from './next.js'

middleware/timeout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import timeout from 'express-timeout-handler'
22

3-
import statsd from '../lib/statsd.js'
3+
import statsd from '../src/observability/lib/statsd.js'
44
import { MAX_REQUEST_TIMEOUT } from '../lib/constants.js'
55

66
export default timeout.handler({

0 commit comments

Comments
 (0)