Commit ff568d09 authored by Tetiana Chupryna's avatar Tetiana Chupryna

Merge branch '344676-investigate-diff-issues-in-production' into 'master'

Adds logging messages for IpynbDiff

See merge request gitlab-org/gitlab!73576
parents adfa0722 3b8405ad
...@@ -121,6 +121,19 @@ class BlobPresenter < Gitlab::View::Presenter::Delegated ...@@ -121,6 +121,19 @@ class BlobPresenter < Gitlab::View::Presenter::Delegated
end end
def transformed_blob_data def transformed_blob_data
@transformed_blob ||= ( blob.path.ends_with?('.ipynb') && IpynbDiff.transform(blob.data, options: { include_metadata: false, cell_decorator: :percent }) ) || blob.data @transformed_blob ||= if blob.path.ends_with?('.ipynb')
new_blob = IpynbDiff.transform(blob.data,
raise_errors: true,
options: { include_metadata: false, cell_decorator: :percent })
Gitlab::AppLogger.info(new_blob ? 'IPYNBDIFF_BLOB_GENERATED' : 'IPYNBDIFF_BLOB_NIL')
new_blob
end
@transformed_blob ||= blob.data
rescue IpynbDiff::InvalidNotebookError => e
Gitlab::ErrorTracking.track_exception(e, issue_url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/344676')
blob.data
end end
end end
...@@ -458,9 +458,17 @@ module Gitlab ...@@ -458,9 +458,17 @@ module Gitlab
new_diff = IpynbDiff.diff(from, to, new_diff = IpynbDiff.diff(from, to,
diff_opts: { context: 5, include_diff_info: true }, diff_opts: { context: 5, include_diff_info: true },
transform_options: { cell_decorator: :percent } ) transform_options: { cell_decorator: :percent },
raise_if_invalid_notebook: true)
diff.diff = new_diff.scan(/.*\n/)[2..-1].join('') if new_diff diff.diff = new_diff.scan(/.*\n/)[2..-1].join('') if new_diff
Gitlab::AppLogger.info({ message: new_diff ? 'IPYNB_DIFF_GENERATED' : 'IPYNB_DIFF_NIL',
from: from&.to_s, to: to&.to_s,
lib_version: Gem.loaded_specs["ipynbdiff"].version.version })
rescue IpynbDiff::InvalidNotebookError => e
Gitlab::ErrorTracking.track_exception(e, issue_url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/344676')
end end
def alternate_viewer_class def alternate_viewer_class
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment