Skip to content

Commit a3f1a3d

Browse files
ref(onboarding): Split tornado onboarding docs
1 parent 673a3c6 commit a3f1a3d

File tree

3 files changed

+206
-1
lines changed

3 files changed

+206
-1
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import type {Docs} from 'sentry/components/onboarding/gettingStartedDoc/types';
2+
import {
3+
feedbackOnboardingJsLoader,
4+
replayOnboardingJsLoader,
5+
} from 'sentry/gettingStartedDocs/javascript/jsLoader/jsLoader';
6+
import {agentMonitoring} from 'sentry/gettingStartedDocs/python/python/agentMonitoring';
7+
import {crashReport} from 'sentry/gettingStartedDocs/python/python/crashReport';
8+
import {featureFlag} from 'sentry/gettingStartedDocs/python/python/featureFlag';
9+
import {logs} from 'sentry/gettingStartedDocs/python/python/logs';
10+
import {mcp} from 'sentry/gettingStartedDocs/python/python/mcp';
11+
import {profiling} from 'sentry/gettingStartedDocs/python/python/profiling';
12+
13+
import {onboarding} from './onboarding';
14+
15+
const docs: Docs = {
16+
onboarding,
17+
replayOnboardingJsLoader,
18+
profilingOnboarding: profiling(),
19+
crashReportOnboarding: crashReport,
20+
featureFlagOnboarding: featureFlag,
21+
feedbackOnboardingJsLoader,
22+
agentMonitoringOnboarding: agentMonitoring,
23+
mcpOnboarding: mcp,
24+
logsOnboarding: logs({
25+
packageName: 'sentry-sdk[tornado]',
26+
}),
27+
};
28+
29+
export default docs;
30+

static/app/gettingStartedDocs/python/tornado.spec.tsx renamed to static/app/gettingStartedDocs/python/tornado/onboarding.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {renderWithOnboardingLayout} from 'sentry-test/onboarding/renderWithOnboa
44
import {screen} from 'sentry-test/reactTestingLibrary';
55
import {textWithMarkupMatcher} from 'sentry-test/utils';
66

7-
import docs from './tornado';
7+
import docs from '.';
88

