Skip to content

Commit

Permalink
Remove prewarm
Browse files Browse the repository at this point in the history
  • Loading branch information
DarcyRaynerDD committed Jun 17, 2019
1 parent c74c8d2 commit 0f938c4
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 35 deletions.
16 changes: 0 additions & 16 deletions internal/metrics/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,6 @@ func MakeAPIClient(ctx context.Context, baseAPIURL, apiKey string) *APIClient {
}
}

// PrewarmConnection sends a redundant GET request to the Datadog API to prewarm the TSL connection
func (cl *APIClient) PrewarmConnection() error {
req, err := http.NewRequest("GET", cl.makeRoute("validate"), nil)
if err != nil {
return fmt.Errorf("Couldn't create prewarming request: %v", err)
}
req = req.WithContext(cl.context)

cl.addAPICredentials(req)
_, err = cl.httpClient.Do(req)
if err != nil {
return fmt.Errorf("Couldn't contact server for prewarm request")
}
return nil
}

// SendMetrics posts a batch metrics payload to the Datadog API
func (cl *APIClient) SendMetrics(metrics []APIMetric) error {
content, err := marshalAPIMetricsModel(metrics)
Expand Down
16 changes: 0 additions & 16 deletions internal/metrics/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,6 @@ func TestAddAPICredentials(t *testing.T) {
assert.Equal(t, "http://some-api.com/endpoint?api_key=12345", req.URL.String())
}

func TestPrewarmConnection(t *testing.T) {

called := false
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
called = true
assert.Equal(t, "/validate?api_key=12345", r.URL.String())
}))
defer server.Close()

cl := MakeAPIClient(context.Background(), server.URL, mockAPIKey)
err := cl.PrewarmConnection()

assert.NoError(t, err)
assert.True(t, called)
}

func TestSendMetricsSuccess(t *testing.T) {
called := false
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down
3 changes: 0 additions & 3 deletions internal/metrics/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ func MakeListener(config Config) Listener {
config.BatchInterval = defaultBatchInterval
}

// Do this in the background, doesn't matter if it returns
go apiClient.PrewarmConnection()

return Listener{
apiClient,
&config,
Expand Down

0 comments on commit 0f938c4

Please sign in to comment.