Skip to content
Merged
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
7 changes: 0 additions & 7 deletions dd-java-agent/dd-java-agent.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,6 @@ dependencies {
testCompile deps.opentracingMock
testCompile deps.testLogging
testCompile deps.guava
testCompile group: 'org.assertj', name: 'assertj-core', version: '2.9.+'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.19.0'

testCompile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.4.2'
testCompile group: 'org.mongodb', name: 'mongodb-driver-async', version: '3.4.2'
// run embedded mongodb for integration testing
testCompile group: 'de.flapdoodle.embed', name: 'de.flapdoodle.embed.mongo', version: '1.50.5'
}

tasks.withType(Test).configureEach {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ dependencies {
implementation deps.autoservice

testCompile project(':dd-java-agent:testing')

testCompile group: 'org.assertj', name: 'assertj-core', version: '2.9.+'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.19.0'
testCompile project(':dd-java-agent:instrumentation:mongo').sourceSets.test.output
testCompile group: 'de.flapdoodle.embed', name: 'de.flapdoodle.embed.mongo', version: '1.50.5'

testCompile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.1.0'
latestDepTestCompile group: 'org.mongodb', name: 'mongo-java-driver', version: '+'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package datadog.trace.instrumentation.mongo;

import com.mongodb.connection.ClusterId;
import com.mongodb.connection.ConnectionDescription;
import com.mongodb.connection.ConnectionId;
import com.mongodb.connection.ServerId;
import com.mongodb.event.CommandStartedEvent;
import datadog.trace.agent.decorator.DatabaseClientDecorator;
import datadog.trace.api.DDSpanTypes;
Expand Down Expand Up @@ -48,19 +52,25 @@ protected String dbUser(final CommandStartedEvent event) {

@Override
protected String dbInstance(final CommandStartedEvent event) {
// Use description if set.
final ConnectionDescription connectionDescription = event.getConnectionDescription();
if (connectionDescription != null) {
final ConnectionId connectionId = connectionDescription.getConnectionId();
if (connectionId != null) {
final ServerId serverId = connectionId.getServerId();
if (serverId != null) {
ClusterId clusterId = serverId.getClusterId();
if (clusterId != null) {
String description = clusterId.getDescription();
if (description != null) {
return description;
}
}
}
}
}
// Fallback to db name.
return event.getDatabaseName();
// This would be the "proper" db.instance:
// final ConnectionDescription connectionDescription = event.getConnectionDescription();
// if (connectionDescription != null) {
// final ConnectionId connectionId = connectionDescription.getConnectionId();
// if (connectionId != null) {
// final ServerId serverId = connectionId.getServerId();
// if (serverId != null) {
// return serverId.toString();
// }
// }
// }
// return null;
}

public Span onStatement(final Span span, final BsonDocument statement) {
Expand Down
Loading