-
Notifications
You must be signed in to change notification settings - Fork 20
track number of clickhouse insert operations #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
track number of clickhouse insert operations #236
Conversation
WalkthroughA new Prometheus counter metric was introduced to track the number of insert operations into ClickHouse main storage. The metrics update logic in the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ClickHouseConnector
participant Metrics
Client->>ClickHouseConnector: InsertBlockData(data)
loop For each batch in data
ClickHouseConnector->>ClickHouseConnector: Insert batch into ClickHouse
ClickHouseConnector->>Metrics: Increment RowsInserted by batch size
ClickHouseConnector->>Metrics: Increment InsertOperations by 1
end
ClickHouseConnector-->>Client: Return result
Possibly related PRs
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
internal/storage/clickhouse.go (1)
1361-1362
: LGTM: Proper per-batch metric tracking implementation.The metrics are correctly updated after successful batch operations:
ClickHouseMainStorageRowsInserted
tracks the exact number of rows in each batch (end - i
)ClickHouseMainStorageInsertOperations
increments once per batch operation- Updates occur after successful
batch.Send()
, ensuring accurate trackingThe mathematical logic is sound - summing batch sizes will equal the total rows processed.
Consider standardizing the metric update approach across all insert methods. Currently:
InsertBlockData
updates metrics per batch (new approach)insertTransactions
,insertLogs
,insertTraces
update metrics once at the end (lines 275, 338, 410)For consistency, you might want to either:
- Update other methods to use per-batch tracking for better granularity
- Or document why
InsertBlockData
requires different tracking granularity
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
internal/metrics/metrics.go
(1 hunks)internal/storage/clickhouse.go
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/storage/clickhouse.go (1)
internal/metrics/metrics.go (2)
ClickHouseMainStorageRowsInserted
(163-166)ClickHouseMainStorageInsertOperations
(158-161)
🔇 Additional comments (1)
internal/metrics/metrics.go (1)
158-161
: LGTM: Well-defined metric for tracking insert operations.The new Prometheus counter metric is properly defined with appropriate naming conventions and clear help text. It complements the existing row count metric by providing visibility into the number of distinct insert operations.
TL;DR
Added a new ClickHouse insert operations metric and fixed row count tracking.
What changed?
ClickHouseMainStorageInsertOperations
counter to track the total number of insert operations into ClickHouse main storageInsertBlockData
method to increment the row count metric within the batch processing loop instead of once at the endHow to test?
clickhouse_main_storage_insert_operations
metric is being reported in Prometheusclickhouse_main_storage_rows_inserted_total
now accurately reflects the actual number of rows inserted in batchesWhy make this change?
This change provides better visibility into ClickHouse database operations by tracking not just the total rows inserted but also the number of distinct insert operations. The previous implementation only counted rows at the end of the function, which could be inaccurate if the function processed data in batches. The new approach ensures metrics are incremented correctly for each batch processed.
Summary by CodeRabbit
New Features
Improvements