Skip to content

Commit f4e480d

Browse files
committed
create test trace using testdata instead of manually
1 parent 622783f commit f4e480d

File tree

1 file changed

+2
-33
lines changed

1 file changed

+2
-33
lines changed

receiver/otlpreceiver/otlp_test.go

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
"go.opentelemetry.io/collector/component/componenttest"
4444
"go.opentelemetry.io/collector/consumer/pdata"
4545
"go.opentelemetry.io/collector/exporter/exportertest"
46+
"go.opentelemetry.io/collector/internal/data/testdata"
4647
"go.opentelemetry.io/collector/observability/observabilitytest"
4748
"go.opentelemetry.io/collector/testutils"
4849
"go.opentelemetry.io/collector/translator/conventions"
@@ -189,39 +190,7 @@ func TestProtoHttp(t *testing.T) {
189190

190191
url := fmt.Sprintf("http://%s/v1/trace", addr)
191192

192-
wantOtlp := []*otlptrace.ResourceSpans{
193-
{
194-
Resource: &otlpresource.Resource{
195-
Attributes: []*otlpcommon.AttributeKeyValue{
196-
{
197-
Key: conventions.AttributeHostHostname,
198-
StringValue: "testHost",
199-
Type: otlpcommon.AttributeKeyValue_STRING,
200-
},
201-
},
202-
},
203-
InstrumentationLibrarySpans: []*otlptrace.InstrumentationLibrarySpans{
204-
{
205-
Spans: []*otlptrace.Span{
206-
{
207-
TraceId: []byte{0x5B, 0x8E, 0xFF, 0xF7, 0x98, 0x3, 0x81, 0x3, 0xD2, 0x69, 0xB6, 0x33, 0x81, 0x3F, 0xC6, 0xC},
208-
SpanId: []byte{0xEE, 0xE1, 0x9B, 0x7E, 0xC3, 0xC1, 0xB1, 0x73},
209-
Name: "testSpan",
210-
StartTimeUnixNano: 1544712660000000000,
211-
EndTimeUnixNano: 1544712661000000000,
212-
Attributes: []*otlpcommon.AttributeKeyValue{
213-
{
214-
Key: "attr1",
215-
Type: otlpcommon.AttributeKeyValue_INT,
216-
IntValue: 55,
217-
},
218-
},
219-
},
220-
},
221-
},
222-
},
223-
},
224-
}
193+
wantOtlp := pdata.TracesToOtlp(testdata.GenerateTraceDataOneSpan())
225194

226195
traceProto := collectortrace.ExportTraceServiceRequest{
227196
ResourceSpans: wantOtlp,

0 commit comments

Comments
 (0)