Skip to content

Commit 5851af1

Browse files
AbhiPrasadconstantinius
authored andcommitted
1 parent a1ce168 commit 5851af1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1771
-122
lines changed

static/app/components/onboarding/productSelection.tsx

Lines changed: 82 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -249,30 +249,96 @@ export const platformProductAvailability = {
249249
ProductSolution.LOGS,
250250
],
251251
'php-symfony': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
252-
python: [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
253-
'python-aiohttp': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
254-
'python-asgi': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
255-
'python-awslambda': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
256-
'python-bottle': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
257-
'python-celery': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
258-
'python-chalice': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
259-
'python-django': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
260-
'python-falcon': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
261-
'python-fastapi': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
262-
'python-flask': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
252+
python: [
253+
ProductSolution.PERFORMANCE_MONITORING,
254+
ProductSolution.PROFILING,
255+
ProductSolution.LOGS,
256+
],
257+
'python-aiohttp': [
258+
ProductSolution.PERFORMANCE_MONITORING,
259+
ProductSolution.PROFILING,
260+
ProductSolution.LOGS,
261+
],
262+
'python-asgi': [
263+
ProductSolution.PERFORMANCE_MONITORING,
264+
ProductSolution.PROFILING,
265+
ProductSolution.LOGS,
266+
],
267+
'python-awslambda': [
268+
ProductSolution.PERFORMANCE_MONITORING,
269+
ProductSolution.PROFILING,
270+
ProductSolution.LOGS,
271+
],
272+
'python-bottle': [
273+
ProductSolution.PERFORMANCE_MONITORING,
274+
ProductSolution.PROFILING,
275+
ProductSolution.LOGS,
276+
],
277+
'python-celery': [
278+
ProductSolution.PERFORMANCE_MONITORING,
279+
ProductSolution.PROFILING,
280+
ProductSolution.LOGS,
281+
],
282+
'python-chalice': [
283+
ProductSolution.PERFORMANCE_MONITORING,
284+
ProductSolution.PROFILING,
285+
ProductSolution.LOGS,
286+
],
287+
'python-django': [
288+
ProductSolution.PERFORMANCE_MONITORING,
289+
ProductSolution.PROFILING,
290+
ProductSolution.LOGS,
291+
],
292+
'python-falcon': [
293+
ProductSolution.PERFORMANCE_MONITORING,
294+
ProductSolution.PROFILING,
295+
ProductSolution.LOGS,
296+
],
297+
'python-fastapi': [
298+
ProductSolution.PERFORMANCE_MONITORING,
299+
ProductSolution.PROFILING,
300+
ProductSolution.LOGS,
301+
],
302+
'python-flask': [
303+
ProductSolution.PERFORMANCE_MONITORING,
304+
ProductSolution.PROFILING,
305+
ProductSolution.LOGS,
306+
],
263307
'python-gcpfunctions': [
264308
ProductSolution.PERFORMANCE_MONITORING,
265309
ProductSolution.PROFILING,
310+
ProductSolution.LOGS,
311+
],
312+
'python-quart': [
313+
ProductSolution.PERFORMANCE_MONITORING,
314+
ProductSolution.PROFILING,
315+
ProductSolution.LOGS,
316+
],
317+
'python-rq': [
318+
ProductSolution.PERFORMANCE_MONITORING,
319+
ProductSolution.PROFILING,
320+
ProductSolution.LOGS,
266321
],
267-
'python-quart': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
268-
'python-rq': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
269322
'python-serverless': [
270323
ProductSolution.PERFORMANCE_MONITORING,
271324
ProductSolution.PROFILING,
325+
ProductSolution.LOGS,
326+
],
327+
'python-tornado': [
328+
ProductSolution.PERFORMANCE_MONITORING,
329+
ProductSolution.PROFILING,
330+
ProductSolution.LOGS,
331+
],
332+
'python-starlette': [
333+
ProductSolution.PERFORMANCE_MONITORING,
334+
ProductSolution.PROFILING,
335+
ProductSolution.LOGS,
336+
],
337+
'python-wsgi': [
338+
ProductSolution.PERFORMANCE_MONITORING,
339+
ProductSolution.PROFILING,
340+
ProductSolution.LOGS,
272341
],
273-
'python-tornado': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
274-
'python-starlette': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
275-
'python-wsgi': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
276342
'react-native': [
277343
ProductSolution.PERFORMANCE_MONITORING,
278344
ProductSolution.PROFILING,

static/app/data/platformCategories.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,36 @@ export const withoutPerformanceSupport: Set<PlatformKey> = new Set([
306306

307307
// List of platforms that have logging onboarding checklist content
308308
export const withLoggingOnboarding: Set<PlatformKey> = new Set([
309+
'javascript',
309310
'javascript-angular',
310311
'javascript-ember',
311312
'javascript-gatsby',
312-
'javascript',
313313
'javascript-react',
314314
'javascript-solid',
315315
'javascript-svelte',
316316
'javascript-vue',
317+
'python',
318+
'python-aiohttp',
319+
'python-asgi',
320+
'python-awslambda',
321+
'python-bottle',
322+
'python-celery',
323+
'python-chalice',
324+
'python-django',
325+
'python-falcon',
326+
'python-fastapi',
327+
'python-flask',
328+
'python-gcpfunctions',
329+
'python-pylons',
330+
'python-pyramid',
331+
'python-quart',
332+
'python-rq',
333+
'python-sanic',
334+
'python-serverless',
335+
'python-starlette',
336+
'python-tornado',
337+
'python-tryton',
338+
'python-wsgi',
317339
]);
318340

319341
// List of platforms that do not have logging support. We make use of this list in the product to not provide any Logging

static/app/gettingStartedDocs/python/aiohttp.spec.tsx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {renderWithOnboardingLayout} from 'sentry-test/onboarding/renderWithOnboa
44
import {screen} from 'sentry-test/reactTestingLibrary';
55
import {textWithMarkupMatcher} from 'sentry-test/utils';
66

7+
import {ProductSolution} from 'sentry/components/onboarding/gettingStartedDoc/types';
8+
79
import docs from './aiohttp';
810

911
describe('aiohttp onboarding docs', () => {
@@ -75,4 +77,46 @@ describe('aiohttp onboarding docs', () => {
7577
screen.getByText(textWithMarkupMatcher(/profile_lifecycle="trace",/))
7678
).toBeInTheDocument();
7779
});
80+
81+
it('renders with logs', () => {
82+
renderWithOnboardingLayout(docs, {
83+
selectedProducts: [ProductSolution.LOGS],
84+
});
85+
86+
// Renders logs config
87+
expect(
88+
screen.getByText(textWithMarkupMatcher(/enable_logs=True,/))
89+
).toBeInTheDocument();
90+
91+
// Renders logs verification steps
92+
expect(
93+
screen.getByText('You can send logs to Sentry using the Sentry logging APIs:')
94+
).toBeInTheDocument();
95+
expect(
96+
screen.getByText(
97+
"You can also use Python's built-in logging module, which will automatically forward logs to Sentry:"
98+
)
99+
).toBeInTheDocument();
100+
});
101+
102+
it('renders without logs', () => {
103+
renderWithOnboardingLayout(docs, {
104+
selectedProducts: [],
105+
});
106+
107+
// Does not render logs config
108+
expect(
109+
screen.queryByText(textWithMarkupMatcher(/enable_logs=True,/))
110+
).not.toBeInTheDocument();
111+
112+
// Does not render logs verification steps
113+
expect(
114+
screen.queryByText('You can send logs to Sentry using the Sentry logging APIs:')
115+
).not.toBeInTheDocument();
116+
expect(
117+
screen.queryByText(
118+
"You can also use Python's built-in logging module, which will automatically forward logs to Sentry:"
119+
)
120+
).not.toBeInTheDocument();
121+
});
78122
});

static/app/gettingStartedDocs/python/aiohttp.tsx

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ import {
1111
} from 'sentry/gettingStartedDocs/javascript/jsLoader/jsLoader';
1212
import {
1313
agentMonitoringOnboarding,
14-
AlternativeConfiguration,
1514
crashReportOnboardingPython,
1615
featureFlagOnboarding,
1716
} from 'sentry/gettingStartedDocs/python/python';
1817
import {t, tct} from 'sentry/locale';
1918
import {
19+
AlternativeConfiguration,
2020
getPythonAiocontextvarsConfig,
2121
getPythonInstallConfig,
22+
getPythonLogsOnboarding,
2223
getPythonProfilingOnboarding,
2324
} from 'sentry/utils/gettingStartedDocs/python';
2425

@@ -34,6 +35,12 @@ sentry_sdk.init(
3435
# Add data like request headers and IP for users,
3536
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
3637
send_default_pii=True,${
38+
params.isLogsSelected
39+
? `
40+
# Enable sending logs to Sentry
41+
enable_logs=True,`
42+
: ''
43+
}${
3744
params.isPerformanceSelected
3845
? `
3946
# Set traces_sample_rate to 1.0 to capture 100%
@@ -100,16 +107,15 @@ const onboarding: OnboardingConfig = {
100107
),
101108
},
102109
],
103-
verify: () => [
110+
verify: (params: Params) => [
104111
{
105112
type: StepType.VERIFY,
106-
description: t(
107-
'You can easily verify your Sentry installation by creating a route that triggers an error:'
108-
),
109113
configurations: [
110114
{
115+
description: t(
116+
'You can easily verify your Sentry installation by creating a route that triggers an error:'
117+
),
111118
language: 'python',
112-
113119
code: `
114120
async def hello(request):
115121
1/0 # raises an error
@@ -121,6 +127,37 @@ app.add_routes([web.get('/', hello)])
121127
web.run_app(app)
122128
`,
123129
},
130+
...(params.isLogsSelected
131+
? [
132+
{
133+
description: t(
134+
'You can send logs to Sentry using the Sentry logging APIs:'
135+
),
136+
language: 'python',
137+
code: `import sentry_sdk
138+
139+
# Send logs directly to Sentry
140+
sentry_sdk.logger.info('This is an info log message')
141+
sentry_sdk.logger.warning('This is a warning message')
142+
sentry_sdk.logger.error('This is an error message')`,
143+
},
144+
{
145+
description: t(
146+
"You can also use Python's built-in logging module, which will automatically forward logs to Sentry:"
147+
),
148+
language: 'python',
149+
code: `import logging
150+
151+
# Your existing logging setup
152+
logger = logging.getLogger(__name__)
153+
154+
# These logs will be automatically sent to Sentry
155+
logger.info('This will be sent to Sentry')
156+
logger.warning('User login failed')
157+
logger.error('Something went wrong')`,
158+
},
159+
]
160+
: []),
124161
],
125162
additionalInfo: (
126163
<span>
@@ -142,9 +179,24 @@ web.run_app(app)
142179
),
143180
},
144181
],
145-
nextSteps: () => [],
182+
nextSteps: (params: Params) => {
183+
const steps = [] as any[];
184+
if (params.isLogsSelected) {
185+
steps.push({
186+
id: 'logs',
187+
name: t('Logging Integrations'),
188+
description: t(
189+
'Add logging integrations to automatically capture logs from your application.'
190+
),
191+
link: 'https://docs.sentry.io/platforms/python/logs/#integrations',
192+
});
193+
}
194+
return steps;
195+
},
146196
};
147197

198+
const logsOnboarding = getPythonLogsOnboarding();
199+
148200
const docs: Docs = {
149201
onboarding,
150202
replayOnboardingJsLoader,
@@ -153,6 +205,7 @@ const docs: Docs = {
153205
featureFlagOnboarding,
154206
feedbackOnboardingJsLoader,
155207
agentMonitoringOnboarding,
208+
logsOnboarding,
156209
};
157210

158211
export default docs;

static/app/gettingStartedDocs/python/asgi.spec.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {renderWithOnboardingLayout} from 'sentry-test/onboarding/renderWithOnboa
44
import {screen} from 'sentry-test/reactTestingLibrary';
55
import {textWithMarkupMatcher} from 'sentry-test/utils';
66

7+
import {ProductSolution} from 'sentry/components/onboarding/gettingStartedDoc/types';
8+
79
import docs from './asgi';
810

911
describe('asgi onboarding docs', () => {
@@ -75,4 +77,42 @@ describe('asgi onboarding docs', () => {
7577
screen.getByText(textWithMarkupMatcher(/profile_lifecycle="trace",/))
7678
).toBeInTheDocument();
7779
});
80+
81+
it('renders with logs', () => {
82+
renderWithOnboardingLayout(docs, {
83+
selectedProducts: [ProductSolution.LOGS],
84+
});
85+
86+
expect(
87+
screen.getByText(textWithMarkupMatcher(/enable_logs=True,/))
88+
).toBeInTheDocument();
89+
90+
expect(
91+
screen.getByText('You can send logs to Sentry using the Sentry logging APIs:')
92+
).toBeInTheDocument();
93+
expect(
94+
screen.getByText(
95+
"You can also use Python's built-in logging module, which will automatically forward logs to Sentry:"
96+
)
97+
).toBeInTheDocument();
98+
});
99+
100+
it('renders without logs', () => {
101+
renderWithOnboardingLayout(docs, {
102+
selectedProducts: [],
103+
});
104+
105+
expect(
106+
screen.queryByText(textWithMarkupMatcher(/enable_logs=True,/))
107+
).not.toBeInTheDocument();
108+
109+
expect(
110+
screen.queryByText('You can send logs to Sentry using the Sentry logging APIs:')
111+
).not.toBeInTheDocument();
112+
expect(
113+
screen.queryByText(
114+
"You can also use Python's built-in logging module, which will automatically forward logs to Sentry:"
115+
)
116+
).not.toBeInTheDocument();
117+
});
78118
});

0 commit comments

Comments
 (0)