Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
contrib/internal/httptrace: set http.host tag on request Host not URL…
….host (#1327)
- Loading branch information
1 parent
b14a582
commit 5915aae
Showing
2 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016 Datadog, Inc. | ||
|
||
package httptrace | ||
|
||
import ( | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/mocktracer" | ||
) | ||
|
||
func TestStartRequestSpan(t *testing.T) { | ||
mt := mocktracer.Start() | ||
defer mt.Stop() | ||
r := httptest.NewRequest(http.MethodGet, "/somePath", nil) | ||
s, _ := StartRequestSpan(r) | ||
s.Finish() | ||
spans := mt.FinishedSpans() | ||
|
||
require.Len(t, spans, 1) | ||
assert.Equal(t, "example.com", spans[0].Tag("http.host")) | ||
} |