Skip to content

Commit 9f2e671

Browse files
devamanvatoulme
andauthored
[receiver/apache] Add support for number of connections per async state metric (#42158)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description The PR adds changes to extract metrics pertaining to connections per async state. See the related issue for more details. <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Relates #41886 <!--Describe what testing was performed and which tests were added.--> #### Testing Unit and integration tests for the scraper have been extended with data for new metrics. <!--Describe the documentation added.--> #### Documentation Documentation generated by mdatagen has been added. <!--Please delete paragraphs that you did not use before submitting.--> --------- Co-authored-by: Antoine Toulme <[email protected]>
1 parent 2a0e445 commit 9f2e671

File tree

12 files changed

+248
-4
lines changed

12 files changed

+248
-4
lines changed
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: apachereceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Add number of connections per async state metrics.
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: [41886]
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: [user]

receiver/apachereceiver/documentation.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ metrics:
1212
enabled: false
1313
```
1414
15+
### apache.connections.async
16+
17+
The number of connections in different asynchronous states reported by Apache's server-status.
18+
19+
| Unit | Metric Type | Value Type |
20+
| ---- | ----------- | ---------- |
21+
| {connections} | Gauge | Int |
22+
23+
#### Attributes
24+
25+
| Name | Description | Values | Optional |
26+
| ---- | ----------- | ------ | -------- |
27+
| connection_state | The asynchronous connection state reported by Apache's server-status. | Str: ``writing``, ``keepalive``, ``closing`` | false |
28+
1529
### apache.cpu.load
1630
1731
Current load of the CPU.

receiver/apachereceiver/internal/metadata/generated_config.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/apachereceiver/internal/metadata/generated_config_test.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/apachereceiver/internal/metadata/generated_metrics.go

Lines changed: 98 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/apachereceiver/internal/metadata/generated_metrics_test.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/apachereceiver/internal/metadata/testdata/config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
default:
22
all_set:
33
metrics:
4+
apache.connections.async:
5+
enabled: true
46
apache.cpu.load:
57
enabled: true
68
apache.cpu.time:
@@ -32,6 +34,8 @@ all_set:
3234
enabled: true
3335
none_set:
3436
metrics:
37+
apache.connections.async:
38+
enabled: false
3539
apache.cpu.load:
3640
enabled: false
3741
apache.cpu.time:

receiver/apachereceiver/metadata.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ attributes:
5858
- finishing
5959
- idle_cleanup
6060
- unknown
61+
connection_state:
62+
description: The asynchronous connection state reported by Apache's server-status.
63+
type: string
64+
enum:
65+
- writing
66+
- keepalive
67+
- closing
6168

6269
metrics:
6370
apache.uptime:
@@ -174,3 +181,11 @@ metrics:
174181
monotonic: false
175182
aggregation_temporality: cumulative
176183
attributes: [scoreboard_state]
184+
apache.connections.async:
185+
enabled: true
186+
description: The number of connections in different asynchronous states reported by Apache's server-status.
187+
unit: "{connections}"
188+
gauge:
189+
value_type: int
190+
input_type: string
191+
attributes: [connection_state]

receiver/apachereceiver/scraper.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ func (r *apacheScraper) scrape(context.Context) (pmetric.Metrics, error) {
7676
addPartialIfError(errs, r.mb.RecordApacheUptimeDataPoint(now, metricValue))
7777
case "ConnsTotal":
7878
addPartialIfError(errs, r.mb.RecordApacheCurrentConnectionsDataPoint(now, metricValue))
79+
case "ConnsAsyncWriting":
80+
addPartialIfError(errs, r.mb.RecordApacheConnectionsAsyncDataPoint(now, metricValue, metadata.AttributeConnectionStateWriting))
81+
case "ConnsAsyncKeepAlive":
82+
addPartialIfError(errs, r.mb.RecordApacheConnectionsAsyncDataPoint(now, metricValue, metadata.AttributeConnectionStateKeepalive))
83+
case "ConnsAsyncClosing":
84+
addPartialIfError(errs, r.mb.RecordApacheConnectionsAsyncDataPoint(now, metricValue, metadata.AttributeConnectionStateClosing))
7985
case "BusyWorkers":
8086
addPartialIfError(errs, r.mb.RecordApacheWorkersDataPoint(now, metricValue, metadata.AttributeWorkersStateBusy))
8187
case "IdleWorkers":

receiver/apachereceiver/scraper_test.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,18 @@ ReqPerSec: 719.771
145145
IdleWorkers: 227
146146
ConnsTotal: 110
147147
BytesPerSec: 73.12
148+
ConnsAsyncWriting: 2
149+
ConnsAsyncKeepAlive: 1
150+
ConnsAsyncClosing: 1
148151
`
149152
want := map[string]string{
150-
"ReqPerSec": "719.771",
151-
"IdleWorkers": "227",
152-
"ConnsTotal": "110",
153-
"BytesPerSec": "73.12",
153+
"ReqPerSec": "719.771",
154+
"IdleWorkers": "227",
155+
"ConnsTotal": "110",
156+
"BytesPerSec": "73.12",
157+
"ConnsAsyncWriting": "2",
158+
"ConnsAsyncKeepAlive": "1",
159+
"ConnsAsyncClosing": "1",
154160
}
155161
require.Equal(t, want, parseStats(got))
156162
})
@@ -185,6 +191,9 @@ CPULoad: 0.66
185191
Load1: 0.9
186192
Load5: 0.4
187193
Load15: 0.3
194+
ConnsAsyncWriting: 2
195+
ConnsAsyncKeepAlive: 1
196+
ConnsAsyncClosing: 1
188197
Total Duration: 1501
189198
Scoreboard: S_DD_L_GGG_____W__IIII_C________________W__________________________________.........................____WR______W____W________________________C______________________________________W_W____W______________R_________R________C_________WK_W________K_____W__C__________W___R______.............................................................................................................................
190199
`))

0 commit comments

Comments
 (0)