diff --git a/airlock/views/workspace.py b/airlock/views/workspace.py index ab57f64e0..ab580ce8a 100644 --- a/airlock/views/workspace.py +++ b/airlock/views/workspace.py @@ -7,6 +7,7 @@ from django.urls import reverse from django.views.decorators.http import require_http_methods from django.views.decorators.vary import vary_on_headers +from opentelemetry import trace from airlock.business_logic import RequestFileType, UrlPath, bll from airlock.file_browser_api import get_workspace_tree @@ -15,6 +16,9 @@ from .helpers import get_path_item_from_tree_or_404, get_workspace_or_raise, serve_file +tracer = trace.get_tracer_provider().get_tracer(__name__) + + def grouped_workspaces(workspaces): workspaces_by_project = defaultdict(list) for workspace in workspaces: @@ -43,7 +47,8 @@ def workspace_view(request, workspace_name: str, path: str = ""): template = "file_browser/contents.html" selected_only = True - tree = get_workspace_tree(workspace, path, selected_only) + with tracer.start_as_current_span("build_workspace_tree") as _span: + tree = get_workspace_tree(workspace, path, selected_only) path_item = get_path_item_from_tree_or_404(tree, path) diff --git a/tests/integration/views/test_workspace.py b/tests/integration/views/test_workspace.py index 0c4186193..f2ddafbc2 100644 --- a/tests/integration/views/test_workspace.py +++ b/tests/integration/views/test_workspace.py @@ -4,6 +4,7 @@ from airlock.business_logic import RequestFileType, UrlPath from tests import factories +from tests.conftest import get_trace pytestmark = pytest.mark.django_db @@ -22,6 +23,12 @@ def test_workspace_view(airlock_client): assert "file.txt" in response.rendered_content assert "release-request-button" not in response.rendered_content + traces = get_trace() + # We have one trace in this view, for the workspace tree + assert len(traces) == 1 + trace = traces[0] + assert trace.name == "build_workspace_tree" + def test_workspace_view_with_existing_request_for_user(airlock_client): user = factories.create_user(output_checker=True)