hvoss-techfak commited on
Commit
041fd85
·
1 Parent(s): 210cb7f

sentry test

Browse files
Files changed (2) hide show
  1. app.py +12 -0
  2. requirements.txt +1 -0
app.py CHANGED
@@ -3,6 +3,7 @@ import os, logging
3
  import sentry_sdk
4
  from sentry_sdk import capture_exception
5
  from sentry_sdk.integrations.logging import LoggingIntegration
 
6
  from sentry_sdk.integrations.fastapi import FastApiIntegration
7
  dsn = os.getenv("SENTRY_DSN")
8
  if not dsn:
@@ -12,6 +13,13 @@ else:
12
  dsn=dsn,
13
  traces_sample_rate=0.1,
14
  integrations=[
 
 
 
 
 
 
 
15
  LoggingIntegration(
16
  level=logging.INFO, # breadcrumb level
17
  event_level=logging.ERROR,
@@ -244,6 +252,8 @@ def get_script_args_info(exclude_args=None):
244
  ]
245
  return [arg for arg in all_args_info if arg["name"] not in exclude_args]
246
 
 
 
247
 
248
  # Initial filament data
249
  initial_filament_data = {
@@ -514,6 +524,8 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
514
  visible=False,
515
  )
516
  with gr.Row():
 
 
517
  with gr.Accordion("Adjust Autoforge Parameters", open=False):
518
  args_for_accordion = get_script_args_info(
519
  exclude_args=["--input_image"]
 
3
  import sentry_sdk
4
  from sentry_sdk import capture_exception
5
  from sentry_sdk.integrations.logging import LoggingIntegration
6
+ from sentry_sdk.integrations.starlette import StarletteIntegration
7
  from sentry_sdk.integrations.fastapi import FastApiIntegration
8
  dsn = os.getenv("SENTRY_DSN")
9
  if not dsn:
 
13
  dsn=dsn,
14
  traces_sample_rate=0.1,
15
  integrations=[
16
+ StarletteIntegration(
17
+ failed_request_status_codes={
18
+ 400,
19
+ 422,
20
+ *range(500, 599),
21
+ }, # also log 4xx from Gradio
22
+ ),
23
  LoggingIntegration(
24
  level=logging.INFO, # breadcrumb level
25
  event_level=logging.ERROR,
 
252
  ]
253
  return [arg for arg in all_args_info if arg["name"] not in exclude_args]
254
 
255
+ def boom():
256
+ raise RuntimeError("Sentry test – should appear in dashboard")
257
 
258
  # Initial filament data
259
  initial_filament_data = {
 
524
  visible=False,
525
  )
526
  with gr.Row():
527
+ test_btn = gr.Button("Trigger Sentry test error")
528
+ test_btn.click(boom)
529
  with gr.Accordion("Adjust Autoforge Parameters", open=False):
530
  args_for_accordion = get_script_args_info(
531
  exclude_args=["--input_image"]
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  autoforge==1.7.2
2
  sentry-sdk[huggingface_hub]
 
 
1
  autoforge==1.7.2
2
  sentry-sdk[huggingface_hub]
3
+ sentry-sdk[fastapi]