Skip to content

improve(go.d/sql): add per-query execution time charts#21313

Merged
ilyam8 merged 1 commit intonetdata:masterfrom
ilyam8:go.d-sql-per-query-exec-time-chart
Nov 17, 2025
Merged

improve(go.d/sql): add per-query execution time charts#21313
ilyam8 merged 1 commit intonetdata:masterfrom
ilyam8:go.d-sql-per-query-exec-time-chart

Conversation

@ilyam8
Copy link
Member

@ilyam8 ilyam8 commented Nov 17, 2025

Summary

This PR adds query execution time charts to the generic SQL collector.

Every SQL query now exposes its own timing metric so users can understand the performance characteristics of their database queries.

Test Plan
Additional Information
For users: How does this change affect me?

Summary by cubic

Adds per-query execution time charts to the SQL collector, exposing a “duration” metric per query to help spot slow statements. Also updates chart metadata and connection handling.

  • New Features

    • Per-query timing charts (ms) for reusable and inline metric queries.
    • One chart per query_id with driver/query_id labels and a single “duration” dimension.
    • Timing metrics emitted via collectQueryTimingMetrics using buildTimingChartIDFromQueryID.
  • Refactors

    • Renamed buildChartID to buildMetricChartID; added createMetricBlockChart with updated context and labels.
    • Split chart priorities; chart context now sql._.
    • openConnection(ctx) with PingContext respecting Timeout; conn max lifetime set to 10m.
    • Renamed QueryRowsCache to queryRowsCache; removed unused skipValues.
    • Fixed MySQL DSN link in metadata.

Written for commit 1bc9ca0. Summary will update automatically on new commits.

@ilyam8 ilyam8 requested a review from Copilot November 17, 2025 20:00
@github-actions github-actions bot added area/collectors Everything related to data collection collectors/go.d area/metadata Integrations metadata area/go labels Nov 17, 2025
@ilyam8 ilyam8 changed the title improve(go.d/sql)add per-query execution time charts improve(go.d/sql): add per-query execution time charts Nov 17, 2025
@ilyam8 ilyam8 force-pushed the go.d-sql-per-query-exec-time-chart branch from 05b41f2 to 1bc9ca0 Compare November 17, 2025 20:01
Copy link
Contributor

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

This PR adds per-query execution time charts to the SQL collector, enabling users to monitor the performance characteristics of their database queries. Each SQL query now exposes its own timing metric measured in milliseconds.

  • Adds timing metric collection for both reusable queries and metric-block inline queries
  • Introduces dedicated query timing charts with driver and query_id labels
  • Refactors type and function names for better consistency and encapsulation

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/go/plugin/go.d/collector/sql/query.go Renamed QueryRowsCache to unexported queryRowsCache for better encapsulation; removed unnecessary zero-duration assignment for query references
src/go/plugin/go.d/collector/sql/collect.go Added collectQueryTimingMetrics function to collect and expose query execution times; updated openConnection to accept context parameter; renamed chart building functions for clarity
src/go/plugin/go.d/collector/sql/charts.go Added createQueryTimingChart function to create per-query timing charts; updated priority constants and chart labels to include driver information
src/go/plugin/go.d/collector/sql/collector.go Removed unused skipValues field from Collector struct
src/go/plugin/go.d/collector/sql/metadata.yaml Fixed malformed markdown link by removing extra opening parenthesis in DSN parameter documentation

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

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 5 files

@ilyam8 ilyam8 merged commit fc1dc39 into netdata:master Nov 17, 2025
116 checks passed
@ilyam8 ilyam8 deleted the go.d-sql-per-query-exec-time-chart branch November 17, 2025 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/collectors Everything related to data collection area/go area/metadata Integrations metadata collectors/go.d

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants