1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
Chris Cummer 31926fd4a7
Integrate vendored NewRelic dependency (#767)
The NewRelic module relies on yfronto/newrelic, which no longer exists.
yfronto deleted that directory quite awhile ago, and since then it has
been vendored.

But vendoring a missing repository creates problems when trying to
update the vendored code.

This PR brings the yfronto/newrelic code into the mainline.

Signed-off-by: Chris Cummer <chriscummer@me.com>
2019-12-01 20:47:02 -08:00

49 lines
1.1 KiB
Go

/*
* NewRelic API for Go
*
* Please see the included LICENSE file for licensing information.
*
* Copyright 2016 by authors and contributors.
*/
package newrelic
import (
"net/http"
"net/url"
"time"
)
const (
// defaultAPIURL is the default base URL for New Relic's latest API.
defaultAPIURL = "https://api.newrelic.com/v2/"
// defaultTimeout is the default timeout for the http.Client used.
defaultTimeout = 5 * time.Second
)
// Client provides a set of methods to interact with the New Relic API.
type Client struct {
apiKey string
httpClient *http.Client
url *url.URL
}
// NewWithHTTPClient returns a new Client object for interfacing with the New
// Relic API, allowing for override of the http.Client object.
func NewWithHTTPClient(apiKey string, client *http.Client) *Client {
u, err := url.Parse(defaultAPIURL)
if err != nil {
panic(err)
}
return &Client{
apiKey: apiKey,
httpClient: client,
url: u,
}
}
// NewClient returns a new Client object for interfacing with the New Relic API.
func NewClient(apiKey string) *Client {
return NewWithHTTPClient(apiKey, &http.Client{Timeout: defaultTimeout})
}