Log expected errors from timeouts during syntax highlighting without tracking in Sentry
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
There are a lot of events in Sentry from syntax highlighting.
For example: https://new-sentry.gitlab.net/organizations/gitlab/issues/1503464/
Timeout::Error: execution expired (Timeout::Error)
from timeout.rb:40:in `rescue in handle_timeout'
from timeout.rb:37:in `handle_timeout'
from timeout.rb:194:in `timeout'
from lib/gitlab/render_timeout.rb:11:in `timeout'
from lib/gitlab/highlight.rb:76:in `highlight_rich'
from lib/gitlab/highlight.rb:65:in `highlight_text'
from lib/gitlab/highlight.rb:32:in `highlight'
from lib/gitlab/highlight.rb:7:in `highlight'
from app/presenters/blob_presenter.rb:29:in `highlight'
from lib/gitlab/diff/highlight.rb:150:in `highlighted_blob_lines'
from lib/gitlab/diff/highlight.rb:142:in `new_lines'
from lib/gitlab/diff/highlight.rb:124:in `blob_highlighting'
from lib/gitlab/diff/highlight.rb:88:in `highlight_line'
from lib/gitlab/diff/highlight.rb:63:in `apply_syntax_highlight'
from lib/gitlab/diff/highlight.rb:35:in `block in highlight'
from lib/gitlab/diff/highlight.rb:30:in `map'
from lib/gitlab/diff/highlight.rb:30:in `highlight'
from lib/gitlab/diff/file.rb:263:in `highlighted_diff_lines'
from app/models/concerns/discussion_on_diff.rb:20:in `highlighted_diff_lines'
from app/models/concerns/discussion_on_diff.rb:46:in `truncated_diff_lines'
from app/views/discussions/_diff_with_notes.html.haml:18
from action_view/base.rb:263:in `public_send'
from action_view/base.rb:263:in `_run'
from action_view/template.rb:261:in `block in render'
from active_support/notifications.rb:208:in `instrument'
from action_view/template.rb:556:in `instrument_render_template'
from action_view/template.rb:249:in `render'
from action_view/renderer/partial_renderer.rb:252:in `block in render_partial_template'
from active_support/notifications.rb:208:in `instrument'
from action_view/renderer/partial_renderer.rb:246:in `render_partial_template'
from action_view/renderer/partial_renderer.rb:237:in `render'
from action_view/renderer/renderer.rb:83:in `render_partial_to_object'
from action_view/renderer/renderer.rb:55:in `render_partial'
from action_view/helpers/rendering_helper.rb:44:in `render'
from app/views/discussions/_discussion.html.haml:8
from action_view/base.rb:263:in `public_send'
from action_view/base.rb:263:in `_run'
from action_view/template.rb:261:in `block in render'
from active_support/notifications.rb:208:in `instrument'
from action_view/template.rb:556:in `instrument_render_template'
from action_view/template.rb:249:in `render'
from action_view/renderer/template_renderer.rb:66:in `block (2 levels) in render_template'
from active_support/notifications.rb:206:in `block in instrument'
from active_support/notifications/instrumenter.rb:58:in `instrument'
from active_support/notifications.rb:206:in `instrument'
from action_view/renderer/template_renderer.rb:60:in `block in render_template'
from action_view/renderer/template_renderer.rb:80:in `render_with_layout'
from action_view/renderer/template_renderer.rb:59:in `render_template'
from action_view/renderer/template_renderer.rb:11:in `render'
from action_view/renderer/renderer.rb:63:in `render_template_to_object'
from action_view/renderer/renderer.rb:31:in `render_to_object'
from action_view/rendering.rb:135:in `block in _render_template'
from action_view/base.rb:290:in `in_rendering_context'
from action_view/rendering.rb:134:in `_render_template'
from action_controller/metal/streaming.rb:256:in `_render_template'
from action_view/rendering.rb:121:in `render_to_body'
from action_controller/metal/rendering.rb:158:in `render_to_body'
from action_controller/metal/renderers.rb:141:in `render_to_body'
from abstract_controller/rendering.rb:45:in `render_to_string'
from action_controller/metal/rendering.rb:147:in `render_to_string'
from app/controllers/concerns/notes_actions.rb:209:in `discussion_html'
from app/controllers/concerns/notes_actions.rb:162:in `note_json'
from app/controllers/concerns/notes_actions.rb:33:in `block in index'
from app/controllers/concerns/notes_actions.rb:33:in `map'
from app/controllers/concerns/notes_actions.rb:33:in `index'
from action_controller/metal/basic_implicit_render.rb:6:in `send_action'
from abstract_controller/base.rb:224:in `process_action'
from action_controller/metal/rendering.rb:165:in `process_action'
from abstract_controller/callbacks.rb:259:in `block in process_action'
from active_support/callbacks.rb:121:in `block in run_callbacks'
from lib/gitlab/ip_address_state.rb:11:in `with'
from ee/application_controller.rb:45:in `set_current_ip_address'
from active_support/callbacks.rb:130:in `block in run_callbacks'
from app/controllers/application_controller.rb:488:in `set_current_admin'
from active_support/callbacks.rb:130:in `block in run_callbacks'
from lib/gitlab/session.rb:11:in `with_session'
from app/controllers/application_controller.rb:479:in `set_session_storage'
from active_support/callbacks.rb:130:in `block in run_callbacks'
from lib/gitlab/i18n.rb:114:in `with_locale'
from app/controllers/application_controller.rb:472:in `set_locale'
from active_support/callbacks.rb:130:in `block in run_callbacks'
from app/controllers/application_controller.rb:463:in `set_current_context'
from active_support/callbacks.rb:130:in `block in run_callbacks'
from marginalia.rb:109:in `record_query_comment'
from active_support/callbacks.rb:130:in `block in run_callbacks'
from sentry/rails/controller_transaction.rb:34:in `block in sentry_around_action'
from sentry/hub.rb:138:in `with_child_span'
from sentry-ruby.rb:515:in `with_child_span'
from sentry/rails/controller_transaction.rb:18:in `sentry_around_action'
from active_support/callbacks.rb:130:in `block in run_callbacks'
from active_support/callbacks.rb:141:in `run_callbacks'
from abstract_controller/callbacks.rb:258:in `process_action'
from action_controller/metal/rescue.rb:25:in `process_action'
from action_controller/metal/instrumentation.rb:74:in `block in process_action'
from active_support/notifications.rb:206:in `block in instrument'
from active_support/notifications/instrumenter.rb:58:in `instrument'
from active_support/notifications.rb:206:in `instrument'
from action_controller/metal/instrumentation.rb:73:in `process_action'
from action_controller/metal/params_wrapper.rb:261:in `process_action'
from active_record/railties/controller_runtime.rb:32:in `process_action'
from abstract_controller/base.rb:160:in `process'
from action_view/rendering.rb:40:in `process'
from action_controller/metal.rb:227:in `dispatch'
from action_controller/metal.rb:307:in `block in dispatch'
from lib/gitlab/middleware/action_controller_static_context.rb:23:in `call'
from action_controller/metal.rb:307:in `dispatch'
from action_dispatch/routing/route_set.rb:49:in `dispatch'
from action_dispatch/routing/route_set.rb:32:in `serve'
from action_dispatch/routing/mapper.rb:30:in `block in <class:Constraints>'
from action_dispatch/routing/mapper.rb:60:in `serve'
from action_dispatch/journey/router.rb:51:in `block in serve'
from config/initializers/action_dispatch_journey_router.rb:53:in `block in find_routes'
from config/initializers/action_dispatch_journey_router.rb:25:in `map!'
from config/initializers/action_dispatch_journey_router.rb:25:in `find_routes'
from action_dispatch/journey/router.rb:32:in `serve'
from action_dispatch/routing/route_set.rb:882:in `call'
from gitlab/experiment/middleware.rb:19:in `call'
from omniauth/strategy.rb:202:in `call!'
from omniauth/strategy.rb:169:in `call'
from omniauth/strategy.rb:470:in `call_app!'
from omni_auth/strategies/group_saml.rb:41:in `other_phase'
from omniauth/strategy.rb:195:in `call!'
from omniauth/strategy.rb:169:in `call'
from omniauth/strategy.rb:202:in `call!'
from omniauth/strategy.rb:169:in `call'
from omniauth/strategy.rb:202:in `call!'
from omniauth/strategy.rb:169:in `call'
from omniauth/strategy.rb:202:in `call!'
from omniauth/strategy.rb:169:in `call'
from flipper/middleware/memoizer.rb:72:in `memoized_call'
from flipper/middleware/memoizer.rb:37:in `call'
from lib/gitlab/metrics/elasticsearch_rack_middleware.rb:16:in `call'
from lib/gitlab/middleware/sidekiq_shard_awareness_validation.rb:20:in `block in call'
from lib/gitlab/sidekiq_sharding/validator.rb:42:in `enabled'
from lib/gitlab/middleware/sidekiq_shard_awareness_validation.rb:20:in `call'
from lib/gitlab/middleware/memory_report.rb:13:in `call'
from lib/gitlab/middleware/speedscope.rb:13:in `call'
from lib/gitlab/database/load_balancing/rack_middleware.rb:23:in `call'
from lib/gitlab/middleware/rails_queue_duration.rb:33:in `call'
from lib/gitlab/etag_caching/middleware.rb:21:in `call'
from lib/gitlab/metrics/rack_middleware.rb:16:in `block in call'
from lib/gitlab/metrics/web_transaction.rb:46:in `run'
from lib/gitlab/metrics/rack_middleware.rb:16:in `call'
from lib/gitlab/middleware/go.rb:21:in `call'
from lib/gitlab/middleware/query_analyzer.rb:11:in `block in call'
from lib/gitlab/database/query_analyzer.rb:83:in `within'
from lib/gitlab/middleware/query_analyzer.rb:11:in `call'
from lib/ci/job_token/middleware.rb:11:in `call'
from batch_loader/middleware.rb:11:in `call'
from rack/attack.rb:103:in `call'
from apollo_upload_server/middleware.rb:19:in `call'
from lib/gitlab/middleware/multipart.rb:173:in `call'
from rack/attack.rb:127:in `call'
from warden/manager.rb:36:in `block in call'
from warden/manager.rb:34:in `catch'
from warden/manager.rb:34:in `call'
from rack/cors.rb:102:in `call'
from rack/tempfile_reaper.rb:15:in `call'
from rack/etag.rb:27:in `call'
from rack/conditional_get.rb:27:in `call'
from rack/head.rb:12:in `call'
from action_dispatch/http/permissions_policy.rb:36:in `call'
from action_dispatch/http/content_security_policy.rb:36:in `call'
from lib/gitlab/middleware/read_only/controller.rb:50:in `call'
from lib/gitlab/middleware/read_only.rb:18:in `call'
from lib/gitlab/middleware/unauthenticated_session_expiry.rb:18:in `call'
from rack/session/abstract/id.rb:266:in `context'
from rack/session/abstract/id.rb:260:in `call'
from lib/gitlab/middleware/secure_headers.rb:11:in `call'
from action_dispatch/middleware/cookies.rb:689:in `call'
from lib/gitlab/middleware/same_site_cookies.rb:27:in `call'
from action_dispatch/middleware/callbacks.rb:29:in `block in call'
from active_support/callbacks.rb:101:in `run_callbacks'
from action_dispatch/middleware/callbacks.rb:28:in `call'
from sentry/rails/rescued_exception_interceptor.rb:14:in `call'
from action_dispatch/middleware/debug_exceptions.rb:29:in `call'
from lib/gitlab/middleware/path_traversal_check.rb:40:in `call'
from lib/gitlab/middleware/handle_malformed_strings.rb:21:in `call'
from sentry/rack/capture_exceptions.rb:30:in `block (2 levels) in call'
from sentry/hub.rb:299:in `with_session_tracking'
from sentry-ruby.rb:428:in `with_session_tracking'
from sentry/rack/capture_exceptions.rb:21:in `block in call'
from sentry/hub.rb:89:in `with_scope'
from sentry-ruby.rb:408:in `with_scope'
from sentry/rack/capture_exceptions.rb:20:in `call'
from action_dispatch/middleware/show_exceptions.rb:31:in `call'
from lib/gitlab/middleware/basic_health_check.rb:25:in `call'
from lograge/rails_ext/rack/logger.rb:15:in `call_app'
from rails/rack/logger.rb:24:in `block in call'
from active_support/tagged_logging.rb:139:in `block in tagged'
from active_support/tagged_logging.rb:39:in `tagged'
from active_support/tagged_logging.rb:139:in `tagged'
from active_support/broadcast_logger.rb:241:in `method_missing'
from rails/rack/logger.rb:24:in `call'
from action_dispatch/middleware/remote_ip.rb:92:in `call'
from lib/gitlab/middleware/handle_ip_spoof_attack_error.rb:25:in `call'
from lib/gitlab/middleware/request_context.rb:15:in `call'
from lib/gitlab/middleware/webhook_recursion_detection.rb:15:in `call'
from request_store/middleware.rb:19:in `call'
from rack/method_override.rb:24:in `call'
from rack/runtime.rb:22:in `call'
from rack/timeout/core.rb:154:in `block in call'
from rack/timeout/support/timeout.rb:19:in `timeout'
from rack/timeout/core.rb:153:in `call'
from config/initializers/fix_local_cache_middleware.rb:11:in `call'
from lib/gitlab/middleware/compressed_json.rb:44:in `call'
from action_dispatch/middleware/executor.rb:14:in `call'
from lib/gitlab/middleware/rack_multipart_tempfile_factory.rb:19:in `call'
from lib/gitlab/metrics/requests_rack_middleware.rb:83:in `call'
from labkit/middleware/rack.rb:22:in `block in call'
from labkit/context.rb:35:in `with_context'
from labkit/middleware/rack.rb:21:in `call'
from rack/sendfile.rb:110:in `call'
from action_dispatch/middleware/request_id.rb:28:in `call'
from lib/gitlab/middleware/sidekiq_web_static.rb:20:in `call'
from rails/engine.rb:536:in `call'
from rails/railtie.rb:226:in `public_send'
from rails/railtie.rb:226:in `method_missing'
from lib/gitlab/middleware/release_env.rb:12:in `call'
from rack/urlmap.rb:74:in `block in call'
from rack/urlmap.rb:58:in `each'
from rack/urlmap.rb:58:in `call'
from puma/configuration.rb:279:in `call'
from puma/request.rb:99:in `block in handle_request'
from puma/thread_pool.rb:389:in `with_force_shutdown'
from puma/request.rb:98:in `handle_request'
from puma/server.rb:468:in `process_client'
from puma/server.rb:249:in `block in run'
from puma/thread_pool.rb:166:in `block in spawn_thread'
These are handled gracefully here by logging the error and tracking in Sentry as well as falling back highlighting as plaintext: https://gitlab.com/gitlab-org/gitlab/-/blob/bc063cd323323a7b27b7c9c9ddfc19591f49100c/lib/gitlab/highlight.rb#L78-79
Proposal:
- Only log the error without also tracking in Sentry reduce noise in Sentry
Edited by 🤖 GitLab Bot 🤖