Skip to content

Commit f3179db

Browse files
fix(receiver/httpcheck): report timing metrics as float64 to preserve sub-millisecond precision
1 parent 35fb3cb commit f3179db

File tree

9 files changed

+150
-44
lines changed

9 files changed

+150
-44
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: bug_fix
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog)
7+
component: receiver/httpcheck
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "Fix timing metrics (`httpcheck.dns.lookup.duration`, `httpcheck.client.connection.duration`, `httpcheck.tls.handshake.duration`, `httpcheck.client.request.duration`, `httpcheck.response.duration`) always reporting 0 on fast networks where phase durations are sub-millisecond."
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: [47257]
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: "Integer division truncated sub-millisecond durations to 0. Metrics are now reported as float64 (milliseconds with decimal precision)."
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/httpcheckreceiver/documentation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Time spent establishing TCP connection to the endpoint.
7474
7575
| Unit | Metric Type | Value Type | Stability |
7676
| ---- | ----------- | ---------- | --------- |
77-
| ms | Gauge | Int | Development |
77+
| ms | Gauge | Double | Development |
7878
7979
#### Attributes
8080
@@ -89,7 +89,7 @@ Time spent sending the HTTP request to the endpoint.
8989
9090
| Unit | Metric Type | Value Type | Stability |
9191
| ---- | ----------- | ---------- | --------- |
92-
| ms | Gauge | Int | Development |
92+
| ms | Gauge | Double | Development |
9393
9494
#### Attributes
9595
@@ -103,7 +103,7 @@ Time spent performing DNS lookup for the endpoint.
103103
104104
| Unit | Metric Type | Value Type | Stability |
105105
| ---- | ----------- | ---------- | --------- |
106-
| ms | Gauge | Int | Development |
106+
| ms | Gauge | Double | Development |
107107
108108
#### Attributes
109109
@@ -117,7 +117,7 @@ Time spent receiving the HTTP response from the endpoint.
117117
118118
| Unit | Metric Type | Value Type | Stability |
119119
| ---- | ----------- | ---------- | --------- |
120-
| ms | Gauge | Int | Development |
120+
| ms | Gauge | Double | Development |
121121
122122
#### Attributes
123123
@@ -162,7 +162,7 @@ Time spent performing TLS handshake with the endpoint.
162162

163163
| Unit | Metric Type | Value Type | Stability |
164164
| ---- | ----------- | ---------- | --------- |
165-
| ms | Gauge | Int | Development |
165+
| ms | Gauge | Double | Development |
166166

167167
#### Attributes
168168

receiver/httpcheckreceiver/generated_package_test.go

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

receiver/httpcheckreceiver/internal/metadata/generated_config_test.go

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

receiver/httpcheckreceiver/internal/metadata/generated_metrics.go

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

receiver/httpcheckreceiver/internal/metadata/generated_metrics_test.go

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

receiver/httpcheckreceiver/metadata.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,23 @@ metrics:
5656
enabled: false
5757
stability: development
5858
gauge:
59-
value_type: int
59+
value_type: double
6060
unit: ms
6161
attributes: [http.url, network.transport]
6262
httpcheck.client.request.duration:
6363
description: Time spent sending the HTTP request to the endpoint.
6464
enabled: false
6565
stability: development
6666
gauge:
67-
value_type: int
67+
value_type: double
6868
unit: ms
6969
attributes: [http.url]
7070
httpcheck.dns.lookup.duration:
7171
description: Time spent performing DNS lookup for the endpoint.
7272
enabled: false
7373
stability: development
7474
gauge:
75-
value_type: int
75+
value_type: double
7676
unit: ms
7777
attributes: [http.url]
7878
httpcheck.duration:
@@ -98,7 +98,7 @@ metrics:
9898
enabled: false
9999
stability: development
100100
gauge:
101-
value_type: int
101+
value_type: double
102102
unit: ms
103103
attributes: [http.url]
104104
httpcheck.response.size:
@@ -132,7 +132,7 @@ metrics:
132132
enabled: false
133133
stability: development
134134
gauge:
135-
value_type: int
135+
value_type: double
136136
unit: ms
137137
attributes: [http.url]
138138
httpcheck.validation.failed:

receiver/httpcheckreceiver/scraper.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,36 +48,36 @@ type timingInfo struct {
4848
responseStart atomic.Int64
4949
}
5050

51-
// getDurations calculates the duration for each phase in milliseconds
52-
func (t *timingInfo) getDurations() (dnsMs, tcpMs, tlsMs, requestMs, responseMs int64) {
51+
// getDurations calculates the duration for each phase in milliseconds.
52+
func (t *timingInfo) getDurations() (dnsMs, tcpMs, tlsMs, requestMs, responseMs float64) {
5353
dnsStartNs := t.dnsStart.Load()
5454
dnsEndNs := t.dnsEnd.Load()
5555
if dnsStartNs != 0 && dnsEndNs != 0 {
56-
dnsMs = (dnsEndNs - dnsStartNs) / int64(time.Millisecond)
56+
dnsMs = float64(dnsEndNs-dnsStartNs) / float64(time.Millisecond)
5757
}
5858

5959
connectStartNs := t.connectStart.Load()
6060
connectEndNs := t.connectEnd.Load()
6161
if connectStartNs != 0 && connectEndNs != 0 {
62-
tcpMs = (connectEndNs - connectStartNs) / int64(time.Millisecond)
62+
tcpMs = float64(connectEndNs-connectStartNs) / float64(time.Millisecond)
6363
}
6464

6565
tlsStartNs := t.tlsStart.Load()
6666
tlsEndNs := t.tlsEnd.Load()
6767
if tlsStartNs != 0 && tlsEndNs != 0 {
68-
tlsMs = (tlsEndNs - tlsStartNs) / int64(time.Millisecond)
68+
tlsMs = float64(tlsEndNs-tlsStartNs) / float64(time.Millisecond)
6969
}
7070

7171
writeStartNs := t.writeStart.Load()
7272
writeEndNs := t.writeEnd.Load()
7373
if writeStartNs != 0 && writeEndNs != 0 {
74-
requestMs = (writeEndNs - writeStartNs) / int64(time.Millisecond)
74+
requestMs = float64(writeEndNs-writeStartNs) / float64(time.Millisecond)
7575
}
7676

7777
readStartNs := t.readStart.Load()
7878
readEndNs := t.readEnd.Load()
7979
if readStartNs != 0 && readEndNs != 0 {
80-
responseMs = (readEndNs - readStartNs) / int64(time.Millisecond)
80+
responseMs = float64(readEndNs-readStartNs) / float64(time.Millisecond)
8181
}
8282

8383
return dnsMs, tcpMs, tlsMs, requestMs, responseMs

0 commit comments

Comments
 (0)