Skip to content

Commit 34f695f

Browse files
committed
Moved to using path instead of the full URL
1 parent fea1aea commit 34f695f

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

exporter/signalfxexporter/exporter_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ func TestConsumeMetrics(t *testing.T) {
210210
converter: c,
211211
}
212212

213-
errMsg := fmt.Sprintf("HTTP %q %d %q",
214-
serverURL.JoinPath("/v2/datapoint").String(),
213+
errMsg := fmt.Sprintf("HTTP \"/v2/datapoint\" %d %q",
215214
tt.wantStatusCode,
216215
http.StatusText(tt.wantStatusCode),
217216
)
@@ -2079,8 +2078,7 @@ func TestConsumeMixedMetrics(t *testing.T) {
20792078
numDroppedTimeSeries, err := sfxClient.pushMetricsData(context.Background(), tt.md)
20802079
assert.Equal(t, tt.numDroppedTimeSeries, numDroppedTimeSeries)
20812080

2082-
errMsg := fmt.Sprintf("HTTP %q %d %q",
2083-
serverURL.JoinPath("/v2/datapoint").String(),
2081+
errMsg := fmt.Sprintf("HTTP \"/v2/datapoint\" %d %q",
20842082
tt.wantStatusCode,
20852083
http.StatusText(tt.wantStatusCode),
20862084
)

exporter/splunkhecexporter/client_test.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,8 +1317,7 @@ func TestErrorReceived(t *testing.T) {
13171317
case <-time.After(5 * time.Second):
13181318
t.Fatal("Should have received request")
13191319
}
1320-
errMsg := fmt.Sprintf("HTTP %q %d %q",
1321-
cfg.ClientConfig.Endpoint,
1320+
errMsg := fmt.Sprintf("HTTP \"/services/collector\" %d %q",
13221321
http.StatusInternalServerError,
13231322
http.StatusText(http.StatusInternalServerError),
13241323
)
@@ -1400,9 +1399,8 @@ func TestHeartbeatStartupFailed(t *testing.T) {
14001399
assert.NoError(t, err)
14011400
assert.EqualError(t,
14021401
exporter.Start(context.Background(), componenttest.NewNopHost()),
1403-
fmt.Sprintf("%s: heartbeat on startup failed: HTTP %q 403 \"Forbidden\"",
1402+
fmt.Sprintf("%s: heartbeat on startup failed: HTTP \"/services/collector\" 403 \"Forbidden\"",
14041403
params.ID.String(),
1405-
cfg.ClientConfig.Endpoint,
14061404
),
14071405
)
14081406
assert.NoError(t, exporter.Shutdown(context.Background()))
@@ -1602,7 +1600,7 @@ func Test_pushLogData_PostError(t *testing.T) {
16021600

16031601
func Test_pushLogData_ShouldAddResponseTo400Error(t *testing.T) {
16041602
config := NewFactory().CreateDefaultConfig().(*Config)
1605-
url := &url.URL{Scheme: "http", Host: "splunk"}
1603+
url := &url.URL{Scheme: "http", Host: "splunk", Path: "/v1/endpoint"}
16061604
splunkClient := newLogsClient(exportertest.NewNopSettings(metadata.Type), NewFactory().CreateDefaultConfig().(*Config))
16071605
logs := createLogData(1, 1, 1)
16081606

@@ -1614,7 +1612,7 @@ func Test_pushLogData_ShouldAddResponseTo400Error(t *testing.T) {
16141612
// Sending logs using the client.
16151613
err := splunkClient.pushLogData(context.Background(), logs)
16161614
require.True(t, consumererror.IsPermanent(err), "Expecting permanent error")
1617-
require.EqualError(t, err, "Permanent error: HTTP \"http://splunk\" 400 \"Bad Request\"")
1615+
require.EqualError(t, err, "Permanent error: HTTP \"/v1/endpoint\" 400 \"Bad Request\"")
16181616
// The returned error should contain the response body responseBody.
16191617

16201618
// An HTTP client that returns some other status code other than 400 and response body responseBody.
@@ -1623,7 +1621,7 @@ func Test_pushLogData_ShouldAddResponseTo400Error(t *testing.T) {
16231621
// Sending logs using the client.
16241622
err = splunkClient.pushLogData(context.Background(), logs)
16251623
require.False(t, consumererror.IsPermanent(err), "Expecting non-permanent error")
1626-
require.EqualError(t, err, "HTTP \"http://splunk\" 500 \"Internal Server Error\"")
1624+
require.EqualError(t, err, "HTTP \"/v1/endpoint\" 500 \"Internal Server Error\"")
16271625
// The returned error should not contain the response body responseBody.
16281626
assert.NotContains(t, err.Error(), responseBody)
16291627
}

internal/splunk/httprequest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func HandleHTTPCode(resp *http.Response) error {
2424

2525
err := fmt.Errorf(
2626
"HTTP %q %d %q",
27-
resp.Request.URL.String(),
27+
resp.Request.URL.Path,
2828
resp.StatusCode,
2929
http.StatusText(resp.StatusCode),
3030
)

internal/splunk/httprequest_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func TestConsumeMetrics(t *testing.T) {
5555
t.Run(tt.name, func(t *testing.T) {
5656
resp := &http.Response{
5757
Request: &http.Request{
58-
URL: &url.URL{Scheme: "http", Host: "splunk.com"},
58+
URL: &url.URL{Scheme: "http", Host: "splunk.com", Path: "/endpoint"},
5959
},
6060
StatusCode: tt.httpResponseCode,
6161
}
@@ -78,7 +78,7 @@ func TestConsumeMetrics(t *testing.T) {
7878
}
7979

8080
if tt.wantThrottleErr {
81-
expected := fmt.Errorf("HTTP \"http://splunk.com\" %d %q", tt.httpResponseCode, http.StatusText(tt.httpResponseCode))
81+
expected := fmt.Errorf("HTTP \"/endpoint\" %d %q", tt.httpResponseCode, http.StatusText(tt.httpResponseCode))
8282
expected = exporterhelper.NewThrottleRetry(expected, time.Duration(tt.retryAfter)*time.Second)
8383
assert.EqualValues(t, expected, err)
8484
return

0 commit comments

Comments
 (0)