99
describe('tornado onboarding docs', () => {
1010
it('renders doc correctly', () => {
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
import {ExternalLink} from 'sentry/components/core/link';
2+
import {
3+
StepType,
4+
type DocsParams,
5+
type OnboardingConfig,
6+
} from 'sentry/components/onboarding/gettingStartedDoc/types';
7+
import {verify} from 'sentry/gettingStartedDocs/python/python/logs';
8+
import {alternativeProfiling} from 'sentry/gettingStartedDocs/python/python/profiling';
9+
import {
10+
getPythonAiocontextvarsCodeBlocks,
11+
getPythonInstallCodeBlock,
12+
} from 'sentry/gettingStartedDocs/python/python/utils';
13+
import {t, tct} from 'sentry/locale';
14+
15+
const getSdkSetupSnippet = (params: DocsParams) => `
16+
import sentry_sdk
17+
18+
sentry_sdk.init(
19+
dsn="${params.dsn.public}",
20+
# Add data like request headers and IP for users,
21+
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
22+
send_default_pii=True,${
23+
params.isLogsSelected
24+
? `
25+
# Enable sending logs to Sentry
26+
enable_logs=True,`
27+
: ''
28+
}${
29+
params.isPerformanceSelected
30+
? `
31+
# Set traces_sample_rate to 1.0 to capture 100%
32+
# of transactions for tracing.
33+
traces_sample_rate=1.0,`
34+
: ''
35+
}${
36+
params.isProfilingSelected &&
37+
params.profilingOptions?.defaultProfilingMode !== 'continuous'
38+
? `
39+
# Set profiles_sample_rate to 1.0 to profile 100%
40+
# of sampled transactions.
41+
# We recommend adjusting this value in production.
42+
profiles_sample_rate=1.0,`
43+
: params.isProfilingSelected &&
44+
params.profilingOptions?.defaultProfilingMode === 'continuous'
45+
? `
46+
# Set profile_session_sample_rate to 1.0 to profile 100%
47+
# of profile sessions.
48+
profile_session_sample_rate=1.0,
49+
# Set profile_lifecycle to "trace" to automatically
50+
# run the profiler on when there is an active transaction
51+
profile_lifecycle="trace",`
52+
: ''
53+
}
54+
)
55+
`;
56+
57+
export const onboarding: OnboardingConfig = {
58+
introduction: () =>
59+
tct('The Tornado integration adds support for the [link:Tornado Web Framework].', {
60+
link: <ExternalLink href="https://www.tornadoweb.org/en/stable/" />,
61+
}),
62+
install: () => [
63+
{
64+
type: StepType.INSTALL,
65+
content: [
66+
{
67+
type: 'text',
68+
text: tct(
69+
'Install [code:sentry-sdk] from PyPI with the [code:tornado] extra:',
70+
{
71+
code: <code />,
72+
}
73+
),
74+
},
75+
getPythonInstallCodeBlock(),
76+
...getPythonAiocontextvarsCodeBlocks(),
77+
],
78+
},
79+
],
80+
configure: (params: DocsParams) => [
81+
{
82+
type: StepType.CONFIGURE,
83+
content: [
84+
{
85+
type: 'text',
86+
text: tct(
87+
'If you have the [codeTornado:tornado] package in your dependencies, the Tornado integration will be enabled automatically when you initialize the Sentry SDK. Initialize the Sentry SDK before your app has been initialized:',
88+
{
89+
codeTornado: <code />,
90+
}
91+
),
92+
},
93+
{
94+
type: 'code',
95+
language: 'python',
96+
code: `
97+
${getSdkSetupSnippet(params)}
98+
class MainHandler(tornado.web.RequestHandler):
99+
# ...
100+
`,
101+
},
102+
alternativeProfiling(params),
103+
],
104+
},
105+
],
106+
verify: (params: DocsParams) => [
107+
{
108+
type: StepType.VERIFY,
109+
content: [
110+
{
111+
type: 'text',
112+
text: t(
113+
'You can easily verify your Sentry installation by creating a route that triggers an error:'
114+
),
115+
},
116+
{
117+
type: 'code',
118+
language: 'python',
119+
code: `
120+
import asyncio
121+
import tornado
122+
${getSdkSetupSnippet(params)}
123+
class MainHandler(tornado.web.RequestHandler):
124+
def get(self):
125+
1/0 # raises an error
126+
self.write("Hello, world")
127+
128+
def make_app():
129+
return tornado.web.Application([
130+
(r"/", MainHandler),
131+
])
132+
133+
async def main():
134+
app = make_app()
135+
app.listen(8888)
136+
await asyncio.Event().wait()
137+
138+
asyncio.run(main())
139+
`,
140+
},
141+
verify(params),
142+
{
143+
type: 'text',
144+
text: [
145+
tct(
146+
'When you point your browser to [link:http://localhost:8888/] a transaction in the Performance section of Sentry will be created.',
147+
{
148+
link: <ExternalLink href="http://localhost:8888/" />,
149+
}
150+
),
151+
t(
152+
'Additionally, an error event will be sent to Sentry and will be connected to the transaction.'
153+
),
154+
t('It takes a couple of moments for the data to appear in Sentry.'),
155+
],
156+
},
157+
],
158+
},
159+
],
160+
nextSteps: (params: DocsParams) => {
161+
const steps = [] as any[];
162+
if (params.isLogsSelected) {
163+
steps.push({
164+
id: 'logs',
165+
name: t('Logging Integrations'),
166+
description: t(
167+
'Add logging integrations to automatically capture logs from your application.'
168+
),
169+
link: 'https://docs.sentry.io/platforms/python/logs/#integrations',
170+
});
171+
}
172+
return steps;
173+
},
174+
};
175+

0 commit comments

Comments
 (0)