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

feat: Add HTTP Probe trace time metrics #150

Merged
merged 6 commits into from
Jun 30, 2022
Merged

feat: Add HTTP Probe trace time metrics #150

merged 6 commits into from
Jun 30, 2022

Conversation

haoel
Copy link
Contributor

@haoel haoel commented Jun 28, 2022

the following tracing metrics have been added:

  • dns: get the ip address, from dnsStartAt() to dnsDone()
  • conn: tcp connection, from connectStart() to connectDone()
  • tls: tls connection, from tlsStart() to tlsDone()
  • send: send the http header, from wroteHeaderField() to wroteHeaders()
  • wait: send the http request, from wroteRequest() to gotFirstResponseByte()
  • transfer : wait all of data received, from gotFirstResponseByte() to putIdleConn()
  • total: from the beginning to the end. getConn() to putIdleConn()
total >= DNS + conn + tls + send + wait +transfer 

it can be seen in Prometheus and Grafana, the following snapshot is an example.

image

open the debug log, you will see the following debug information

DEBU[2022-06-28T20:26:33+08:00] [http TRACE MegaEase] - total - start get connection: 1656419193697500000 
DEBU[2022-06-28T20:26:33+08:00] [http TRACE MegaEase] - dns - start resolve megaease.com: 1656419193697806 
DEBU[2022-06-28T20:26:33+08:00] [http TRACE MegaEase] - dns - resolve ip [{172.67.222.231 } {104.21.46.25 } {2606:4700:3033::6815:2e19 } {2606:4700:3033::ac43:dee7 }], time 67.725ms 
DEBU[2022-06-28T20:26:33+08:00] [http TRACE MegaEase] - conn - start tcp connect to 172.67.222.231:443: 1656419193765629 
DEBU[2022-06-28T20:26:33+08:00] [http TRACE MegaEase] - conn - tcp connection created to 172.67.222.231:443. time: 85.463ms 
DEBU[2022-06-28T20:26:33+08:00] [http TRACE MegaEase] - tls - start negotiation: 1656419193851180 
DEBU[2022-06-28T20:26:33+08:00] [http TRACE MegaEase] - tls - negotiated to "megaease.com", time: 96.888ms 
DEBU[2022-06-28T20:26:33+08:00] [http TRACE MegaEase] - connection established. reused: false idle: false idle time: 0ms 
DEBU[2022-06-28T20:26:33+08:00] [http TRACE MegaEase] - send - start write header field :authority [megaease.com] : 1656419193948308 
DEBU[2022-06-28T20:26:33+08:00] [http TRACE MegaEase] - send - start write header field :method [GET] : 1656419193948308 
DEBU[2022-06-28T20:26:33+08:00] [http TRACE MegaEase] - send - start write header field :path [/] : 1656419193948308 
DEBU[2022-06-28T20:26:33+08:00] [http TRACE MegaEase] - send - start write header field :scheme [https] : 1656419193948308 
DEBU[2022-06-28T20:26:33+08:00] [http TRACE MegaEase] - send - start write header field user-agent [MegaEase EaseProbe/v1.7.0] : 1656419193948308 
DEBU[2022-06-28T20:26:33+08:00] [http TRACE MegaEase] - send - start write header field accept-encoding [gzip] : 1656419193948308 
DEBU[2022-06-28T20:26:33+08:00] [http TRACE MegaEase] - send - headers written, time: 0.089ms 
DEBU[2022-06-28T20:26:33+08:00] [http TRACE MegaEase] - wait - start write request: 1656419193948405 
DEBU[2022-06-28T20:26:34+08:00] [http TRACE MegaEase] - transfer - start transfer the response: 1656419194738504 
DEBU[2022-06-28T20:26:34+08:00] [http TRACE MegaEase] - wait - got first response byte, time: 790.082ms 
DEBU[2022-06-28T20:26:34+08:00] [http TRACE MegaEase] - transfer - done, time: 0.085ms 
DEBU[2022-06-28T20:26:34+08:00] [http TRACE MegaEase] - total - done , time: 1041.068ms 
DEBU[2022-06-28T20:26:34+08:00] [http TRACE MegaEase] ======================== Trace Stats ====================== 
DEBU[2022-06-28T20:26:34+08:00] [http TRACE MegaEase] DNS       Connect TLS     Send    Wait    Trans   Total 
DEBU[2022-06-28T20:26:34+08:00] [http TRACE MegaEase] 67.73     85.46   96.89   0.09    790.08  0.09    1041.07 
DEBU[2022-06-28T20:26:34+08:00] [http TRACE MegaEase] =========================================================== 

@haoel haoel requested review from proditis and zhao-kun June 28, 2022 09:01
@codecov-commenter
Copy link

codecov-commenter commented Jun 28, 2022

Codecov Report

Merging #150 (6df2594) into main (2f049ee) will increase coverage by 1.25%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #150      +/-   ##
==========================================
+ Coverage   90.92%   92.18%   +1.25%     
==========================================
  Files          44       45       +1     
  Lines        3020     3197     +177     
==========================================
+ Hits         2746     2947     +201     
+ Misses        203      185      -18     
+ Partials       71       65       -6     
Impacted Files Coverage Δ
global/global.go 100.00% <ø> (ø)
metric/prometheus.go 100.00% <ø> (+25.80%) ⬆️
probe/http/http.go 100.00% <100.00%> (ø)
probe/http/metrics.go 100.00% <100.00%> (ø)
probe/http/trace.go 100.00% <100.00%> (ø)
probe/tls/metrics.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2f049ee...6df2594. Read the comment docs.

Copy link
Collaborator

@proditis proditis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and confirmed working as advertised 😄

LGTM

Copy link
Contributor

@zhao-kun zhao-kun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the README for the new feature.

@haoel
Copy link
Contributor Author

haoel commented Jun 30, 2022

Please update the README for the new feature.

Done!

Copy link
Contributor

@zhao-kun zhao-kun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zhao-kun zhao-kun merged commit db50a78 into megaease:main Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants