@@ -372,41 +372,50 @@ def handle_query_errors() -> Generator[None]:
372372 except InvalidColumnError as error :
373373 message = str (error )
374374 sentry_sdk .set_tag ("query.error_reason" , message )
375+ sentry_sdk .set_attribute ("query.error_reason" , message )
375376 raise ParseError (detail = message )
376377 except InvalidSearchQuery as error :
377378 message = original_error = str (error )
378379 # Special case the project message since it has so many variants so tagging is messy otherwise
379380 if message .endswith ("do not exist or are not actively selected." ):
380381 message = "Project in query does not exist or not selected"
381382 sentry_sdk .set_tag ("query.error_reason" , message )
383+ sentry_sdk .set_attribute ("query.error_reason" , message )
382384 logger .info ("A query error was handled" , extra = {"query.error_reason" : message })
383385 raise ParseError (detail = original_error )
384386 except ArithmeticError as error :
385387 message = str (error )
386388 sentry_sdk .set_tag ("query.error_reason" , message )
389+ sentry_sdk .set_attribute ("query.error_reason" , message )
387390 raise ParseError (detail = message )
388391 except QueryOutsideRetentionError as error :
389392 sentry_sdk .set_tag ("query.error_reason" , "QueryOutsideRetentionError" )
393+ sentry_sdk .set_attribute ("query.error_reason" , "QueryOutsideRetentionError" )
390394 raise ParseError (detail = str (error ))
391395 except QueryIllegalTypeOfArgument :
392396 message = "Invalid query. Argument to function is wrong type."
393397 sentry_sdk .set_tag ("query.error_reason" , message )
398+ sentry_sdk .set_attribute ("query.error_reason" , message )
394399 raise ParseError (detail = message )
395400 except IncompatibleMetricsQuery as error :
396401 message = str (error )
397402 sentry_sdk .set_tag ("query.error_reason" , f"Metric Error: { message } " )
403+ sentry_sdk .set_attribute ("query.error_reason" , f"Metric Error: { message } " )
398404 raise ParseError (detail = message )
399405 except SnubaRPCRateLimitExceeded :
400406 sentry_sdk .set_tag ("query.error_reason" , "RateLimitExceeded" )
407+ sentry_sdk .set_attribute ("query.error_reason" , "RateLimitExceeded" )
401408 raise Throttled (detail = RATE_LIMIT_ERROR_MESSAGE )
402409 except SnubaRPCTooManySimultaneous :
403410 sentry_sdk .set_tag ("query.error_reason" , "TooManySimultaneousQueries" )
411+ sentry_sdk .set_attribute ("query.error_reason" , "TooManySimultaneousQueries" )
404412 raise Throttled (detail = RATE_LIMIT_ERROR_MESSAGE )
405413 except SnubaRPCError as error :
406414 message = "Internal error. Please try again."
407415 arg = error .args [0 ] if len (error .args ) > 0 else None
408416 if isinstance (arg , TimeoutError ):
409417 sentry_sdk .set_tag ("query.error_reason" , "Timeout" )
418+ sentry_sdk .set_attribute ("query.error_reason" , "Timeout" )
410419 raise TimeoutException (detail = TIMEOUT_RPC_ERROR_MESSAGE )
411420 sentry_sdk .capture_exception (error )
412421 if hasattr (error , "debug" ):
@@ -422,9 +431,11 @@ def handle_query_errors() -> Generator[None]:
422431 arg = error .args [0 ] if len (error .args ) > 0 else None
423432 if isinstance (error , RateLimitExceeded ):
424433 sentry_sdk .set_tag ("query.error_reason" , "RateLimitExceeded" )
434+ sentry_sdk .set_attribute ("query.error_reason" , "RateLimitExceeded" )
425435 raise
426436 if isinstance (error , QueryTooManySimultaneous ):
427437 sentry_sdk .set_tag ("query.error_reason" , "TooManySimultaneousQueries" )
438+ sentry_sdk .set_attribute ("query.error_reason" , "TooManySimultaneousQueries" )
428439 raise Throttled (detail = RATE_LIMIT_ERROR_MESSAGE )
429440 if isinstance (
430441 error ,
@@ -437,9 +448,11 @@ def handle_query_errors() -> Generator[None]:
437448 ReadTimeoutError ,
438449 ):
439450 sentry_sdk .set_tag ("query.error_reason" , "Timeout" )
451+ sentry_sdk .set_attribute ("query.error_reason" , "Timeout" )
440452 raise TimeoutException (detail = TIMEOUT_ERROR_MESSAGE )
441453 elif isinstance (error , (UnqualifiedQueryError )):
442454 sentry_sdk .set_tag ("query.error_reason" , str (error ))
455+ sentry_sdk .set_attribute ("query.error_reason" , str (error ))
443456 raise ParseError (detail = str (error ))
444457 elif isinstance (
445458 error ,
@@ -468,6 +481,7 @@ def handle_query_errors() -> Generator[None]:
468481 is_timeout = "canceling statement due to statement timeout" in error_message
469482 if is_timeout :
470483 sentry_sdk .set_tag ("query.error_reason" , "Postgres statement timeout" )
484+ sentry_sdk .set_attribute ("query.error_reason" , "Postgres statement timeout" )
471485 sentry_sdk .capture_exception (error , level = "warning" )
472486 raise Throttled (
473487 detail = "Query timeout. Please try with a smaller date range or fewer conditions."
@@ -486,6 +500,7 @@ def update_snuba_params_with_timestamp(
486500 faster than the default 7d or 14d queries"""
487501 # during the transition this is optional but it will become required for the trace view
488502 sentry_sdk .set_tag ("trace_view.used_timestamp" , timestamp_key in request .GET )
503+ sentry_sdk .set_attribute ("trace_view.used_timestamp" , timestamp_key in request .GET )
489504 has_dates = params .start is not None and params .end is not None
490505 if timestamp_key in request .GET and has_dates :
491506 example_timestamp = parse_datetime_string (request .GET [timestamp_key ])
0 commit comments