Create and migrate observability directory (#37448)

This commit is contained in:
Kevin Heis 2023-06-05 08:42:53 -07:00 коммит произвёл GitHub
Родитель be8be7e4b3
Коммит f520432027
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
34 изменённых файлов: 1447 добавлений и 387 удалений

Просмотреть файл

@ -6,7 +6,7 @@ module.exports = {
node: true,
},
parser: '@babel/eslint-parser',
extends: ['eslint:recommended', 'standard', 'prettier'],
extends: ['eslint:recommended', 'standard', 'plugin:import/errors', 'prettier'],
parserOptions: {
ecmaVersion: 11,
requireConfigFile: 'false',
@ -39,4 +39,10 @@ module.exports = {
},
},
],
settings: {
'import/resolver': {
typescript: true,
node: true
}
}
}

14
.github/workflows/test.yml поставляемый
Просмотреть файл

@ -40,23 +40,27 @@ jobs:
// repos.
// You can run multiple paths per suite as space-separated in `path`.
return [
{ name: 'content', path: 'tests/content', },
{ name: 'automated-pipelines', path: 'src/automated-pipelines/tests', },
{ name: 'content', path: 'tests/content', },
// { name: 'content-linter', path: 'src/content-linter/tests', },
{ name: 'events', path: 'src/events/tests', },
{ name: 'ghes-releases', path: 'src/ghes-releases/tests', },
{ name: 'github-apps', path: 'src/github-apps/tests', },
{ name: 'graphql', path: 'src/graphql/tests', },
{ name: 'rest', path: 'src/rest/tests', },
{ name: 'webhooks', path: 'src/webhooks/tests', },
{ name: 'landings', path: 'src/landings/tests', },
{ name: 'linting', path: 'src/content-linter/tests', },
{ name: 'meta', path: 'tests/meta', },
{ name: 'routing', path: 'tests/routing', },
{ name: 'observability', path: 'src/observability/tests' },
{ name: 'pageinfo', path: 'src/pageinfo/tests', },
{ name: 'rendering', path: 'tests/rendering', },
{ name: 'rendering-fixtures', path: 'tests/rendering-fixtures', },
{ name: 'rest', path: 'src/rest/tests', },
{ name: 'routing', path: 'tests/routing', },
{ name: 'search', path: 'src/search/tests', },
{ name: 'pageinfo', path: 'src/pageinfo/tests', },
context.payload.repository.full_name === 'github/docs-internal' &&
{ name: 'translations', path: 'tests/translations', },
{ name: 'unit', path: 'tests/unit', },
{ name: 'webhooks', path: 'src/webhooks/tests', },
].filter(Boolean)
test:

Просмотреть файл

@ -1,4 +1,4 @@
import statsd from './statsd.js'
import statsd from '../src/observability/lib/statsd.js'
import { loadUnversionedTree, loadSiteTree, loadPages, loadPageMap } from './page-data.js'
import loadRedirects from './redirects/precompile.js'

Просмотреть файл

@ -1,4 +1,4 @@
import statsd from '../lib/statsd.js'
import statsd from '../src/observability/lib/statsd.js'
export default function abort(req, res, next) {
// If the client aborts the connection, send an error

Просмотреть файл

@ -1,6 +1,6 @@
import path from 'path'
import slash from 'slash'
import statsd from '../lib/statsd.js'
import statsd from '../src/observability/lib/statsd.js'
import {
firstVersionDeprecatedOnNewSite,
lastVersionWithoutArchivedRedirectsFile,

Просмотреть файл

@ -3,7 +3,7 @@ import fs from 'fs'
import crypto from 'crypto'
import got from 'got'
import statsd from '../lib/statsd.js'
import statsd from '../src/observability/lib/statsd.js'
// The only reason this is exported is for the sake of the unit tests'
// ability to test in-memory miss after purging this with a mutation

Просмотреть файл

@ -3,20 +3,20 @@ import path from 'path'
import express from 'express'
import instrument from '../lib/instrument-middleware.js'
import instrument from '../src/observability/lib/instrument-middleware.js'
import haltOnDroppedConnection from './halt-on-dropped-connection.js'
import abort from './abort.js'
import timeout from './timeout.js'
import morgan from 'morgan'
import datadog from './connect-datadog.js'
import datadog from '../src/observability/middleware/connect-datadog.js'
import helmet from './helmet.js'
import cookieParser from './cookie-parser.js'
import {
setDefaultFastlySurrogateKey,
setLanguageFastlySurrogateKey,
} from './set-fastly-surrogate-key.js'
import handleErrors from './handle-errors.js'
import handleInvalidPaths from './handle-invalid-paths.js'
import handleErrors from '../src/observability/middleware/handle-errors.js'
import handleInvalidPaths from '../src/observability/middleware/handle-invalid-paths.js'
import handleNextDataPath from './handle-next-data-path.js'
import detectLanguage from './detect-language.js'
import reloadTree from './reload-tree.js'
@ -37,7 +37,7 @@ import archivedEnterpriseVersions from './archived-enterprise-versions.js'
import robots from './robots.js'
import earlyAccessLinks from './contextualizers/early-access-links.js'
import categoriesForSupport from './categories-for-support.js'
import triggerError from './trigger-error.js'
import triggerError from '../src/observability/middleware/trigger-error.js'
import secretScanning from './contextualizers/secret-scanning.js'
import ghesReleaseNotes from './contextualizers/ghes-release-notes.js'
import ghaeReleaseNotes from './contextualizers/ghae-release-notes.js'
@ -66,7 +66,7 @@ import mockVaPortal from './mock-va-portal.js'
import dynamicAssets from './dynamic-assets.js'
import contextualizeSearch from '../src/search/middleware/contextualize.js'
import rateLimit from './rate-limit.js'
import handleInvalidQuerystrings from './handle-invalid-querystrings.js'
import handleInvalidQuerystrings from '../src/observability/middleware/handle-invalid-query-strings.js'
const { DEPLOYMENT_ENV, NODE_ENV } = process.env
const isTest = NODE_ENV === 'test' || process.env.GITHUB_ACTIONS === 'true'

Просмотреть файл

@ -1,6 +1,6 @@
import rateLimit from 'express-rate-limit'
import statsd from '../lib/statsd.js'
import statsd from '../src/observability/lib/statsd.js'
import { noCacheControl } from './cache-control.js'
const EXPIRES_IN_AS_SECONDS = 60

Просмотреть файл

@ -1,10 +1,10 @@
import { get } from 'lodash-es'
import FailBot from '../lib/failbot.js'
import FailBot from '../src/observability/lib/failbot.js'
import patterns from '../lib/patterns.js'
import getMiniTocItems from '../lib/get-mini-toc-items.js'
import Page from '../lib/page.js'
import statsd from '../lib/statsd.js'
import statsd from '../src/observability/lib/statsd.js'
import { allVersions } from '../lib/all-versions.js'
import { isConnectionDropped } from './halt-on-dropped-connection.js'
import { nextApp, nextHandleRequest } from './next.js'

Просмотреть файл

@ -1,6 +1,6 @@
import timeout from 'express-timeout-handler'
import statsd from '../lib/statsd.js'
import statsd from '../src/observability/lib/statsd.js'
import { MAX_REQUEST_TIMEOUT } from '../lib/constants.js'
export default timeout.handler({

1721
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -130,7 +130,8 @@
"eslint": "8.38.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.0.0",

Просмотреть файл

@ -2,7 +2,7 @@
import fs from 'fs'
import path from 'path'
import walk from 'walk-sync'
import frontmatter from '../lib/read-frontmatter.js'
import frontmatter from '../../lib/read-frontmatter.js'
const contentPath = path.join(process.cwd(), 'content')
const dataPath = path.join(process.cwd(), 'data')

Просмотреть файл

@ -2,8 +2,8 @@ import { createHmac } from 'crypto'
import { Agent } from 'node:https'
import got from 'got'
import { isNil } from 'lodash-es'
import statsd from '../../../lib/statsd.js'
import { report } from '../../../lib/failbot.js'
import statsd from '../../../src/observability/lib/statsd.js'
import { report } from '../../../src/observability/lib/failbot.js'
import { MAX_REQUEST_TIMEOUT } from '../../../lib/constants.js'
const TIME_OUT_TEXT = 'ms has passed since batch creation'

Просмотреть файл

@ -3,7 +3,7 @@ import { omit, without, mapValues } from 'lodash-es'
import Ajv from 'ajv'
import addFormats from 'ajv-formats'
import { schemas, hydroNames } from './lib/schema.js'
import catchMiddlewareError from '../../middleware/catch-middleware-error.js'
import catchMiddlewareError from '../../src/observability/middleware/catch-middleware-error.js'
import { noCacheControl } from '../../middleware/cache-control.js'
import { formatErrors } from './lib/middleware-errors.js'
import { publish as _publish } from './lib/hydro.js'

Просмотреть файл

@ -1,6 +1,6 @@
import { expect, jest } from '@jest/globals'
import { getDOM } from '../helpers/e2etest.js'
import { getDOM } from '../../../tests/helpers/e2etest.js'
describe('rendering the home page(s)', () => {
jest.setTimeout(5 * 60 * 1000)

Просмотреть файл

@ -0,0 +1,19 @@
# OBSERVABILITY
TBD what is OBSERVABILITY
## What OBSERVABILITY does
TBD why is OBSERVABILITY on the docs
## How OBSERVABILITY works
TBD step-by-step instructions to work on OBSERVABILITY
## How to work on OBSERVABILITY
TBD step-by-step instructions on how to work on OBSERVABILITY
## How to get help for OBSERVABILITY
TBD reference material

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -1,7 +1,10 @@
import FailBot from '../lib/failbot.js'
import { nextApp } from './next.js'
import { setFastlySurrogateKey, SURROGATE_ENUMS } from './set-fastly-surrogate-key.js'
import { errorCacheControl } from './cache-control.js'
import { nextApp } from '../../../middleware/next.js'
import {
setFastlySurrogateKey,
SURROGATE_ENUMS,
} from '../../../middleware/set-fastly-surrogate-key.js'
import { errorCacheControl } from '../../../middleware/cache-control.js'
const DEBUG_MIDDLEWARE_TESTS = Boolean(JSON.parse(process.env.DEBUG_MIDDLEWARE_TESTS || 'false'))

Просмотреть файл

@ -1,4 +1,4 @@
import { defaultCacheControl } from './cache-control.js'
import { defaultCacheControl } from '../../../middleware/cache-control.js'
// When a *whole* path is considerered junk.
const JUNK_PATHS = new Set([

Просмотреть файл

@ -1,5 +1,5 @@
import statsd from '../lib/statsd.js'
import { noCacheControl, defaultCacheControl } from './cache-control.js'
import { noCacheControl, defaultCacheControl } from '../../../middleware/cache-control.js'
const STATSD_KEY = 'middleware.handle_invalid_querystrings'

Просмотреть файл

@ -1,4 +1,4 @@
import FailBot from '../../lib/failbot.js'
import FailBot from '../lib/failbot.js'
import nock from 'nock'
describe('FailBot', () => {

Просмотреть файл

@ -1,8 +1,8 @@
import express from 'express'
import statsd from '../../lib/statsd.js'
import statsd from '../../src/observability/lib/statsd.js'
import { defaultCacheControl } from '../../middleware/cache-control.js'
import catchMiddlewareError from '../../middleware/catch-middleware-error.js'
import catchMiddlewareError from '../../src/observability/middleware/catch-middleware-error.js'
import {
SURROGATE_ENUMS,
setFastlySurrogateKey,

Просмотреть файл

@ -1,9 +1,9 @@
import express from 'express'
import FailBot from '../../../lib/failbot.js'
import statsd from '../../../lib/statsd.js'
import FailBot from '../../../src/observability/lib/failbot.js'
import statsd from '../../../src/observability/lib/statsd.js'
import { searchCacheControl } from '../../../middleware/cache-control.js'
import catchMiddlewareError from '../../../middleware/catch-middleware-error.js'
import catchMiddlewareError from '../../../src/observability/middleware/catch-middleware-error.js'
import { setFastlySurrogateKey } from '../../../middleware/set-fastly-surrogate-key.js'
import { getSearchResults } from './es-search.js'
import { getSearchFromRequest } from './get-search-request.js'

Просмотреть файл

@ -18,7 +18,7 @@ import dotenv from 'dotenv'
import { retryOnErrorTest } from '../../../script/helpers/retry-on-error-test.js'
import { languageKeys } from '../../../lib/languages.js'
import { allVersions } from '../../../lib/all-versions.js'
import statsd from '../../../lib/statsd.js'
import statsd from '../../../src/observability/lib/statsd.js'
// Now you can optionally have set the ELASTICSEARCH_URL in your .env file.
dotenv.config()

Просмотреть файл

@ -1,6 +1,6 @@
import dotenv from 'dotenv'
import './lib/check-node-version.js'
import './lib/handle-exceptions.js'
import './src/observability/lib/handle-exceptions.js'
import portUsed from 'port-used'
import createApp from './lib/app.js'
import warmServer from './lib/warm-server.js'

Просмотреть файл

@ -4,7 +4,7 @@ import { get } from '../helpers/e2etest.js'
import {
MAX_UNFAMILIAR_KEYS_BAD_REQUEST,
MAX_UNFAMILIAR_KEYS_REDIRECT,
} from '../../middleware/handle-invalid-querystrings.js'
} from '../../src/observability/middleware/handle-invalid-query-strings.js'
const alpha = Array.from(Array(26)).map((e, i) => i + 65)
const alphabet = alpha.map((x) => String.fromCharCode(x))