diff --git a/.chloggen/smaller_numbers.yaml b/.chloggen/smaller_numbers.yaml new file mode 100644 index 000000000000..dc5e3b6c5b68 --- /dev/null +++ b/.chloggen/smaller_numbers.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: mysqlreceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Divide large values directly in SQL queries to avoid int overflows + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [35495] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/receiver/mysqlreceiver/client.go b/receiver/mysqlreceiver/client.go index 9e939d299533..977441809c0d 100644 --- a/receiver/mysqlreceiver/client.go +++ b/receiver/mysqlreceiver/client.go @@ -292,7 +292,7 @@ func (c *mySQLClient) getTableStats() ([]TableStats, error) { func (c *mySQLClient) getTableIoWaitsStats() ([]TableIoWaitsStats, error) { query := "SELECT OBJECT_SCHEMA, OBJECT_NAME, " + "COUNT_DELETE, COUNT_FETCH, COUNT_INSERT, COUNT_UPDATE," + - "SUM_TIMER_DELETE, SUM_TIMER_FETCH, SUM_TIMER_INSERT, SUM_TIMER_UPDATE " + + "SUM_TIMER_DELETE/1000, SUM_TIMER_FETCH/1000, SUM_TIMER_INSERT/1000, SUM_TIMER_UPDATE/1000 " + "FROM performance_schema.table_io_waits_summary_by_table " + "WHERE OBJECT_SCHEMA NOT IN ('mysql', 'performance_schema');" rows, err := c.client.Query(query) @@ -319,7 +319,7 @@ func (c *mySQLClient) getTableIoWaitsStats() ([]TableIoWaitsStats, error) { func (c *mySQLClient) getIndexIoWaitsStats() ([]IndexIoWaitsStats, error) { query := "SELECT OBJECT_SCHEMA, OBJECT_NAME, ifnull(INDEX_NAME, 'NONE') as INDEX_NAME," + "COUNT_FETCH, COUNT_INSERT, COUNT_UPDATE, COUNT_DELETE," + - "SUM_TIMER_FETCH, SUM_TIMER_INSERT, SUM_TIMER_UPDATE, SUM_TIMER_DELETE " + + "SUM_TIMER_FETCH/1000, SUM_TIMER_INSERT/1000, SUM_TIMER_UPDATE/1000, SUM_TIMER_DELETE/1000 " + "FROM performance_schema.table_io_waits_summary_by_index_usage " + "WHERE OBJECT_SCHEMA NOT IN ('mysql', 'performance_schema');" @@ -345,7 +345,7 @@ func (c *mySQLClient) getIndexIoWaitsStats() ([]IndexIoWaitsStats, error) { func (c *mySQLClient) getStatementEventsStats() ([]StatementEventStats, error) { query := fmt.Sprintf("SELECT ifnull(SCHEMA_NAME, 'NONE') as SCHEMA_NAME, DIGEST,"+ - "LEFT(DIGEST_TEXT, %d) as DIGEST_TEXT, SUM_TIMER_WAIT, SUM_ERRORS,"+ + "LEFT(DIGEST_TEXT, %d) as DIGEST_TEXT, SUM_TIMER_WAIT/1000, 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 "+ @@ -384,10 +384,10 @@ func (c *mySQLClient) getTableLockWaitEventStats() ([]tableLockWaitEventStats, e query := "SELECT OBJECT_SCHEMA, OBJECT_NAME, COUNT_READ_NORMAL, COUNT_READ_WITH_SHARED_LOCKS," + "COUNT_READ_HIGH_PRIORITY, COUNT_READ_NO_INSERT, COUNT_READ_EXTERNAL, COUNT_WRITE_ALLOW_WRITE," + "COUNT_WRITE_CONCURRENT_INSERT, COUNT_WRITE_LOW_PRIORITY, COUNT_WRITE_NORMAL," + - "COUNT_WRITE_EXTERNAL, SUM_TIMER_READ_NORMAL, SUM_TIMER_READ_WITH_SHARED_LOCKS," + - "SUM_TIMER_READ_HIGH_PRIORITY, SUM_TIMER_READ_NO_INSERT, SUM_TIMER_READ_EXTERNAL," + - "SUM_TIMER_WRITE_ALLOW_WRITE, SUM_TIMER_WRITE_CONCURRENT_INSERT, SUM_TIMER_WRITE_LOW_PRIORITY," + - "SUM_TIMER_WRITE_NORMAL, SUM_TIMER_WRITE_EXTERNAL " + + "COUNT_WRITE_EXTERNAL, SUM_TIMER_READ_NORMAL/1000, SUM_TIMER_READ_WITH_SHARED_LOCKS/1000," + + "SUM_TIMER_READ_HIGH_PRIORITY/1000, SUM_TIMER_READ_NO_INSERT/1000, SUM_TIMER_READ_EXTERNAL/1000," + + "SUM_TIMER_WRITE_ALLOW_WRITE/1000, SUM_TIMER_WRITE_CONCURRENT_INSERT/1000, SUM_TIMER_WRITE_LOW_PRIORITY/1000," + + "SUM_TIMER_WRITE_NORMAL/1000, SUM_TIMER_WRITE_EXTERNAL/1000 " + "FROM performance_schema.table_lock_waits_summary_by_table " + "WHERE OBJECT_SCHEMA NOT IN ('mysql', 'performance_schema', 'information_schema')" diff --git a/receiver/mysqlreceiver/scraper.go b/receiver/mysqlreceiver/scraper.go index 18afa4080d28..d81eada662c1 100644 --- a/receiver/mysqlreceiver/scraper.go +++ b/receiver/mysqlreceiver/scraper.go @@ -19,10 +19,6 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mysqlreceiver/internal/metadata" ) -const ( - picosecondsInNanoseconds int64 = 1000 -) - type mySQLScraper struct { sqlclient client logger *zap.Logger @@ -451,16 +447,16 @@ func (m *mySQLScraper) scrapeTableIoWaitsStats(now pcommon.Timestamp, errs *scra // times m.mb.RecordMysqlTableIoWaitTimeDataPoint( - now, s.timeDelete/picosecondsInNanoseconds, metadata.AttributeIoWaitsOperationsDelete, s.name, s.schema, + now, s.timeDelete, metadata.AttributeIoWaitsOperationsDelete, s.name, s.schema, ) m.mb.RecordMysqlTableIoWaitTimeDataPoint( - now, s.timeFetch/picosecondsInNanoseconds, metadata.AttributeIoWaitsOperationsFetch, s.name, s.schema, + now, s.timeFetch, metadata.AttributeIoWaitsOperationsFetch, s.name, s.schema, ) m.mb.RecordMysqlTableIoWaitTimeDataPoint( - now, s.timeInsert/picosecondsInNanoseconds, metadata.AttributeIoWaitsOperationsInsert, s.name, s.schema, + now, s.timeInsert, metadata.AttributeIoWaitsOperationsInsert, s.name, s.schema, ) m.mb.RecordMysqlTableIoWaitTimeDataPoint( - now, s.timeUpdate/picosecondsInNanoseconds, metadata.AttributeIoWaitsOperationsUpdate, s.name, s.schema, + now, s.timeUpdate, metadata.AttributeIoWaitsOperationsUpdate, s.name, s.schema, ) } } @@ -483,16 +479,16 @@ func (m *mySQLScraper) scrapeIndexIoWaitsStats(now pcommon.Timestamp, errs *scra // times m.mb.RecordMysqlIndexIoWaitTimeDataPoint( - now, s.timeDelete/picosecondsInNanoseconds, metadata.AttributeIoWaitsOperationsDelete, s.name, s.schema, s.index, + now, s.timeDelete, metadata.AttributeIoWaitsOperationsDelete, s.name, s.schema, s.index, ) m.mb.RecordMysqlIndexIoWaitTimeDataPoint( - now, s.timeFetch/picosecondsInNanoseconds, metadata.AttributeIoWaitsOperationsFetch, s.name, s.schema, s.index, + now, s.timeFetch, metadata.AttributeIoWaitsOperationsFetch, s.name, s.schema, s.index, ) m.mb.RecordMysqlIndexIoWaitTimeDataPoint( - now, s.timeInsert/picosecondsInNanoseconds, metadata.AttributeIoWaitsOperationsInsert, s.name, s.schema, s.index, + now, s.timeInsert, metadata.AttributeIoWaitsOperationsInsert, s.name, s.schema, s.index, ) m.mb.RecordMysqlIndexIoWaitTimeDataPoint( - now, s.timeUpdate/picosecondsInNanoseconds, metadata.AttributeIoWaitsOperationsUpdate, s.name, s.schema, s.index, + now, s.timeUpdate, metadata.AttributeIoWaitsOperationsUpdate, s.name, s.schema, s.index, ) } } @@ -518,7 +514,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.RecordMysqlStatementEventWaitTimeDataPoint(now, s.sumTimerWait/picosecondsInNanoseconds, s.schema, s.digest, s.digestText) + m.mb.RecordMysqlStatementEventWaitTimeDataPoint(now, s.sumTimerWait, s.schema, s.digest, s.digestText) } } @@ -540,11 +536,11 @@ func (m *mySQLScraper) scrapeTableLockWaitEventStats(now pcommon.Timestamp, errs m.mb.RecordMysqlTableLockWaitReadCountDataPoint(now, s.countReadExternal, s.schema, s.name, metadata.AttributeReadLockTypeExternal) // read time data points - m.mb.RecordMysqlTableLockWaitReadTimeDataPoint(now, s.sumTimerReadNormal/picosecondsInNanoseconds, s.schema, s.name, metadata.AttributeReadLockTypeNormal) - m.mb.RecordMysqlTableLockWaitReadTimeDataPoint(now, s.sumTimerReadWithSharedLocks/picosecondsInNanoseconds, s.schema, s.name, metadata.AttributeReadLockTypeWithSharedLocks) - m.mb.RecordMysqlTableLockWaitReadTimeDataPoint(now, s.sumTimerReadHighPriority/picosecondsInNanoseconds, s.schema, s.name, metadata.AttributeReadLockTypeHighPriority) - m.mb.RecordMysqlTableLockWaitReadTimeDataPoint(now, s.sumTimerReadNoInsert/picosecondsInNanoseconds, s.schema, s.name, metadata.AttributeReadLockTypeNoInsert) - m.mb.RecordMysqlTableLockWaitReadTimeDataPoint(now, s.sumTimerReadExternal/picosecondsInNanoseconds, s.schema, s.name, metadata.AttributeReadLockTypeExternal) + m.mb.RecordMysqlTableLockWaitReadTimeDataPoint(now, s.sumTimerReadNormal, s.schema, s.name, metadata.AttributeReadLockTypeNormal) + m.mb.RecordMysqlTableLockWaitReadTimeDataPoint(now, s.sumTimerReadWithSharedLocks, s.schema, s.name, metadata.AttributeReadLockTypeWithSharedLocks) + m.mb.RecordMysqlTableLockWaitReadTimeDataPoint(now, s.sumTimerReadHighPriority, s.schema, s.name, metadata.AttributeReadLockTypeHighPriority) + m.mb.RecordMysqlTableLockWaitReadTimeDataPoint(now, s.sumTimerReadNoInsert, s.schema, s.name, metadata.AttributeReadLockTypeNoInsert) + m.mb.RecordMysqlTableLockWaitReadTimeDataPoint(now, s.sumTimerReadExternal, s.schema, s.name, metadata.AttributeReadLockTypeExternal) // write data points m.mb.RecordMysqlTableLockWaitWriteCountDataPoint(now, s.countWriteAllowWrite, s.schema, s.name, metadata.AttributeWriteLockTypeAllowWrite) @@ -554,11 +550,11 @@ func (m *mySQLScraper) scrapeTableLockWaitEventStats(now pcommon.Timestamp, errs m.mb.RecordMysqlTableLockWaitWriteCountDataPoint(now, s.countWriteExternal, s.schema, s.name, metadata.AttributeWriteLockTypeExternal) // write time data points - m.mb.RecordMysqlTableLockWaitWriteTimeDataPoint(now, s.sumTimerWriteAllowWrite/picosecondsInNanoseconds, s.schema, s.name, metadata.AttributeWriteLockTypeAllowWrite) - m.mb.RecordMysqlTableLockWaitWriteTimeDataPoint(now, s.sumTimerWriteConcurrentInsert/picosecondsInNanoseconds, s.schema, s.name, metadata.AttributeWriteLockTypeConcurrentInsert) - m.mb.RecordMysqlTableLockWaitWriteTimeDataPoint(now, s.sumTimerWriteLowPriority/picosecondsInNanoseconds, s.schema, s.name, metadata.AttributeWriteLockTypeLowPriority) - m.mb.RecordMysqlTableLockWaitWriteTimeDataPoint(now, s.sumTimerWriteNormal/picosecondsInNanoseconds, s.schema, s.name, metadata.AttributeWriteLockTypeNormal) - m.mb.RecordMysqlTableLockWaitWriteTimeDataPoint(now, s.sumTimerWriteExternal/picosecondsInNanoseconds, s.schema, s.name, metadata.AttributeWriteLockTypeExternal) + m.mb.RecordMysqlTableLockWaitWriteTimeDataPoint(now, s.sumTimerWriteAllowWrite, s.schema, s.name, metadata.AttributeWriteLockTypeAllowWrite) + m.mb.RecordMysqlTableLockWaitWriteTimeDataPoint(now, s.sumTimerWriteConcurrentInsert, s.schema, s.name, metadata.AttributeWriteLockTypeConcurrentInsert) + m.mb.RecordMysqlTableLockWaitWriteTimeDataPoint(now, s.sumTimerWriteLowPriority, s.schema, s.name, metadata.AttributeWriteLockTypeLowPriority) + m.mb.RecordMysqlTableLockWaitWriteTimeDataPoint(now, s.sumTimerWriteNormal, s.schema, s.name, metadata.AttributeWriteLockTypeNormal) + m.mb.RecordMysqlTableLockWaitWriteTimeDataPoint(now, s.sumTimerWriteExternal, s.schema, s.name, metadata.AttributeWriteLockTypeExternal) } } diff --git a/receiver/mysqlreceiver/testdata/scraper/index_io_waits_stats.txt b/receiver/mysqlreceiver/testdata/scraper/index_io_waits_stats.txt index a9a654474d05..fd99d80c50b9 100644 --- a/receiver/mysqlreceiver/testdata/scraper/index_io_waits_stats.txt +++ b/receiver/mysqlreceiver/testdata/scraper/index_io_waits_stats.txt @@ -1 +1 @@ -a_schema a_table an_index 9 10 11 12 13000 14000 15000 16000 +a_schema a_table an_index 9 10 11 12 13 14 15 16 diff --git a/receiver/mysqlreceiver/testdata/scraper/statement_events.txt b/receiver/mysqlreceiver/testdata/scraper/statement_events.txt index fd49b0d4058e..333e8cdb4caf 100644 --- a/receiver/mysqlreceiver/testdata/scraper/statement_events.txt +++ b/receiver/mysqlreceiver/testdata/scraper/statement_events.txt @@ -1 +1 @@ -otel 070e38632eb4444e50cdcbf0b17474ba801e203add89783a24584951442a2317 SHOW GLOBAL STATUS 2000 3 4 5 6 7 8 9 10 11 12 +otel 070e38632eb4444e50cdcbf0b17474ba801e203add89783a24584951442a2317 SHOW GLOBAL STATUS 2 3 4 5 6 7 8 9 10 11 12 diff --git a/receiver/mysqlreceiver/testdata/scraper/table_io_waits_stats.txt b/receiver/mysqlreceiver/testdata/scraper/table_io_waits_stats.txt index 4cd424c899e1..bd3e3a96b9ac 100644 --- a/receiver/mysqlreceiver/testdata/scraper/table_io_waits_stats.txt +++ b/receiver/mysqlreceiver/testdata/scraper/table_io_waits_stats.txt @@ -1 +1 @@ -a_schema a_table 1 2 3 4 5000 6000 7000 8000 +a_schema a_table 1 2 3 4 5 6 7 8 diff --git a/receiver/mysqlreceiver/testdata/scraper/table_lock_wait_event_stats.txt b/receiver/mysqlreceiver/testdata/scraper/table_lock_wait_event_stats.txt index 926cd4d84cca..c14beb199dea 100644 --- a/receiver/mysqlreceiver/testdata/scraper/table_lock_wait_event_stats.txt +++ b/receiver/mysqlreceiver/testdata/scraper/table_lock_wait_event_stats.txt @@ -1 +1 @@ -otel otel 0 1 2 3 4 5 6 7 8 9 10000 11000 12000 13000 14000 15000 16000 17000 18000 19000 +otel otel 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19