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

[receiver/mysql]: add mysql.uptime metric #14747

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-upstream-metric.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: enhancement

# 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: add mysql.uptime 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:
8 changes: 8 additions & 0 deletions receiver/mysqlreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ The number of created temporary resources.
| ---- | ----------- | ------ |
| resource | The kind of temporary resources. | Str: ``disk_tables``, ``files``, ``tables`` |

### mysql.uptime

The number of seconds that the server has been up.

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

## Optional Metrics

The following metrics are not emitted by default. Each of them can be enabled by applying the following configuration:
Expand Down

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.

64 changes: 64 additions & 0 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 @@ -87,6 +87,8 @@ all_set:
enabled: true
mysql.tmp_resources:
enabled: true
mysql.uptime:
enabled: true
resource_attributes:
mysql.instance.endpoint:
enabled: true
Expand Down Expand Up @@ -178,6 +180,8 @@ none_set:
enabled: false
mysql.tmp_resources:
enabled: false
mysql.uptime:
enabled: false
resource_attributes:
mysql.instance.endpoint:
enabled: false
9 changes: 9 additions & 0 deletions receiver/mysqlreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,15 @@ metrics:
monotonic: true
aggregation: cumulative
attributes: [opened_resources]
mysql.uptime:
enabled: true
description: The number of seconds that the server has been up.
unit: s
sum:
value_type: int
input_type: string
monotonic: true
aggregation: cumulative
mysql.table.lock_wait.read.count:
enabled: false
description: The total table lock wait read events.
Expand Down
4 changes: 4 additions & 0 deletions receiver/mysqlreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ func (m *mySQLScraper) scrapeGlobalStats(now pcommon.Timestamp, errs *scrapererr
addPartialIfError(errs, m.mb.RecordMysqlMysqlxConnectionsDataPoint(now, v, metadata.AttributeConnectionStatusClosed))
case "Mysqlx_connections_rejected":
addPartialIfError(errs, m.mb.RecordMysqlMysqlxConnectionsDataPoint(now, v, metadata.AttributeConnectionStatusRejected))

// uptime
case "Uptime":
addPartialIfError(errs, m.mb.RecordMysqlUptimeDataPoint(now, v))
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions receiver/mysqlreceiver/testdata/integration/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,16 @@ resourceMetrics:
timeUnixNano: "1674545265375344000"
isMonotonic: true
unit: "1"
- description: The number of seconds that the server has been up.
name: mysql.uptime
sum:
aggregationTemporality: 2
dataPoints:
- asInt: "452"
startTimeUnixNano: "1644862687825728000"
timeUnixNano: "1644862687825772000"
isMonotonic: true
unit: "s"
scope:
name: otelcol/mysqlreceiver
version: latest
10 changes: 10 additions & 0 deletions receiver/mysqlreceiver/testdata/scraper/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,16 @@ resourceMetrics:
timeUnixNano: "1644862687825772000"
isMonotonic: true
unit: "1"
- description: The number of seconds that the server has been up.
name: mysql.uptime
sum:
aggregationTemporality: 2
dataPoints:
- asInt: "452"
startTimeUnixNano: "1644862687825728000"
timeUnixNano: "1644862687825772000"
isMonotonic: true
unit: "s"
scope:
name: otelcol/mysqlreceiver
version: latest