Skip to content

Commit 797e86a

Browse files
authored
Merge pull request #37109 from github/repo-sync
Repo sync
2 parents 983937a + c6b1250 commit 797e86a

File tree

5 files changed

+50
-24
lines changed

5 files changed

+50
-24
lines changed

src/ghes-releases/lib/release-templates/release-steps-0.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ labels:
88
- skip FR board
99
- GHES {{ release-number }}
1010
- ghes-release-automation
11+
- rhythm of docs operations
1112
---
1213

1314
This issue tracks Docs work for the GA release of GHES {{ release-number }}.
@@ -26,11 +27,11 @@ This issue tracks Docs work for the GA release of GHES {{ release-number }}.
2627

2728
## Instructions for triage
2829

29-
- [ ] In the Enterprise project, adjust the "Cycle" field to the cycle containing the target date.
30+
- [ ] Add this issue to the [Rhythm of Docs: Operations](https://github.com/orgs/github/projects/20190) project.
31+
- [ ] For assignee: if needed, add this issue to your persona team project for tracking purposes.
3032

3133
<br/>
3234

33-
```[tasklist]
3435
# Tasks
3536
- [ ] {{ release-steps-1-url }}
3637
- [ ] {{ release-steps-2-url }}
@@ -43,7 +44,6 @@ This issue tracks Docs work for the GA release of GHES {{ release-number }}.
4344
- [ ] After merging PR for RC, notify the API team in [#ecosystem-api](https://github.slack.com/archives/C1042T6MS) on Slack that they can now merge "Update OpenAPI 3.x Descriptions" PRs in [`github/rest-api-description`](https://github.com/github/rest-api-description/pulls), which you blocked as part of the issue for preparing OpenAPI assets.
4445
- [ ] Notify the Docs Content first responder (`@TBD`) that they can now merge OpenAPI PRs.
4546
- [ ] To close this issue, open a PR to complete [these steps](https://github.com/github/docs-content/issues/12972#issuecomment-1947981671).
46-
```
4747

4848
## Resources
4949

src/ghes-releases/lib/release-templates/release-steps-1.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ labels:
55
- new-release
66
- priority-0
77
- skip FR board
8+
- rhythm of docs operations
89
- GHES {{ release-number }}
910
---
1011

1112
## Instructions for triage
1213

13-
- [ ] In the Enterprise project, adjust the "Cycle" field to the cycle containing the target date.
14+
- [ ] Add this issue to the [Rhythm of Docs: Operations](https://github.com/orgs/github/projects/20190) project.
15+
- [ ] For assignee: if needed, add this issue to your persona team project for tracking purposes.
1416

1517
## Instructions for assignee
1618

src/ghes-releases/lib/release-templates/release-steps-2.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ labels:
66
- priority-0
77
- skip FR board
88
- GHES {{ release-number }}
9+
- rhythm of docs operations
910
---
1011

1112
## Instructions for triage
1213

13-
- [ ] In the Enterprise project, adjust the "Cycle" field to the cycle **four weeks** before the target date.
14+
- [ ] Add this issue to the [Rhythm of Docs: Operations](https://github.com/orgs/github/projects/20190) project.
15+
- [ ] For assignee: if needed, add this issue to your persona team project for tracking purposes.
1416

1517
## Instructions for assignee
1618

src/ghes-releases/lib/release-templates/release-steps-5.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ labels:
66
- new-release
77
- priority-0
88
- skip FR board
9+
- rhythm of docs operations
910
---
1011

1112
## Instructions for triage
1213

13-
- [ ] In the Enterprise focus area's project, adjust the "Cycle" field for this issue to the cycle four weeks before the target date.
14+
- [ ] Add this issue to the [Rhythm of Docs: Operations](https://github.com/orgs/github/projects/20190) project.
15+
- [ ] For assignee: if needed, add this issue to your persona team project for tracking purposes.
1416

1517
## Instructions for assignee
1618

@@ -83,7 +85,7 @@ To prepare for publication, create a PR in `github/github` that publishes the sc
8385

8486
- [ ] Create a PR.
8587

86-
- [ ] Get the necessary reviews, but **do not deploy and merge the PR**. You'll merge this PR closer to the RC's release date, while Docs' repositories are frozen.
88+
- [ ] Get the necessary reviews, but **do not deploy and merge the PR yet**. You'll merge this PR closer to the RC's release date.
8789

8890
<br/>
8991
<a name="merge">
@@ -92,19 +94,19 @@ To prepare for publication, create a PR in `github/github` that publishes the sc
9294

9395
To trigger creation of an OpenAPI PR with the updated schema for the RC, merge your publication PR in `github/github`.
9496

95-
- [ ] On the Thursday after you begin the freeze of Docs' repositories per {{ release-steps-0-url }}, merge the publication PR you [prepared in `github/github`](#publication-preparation).
97+
- [ ] 2-3 days before the RC release date, merge the publication PR you [prepared in `github/github`](#publication-preparation).
9698

97-
- [ ] In [#ecosystem-api](https://github.slack.com/archives/C1042T6MS) on Slack, update and then post the following message to notify the team of the upcoming release. Replace VERSION with the version we're releasing.
99+
- [ ] In [#api-platform](https://github.slack.com/archives/C1042T6MS) on Slack, update and then post the following message to notify the team of the upcoming release. Replace VERSION with the version we're releasing.
98100

99101
> 👋 Hi from Docs! We have just marked `published` for the GHES VERSION release configuration to `true`. Please **do not** merge subsequent "Update OpenAPI 3.x Descriptions" PRs [in github/rest-api-description](https://github.com/github/rest-api-description/pulls) until further notice. Thanks!
100102

101-
- [ ] On the Friday during the freeze, locate the latest "Update OpenAPI 3.x Descriptions" PRs [in `github/rest-api-description`](https://github.com/github/rest-api-description/pulls).
103+
- [ ] Locate the latest "Update OpenAPI 3.x Descriptions" PRs [in `github/rest-api-description`](https://github.com/github/rest-api-description/pulls).
102104

103105
- [ ] On each new PR, leave a review that requests changes with the following comment.
104106

105107
> This PR contains changes for the upcoming GHES RC. Please do not merge this or subsequent PRs until further notice in #ecosystem-api. Thanks!
106108

107-
- [ ] From now until after the freeze, all [existing "Update OpenAPI Description" PRs](https://github.com/github/docs-internal/labels/github-openapi-bot) in `github/docs-internal` can be closed.
109+
- [ ] From now until the RC ships, all [existing "Update OpenAPI Description" PRs](https://github.com/github/docs-internal/labels/github-openapi-bot) in `github/docs-internal` can be closed.
108110

109111
To get the latest changes from the latest "Update OpenAPI 3.x Descriptions" PR in the `github/rest-api-description` repository into your PR to close {{ release-steps-1-url }}, you can use one of two methods.
110112

src/search/lib/ai-search-proxy.ts

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { Request, Response } from 'express'
2+
import statsd from '@/observability/lib/statsd'
23
import got from 'got'
34
import { getHmacWithEpoch } from '@/search/lib/helpers/get-cse-copilot-auth'
4-
import { getCSECopilotSource } from '#src/search/lib/helpers/cse-copilot-docs-versions.js'
5+
import { getCSECopilotSource } from '@/search/lib/helpers/cse-copilot-docs-versions'
56

67
const memoryCache = new Map<string, Buffer>()
78

89
export const aiSearchProxy = async (req: Request, res: Response) => {
910
const { query, version, language } = req.body
11+
1012
const errors = []
1113

1214
// Validate request body
@@ -34,13 +36,25 @@ export const aiSearchProxy = async (req: Request, res: Response) => {
3436
return
3537
}
3638

39+
const diagnosticTags = [
40+
`version:${version}`.slice(0, 200),
41+
`language:${language}`.slice(0, 200),
42+
`queryLength:${query.length}`.slice(0, 200),
43+
]
44+
statsd.increment('ai-search.call', 1, diagnosticTags)
45+
46+
// TODO: Caching here may cause an issue if the cache grows too large. Additionally, the cache will be inconsistent across pods
3747
const cacheKey = `${query}:${version}:${language}`
3848
if (memoryCache.has(cacheKey)) {
49+
statsd.increment('ai-search.cache_hit', 1, diagnosticTags)
3950
res.setHeader('Content-Type', 'application/x-ndjson')
4051
res.send(memoryCache.get(cacheKey))
4152
return
4253
}
4354

55+
const startTime = Date.now()
56+
let totalChars = 0
57+
4458
const body = {
4559
chat_context: 'docs',
4660
docs_source: docsSource,
@@ -57,22 +71,19 @@ export const aiSearchProxy = async (req: Request, res: Response) => {
5771
},
5872
})
5973

60-
const chunks: Buffer[] = []
61-
stream.on('data', (chunk) => {
62-
chunks.push(chunk)
74+
// Listen for data events to count characters
75+
stream.on('data', (chunk: Buffer | string) => {
76+
// Ensure we have a string for proper character count
77+
const dataStr = typeof chunk === 'string' ? chunk : chunk.toString()
78+
totalChars += dataStr.length
6379
})
6480

6581
// Handle the upstream response before piping
6682
stream.on('response', (upstreamResponse) => {
67-
// When cse-copilot returns a 204, it means the backend received the request
68-
// but was unable to answer the question. So we return a 400 to the client to be handled.
69-
if (upstreamResponse.statusCode === 204) {
70-
return res
71-
.status(400)
72-
.json({ errors: [{ message: 'Sorry I am unable to answer this question.' }] })
73-
} else if (upstreamResponse.statusCode !== 200) {
83+
if (upstreamResponse.statusCode !== 200) {
7484
const errorMessage = `Upstream server responded with status code ${upstreamResponse.statusCode}`
7585
console.error(errorMessage)
86+
statsd.increment('ai-search.stream_response_error', 1, diagnosticTags)
7687
res.status(500).json({ errors: [{ message: errorMessage }] })
7788
stream.destroy()
7889
} else {
@@ -95,6 +106,8 @@ export const aiSearchProxy = async (req: Request, res: Response) => {
95106
.json({ errors: [{ message: 'Sorry I am unable to answer this question.' }] })
96107
}
97108

109+
statsd.increment('ai-search.stream_error', 1, diagnosticTags)
110+
98111
if (!res.headersSent) {
99112
res.status(500).json({ errors: [{ message: 'Internal server error' }] })
100113
} else {
@@ -106,12 +119,19 @@ export const aiSearchProxy = async (req: Request, res: Response) => {
106119
}
107120
})
108121

109-
// Ensure response ends when stream ends
122+
// Calculate metrics on stream end
110123
stream.on('end', () => {
111-
memoryCache.set(cacheKey, Buffer.concat(chunks as Uint8Array[]))
124+
const totalResponseTime = Date.now() - startTime // in ms
125+
const charPerMsRatio = totalResponseTime > 0 ? totalChars / totalResponseTime : 0 // chars per ms
126+
127+
statsd.gauge('ai-search.total_response_time', totalResponseTime, diagnosticTags)
128+
statsd.gauge('ai-search.response_chars_per_ms', charPerMsRatio, diagnosticTags)
129+
130+
statsd.increment('ai-search.success_stream_end', 1, diagnosticTags)
112131
res.end()
113132
})
114133
} catch (error) {
134+
statsd.increment('ai-search.route_error', 1, diagnosticTags)
115135
console.error('Error posting /answers to cse-copilot:', error)
116136
res.status(500).json({ errors: [{ message: 'Internal server error' }] })
117137
}

0 commit comments

Comments
 (0)