Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
qorus
prometheus
Commits
2b45d516
Commit
2b45d516
authored
Sep 05, 2016
by
Fabian Reinartz
Committed by
GitHub
Sep 05, 2016
Browse files
Merge pull request #1948 from prometheus/httpclient
retrieval: export NewHTTPClient
parents
75bae065
0322c59d
Changes
3
Hide whitespace changes
Inline
Side-by-side
retrieval/scrape.go
View file @
2b45d516
...
...
@@ -115,7 +115,7 @@ type scrapePool struct {
}
func
newScrapePool
(
cfg
*
config
.
ScrapeConfig
,
app
storage
.
SampleAppender
)
*
scrapePool
{
client
,
err
:=
n
ewHTTPClient
(
cfg
)
client
,
err
:=
N
ewHTTPClient
(
cfg
)
if
err
!=
nil
{
// Any errors that could occur here should be caught during config validation.
log
.
Errorf
(
"Error creating HTTP client for job %q: %s"
,
cfg
.
JobName
,
err
)
...
...
@@ -167,7 +167,7 @@ func (sp *scrapePool) reload(cfg *config.ScrapeConfig) {
sp
.
mtx
.
Lock
()
defer
sp
.
mtx
.
Unlock
()
client
,
err
:=
n
ewHTTPClient
(
cfg
)
client
,
err
:=
N
ewHTTPClient
(
cfg
)
if
err
!=
nil
{
// Any errors that could occur here should be caught during config validation.
log
.
Errorf
(
"Error creating HTTP client for job %q: %s"
,
cfg
.
JobName
,
err
)
...
...
retrieval/target.go
View file @
2b45d516
...
...
@@ -66,7 +66,8 @@ func NewTarget(labels, metaLabels model.LabelSet, params url.Values) *Target {
}
}
func
newHTTPClient
(
cfg
*
config
.
ScrapeConfig
)
(
*
http
.
Client
,
error
)
{
// NewHTTPClient returns a new HTTP client configured for the given scrape configuration.
func
NewHTTPClient
(
cfg
*
config
.
ScrapeConfig
)
(
*
http
.
Client
,
error
)
{
tlsOpts
:=
httputil
.
TLSOptions
{
InsecureSkipVerify
:
cfg
.
TLSConfig
.
InsecureSkipVerify
,
CAFile
:
cfg
.
TLSConfig
.
CAFile
,
...
...
retrieval/target_test.go
View file @
2b45d516
...
...
@@ -155,7 +155,7 @@ func TestNewHTTPBearerToken(t *testing.T) {
ScrapeTimeout
:
model
.
Duration
(
1
*
time
.
Second
),
BearerToken
:
"1234"
,
}
c
,
err
:=
n
ewHTTPClient
(
cfg
)
c
,
err
:=
N
ewHTTPClient
(
cfg
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -183,7 +183,7 @@ func TestNewHTTPBearerTokenFile(t *testing.T) {
ScrapeTimeout
:
model
.
Duration
(
1
*
time
.
Second
),
BearerTokenFile
:
"testdata/bearertoken.txt"
,
}
c
,
err
:=
n
ewHTTPClient
(
cfg
)
c
,
err
:=
N
ewHTTPClient
(
cfg
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -213,7 +213,7 @@ func TestNewHTTPBasicAuth(t *testing.T) {
Password
:
"password123"
,
},
}
c
,
err
:=
n
ewHTTPClient
(
cfg
)
c
,
err
:=
N
ewHTTPClient
(
cfg
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -242,7 +242,7 @@ func TestNewHTTPCACert(t *testing.T) {
CAFile
:
caCertPath
,
},
}
c
,
err
:=
n
ewHTTPClient
(
cfg
)
c
,
err
:=
N
ewHTTPClient
(
cfg
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -277,7 +277,7 @@ func TestNewHTTPClientCert(t *testing.T) {
KeyFile
:
"testdata/client.key"
,
},
}
c
,
err
:=
n
ewHTTPClient
(
cfg
)
c
,
err
:=
N
ewHTTPClient
(
cfg
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -307,7 +307,7 @@ func TestNewHTTPWithServerName(t *testing.T) {
ServerName
:
"prometheus.rocks"
,
},
}
c
,
err
:=
n
ewHTTPClient
(
cfg
)
c
,
err
:=
N
ewHTTPClient
(
cfg
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -337,7 +337,7 @@ func TestNewHTTPWithBadServerName(t *testing.T) {
ServerName
:
"badname"
,
},
}
c
,
err
:=
n
ewHTTPClient
(
cfg
)
c
,
err
:=
N
ewHTTPClient
(
cfg
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -377,7 +377,7 @@ func TestNewClientWithBadTLSConfig(t *testing.T) {
KeyFile
:
"testdata/nonexistent_client.key"
,
},
}
_
,
err
:=
n
ewHTTPClient
(
cfg
)
_
,
err
:=
N
ewHTTPClient
(
cfg
)
if
err
==
nil
{
t
.
Fatalf
(
"Expected error, got nil."
)
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment