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

Add HTTP probing support #89

Merged
merged 13 commits into from
Mar 9, 2024

Conversation

anton-kuklin
Copy link

@anton-kuklin anton-kuklin commented Jan 25, 2024

This PR adds support for HTTP probing. It provides an API based on httptrace callbacks.

Current list of configurable options:

  • URL
  • Host
  • Method
  • Headers
  • Body
  • Timeout
  • CallFrequency (aka target RPS)
  • MaxConcurrentCalls (aka number of call workers)

Available callbacks:

  • OnReq
  • OnResp
  • OnDNSStart
  • OnDNSDone
  • OnConnStart
  • OnConnDone
  • OnTLSStart
  • OnTLSDone
  • OnWroteHeaders
  • OnFirstByReceived

Misc config:

  • Custom http client
  • Logger

Basic usage example

httpCaller := probing.NewHttpCaller("https://www.google.com",
    probing.WithHTTPCallerCallFrequency(time.Second),
    probing.WithHTTPCallerOnResp(func(suite *probing.TraceSuite, info *probing.HTTPCallInfo) {
        fmt.Printf("got resp, status code: %d, latency: %s\n",
            info.StatusCode,
            suite.GetGeneralEnd().Sub(suite.GetGeneralStart()),
        )
    }),
)

// Listen for Ctrl-C.
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
go func() {
    <-c
    httpCaller.Stop()
}()
httpCaller.Run()

Based on issue: #88

@anton-kuklin anton-kuklin force-pushed the feat/http-probe branch 3 times, most recently from db0ab1f to 71cf26e Compare January 25, 2024 12:36
@anton-kuklin
Copy link
Author

CC: @davinci26

@SuperQ SuperQ requested review from metalmatze and SuperQ January 25, 2024 12:57
Anton Kuklin added 13 commits January 26, 2024 20:38
Signed-off-by: Anton Kuklin <anton.a.kuklin@gmail.com>
Signed-off-by: Anton Kuklin <anton.a.kuklin@gmail.com>
Signed-off-by: Anton Kuklin <anton.a.kuklin@gmail.com>
Signed-off-by: Anton Kuklin <anton.a.kuklin@gmail.com>
Signed-off-by: Anton Kuklin <anton.a.kuklin@gmail.com>
Signed-off-by: Anton Kuklin <anton.a.kuklin@gmail.com>
Signed-off-by: Anton Kuklin <anton.a.kuklin@gmail.com>
Signed-off-by: Anton Kuklin <anton.a.kuklin@gmail.com>
Signed-off-by: Anton Kuklin <anton.a.kuklin@gmail.com>
Signed-off-by: Anton Kuklin <anton.a.kuklin@gmail.com>
Signed-off-by: Anton Kuklin <anton.a.kuklin@gmail.com>
Signed-off-by: Anton Kuklin <anton.a.kuklin@gmail.com>
Signed-off-by: Anton Kuklin <anton.a.kuklin@gmail.com>
Copy link
Contributor

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

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

Going to merge this so we can iterate on it.

@SuperQ SuperQ merged commit e81b2be into prometheus-community:main Mar 9, 2024
4 checks passed
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.

2 participants