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 endpoint resource attribute #14340

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
6 changes: 6 additions & 0 deletions receiver/mysqlreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ metrics:
enabled: <true|false>
```

## Resource attributes

| Name | Description | Type |
| ---- | ----------- | ---- |
| mysql.instance.endpoint | Endpoint of the MySQL instance. | String |

## Metric attributes

| Name | Description | Values |
Expand Down

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

5 changes: 5 additions & 0 deletions receiver/mysqlreceiver/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: mysqlreceiver

resource_attributes:
mysql.instance.endpoint:
description: Endpoint of the MySQL instance.
type: string

attributes:
buffer_pool_pages:
value: kind
Expand Down
2 changes: 2 additions & 0 deletions receiver/mysqlreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ func (m *mySQLScraper) scrape(context.Context) (pmetric.Metrics, error) {
}
}

m.mb.EmitForResource(metadata.WithMysqlInstanceEndpoint(m.config.Endpoint))

return m.mb.Emit(), errs.Combine()
}

Expand Down
11 changes: 10 additions & 1 deletion receiver/mysqlreceiver/testdata/scraper/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,16 @@
]
}
],
"resource": {}
"resource": {
"attributes": [
{
"key": "mysql.instance.endpoint",
"value": {
"stringValue": "localhost:3306"
}
}
]
}
}
]
}
11 changes: 10 additions & 1 deletion receiver/mysqlreceiver/testdata/scraper/expected_partial.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{
"resourceMetrics": [
{
"resource": {},
"resource": {
"attributes": [
{
"key": "mysql.instance.endpoint",
"value": {
"stringValue": "localhost:3306"
}
}
]
},
"scopeMetrics": [
{
"metrics": [
Expand Down
5 changes: 5 additions & 0 deletions unreleased/mysql-add-endpoint-attribute.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
change_type: breaking
component: mysqlreceiver
note: The metrics are now being emitted with a resource attribute marking the endpoint of the database.
issues: [14138]
subtext: