diff --git a/receiver/mysqlreceiver/internal/metadata/generated_metrics_test.go b/receiver/mysqlreceiver/internal/metadata/generated_metrics_test.go index 67710d46b791..40d296ee3e5c 100644 --- a/receiver/mysqlreceiver/internal/metadata/generated_metrics_test.go +++ b/receiver/mysqlreceiver/internal/metadata/generated_metrics_test.go @@ -185,6 +185,10 @@ func TestMetricsBuilder(t *testing.T) { allMetricsCount++ mb.RecordMysqlStatementEventCountDataPoint(ts, 1, "schema-val", "digest-val", "digest_text-val", AttributeEventStateErrors) + defaultMetricsCount++ + allMetricsCount++ + mb.RecordMysqlStatementEventCountStarsDataPoint(ts, 1, "schema-val", "digest-val", "digest_text-val") + defaultMetricsCount++ allMetricsCount++ mb.RecordMysqlStatementEventWaitTimeDataPoint(ts, 1, "schema-val", "digest-val", "digest_text-val") @@ -804,6 +808,29 @@ func TestMetricsBuilder(t *testing.T) { attrVal, ok = dp.Attributes().Get("kind") assert.True(t, ok) assert.EqualValues(t, "errors", attrVal.Str()) + case "mysql.statement_event.count_stars": + assert.False(t, validatedMetrics["mysql.statement_event.count_stars"], "Found a duplicate in the metrics slice: mysql.statement_event.count_stars") + validatedMetrics["mysql.statement_event.count_stars"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The total count of executed queries per normalized query and schema.", ms.At(i).Description()) + assert.Equal(t, "1", ms.At(i).Unit()) + assert.Equal(t, false, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("schema") + assert.True(t, ok) + assert.EqualValues(t, "schema-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("digest") + assert.True(t, ok) + assert.EqualValues(t, "digest-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("digest_text") + assert.True(t, ok) + assert.EqualValues(t, "digest_text-val", attrVal.Str()) case "mysql.statement_event.wait.time": assert.False(t, validatedMetrics["mysql.statement_event.wait.time"], "Found a duplicate in the metrics slice: mysql.statement_event.wait.time") validatedMetrics["mysql.statement_event.wait.time"] = true diff --git a/receiver/mysqlreceiver/internal/metadata/testdata/config.yaml b/receiver/mysqlreceiver/internal/metadata/testdata/config.yaml index 089ba32fc149..06a7550ec839 100644 --- a/receiver/mysqlreceiver/internal/metadata/testdata/config.yaml +++ b/receiver/mysqlreceiver/internal/metadata/testdata/config.yaml @@ -65,6 +65,8 @@ all_set: enabled: true mysql.statement_event.count: enabled: true + mysql.statement_event.count_stars: + enabled: true mysql.statement_event.wait.time: enabled: true mysql.table.average_row_length: @@ -162,6 +164,8 @@ none_set: enabled: false mysql.statement_event.count: enabled: false + mysql.statement_event.count_stars: + enabled: false mysql.statement_event.wait.time: enabled: false mysql.table.average_row_length: diff --git a/receiver/mysqlreceiver/metadata.yaml b/receiver/mysqlreceiver/metadata.yaml index ba0a9e50c194..89bb02fe6886 100644 --- a/receiver/mysqlreceiver/metadata.yaml +++ b/receiver/mysqlreceiver/metadata.yaml @@ -554,6 +554,15 @@ metrics: monotonic: false aggregation_temporality: cumulative attributes: [schema, digest, digest_text, event_state] + mysql.statement_event.count_stars: + enabled: true + description: The total count of executed queries per normalized query and schema. + unit: 1 + sum: + value_type: int + monotonic: false + aggregation_temporality: cumulative + attributes: [schema, digest, digest_text] mysql.statement_event.wait.time: enabled: true description: The total wait time of the summarized timed events. diff --git a/receiver/mysqlreceiver/scraper.go b/receiver/mysqlreceiver/scraper.go index 139233fc37b2..f842d70fbb68 100644 --- a/receiver/mysqlreceiver/scraper.go +++ b/receiver/mysqlreceiver/scraper.go @@ -518,6 +518,7 @@ func (m *mySQLScraper) scrapeStatementEventsStats(now pcommon.Timestamp, errs *s m.mb.RecordMysqlStatementEventCountDataPoint(now, s.countSortRows, s.schema, s.digest, s.digestText, metadata.AttributeEventStateSortRows) m.mb.RecordMysqlStatementEventCountDataPoint(now, s.countWarnings, s.schema, s.digest, s.digestText, metadata.AttributeEventStateWarnings) + m.mb.RecordMysqlStatementEventCountStarsDataPoint(now, s.countStar, s.schema, s.digest, s.digestText) m.mb.RecordMysqlStatementEventWaitTimeDataPoint(now, s.sumTimerWait/picosecondsInNanoseconds, s.schema, s.digest, s.digestText) } }