Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more tests about OpenTelemetry attributes conventions #7163

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import static datadog.opentelemetry.shim.trace.OtelConventions.OPERATION_NAME_SP
import static datadog.opentelemetry.shim.trace.OtelConventions.SPAN_KIND_INTERNAL
import static datadog.opentelemetry.shim.trace.OtelConventions.toSpanKindTagValue
import static io.opentelemetry.api.common.AttributeKey.longKey
import static io.opentelemetry.api.common.AttributeKey.stringKey
import static io.opentelemetry.api.trace.SpanKind.CLIENT
import static io.opentelemetry.api.trace.SpanKind.CONSUMER
import static io.opentelemetry.api.trace.SpanKind.INTERNAL
Expand Down Expand Up @@ -100,20 +101,21 @@ class OpenTelemetry14ConventionsTest extends AgentTestRunner {
def "test span specific tags"() {
setup:
def builder = tracer.spanBuilder("some-name")
def keyFor = (String key) -> useAttributeKey ? stringKey(key) : key

when:
if (setInBuilder) {
builder.setAttribute("operation.name", "my-operation")
.setAttribute("service.name", "my-service")
.setAttribute("resource.name", "/my-resource")
.setAttribute("span.type", "http")
builder.setAttribute(keyFor("operation.name"), "my-operation")
.setAttribute(keyFor("service.name"), "my-service")
.setAttribute(keyFor("resource.name"), "/my-resource")
.setAttribute(keyFor("span.type"), "http")
}
def result = builder.startSpan()
if (!setInBuilder) {
result.setAttribute("operation.name", "my-operation")
.setAttribute("service.name", "my-service")
.setAttribute("resource.name", "/my-resource")
.setAttribute("span.type", "http")
result.setAttribute(keyFor("operation.name"), "my-operation")
.setAttribute(keyFor("service.name"), "my-service")
.setAttribute(keyFor("resource.name"), "/my-resource")
.setAttribute(keyFor("span.type"), "http")
}
result.end()

Expand All @@ -135,7 +137,11 @@ class OpenTelemetry14ConventionsTest extends AgentTestRunner {
}

where:
setInBuilder << [true, false]
setInBuilder | useAttributeKey
true | true
true | false
false | true
false | false
}

def "test span analytics.event specific tag"() {
Expand Down
Loading