Skip to content
Draft

wip #10607

Show file tree
Hide file tree
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 @@ -13,8 +13,9 @@ protected String spanKind() {

@Override
public AgentSpan afterStart(final AgentSpan span) {
if (service() != null) {
span.setServiceName(service());
final String service = service();
if (service != null) {
span.setServiceName(service, component());
}
span.setTag(Tags.SPAN_KIND, spanKind());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public AgentSpan onConnection(final AgentSpan span, final CONNECTION connection)
span.setTag(Tags.PEER_HOSTNAME, hostName);

if (Config.get().isDbClientSplitByHost()) {
span.setServiceName(hostName.toString());
span.setServiceName(hostName.toString(), component());
}
}
}
Expand All @@ -88,7 +88,7 @@ protected AgentSpan onInstance(final AgentSpan span, final String dbInstance) {
span.setTag(Tags.DB_INSTANCE, dbInstance);
String serviceName = dbClientService(dbInstance);
if (null != serviceName) {
span.setServiceName(serviceName);
span.setServiceName(serviceName, component());
}
}
return span;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void onURI(@Nonnull final AgentSpan span, @Nonnull final URI uri) {
if (null != host && !host.isEmpty()) {
span.setTag(Tags.PEER_HOSTNAME, host);
if (Config.get().isHttpClientSplitByDomain() && host.charAt(0) >= 'A') {
span.setServiceName(host);
span.setServiceName(host, component());
}
if (port > 0) {
setPeerPort(span, port);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BaseDecoratorTest extends DDSpecification {
_ * span.setTag(_, _) // Want to allow other calls from child implementations.
_ * span.setMeasured(true)
_ * span.setMetric(_, _)
_ * span.setServiceName(_)
_ * span.setServiceName(_, _)
_ * span.setOperationName(_)
_ * span.setSamplingPriority(_)
0 * _
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ClientDecoratorTest extends BaseDecoratorTest {

then:
if (serviceName != null) {
1 * span.setServiceName(serviceName)
1 * span.setServiceName(serviceName, "test-component")
}
1 * span.setMeasured(true)
1 * span.setTag(Tags.COMPONENT, "test-component")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DBTypeProcessingDatabaseClientDecoratorTest extends ClientDecoratorTest {

then:
if (serviceName != null) {
1 * span.setServiceName(serviceName)
1 * span.setServiceName(serviceName, "test-component")
}
1 * span.setMeasured(true)
1 * span.setTag(Tags.COMPONENT, "test-component")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DatabaseClientDecoratorTest extends ClientDecoratorTest {

then:
if (serviceName != null) {
1 * span.setServiceName(serviceName)
1 * span.setServiceName(serviceName, "test-component")
}
1 * span.setMeasured(true)
1 * span.setTag(Tags.COMPONENT, "test-component")
Expand Down Expand Up @@ -58,11 +58,11 @@ class DatabaseClientDecoratorTest extends ClientDecoratorTest {
1 * span.setTag(Tags.PEER_HOSTNAME, session.hostname)
}
if (instanceTypeSuffix && renameByInstance && session.instance) {
1 * span.setServiceName(session.instance + "-" + decorator.dbType())
1 * span.setServiceName(session.instance + "-" + decorator.dbType(), _)
} else if (renameByInstance && session.instance) {
1 * span.setServiceName(session.instance)
1 * span.setServiceName(session.instance, _)
} else if (renameByHost) {
1 * span.setServiceName(session.hostname)
1 * span.setServiceName(session.hostname, _)
}
}
0 * _
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class HttpClientDecoratorTest extends ClientDecoratorTest {
1 * span.setTag(Tags.PEER_PORT, req.url.port)
1 * span.setResourceName({ it as String == req.method.toUpperCase() + " " + req.path }, ResourceNamePriorities.HTTP_PATH_NORMALIZER)
if (renameService) {
1 * span.setServiceName(req.url.host)
1 * span.setServiceName(req.url.host, _)
}
1 * span.traceConfig() >> AgentTracer.traceConfig()
}
Expand Down Expand Up @@ -147,7 +147,7 @@ class HttpClientDecoratorTest extends ClientDecoratorTest {

then:
if (expectedServiceName) {
1 * span.setServiceName(expectedServiceName)
1 * span.setServiceName(expectedServiceName, _)
}
if (url != null) {
1 * span.setResourceName(_, _)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public AgentSpan onConnection(
}
span.setTag(Tags.DB_INSTANCE, instanceName);
if (Config.get().isDbClientSplitByInstance()) {
span.setServiceName(instanceName);
span.setServiceName(instanceName, component());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class AwsSdkClientDecorator extends HttpClientDecorator<Request, Response
public static final boolean SQS_LEGACY_TRACING = Config.get().isSqsLegacyTracingEnabled();

private static final String SQS_SERVICE_NAME =
// this is probably wrong since it should use SpanNaming.instance()...
// but at this point changing the naming will be a breaking change
AWS_LEGACY_TRACING || SQS_LEGACY_TRACING ? "sqs" : Config.get().getServiceName();

private static final String SNS_SERVICE_NAME =
Expand Down Expand Up @@ -106,19 +108,17 @@ public AgentSpan onRequest(final AgentSpan span, final Request request) {
case "SQS.ReceiveMessage":
case "SQS.DeleteMessage":
case "SQS.DeleteMessageBatch":
if (SQS_SERVICE_NAME != null) {
span.setServiceName(SQS_SERVICE_NAME);
}
span.setServiceName(SQS_SERVICE_NAME, component());
break;
case "SNS.Publish":
case "SNS.PublishBatch":
if (SNS_SERVICE_NAME != null) {
span.setServiceName(SNS_SERVICE_NAME);
span.setServiceName(SNS_SERVICE_NAME, component());
}
break;
default:
if (GENERIC_SERVICE_NAME != null) {
span.setServiceName(GENERIC_SERVICE_NAME);
span.setServiceName(GENERIC_SERVICE_NAME, component());
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ abstract class AWS1ClientTest extends VersionedNamingTestBase {
for (def addedTag : additionalTags) {
"$addedTag.key" "$addedTag.value"
}
if (operation == "SendMessage") {
// this is a corner case. The issues is that the aws integration should not set the service name
// but it's doing it.
serviceNameSource "java-aws-sdk"
}
if (peerService == null) {
defaultTagsNoPeerService()
} else {
Expand Down Expand Up @@ -462,6 +467,15 @@ abstract class AWS1ClientTest extends VersionedNamingTestBase {
"peer.service" "${server.address.host}:${server.address.port}"
"_dd.peer.service.source" "peer.service"

System.err.println("BORDEL $operation")

if (operation == "SendMessage") {
System.err.println("BORDEL")
// this is a corner case. The issues is that the aws integration should not set the service name
// but it's doing it.
serviceNameSource "java-aws-sdk"
}

defaultTags(false, true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,18 +242,18 @@ private static AgentSpan onOperation(
case "Sqs.DeleteMessage":
case "Sqs.DeleteMessageBatch":
if (SQS_SERVICE_NAME != null) {
span.setServiceName(SQS_SERVICE_NAME);
span.setServiceName(SQS_SERVICE_NAME, COMPONENT_NAME);
}
break;
case "Sns.PublishBatch":
case "Sns.Publish":
if (SNS_SERVICE_NAME != null) {
span.setServiceName(SNS_SERVICE_NAME);
span.setServiceName(SNS_SERVICE_NAME, COMPONENT_NAME);
}
break;
default:
if (GENERIC_SERVICE_NAME != null) {
span.setServiceName(GENERIC_SERVICE_NAME);
span.setServiceName(GENERIC_SERVICE_NAME, COMPONENT_NAME);
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ abstract class Aws2ClientTest extends VersionedNamingTestBase {
checkPeerService = true
}
urlTags("${server.address}${path}", ExpectedQueryParams.getExpectedQueryParams(operation))
if (operation == "SendMessage") {
// this is a corner case. The issues is that the aws integration should not set the service name
// but it's doing it.
serviceNameSource "java-aws-sdk"
}
defaultTags(false, checkPeerService)
}
}
Expand Down Expand Up @@ -309,6 +314,11 @@ abstract class Aws2ClientTest extends VersionedNamingTestBase {
checkPeerService = true
}
urlTags("${server.address}${path}", ExpectedQueryParams.getExpectedQueryParams(operation))
if (operation == "SendMessage") {
// this is a corner case. The issues is that the aws integration should not set the service name
// but it's doing it.
serviceNameSource "java-aws-sdk"
}
defaultTags(false, checkPeerService)
}
}
Expand Down Expand Up @@ -468,6 +478,11 @@ abstract class Aws2ClientTest extends VersionedNamingTestBase {
measured true
parent()
tags {
if (operation == "SendMessage") {
// this is a corner case. The issues is that the aws integration should not set the service name
// but it's doing it.
serviceNameSource "java-aws-sdk"
}
defaultTags(false, true)

// AWS specific tags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ abstract class SqsClientTest extends VersionedNamingTestBase {
if ({ isDataStreamsEnabled() }) {
"$DDTags.PATHWAY_HASH" { String }
}
serviceNameSource("java-aws-sdk")
defaultTags()
}
}
Expand Down Expand Up @@ -410,6 +411,7 @@ abstract class SqsClientTest extends VersionedNamingTestBase {
"aws.operation" "SendMessageRequest"
"aws.agent" "java-aws-sdk"
"aws.queue.url" "http://localhost:${address.port}/000000000000/somequeue"
serviceNameSource("java-aws-sdk")
defaultTags()
}
}
Expand Down Expand Up @@ -477,6 +479,7 @@ abstract class SqsClientTest extends VersionedNamingTestBase {
"aws.operation" "DeleteMessageRequest"
"aws.agent" "java-aws-sdk"
"aws.queue.url" "http://localhost:${address.port}/000000000000/somequeue"
serviceNameSource("java-aws-sdk")
defaultTags()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ class TimeInQueueForkedTest extends InstrumentationSpecification {
"aws.operation" "SendMessageBatchRequest"
"aws.agent" "java-aws-sdk"
"aws.queue.url" "http://localhost:${address.port}/000000000000/somequeue"
serviceNameSource("java-aws-sdk")
defaultTags()
}
}
Expand All @@ -305,6 +306,9 @@ class TimeInQueueForkedTest extends InstrumentationSpecification {
"aws.operation" "ReceiveMessageRequest"
"aws.agent" "java-aws-sdk"
"aws.queue.url" "http://localhost:${address.port}/000000000000/somequeue"
// the receive instrumentation always do setInstrumentationServiceName
// even when == to DD_SERVICE
serviceNameSource("java-aws-sdk")
defaultTags(parent.resourceName as String == "SQS.SendMessageBatch")
}
}
Expand All @@ -323,6 +327,7 @@ class TimeInQueueForkedTest extends InstrumentationSpecification {
"$Tags.COMPONENT" "java-aws-sdk"
"$Tags.SPAN_KIND" Tags.SPAN_KIND_BROKER
"aws.queue.url" "http://localhost:${address.port}/000000000000/somequeue"
serviceNameSource("java-aws-sdk")
defaultTags(true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ abstract class SqsClientTest extends VersionedNamingTestBase {
"$DDTags.PATHWAY_HASH" { String }
}
urlTags("http://localhost:${address.port}/", ExpectedQueryParams.getExpectedQueryParams("SendMessage"))
serviceNameSource("java-aws-sdk")
defaultTags()
}
}
Expand Down Expand Up @@ -366,6 +367,7 @@ abstract class SqsClientTest extends VersionedNamingTestBase {
"aws.queue.url" "http://localhost:${address.port}/000000000000/somequeue"
"aws.requestId" "00000000-0000-0000-0000-000000000000"
urlTags("http://localhost:${address.port}/", ExpectedQueryParams.getExpectedQueryParams("SendMessage"))
serviceNameSource("java-aws-sdk")
defaultTags()
}
}
Expand Down Expand Up @@ -435,6 +437,7 @@ abstract class SqsClientTest extends VersionedNamingTestBase {
"aws.queue.url" "http://localhost:${address.port}/000000000000/somequeue"
"aws.requestId" { it.trim() == "00000000-0000-0000-0000-000000000000" } // the test server seem messing with request id and insert \n
urlTags("http://localhost:${address.port}/", ExpectedQueryParams.getExpectedQueryParams("DeleteMessage"))
serviceNameSource("java-aws-sdk")
defaultTags()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ class TimeInQueueForkedTest extends InstrumentationSpecification {
"aws.queue.url" "http://localhost:${address.port}/000000000000/somequeue"
"aws.requestId" { it.trim() == "00000000-0000-0000-0000-000000000000" } // the test server seem messing with request id and insert \n
urlTags("http://localhost:${address.port}/", ExpectedQueryParams.getExpectedQueryParams("SendMessageBatch"))
serviceNameSource("java-aws-sdk")
defaultTags()
}
}
Expand All @@ -331,6 +332,9 @@ class TimeInQueueForkedTest extends InstrumentationSpecification {
"aws.agent" "java-aws-sdk"
"aws.queue.url" "http://localhost:${address.port}/000000000000/somequeue"
"aws.requestId" { it.trim() == "00000000-0000-0000-0000-000000000000" } // the test server seem messing with request id and insert \n
// when using time in queue, the instrumentation always set the service name for the receive span
// while it's the same as dd-service, forcing a service name means setting the _dd.svc_src tag
serviceNameSource "java-aws-sdk"
defaultTags(parent.resourceName as String == "Sqs.SendMessageBatch")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void onTransport(AgentSpan span, MessageContext message) {
if (null != host && !host.isEmpty()) {
span.setTag(Tags.PEER_HOSTNAME, host);
if (Config.get().isHttpClientSplitByDomain() && host.charAt(0) >= 'A') {
span.setServiceName(host);
span.setServiceName(host, component());
}
if (port > 0) {
setPeerPort(span, port);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ public void setApplicationName(AgentSpan span, Connection connection) {
protected void postProcessServiceAndOperationName(
AgentSpan span, DatabaseClientDecorator.NamingEntry namingEntry) {
if (namingEntry.getService() != null) {
span.setServiceName(namingEntry.getService());
span.setServiceName(namingEntry.getService(), component());
}
span.setOperationName(namingEntry.getOperation());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public void onTimeInQueue(AgentSpan span, CharSequence resourceName, String serv
span.setResourceName(resourceName);
}
if (null != serviceName) {
span.setServiceName(serviceName);
span.setServiceName(serviceName, component());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,9 @@ abstract class TimeInQueueForkedTestBase extends VersionedNamingTestBase {
tags {
"$Tags.COMPONENT" "jms"
"$Tags.SPAN_KIND" Tags.SPAN_KIND_PRODUCER
// when not using the legacy tracing the service is set to DD_SERVICE
// while it should just not be set at all.
serviceNameSource "jms"
defaultTagsNoPeerService()
}
}
Expand Down Expand Up @@ -679,6 +682,9 @@ abstract class TimeInQueueForkedTestBase extends VersionedNamingTestBase {
if (!isTimestampDisabled) {
"$InstrumentationTags.RECORD_QUEUE_TIME_MS" { it >= 0 }
}
// when not using the legacy tracing the service is set to DD_SERVICE
// while it should just not be set at all.
serviceNameSource "jms"
defaultTags(false)
}
}
Expand Down
Loading
Loading