digma-ai / digma-intellij-plugin

Digma JetBrains plugin
MIT License
32 stars 7 forks source link

Target button action - implementation details #1818

Open shaykeren opened 9 months ago

shaykeren commented 9 months ago

Direct Navigation

Having sp1 not discoverable by span_code_object_id, but discoverable by method_code_object_id#1 When I click on target I should be navigate to sp1 (method_code_object_id#1)

Having ep1(endpoint) not discoverable by span_code_object_id, but discoverable by endpoint_code_object_id#1 with single method match (m1) When I click on target I should be navigate to ep1 (m1)

Code Locations:

Having ep1(endpoint) not discoverable by span_code_object_id, but discoverable by endpoint_code_object_id#1 with 2 method match (m1,m2) When I click on target I should see popup with 2 code locations (m1, m2) please note - the user should see the method information (class/file.function)

Related Code Locations:

[foreach flow find the closest method to the span, no more than 8(total)] Having the following 2 flows: sp1(discoverable) sp2(not discoverable) sp6(not discoverable)

sp7(discoverable) sp8(discoverable) sp6 (not discoverable)

And the scope is sp6 When I click on the target button I should see popup with the following "Related Code Locations" in the following order(by distance):

Having the following 2 flows: ep1(project#1 - discoverable by endpoint) sp2(not discoverable) sp3(not discoverable)

ep1(project#2 - discoverable by endpoint) sp3 (not discoverable)

And the scope is sp3 When I click on the target button I should see popup with the following "Related Code Locations" in the following order(by distance):

need to find a way to differentiate between the 2 endpoints if they have the same method and class we should use the project name for example [PROJECT_NAME]/[ENDPOINT_DISPLAY_NAME] (like we have in KTOR)

LOGIC


The rule order for discovery is:
1. is current span discovered by span_code_object_id
2. if current span has method_code_object_id and is discovered
3. if current span has endpoint_code_object_id(is an endpoint) and is discovered
[this option might introduce multiple code locations cause same endpoint can be declared in more than one location]

if current span discovered by span_code_object_id:
   //user should be navigated to code location

//get code navigation by using the new api

if current span has method_code_object_id and method_code_object_id is discoverable:
   //and navigate the user to that location
if current span has endpoint_code_object_id and endpoint_code_object_id is discoverable:
   /*

     if more than one result:
         show the options under code locations (popup)
     if a single result:
         navigate the user to that code location
if none of the above condition passed:
     if related_code_locations length  == 0:
            //show user no code location found message
     else:

          for each flow, order by distance and check if span is discoverable
          exit from a flow if found span which is discoverable
          show no more 8 options for navigation, ordered by distance
shaykeren commented 9 months ago

related : https://github.com/digma-ai/digma-collector-backend/issues/1663