Skip to content

Commit a80b114

Browse files
authored
[receiver/mysqlreceiver]: Unexport non-config structs from mysqlreceiver (#40719)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Unexport TableStats,TableIoWaitsStats,StatementEventStats,ReplicaStatusStats,IoWaitsStats,IndexIoWaitsStats,MySQLTestConfig structs <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes #40671
1 parent 6ef36d6 commit a80b114

File tree

4 files changed

+72
-45
lines changed

4 files changed

+72
-45
lines changed

.chloggen/unexport-mysql-structs.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: mysqlreceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Unexport TableStats,TableIoWaitsStats,StatementEventStats,ReplicaStatusStats,IoWaitsStats,IndexIoWaitsStats,MySQLTestConfig structs from mysqlreceiver
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [40671]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [api]

receiver/mysqlreceiver/client.go

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ type client interface {
2020
getVersion() (*version.Version, error)
2121
getGlobalStats() (map[string]string, error)
2222
getInnodbStats() (map[string]string, error)
23-
getTableStats() ([]TableStats, error)
24-
getTableIoWaitsStats() ([]TableIoWaitsStats, error)
25-
getIndexIoWaitsStats() ([]IndexIoWaitsStats, error)
26-
getStatementEventsStats() ([]StatementEventStats, error)
23+
getTableStats() ([]tableStats, error)
24+
getTableIoWaitsStats() ([]tableIoWaitsStats, error)
25+
getIndexIoWaitsStats() ([]indexIoWaitsStats, error)
26+
getStatementEventsStats() ([]statementEventStats, error)
2727
getTableLockWaitEventStats() ([]tableLockWaitEventStats, error)
28-
getReplicaStatusStats() ([]ReplicaStatusStats, error)
28+
getReplicaStatusStats() ([]replicaStatusStats, error)
2929
Close() error
3030
}
3131

@@ -37,7 +37,7 @@ type mySQLClient struct {
3737
statementEventsTimeLimit time.Duration
3838
}
3939

40-
type IoWaitsStats struct {
40+
type ioWaitsStats struct {
4141
schema string
4242
name string
4343
countDelete int64
@@ -50,16 +50,16 @@ type IoWaitsStats struct {
5050
timeUpdate int64
5151
}
5252

53-
type TableIoWaitsStats struct {
54-
IoWaitsStats
53+
type tableIoWaitsStats struct {
54+
ioWaitsStats
5555
}
5656

57-
type IndexIoWaitsStats struct {
58-
IoWaitsStats
57+
type indexIoWaitsStats struct {
58+
ioWaitsStats
5959
index string
6060
}
6161

62-
type TableStats struct {
62+
type tableStats struct {
6363
schema string
6464
name string
6565
rows int64
@@ -68,7 +68,7 @@ type TableStats struct {
6868
indexLength int64
6969
}
7070

71-
type StatementEventStats struct {
71+
type statementEventStats struct {
7272
schema string
7373
digest string
7474
digestText string
@@ -110,7 +110,7 @@ type tableLockWaitEventStats struct {
110110
sumTimerWriteExternal int64
111111
}
112112

113-
type ReplicaStatusStats struct {
113+
type replicaStatusStats struct {
114114
replicaIOState string
115115
sourceHost string
116116
sourceUser string
@@ -260,7 +260,7 @@ func (c *mySQLClient) getInnodbStats() (map[string]string, error) {
260260
}
261261

262262
// getTableStats queries the db for information_schema table size metrics.
263-
func (c *mySQLClient) getTableStats() ([]TableStats, error) {
263+
func (c *mySQLClient) getTableStats() ([]tableStats, error) {
264264
query := "SELECT TABLE_SCHEMA, TABLE_NAME, " +
265265
"COALESCE(TABLE_ROWS, 0) as TABLE_ROWS, " +
266266
"COALESCE(AVG_ROW_LENGTH, 0) as AVG_ROW_LENGTH, " +
@@ -273,9 +273,9 @@ func (c *mySQLClient) getTableStats() ([]TableStats, error) {
273273
return nil, err
274274
}
275275
defer rows.Close()
276-
var stats []TableStats
276+
var stats []tableStats
277277
for rows.Next() {
278-
var s TableStats
278+
var s tableStats
279279
err := rows.Scan(&s.schema, &s.name,
280280
&s.rows, &s.averageRowLength,
281281
&s.dataLength, &s.indexLength)
@@ -289,7 +289,7 @@ func (c *mySQLClient) getTableStats() ([]TableStats, error) {
289289
}
290290

291291
// getTableIoWaitsStats queries the db for table_io_waits metrics.
292-
func (c *mySQLClient) getTableIoWaitsStats() ([]TableIoWaitsStats, error) {
292+
func (c *mySQLClient) getTableIoWaitsStats() ([]tableIoWaitsStats, error) {
293293
query := "SELECT OBJECT_SCHEMA, OBJECT_NAME, " +
294294
"COUNT_DELETE, COUNT_FETCH, COUNT_INSERT, COUNT_UPDATE," +
295295
"FLOOR(SUM_TIMER_DELETE/1000), FLOOR(SUM_TIMER_FETCH/1000), FLOOR(SUM_TIMER_INSERT/1000), FLOOR(SUM_TIMER_UPDATE/1000) " +
@@ -300,9 +300,9 @@ func (c *mySQLClient) getTableIoWaitsStats() ([]TableIoWaitsStats, error) {
300300
return nil, err
301301
}
302302
defer rows.Close()
303-
var stats []TableIoWaitsStats
303+
var stats []tableIoWaitsStats
304304
for rows.Next() {
305-
var s TableIoWaitsStats
305+
var s tableIoWaitsStats
306306
err := rows.Scan(&s.schema, &s.name,
307307
&s.countDelete, &s.countFetch, &s.countInsert, &s.countUpdate,
308308
&s.timeDelete, &s.timeFetch, &s.timeInsert, &s.timeUpdate)
@@ -316,7 +316,7 @@ func (c *mySQLClient) getTableIoWaitsStats() ([]TableIoWaitsStats, error) {
316316
}
317317

318318
// getIndexIoWaitsStats queries the db for index_io_waits metrics.
319-
func (c *mySQLClient) getIndexIoWaitsStats() ([]IndexIoWaitsStats, error) {
319+
func (c *mySQLClient) getIndexIoWaitsStats() ([]indexIoWaitsStats, error) {
320320
query := "SELECT OBJECT_SCHEMA, OBJECT_NAME, ifnull(INDEX_NAME, 'NONE') as INDEX_NAME," +
321321
"COUNT_FETCH, COUNT_INSERT, COUNT_UPDATE, COUNT_DELETE," +
322322
"FLOOR(SUM_TIMER_FETCH/1000), FLOOR(SUM_TIMER_INSERT/1000), FLOOR(SUM_TIMER_UPDATE/1000), FLOOR(SUM_TIMER_DELETE/1000) " +
@@ -328,9 +328,9 @@ func (c *mySQLClient) getIndexIoWaitsStats() ([]IndexIoWaitsStats, error) {
328328
return nil, err
329329
}
330330
defer rows.Close()
331-
var stats []IndexIoWaitsStats
331+
var stats []indexIoWaitsStats
332332
for rows.Next() {
333-
var s IndexIoWaitsStats
333+
var s indexIoWaitsStats
334334
err := rows.Scan(&s.schema, &s.name, &s.index,
335335
&s.countDelete, &s.countFetch, &s.countInsert, &s.countUpdate,
336336
&s.timeDelete, &s.timeFetch, &s.timeInsert, &s.timeUpdate)
@@ -343,7 +343,7 @@ func (c *mySQLClient) getIndexIoWaitsStats() ([]IndexIoWaitsStats, error) {
343343
return stats, nil
344344
}
345345

346-
func (c *mySQLClient) getStatementEventsStats() ([]StatementEventStats, error) {
346+
func (c *mySQLClient) getStatementEventsStats() ([]statementEventStats, error) {
347347
query := fmt.Sprintf("SELECT ifnull(SCHEMA_NAME, 'NONE') as SCHEMA_NAME, DIGEST,"+
348348
"LEFT(DIGEST_TEXT, %d) as DIGEST_TEXT, FLOOR(SUM_TIMER_WAIT/1000), SUM_ERRORS,"+
349349
"SUM_WARNINGS, SUM_ROWS_AFFECTED, SUM_ROWS_SENT, SUM_ROWS_EXAMINED,"+
@@ -364,9 +364,9 @@ func (c *mySQLClient) getStatementEventsStats() ([]StatementEventStats, error) {
364364
}
365365
defer rows.Close()
366366

367-
var stats []StatementEventStats
367+
var stats []statementEventStats
368368
for rows.Next() {
369-
var s StatementEventStats
369+
var s statementEventStats
370370
err := rows.Scan(&s.schema, &s.digest, &s.digestText,
371371
&s.sumTimerWait, &s.countErrors, &s.countWarnings,
372372
&s.countRowsAffected, &s.countRowsSent, &s.countRowsExamined, &s.countCreatedTmpDiskTables,
@@ -414,7 +414,7 @@ func (c *mySQLClient) getTableLockWaitEventStats() ([]tableLockWaitEventStats, e
414414
return stats, nil
415415
}
416416

417-
func (c *mySQLClient) getReplicaStatusStats() ([]ReplicaStatusStats, error) {
417+
func (c *mySQLClient) getReplicaStatusStats() ([]replicaStatusStats, error) {
418418
mysqlVersion, err := c.getVersion()
419419
if err != nil {
420420
return nil, err
@@ -439,9 +439,9 @@ func (c *mySQLClient) getReplicaStatusStats() ([]ReplicaStatusStats, error) {
439439
return nil, err
440440
}
441441

442-
var stats []ReplicaStatusStats
442+
var stats []replicaStatusStats
443443
for rows.Next() {
444-
var s ReplicaStatusStats
444+
var s replicaStatusStats
445445
dest := []any{}
446446
for _, col := range cols {
447447
switch strings.ToLower(col) {

receiver/mysqlreceiver/integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
const mysqlPort = "3306"
2323

24-
type MySQLTestConfig struct {
24+
type mySQLTestConfig struct {
2525
name string
2626
containerCmd []string
2727
tlsEnabled bool
@@ -31,7 +31,7 @@ type MySQLTestConfig struct {
3131
}
3232

3333
func TestIntegration(t *testing.T) {
34-
testCases := []MySQLTestConfig{
34+
testCases := []mySQLTestConfig{
3535
{
3636
name: "MySql-8.0.33-WithoutTLS",
3737
containerCmd: nil,

receiver/mysqlreceiver/scraper_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ func (c *mockClient) getInnodbStats() (map[string]string, error) {
202202
return readFile(c.innodbStatsFile)
203203
}
204204

205-
func (c *mockClient) getTableStats() ([]TableStats, error) {
206-
var stats []TableStats
205+
func (c *mockClient) getTableStats() ([]tableStats, error) {
206+
var stats []tableStats
207207
file, err := os.Open(filepath.Join("testdata", "scraper", c.tableStatsFile+".txt"))
208208
if err != nil {
209209
return nil, err
@@ -212,7 +212,7 @@ func (c *mockClient) getTableStats() ([]TableStats, error) {
212212

213213
scanner := bufio.NewScanner(file)
214214
for scanner.Scan() {
215-
var s TableStats
215+
var s tableStats
216216
text := strings.Split(scanner.Text(), "\t")
217217
s.schema = text[0]
218218
s.name = text[1]
@@ -226,8 +226,8 @@ func (c *mockClient) getTableStats() ([]TableStats, error) {
226226
return stats, nil
227227
}
228228

229-
func (c *mockClient) getTableIoWaitsStats() ([]TableIoWaitsStats, error) {
230-
var stats []TableIoWaitsStats
229+
func (c *mockClient) getTableIoWaitsStats() ([]tableIoWaitsStats, error) {
230+
var stats []tableIoWaitsStats
231231
file, err := os.Open(filepath.Join("testdata", "scraper", c.tableIoWaitsFile+".txt"))
232232
if err != nil {
233233
return nil, err
@@ -236,7 +236,7 @@ func (c *mockClient) getTableIoWaitsStats() ([]TableIoWaitsStats, error) {
236236

237237
scanner := bufio.NewScanner(file)
238238
for scanner.Scan() {
239-
var s TableIoWaitsStats
239+
var s tableIoWaitsStats
240240
text := strings.Split(scanner.Text(), "\t")
241241

242242
s.schema = text[0]
@@ -255,8 +255,8 @@ func (c *mockClient) getTableIoWaitsStats() ([]TableIoWaitsStats, error) {
255255
return stats, nil
256256
}
257257

258-
func (c *mockClient) getIndexIoWaitsStats() ([]IndexIoWaitsStats, error) {
259-
var stats []IndexIoWaitsStats
258+
func (c *mockClient) getIndexIoWaitsStats() ([]indexIoWaitsStats, error) {
259+
var stats []indexIoWaitsStats
260260
file, err := os.Open(filepath.Join("testdata", "scraper", c.indexIoWaitsFile+".txt"))
261261
if err != nil {
262262
return nil, err
@@ -265,7 +265,7 @@ func (c *mockClient) getIndexIoWaitsStats() ([]IndexIoWaitsStats, error) {
265265

266266
scanner := bufio.NewScanner(file)
267267
for scanner.Scan() {
268-
var s IndexIoWaitsStats
268+
var s indexIoWaitsStats
269269
text := strings.Split(scanner.Text(), "\t")
270270

271271
s.schema = text[0]
@@ -285,8 +285,8 @@ func (c *mockClient) getIndexIoWaitsStats() ([]IndexIoWaitsStats, error) {
285285
return stats, nil
286286
}
287287

288-
func (c *mockClient) getStatementEventsStats() ([]StatementEventStats, error) {
289-
var stats []StatementEventStats
288+
func (c *mockClient) getStatementEventsStats() ([]statementEventStats, error) {
289+
var stats []statementEventStats
290290
file, err := os.Open(filepath.Join("testdata", "scraper", c.statementEventsFile+".txt"))
291291
if err != nil {
292292
return nil, err
@@ -295,7 +295,7 @@ func (c *mockClient) getStatementEventsStats() ([]StatementEventStats, error) {
295295

296296
scanner := bufio.NewScanner(file)
297297
for scanner.Scan() {
298-
var s StatementEventStats
298+
var s statementEventStats
299299
text := strings.Split(scanner.Text(), "\t")
300300

301301
s.schema = text[0]
@@ -359,8 +359,8 @@ func (c *mockClient) getTableLockWaitEventStats() ([]tableLockWaitEventStats, er
359359
return stats, nil
360360
}
361361

362-
func (c *mockClient) getReplicaStatusStats() ([]ReplicaStatusStats, error) {
363-
var stats []ReplicaStatusStats
362+
func (c *mockClient) getReplicaStatusStats() ([]replicaStatusStats, error) {
363+
var stats []replicaStatusStats
364364
file, err := os.Open(filepath.Join("testdata", "scraper", c.replicaStatusFile+".txt"))
365365
if err != nil {
366366
return nil, err
@@ -369,7 +369,7 @@ func (c *mockClient) getReplicaStatusStats() ([]ReplicaStatusStats, error) {
369369

370370
scanner := bufio.NewScanner(file)
371371
for scanner.Scan() {
372-
var s ReplicaStatusStats
372+
var s replicaStatusStats
373373
text := strings.Split(scanner.Text(), "\t")
374374

375375
s.replicaIOState = text[0]

0 commit comments

Comments
 (0)