Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Commit 5a68a4f

Browse files
authored
update logging docs (#451)
* error monitoring setup should link language logging setup * logging setup docs should explain the SDK setup and log enablement options closes #4660
1 parent badc3ae commit 5a68a4f

File tree

9 files changed

+740
-1735
lines changed

9 files changed

+740
-1735
lines changed

components/QuickstartContent/backend/js/express.tsx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,42 @@ export const JSExpressContent: QuickStartContent = {
1919
2020
const app = express()
2121
22-
const highlightErrorHandler = Handlers.errorHandler({ projectID: 'YOUR_PROJECT_ID' })
23-
2422
app.get('/', (req, res) => {
2523
res.send(\`Hello World! ${Math.random()}\`)
2624
})
2725
2826
// This should be before any other error middleware and after all controllers (route definitions)
29-
app.use(highlightErrorHandler)
27+
app.use(Handlers.errorHandler({ projectID: 'YOUR_PROJECT_ID' }))
3028
app.listen(8080, () => {
3129
console.log(\`Example app listening on port 8080\`)
3230
})`,
3331
language: `js`,
3432
},
3533
},
34+
{
35+
title: `Try/catch an error manually (without middleware).`,
36+
content:
37+
'If you are using express.js async handlers, you will need your own try/catch block that directly calls the highlight SDK to report an error. ' +
38+
'This is because express.js async handlers do not invoke error middleware.',
39+
code: {
40+
text: `app.get('/async', async (req: Request, res: Response) => {
41+
try {
42+
// do something dangerous...
43+
throw new Error('oh no!');
44+
} catch (error) {
45+
const parsedHeaders = H.parseHeaders(req.headers);
46+
H.consumeError(
47+
error as Error,
48+
parsedHeaders?.secureSessionId,
49+
parsedHeaders?.requestId
50+
);
51+
} finally {
52+
res.status(200).json({hello: 'world'});
53+
}
54+
});`,
55+
language: `js`,
56+
},
57+
},
3658
verifyError(
3759
'express.js',
3860
`app.get('/', (req, res) => {

components/QuickstartContent/backend/js/shared-snippets.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ H.consumeError(error, parsed?.secureSessionId, parsed?.requestId)`,
5454
}
5555

5656
export const setupLogging: (slug: string) => QuickStartStep = (slug) => ({
57-
title: 'Verify your backend logs are being recorded.',
58-
content:
59-
'With the JS SDKs, your logs are reported automatically from console methods. Visit the [highlight logs portal](http://app.highlight.io/logs) and check that backend logs are coming in.',
57+
title: 'Set up logging.',
58+
content: `With the JS SDKs, your logs are reported automatically from console methods. See the JS [logging setup guide](${siteUrl(
59+
'/docs/getting-started/backend-logging/js/overview',
60+
)}) for more details.`,
6061
})
6162

6263
export const addIntegrationContent = (name: string, slug: string) =>

components/QuickstartContent/backend/python/shared-snippets.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { siteUrl } from '../../../../utils/urls'
12
import { fullstackMappingLink } from '../../frontend/shared-snippets'
23
import { QuickStartStep } from '../../QuickstartContent'
34

@@ -33,7 +34,8 @@ pip install highlight-io${variant ? '[' + variant + ']' : ''}`,
3334
}
3435

3536
export const setupLogging: (slug: string) => QuickStartStep = (slug) => ({
36-
title: 'Verify your backend logs are being recorded.',
37-
content:
38-
'With the Python SDK, your logs are reported automatically from the builtin logging methods (as long as `record_logs=True` is provided to the `highlight_io.H` constructor). Visit the [highlight logs portal](http://app.highlight.io/logs) and check that backend logs are coming in.',
37+
title: 'Set up logging.',
38+
content: `With the Python SDK, your logs are reported automatically from builtin logging methods. See the Python [logging setup guide](${siteUrl(
39+
'/docs/getting-started/backend-logging/python/overview',
40+
)}) for more details.`,
3941
})

components/QuickstartContent/logging/js/other.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { initializeNodeSDK, jsGetSnippet } from '../../backend/js/shared-snippets'
12
import { QuickStartContent } from '../../QuickstartContent'
23
import { previousInstallSnippet, verifyLogs } from '../shared-snippets'
34

@@ -6,6 +7,8 @@ export const JSOtherLogContent: QuickStartContent = {
67
subtitle: 'Learn how to set up highlight.io JS log ingestion without a logging library.',
78
entries: [
89
previousInstallSnippet('js'),
10+
jsGetSnippet('node'),
11+
initializeNodeSDK('node'),
912
{
1013
title: 'Call built-in console methods.',
1114
content:

components/QuickstartContent/logging/python/other.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { downloadSnippet } from '../../backend/python/shared-snippets'
12
import { QuickStartContent } from '../../QuickstartContent'
23
import { previousInstallSnippet, verifyLogs } from '../shared-snippets'
34

@@ -6,10 +7,23 @@ export const PythonOtherLogContent: QuickStartContent = {
67
subtitle: 'Learn how to set up highlight.io Python log ingestion without a logging library.',
78
entries: [
89
previousInstallSnippet('python'),
10+
downloadSnippet('Flask'),
11+
{
12+
title: 'Initialize the Highlight SDK.',
13+
content: 'Setup the SDK with `record_logs` enabled.',
14+
code: {
15+
text: `import highlight_io
16+
17+
H = highlight_io.H("YOUR_PROJECT_ID", record_logs=True)`,
18+
language: 'python',
19+
},
20+
},
921
{
1022
title: 'Call the built-in Python logging library.',
1123
content:
12-
'Logs are automatically recorded by the highlight SDK. Arguments passed as a dictionary as the second parameter will be interpreted as structured key-value pairs that logs can be easily searched by.',
24+
'Logs are reported automatically from the builtin logging methods (as long as `record_logs=True` is provided to the `highlight_io.H` constructor). ' +
25+
'Visit the [highlight logs portal](http://app.highlight.io/logs) and check that backend logs are coming in. ' +
26+
'Arguments passed as a dictionary as the second parameter will be interpreted as structured key-value pairs that logs can be easily searched by.',
1327
code: {
1428
text: `import logging
1529

components/QuickstartContent/logging/shared-snippets.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { siteUrl } from '../../../utils/urls'
22
import { QuickStartStep } from '../QuickstartContent'
33

44
export const previousInstallSnippet: (slug: string) => QuickStartStep = (slug) => ({
5-
title: 'Set up your frontend and backend highlight.io integration.',
5+
title: 'Set up your frontend highlight.io integration.',
66
content: `First, make sure you've followed the [frontend getting started](${siteUrl(
77
'/docs/getting-started/overview',
8-
)}) and [backend getting started](${siteUrl(`/docs/getting-started/backend-sdk/${slug}/overview`)}) guides.`,
8+
)}) guide.`,
99
})
1010

1111
export const verifyLogs: QuickStartStep = {

docs-content/getting-started/3_client-sdk/6_sveltekit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Svelte Kit
2+
title: SvelteKit
33
heading: Using highlight.io with SvelteKit
44
slug: svelte-kit
55
quickstart: true

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@graphcms/rich-text-react-renderer": "^0.6.1",
1818
"@headlessui/react": "^1.7.4",
1919
"@heroicons/react": "^2.0.13",
20-
"@highlight-run/next": "^2.2.1",
20+
"@highlight-run/next": "^2.2.3",
2121
"@radix-ui/react-slider": "^1.1.0",
2222
"@types/js-cookie": "^3.0.2",
2323
"@vercel/og": "^0.0.27",
@@ -30,7 +30,7 @@
3030
"graphql": "^16.6.0",
3131
"graphql-request": "^5.1.0",
3232
"gray-matter": "^4.0.3",
33-
"highlight.run": "^5.3.1",
33+
"highlight.run": "^5.4.1",
3434
"js-cookie": "^3.0.1",
3535
"js-yaml": "^4.1.0",
3636
"lodash.debounce": "^4.0.8",

0 commit comments

Comments
 (0)