Skip to content

Commit

Permalink
Added test case to the new option in datadog exporter.
Browse files Browse the repository at this point in the history
  • Loading branch information
gfonseca-tc committed Dec 3, 2021
1 parent 7477ec5 commit fa17765
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion exporter/datadogexporter/translate_traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,8 @@ func TestSpanResourceTranslationRpcFallback(t *testing.T) {
// ensure that the datadog span name uses IL name +kind when available and falls back to opetelemetry + kind
func TestSpanNameTranslation(t *testing.T) {
span := pdata.NewSpan()
span.SetName("Default Name")
spanName := "Default Name"
span.SetName(spanName)
span.SetKind(pdata.SpanKindServer)

ddIlTags := map[string]string{
Expand Down Expand Up @@ -1061,13 +1062,15 @@ func TestSpanNameTranslation(t *testing.T) {
spanNameCur := getDatadogSpanName(span, ddIlTagsCur, false)
spanNameUnusual := getDatadogSpanName(span, ddIlTagsUnusual, false)
spanNameHyphen := getDatadogSpanName(span, ddIlTagsHyphen, false)
spanNameAsResourceName := getDatadogSpanName(span, ddIlTagsHyphen, true)

assert.Equal(t, strings.ToLower(fmt.Sprintf("%s.%s", "il_name", strings.TrimPrefix(pdata.SpanKindServer.String(), "SPAN_KIND_"))), spanNameIl)
assert.Equal(t, strings.ToLower(fmt.Sprintf("%s.%s", "opentelemetry", strings.TrimPrefix(pdata.SpanKindServer.String(), "SPAN_KIND_"))), spanNameDefault)
assert.Equal(t, strings.ToLower(fmt.Sprintf("%s.%s", "old_value", strings.TrimPrefix(pdata.SpanKindServer.String(), "SPAN_KIND_"))), spanNameOld)
assert.Equal(t, strings.ToLower(fmt.Sprintf("%s.%s", "current_value", strings.TrimPrefix(pdata.SpanKindServer.String(), "SPAN_KIND_"))), spanNameCur)
assert.Equal(t, strings.ToLower(fmt.Sprintf("%s.%s", "unusual_value", strings.TrimPrefix(pdata.SpanKindServer.String(), "SPAN_KIND_"))), spanNameUnusual)
assert.Equal(t, strings.ToLower(fmt.Sprintf("%s.%s", "hyphenated_value", strings.TrimPrefix(pdata.SpanKindServer.String(), "SPAN_KIND_"))), spanNameHyphen)
assert.Equal(t, spanName, spanNameAsResourceName)
}

// ensure that the datadog span name uses IL name +kind when available and falls back to opetelemetry + kind
Expand Down

0 comments on commit fa17765

Please sign in to comment.