[#189] Add Soroban core metrics and config settings snapshot models#204
[#189] Add Soroban core metrics and config settings snapshot models#204PoojaDoctor wants to merge 3 commits intomasterfrom
Conversation
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>
There was a problem hiding this comment.
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_metricsincremental model + schema tests/docs to flattencore_metricsdiagnostic events. - Adds
config_settings_snapshotmodel + schema tests/docs to unpivot config settings into a historical snapshot table enriched by a mapping seed. - Adds
config_setting_to_metrics_mappingseed and configures its dataset indbt_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.
| , 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' |
There was a problem hiding this comment.
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.
| , 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' |
| ,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 |
There was a problem hiding this comment.
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.
| 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 |
| @@ -0,0 +1,21 @@ | |||
| [comment]: < Soroban Core Metrics - | |||
There was a problem hiding this comment.
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.
| [comment]: < Soroban Core Metrics - | |
| [comment]: <> (Soroban Core Metrics -) |
| 'batch_insert_ts', | ||
| 'ledger_sequence', | ||
| 'bucket_list_size_window', | ||
| 'closed_at', | ||
| 'airflow_start_ts' | ||
| ] %} |
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
soroban_core_metricsincremental model that pre-parsescore_metricsdiagnostic contract events, enabling efficient Soroban network utilization queries without full table scans and JSON parsingconfig_settings_snapshottable model with SCD2 history of network config settings, enriched with metric mapping seed for utilization analysisconfig_setting_to_metrics_mappingseed mapping config setting names to core metrics, grain, and utilization relevanceCloses #189
Test plan
soroban_core_metricsincremental logic filters correctly bybatch_start_date/batch_end_datewith partition pruningconfig_settings_snapshotcorrectly unpivots all config settings and applies SCD2 logiccore_metric,grain,is_resource_utilization_relevent,pretty_config_namedbt testto confirm uniqueness, not_null, and accepted_values constraints pass🤖 Generated with Claude Code