diff --git a/receiver/mysqlreceiver/client.go b/receiver/mysqlreceiver/client.go index 9e939d299533..680d5dc70308 100644 --- a/receiver/mysqlreceiver/client.go +++ b/receiver/mysqlreceiver/client.go @@ -83,6 +83,7 @@ type StatementEventStats struct { countSortMergePasses int64 countSortRows int64 countNoIndexUsed int64 + countStar int64 } type tableLockWaitEventStats struct { @@ -348,7 +349,7 @@ func (c *mySQLClient) getStatementEventsStats() ([]StatementEventStats, error) { "LEFT(DIGEST_TEXT, %d) as DIGEST_TEXT, SUM_TIMER_WAIT, SUM_ERRORS,"+ "SUM_WARNINGS, SUM_ROWS_AFFECTED, SUM_ROWS_SENT, SUM_ROWS_EXAMINED,"+ "SUM_CREATED_TMP_DISK_TABLES, SUM_CREATED_TMP_TABLES, SUM_SORT_MERGE_PASSES,"+ - "SUM_SORT_ROWS, SUM_NO_INDEX_USED "+ + "SUM_SORT_ROWS, SUM_NO_INDEX_USED , COUNT_STAR "+ "FROM performance_schema.events_statements_summary_by_digest "+ "WHERE SCHEMA_NAME NOT IN ('mysql', 'performance_schema', 'information_schema') "+ "AND last_seen > DATE_SUB(NOW(), INTERVAL %d SECOND) "+ @@ -360,6 +361,7 @@ func (c *mySQLClient) getStatementEventsStats() ([]StatementEventStats, error) { rows, err := c.client.Query(query) if err != nil { + fmt.Println(err.Error()) return nil, err } defer rows.Close() @@ -370,13 +372,12 @@ func (c *mySQLClient) getStatementEventsStats() ([]StatementEventStats, error) { err := rows.Scan(&s.schema, &s.digest, &s.digestText, &s.sumTimerWait, &s.countErrors, &s.countWarnings, &s.countRowsAffected, &s.countRowsSent, &s.countRowsExamined, &s.countCreatedTmpDiskTables, - &s.countCreatedTmpTables, &s.countSortMergePasses, &s.countSortRows, &s.countNoIndexUsed) + &s.countCreatedTmpTables, &s.countSortMergePasses, &s.countSortRows, &s.countNoIndexUsed, &s.countStar) if err != nil { return nil, err } stats = append(stats, s) } - return stats, nil } diff --git a/receiver/mysqlreceiver/config.go b/receiver/mysqlreceiver/config.go index a6e6ab6320a8..ad7e7a0c8da4 100644 --- a/receiver/mysqlreceiver/config.go +++ b/receiver/mysqlreceiver/config.go @@ -4,6 +4,7 @@ package mysqlreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mysqlreceiver" import ( + "math" "time" "go.opentelemetry.io/collector/config/confignet" @@ -18,7 +19,7 @@ import ( const ( defaultStatementEventsDigestTextLimit = 120 defaultStatementEventsLimit = 250 - defaultStatementEventsTimeLimit = 24 * time.Hour + defaultStatementEventsTimeLimit = time.Duration(math.MaxInt64) ) type Config struct { diff --git a/receiver/mysqlreceiver/internal/metadata/generated_config.go b/receiver/mysqlreceiver/internal/metadata/generated_config.go index 90d5e9058eb4..9340cd8486fc 100644 --- a/receiver/mysqlreceiver/internal/metadata/generated_config.go +++ b/receiver/mysqlreceiver/internal/metadata/generated_config.go @@ -172,10 +172,10 @@ func DefaultMetricsConfig() MetricsConfig { Enabled: true, }, MysqlStatementEventCount: MetricConfig{ - Enabled: false, + Enabled: true, }, MysqlStatementEventWaitTime: MetricConfig{ - Enabled: false, + Enabled: true, }, MysqlTableAverageRowLength: MetricConfig{ Enabled: false, diff --git a/receiver/mysqlreceiver/internal/metadata/generated_metrics.go b/receiver/mysqlreceiver/internal/metadata/generated_metrics.go index 370b47b5a7f5..d2cdae35a3c3 100644 --- a/receiver/mysqlreceiver/internal/metadata/generated_metrics.go +++ b/receiver/mysqlreceiver/internal/metadata/generated_metrics.go @@ -2711,7 +2711,7 @@ func (m *metricMysqlStatementEventWaitTime) init() { m.data.SetDescription("The total wait time of the summarized timed events.") m.data.SetUnit("ns") m.data.SetEmptySum() - m.data.Sum().SetIsMonotonic(false) + m.data.Sum().SetIsMonotonic(true) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } diff --git a/receiver/mysqlreceiver/internal/metadata/generated_metrics_test.go b/receiver/mysqlreceiver/internal/metadata/generated_metrics_test.go index 09e4c8474a26..67710d46b791 100644 --- a/receiver/mysqlreceiver/internal/metadata/generated_metrics_test.go +++ b/receiver/mysqlreceiver/internal/metadata/generated_metrics_test.go @@ -181,9 +181,11 @@ func TestMetricsBuilder(t *testing.T) { allMetricsCount++ mb.RecordMysqlSortsDataPoint(ts, "1", AttributeSortsMergePasses) + defaultMetricsCount++ allMetricsCount++ mb.RecordMysqlStatementEventCountDataPoint(ts, 1, "schema-val", "digest-val", "digest_text-val", AttributeEventStateErrors) + defaultMetricsCount++ allMetricsCount++ mb.RecordMysqlStatementEventWaitTimeDataPoint(ts, 1, "schema-val", "digest-val", "digest_text-val") diff --git a/receiver/mysqlreceiver/metadata.yaml b/receiver/mysqlreceiver/metadata.yaml index 9ad7bf97c98a..ba0a9e50c194 100644 --- a/receiver/mysqlreceiver/metadata.yaml +++ b/receiver/mysqlreceiver/metadata.yaml @@ -546,7 +546,7 @@ metrics: aggregation_temporality: cumulative attributes: [] mysql.statement_event.count: - enabled: false + enabled: true description: Summary of current and recent statement events. unit: "1" sum: @@ -555,7 +555,7 @@ metrics: aggregation_temporality: cumulative attributes: [schema, digest, digest_text, event_state] mysql.statement_event.wait.time: - enabled: false + enabled: true description: The total wait time of the summarized timed events. unit: ns sum: