Skip to content

[#189] Add Soroban core metrics and config settings snapshot models#204

Open
PoojaDoctor wants to merge 3 commits intomasterfrom
soroban-utilization-table
Open

[#189] Add Soroban core metrics and config settings snapshot models#204
PoojaDoctor wants to merge 3 commits intomasterfrom
soroban-utilization-table

Conversation

@PoojaDoctor
Copy link
Copy Markdown
Contributor

Summary

  • Adds soroban_core_metrics incremental model that pre-parses core_metrics diagnostic contract events, enabling efficient Soroban network utilization queries without full table scans and JSON parsing
  • Adds config_settings_snapshot table model with SCD2 history of network config settings, enriched with metric mapping seed for utilization analysis
  • Adds config_setting_to_metrics_mapping seed mapping config setting names to core metrics, grain, and utilization relevance

Closes #189

Test plan

  • Verify soroban_core_metrics incremental logic filters correctly by batch_start_date/batch_end_date with partition pruning
  • Verify config_settings_snapshot correctly unpivots all config settings and applies SCD2 logic
  • Verify seed join enriches config settings with core_metric, grain, is_resource_utilization_relevent, pretty_config_name
  • Run dbt test to confirm uniqueness, not_null, and accepted_values constraints pass
  • Validate output matches reference utilization query against production tables

🤖 Generated with Claude Code

Add two new mart models for Soroban network utilization analysis:
- soroban_core_metrics: incremental model pre-parsing core_metrics
  contract events for efficient utilization queries
- config_settings_snapshot: table model with SCD2 history of network
  config settings enriched with metric mapping seed

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@PoojaDoctor PoojaDoctor requested a review from a team as a code owner March 4, 2026 00:07
Copilot AI review requested due to automatic review settings March 4, 2026 00:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds new Soroban-focused mart assets to support efficient network utilization analytics by pre-flattening diagnostic core_metrics events and tracking historical config limit changes over time.

Changes:

  • Introduces soroban_core_metrics incremental model + schema tests/docs to flatten core_metrics diagnostic events.
  • Adds config_settings_snapshot model + schema tests/docs to unpivot config settings into a historical snapshot table enriched by a mapping seed.
  • Adds config_setting_to_metrics_mapping seed and configures its dataset in dbt_project.yml.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
seeds/config_setting_to_metrics_mapping.csv New seed mapping config setting names to core metrics + metadata used for enrichment/utilization analysis.
models/marts/soroban/soroban_core_metrics.sql New incremental mart model to extract metric_key/metric_value from decoded contract events.
models/marts/soroban/soroban_core_metrics.yml Tests/docs configuration for soroban_core_metrics.
models/marts/soroban/config_settings_snapshot.sql New mart model to unpivot config settings and build SCD-like validity ranges, then enrich from seed mapping.
models/marts/soroban/config_settings_snapshot.yml Tests/docs configuration for config_settings_snapshot.
models/docs/marts/soroban/soroban_core_metrics.md New docs blocks for soroban_core_metrics and its key columns.
models/docs/marts/soroban/config_settings_snapshot.md New docs blocks for config_settings_snapshot and its key columns.
dbt_project.yml Configures the new seed’s dataset placement.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +24 to +28
, safe_cast(json_value(topics_decoded[1], '$.symbol') as string) as metric_key
, safe_cast(json_value(data_decoded, '$.u64') as int64) as metric_value
from {{ ref('stg_history_contract_events') }}
where
json_value(topics_decoded[0], '$.symbol') = 'core_metrics'
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

topics_decoded is being indexed as topics_decoded[0] / topics_decoded[1], which is not valid BigQuery array syntax and will fail to compile. Use topics_decoded[OFFSET(n)] or topics_decoded[SAFE_OFFSET(n)] (and then apply json_value) to safely access topic elements.

Suggested change
, safe_cast(json_value(topics_decoded[1], '$.symbol') as string) as metric_key
, safe_cast(json_value(data_decoded, '$.u64') as int64) as metric_value
from {{ ref('stg_history_contract_events') }}
where
json_value(topics_decoded[0], '$.symbol') = 'core_metrics'
, safe_cast(json_value(topics_decoded[OFFSET(1)], '$.symbol') as string) as metric_key
, safe_cast(json_value(data_decoded, '$.u64') as int64) as metric_value
from {{ ref('stg_history_contract_events') }}
where
json_value(topics_decoded[OFFSET(0)], '$.symbol') = 'core_metrics'

Copilot uses AI. Check for mistakes.
,bucket_list_size_window_sample_size,,,FALSE,FALSE,FALSE
Eviction Scan Size ,eviction_scan_size,,,FALSE,FALSE,TRUE
,starting_eviction_scan_level,,,FALSE,FALSE,FALSE
Soroban txn per ledger,ledger_max_tx_count,transaction_hash,ledger,TRUE,FALSE,TRUE
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

core_metric is documented/used as a Soroban core metric key (e.g., cpu_insn, mem_byte), but this row sets it to transaction_hash, which looks like a field name rather than a metric key. If there isn't a corresponding metric emitted in soroban_core_metrics.metric_key, this mapping will be incorrect/misleading for utilization analysis.

Suggested change
Soroban txn per ledger,ledger_max_tx_count,transaction_hash,ledger,TRUE,FALSE,TRUE
Soroban txn per ledger,ledger_max_tx_count,,ledger,TRUE,FALSE,TRUE

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,21 @@
[comment]: < Soroban Core Metrics -
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The markdown comment header appears to be malformed ([comment]: < Soroban Core Metrics -). Other docs in the repo use a closed > form; consider fixing this to avoid confusing or inconsistent generated docs rendering.

Suggested change
[comment]: < Soroban Core Metrics -
[comment]: <> (Soroban Core Metrics -)

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +25
'batch_insert_ts',
'ledger_sequence',
'bucket_list_size_window',
'closed_at',
'airflow_start_ts'
] %}
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bucket_list_size_window is excluded from the unpivot (excluded_cols) but it is still present in the mapping seed. This contradicts the PR goal of unpivoting all config settings and will leave unmapped seed rows / missing snapshot history for that setting; either include it with appropriate handling (it may be non-scalar) or remove it from the seed mapping.

Copilot uses AI. Check for mistakes.
PoojaDoctor and others added 2 commits March 4, 2026 10:47
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Normalize core_metrics events into a standalone Soroban utilization table

2 participants