Skip to content

Sub-expression level detailed tracing and fix CachingModelResolverDecorator null cache bug#1696

Merged
antvaset merged 3 commits intomainfrom
feature/sub-expression-detailed-tracing-
Mar 4, 2026
Merged

Sub-expression level detailed tracing and fix CachingModelResolverDecorator null cache bug#1696
antvaset merged 3 commits intomainfrom
feature/sub-expression-detailed-tracing-

Conversation

@c-schuler
Copy link
Copy Markdown
Contributor

Add EnableDetailedTracing engine option that captures every sub-expression's result in the trace tree. When enabled, visitExpression() wraps each non-filtered expression evaluation with sub-expression frame push/pop, producing a full trace of intermediate computations. A configurable filter skips trivial leaf nodes (Literal, Null, OperandRef, etc.) by default.

  • Add EnableDetailedTracing to CqlEngine.Options with auto-implication of EnableTracing
  • Add subExpressionStack, currentTraceParent, traceExpressionFilter, and isTracingEnabled to State
  • Hook EvaluationVisitor.visitExpression() to push/pop sub-expression frames when detailed tracing is active
  • Create SubExpressionTraceFrame for rendering sub-expression trace output with ELM node type, source locator, and result
  • Update Trace and ExpressionDefTraceFrame to support detailed mode and List return type
  • Fix CachingModelResolverDecorator null value bug in getContextPath(), resolveType(String), and resolveType(Any) where getOrPut could insert null into ConcurrentHashMap

I have actually built this locally to test out in a measure evaluation stack. Here is an example of what the detailed tracing logs look like:

{
  "library": "NHSNGlycemicControlHypoglycemicInitialPopulation",
  "libraryVersion": "0.0.002",
  "expressionName": "Antidiabetic Drugs Administered or Ordered",
  "locator": "60:1-67:3",
  "context": "nhsn-iip-ip101",
  "result": "[MedicationRequest/nhsn-iip-add101, MedicationRequest/nhsn-iip-add101-10]",
  "children": [
    {
      "library": "NHSNGlycemicControlHypoglycemicInitialPopulation",
      "libraryVersion": "0.0.002",
      "nodeType": "Union",
      "locator": "61:3-67:3",
      "context": "nhsn-iip-ip101",
      "result": "[MedicationRequest/nhsn-iip-add101, MedicationRequest/nhsn-iip-add101-10]",
      "children": [
        {
          "library": "NHSNGlycemicControlHypoglycemicInitialPopulation",
          "libraryVersion": "0.0.002",
          "nodeType": "As",
          "context": "nhsn-iip-ip101",
          "result": "[]",
          "children": [
            {
              "library": "NHSNGlycemicControlHypoglycemicInitialPopulation",
              "libraryVersion": "0.0.002",
              "nodeType": "Query",
              "locator": "61:3-63:43",
              "context": "nhsn-iip-ip101",
              "result": "[]",
              "children": [
                {
                  "library": "NHSNGlycemicControlHypoglycemicInitialPopulation",
                  "libraryVersion": "0.0.002",
                  "nodeType": "Retrieve",
                  "locator": "61:4-61:29",
                  "context": "nhsn-iip-ip101",
                  "result": "[]",
                  "children": [
                    {
                      "library": "NHSNGlycemicControlHypoglycemicInitialPopulation",
                      "libraryVersion": "0.0.002",
                      "nodeType": "Retrieve",
                      "locator": "61:4-61:29",
                      "context": "nhsn-iip-ip101",
                      "result": "null"
                    }
                  ]
                }
              ]
            }
          ]
        }
... Snipped

…rDecorator null cache bug

Add EnableDetailedTracing engine option that captures every sub-expression's result in the trace tree. When enabled, visitExpression() wraps each non-filtered expression evaluation with sub-expression frame push/pop, producing a full trace of intermediate computations. A configurable filter skips trivial leaf nodes (Literal, Null, OperandRef, etc.) by default.
@c-schuler c-schuler requested a review from antvaset March 4, 2026 16:42
@c-schuler c-schuler self-assigned this Mar 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 4, 2026

Formatting check succeeded!

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.97%. Comparing base (23b9678) to head (30752c1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1696   +/-   ##
=========================================
  Coverage     61.97%   61.97%           
  Complexity     3940     3940           
=========================================
  Files           210      210           
  Lines         20366    20366           
  Branches       3879     3879           
=========================================
  Hits          12621    12621           
  Misses         6138     6138           
  Partials       1607     1607           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 4, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@c-schuler
Copy link
Copy Markdown
Contributor Author

I have added tests - so surely not 0% coverage on new code. I believe the issue is that the cql.kotlin-multiplatform-conventions plugin (used by the engine module) does not include JaCoCo. Only cql.kotlin-conventions does. So the engine's jvmTest runs without the JaCoCo agent, producing no coverage data for SonarQube.

Addressing that is outside the scope of this PR

@antvaset antvaset merged commit 4021315 into main Mar 4, 2026
8 of 9 checks passed
@antvaset antvaset deleted the feature/sub-expression-detailed-tracing- branch March 4, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants