Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mysqlreceiver]: remove deprecated mysql.commands metric #17270

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .chloggen/drosiek-mysql-remove-commands.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: deprecation

# 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: remove mysql.commands metric

# One or more tracking issues related to the change
issues: [14138]

# (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:
14 changes: 0 additions & 14 deletions receiver/mysqlreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,6 @@ The number of bytes in the InnoDB buffer pool.
| ---- | ----------- | ------ |
| status | The status of buffer pool data. | Str: ``dirty``, ``clean`` |

### mysql.commands

The number of times each type of command has been executed.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| 1 | Sum | Int | Cumulative | true |

#### Attributes

| Name | Description | Values |
| ---- | ----------- | ------ |
| command | The prepare statement command types. | Str: ``execute``, ``close``, ``fetch``, ``prepare``, ``reset``, ``send_long_data`` |

### mysql.double_writes

The number of writes to the InnoDB doublewrite buffer.
Expand Down
2 changes: 1 addition & 1 deletion receiver/mysqlreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ require (
go.opentelemetry.io/collector/component v0.68.0
go.opentelemetry.io/collector/confmap v0.68.0
go.opentelemetry.io/collector/consumer v0.68.0
go.opentelemetry.io/collector/featuregate v0.68.0
go.opentelemetry.io/collector/pdata v1.0.0-rc2
go.uber.org/zap v1.24.0
)
Expand Down Expand Up @@ -52,6 +51,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/collector/featuregate v0.68.0 // indirect
go.opentelemetry.io/otel v1.11.2 // indirect
go.opentelemetry.io/otel/metric v0.34.0 // indirect
go.opentelemetry.io/otel/trace v1.11.2 // indirect
Expand Down

This file was deleted.

70 changes: 0 additions & 70 deletions receiver/mysqlreceiver/internal/metadata/generated_metrics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ all_metrics:
enabled: true
mysql.client.network.io:
enabled: true
mysql.commands:
enabled: true
mysql.connection.count:
enabled: true
mysql.connection.errors:
Expand Down Expand Up @@ -101,8 +99,6 @@ no_metrics:
enabled: false
mysql.client.network.io:
enabled: false
mysql.commands:
enabled: false
mysql.connection.count:
enabled: false
mysql.connection.errors:
Expand Down
10 changes: 0 additions & 10 deletions receiver/mysqlreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,6 @@ metrics:
monotonic: false
aggregation: cumulative
attributes: [buffer_pool_data]
mysql.commands:
enabled: true
description: The number of times each type of command has been executed.
unit: 1
sum:
value_type: int
input_type: string
monotonic: true
aggregation: cumulative
attributes: [prepared_statements_command]
mysql.prepared_statements:
enabled: true
description: The number of times each type of prepared statement command has been issued.
Expand Down
76 changes: 15 additions & 61 deletions receiver/mysqlreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ package mysqlreceiver // import "github.com/open-telemetry/opentelemetry-collect
import (
"context"
"errors"
"fmt"
"strconv"
"time"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/receiver"
Expand All @@ -34,19 +32,8 @@ import (

const (
picosecondsInNanoseconds int64 = 1000
RenameCommands = "receiver.mysqlreceiver.renameCommands"
deprecationVersion = "v0.67.0"
renameVersion = "v0.68.0"
)

func init() {
featuregate.GetRegistry().MustRegisterID(
RenameCommands,
featuregate.StageBeta,
featuregate.WithRegisterDescription("When enabled, the mysql.commands will be deprecated and additionally emitted as optional mysql.prepared_statements metric"),
)
}

type mySQLScraper struct {
sqlclient client
logger *zap.Logger
Expand All @@ -62,24 +49,9 @@ func newMySQLScraper(
config *Config,
) *mySQLScraper {
ms := &mySQLScraper{
logger: settings.Logger,
config: config,
mb: metadata.NewMetricsBuilder(config.Metrics, settings),
renameCommands: featuregate.GetRegistry().IsEnabled(RenameCommands),
}

if !ms.renameCommands {
settings.Logger.Warn(fmt.Sprintf("[WARNING] Metric `mysql.commands` is deprecated and duplicated as `mysql.prepared_statements`. Metric `mysql.commands` will be removed and `mysql.prepared_statements` will be a default metric in %s. Disable a feature gate `%s` to keep previous behavior", renameVersion, RenameCommands))
ms.config.Metrics.MysqlPreparedStatements.Enabled = false
} else {
if ms.config.Metrics.MysqlCommands.Enabled {
ms.mb.DeprecateMetrics()
settings.Logger.Warn(fmt.Sprintf("[WARNING] Metric `mysql.commands` is deprecated and will be removed in %s. Please use `mysql.prepared_statements` instead", renameVersion))
}

if !ms.config.Metrics.MysqlPreparedStatements.Enabled {
settings.Logger.Warn(fmt.Sprintf("[WARNING] Metric `mysql.prepared_statements` will be a default metric in %s", renameVersion))
}
logger: settings.Logger,
config: config,
mb: metadata.NewMetricsBuilder(config.Metrics, settings),
}

return ms
Expand Down Expand Up @@ -231,41 +203,23 @@ func (m *mySQLScraper) scrapeGlobalStats(now pcommon.Timestamp, errs *scrapererr

// commands
case "Com_stmt_execute":
if m.renameCommands {
addPartialIfError(errs, m.mb.RecordMysqlPreparedStatementsDataPoint(now, v,
metadata.AttributePreparedStatementsCommandExecute))
}
addPartialIfError(errs, m.mb.RecordMysqlCommandsDataPoint(now, v, metadata.AttributePreparedStatementsCommandExecute))
addPartialIfError(errs, m.mb.RecordMysqlPreparedStatementsDataPoint(now, v,
metadata.AttributePreparedStatementsCommandExecute))
case "Com_stmt_close":
if m.renameCommands {
addPartialIfError(errs, m.mb.RecordMysqlPreparedStatementsDataPoint(now, v,
metadata.AttributePreparedStatementsCommandClose))
}
addPartialIfError(errs, m.mb.RecordMysqlCommandsDataPoint(now, v, metadata.AttributePreparedStatementsCommandClose))
addPartialIfError(errs, m.mb.RecordMysqlPreparedStatementsDataPoint(now, v,
metadata.AttributePreparedStatementsCommandClose))
case "Com_stmt_fetch":
if m.renameCommands {
addPartialIfError(errs, m.mb.RecordMysqlPreparedStatementsDataPoint(now, v,
metadata.AttributePreparedStatementsCommandFetch))
}
addPartialIfError(errs, m.mb.RecordMysqlCommandsDataPoint(now, v, metadata.AttributePreparedStatementsCommandFetch))
addPartialIfError(errs, m.mb.RecordMysqlPreparedStatementsDataPoint(now, v,
metadata.AttributePreparedStatementsCommandFetch))
case "Com_stmt_prepare":
if m.renameCommands {
addPartialIfError(errs, m.mb.RecordMysqlPreparedStatementsDataPoint(now, v,
metadata.AttributePreparedStatementsCommandPrepare))
}
addPartialIfError(errs, m.mb.RecordMysqlCommandsDataPoint(now, v, metadata.AttributePreparedStatementsCommandPrepare))
addPartialIfError(errs, m.mb.RecordMysqlPreparedStatementsDataPoint(now, v,
metadata.AttributePreparedStatementsCommandPrepare))
case "Com_stmt_reset":
if m.renameCommands {
addPartialIfError(errs, m.mb.RecordMysqlPreparedStatementsDataPoint(now, v,
metadata.AttributePreparedStatementsCommandReset))
}
addPartialIfError(errs, m.mb.RecordMysqlCommandsDataPoint(now, v, metadata.AttributePreparedStatementsCommandReset))
addPartialIfError(errs, m.mb.RecordMysqlPreparedStatementsDataPoint(now, v,
metadata.AttributePreparedStatementsCommandReset))
case "Com_stmt_send_long_data":
if m.renameCommands {
addPartialIfError(errs, m.mb.RecordMysqlPreparedStatementsDataPoint(now, v,
metadata.AttributePreparedStatementsCommandSendLongData))
}
addPartialIfError(errs, m.mb.RecordMysqlCommandsDataPoint(now, v, metadata.AttributePreparedStatementsCommandSendLongData))
addPartialIfError(errs, m.mb.RecordMysqlPreparedStatementsDataPoint(now, v,
metadata.AttributePreparedStatementsCommandSendLongData))

// created tmps
case "Created_tmp_disk_tables":
Expand Down
Loading