Skip to content

Commit 6da22d9

Browse files
author
youjie_li
committed
support mongo db.instance tag,db.collection tag and AggregateOperation:code review
1 parent d3b3ca2 commit 6da22d9

File tree

2 files changed

+8
-72
lines changed
  • apm-sniffer/apm-sdk-plugin

2 files changed

+8
-72
lines changed

apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mongodb/v3/support/MongoNamespaceInfo.java

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
package org.apache.skywalking.apm.plugin.mongodb.v3.support;
2020

2121
import com.mongodb.MongoNamespace;
22-
import com.mongodb.annotations.Immutable;
22+
import lombok.EqualsAndHashCode;
23+
import lombok.Getter;
2324
import org.apache.skywalking.apm.util.StringUtil;
2425

25-
@Immutable
26+
@EqualsAndHashCode
27+
@Getter
2628
public class MongoNamespaceInfo {
2729

2830
private final String databaseName;
@@ -49,34 +51,6 @@ public String getCollectionName() {
4951
return collectionName;
5052
}
5153

52-
public boolean equals(Object o) {
53-
if (this == o) {
54-
return true;
55-
} else if (o != null && this.getClass() == o.getClass()) {
56-
MongoNamespaceInfo that = (MongoNamespaceInfo) o;
57-
if (!equals(this.databaseName, that.databaseName)) {
58-
return false;
59-
} else {
60-
return equals(this.collectionName, that.collectionName);
61-
}
62-
} else {
63-
return false;
64-
}
65-
}
66-
67-
private boolean equals(String src, String tgt) {
68-
if (src == null && tgt == null) {
69-
return true;
70-
}
71-
if (src == null && tgt != null) {
72-
return false;
73-
}
74-
if (src != null && tgt == null) {
75-
return false;
76-
}
77-
return src.equals(tgt);
78-
}
79-
8054
public String toString() {
8155
if (StringUtil.isNotBlank(collectionName)) {
8256
return databaseName + '.' + collectionName;
@@ -85,10 +59,4 @@ public String toString() {
8559
}
8660
}
8761

88-
public int hashCode() {
89-
int result = this.databaseName.hashCode();
90-
result = 31 * result + this.collectionName.hashCode();
91-
return result;
92-
}
93-
9462
}

apm-sniffer/apm-sdk-plugin/mongodb-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mongodb/v4/support/MongoNamespaceInfo.java

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
package org.apache.skywalking.apm.plugin.mongodb.v4.support;
2020

2121
import com.mongodb.MongoNamespace;
22-
import com.mongodb.annotations.Immutable;
22+
import lombok.EqualsAndHashCode;
23+
import lombok.Getter;
2324
import org.apache.skywalking.apm.util.StringUtil;
2425

25-
@Immutable
26+
@EqualsAndHashCode
27+
@Getter
2628
public class MongoNamespaceInfo {
2729

2830
private final String databaseName;
@@ -49,34 +51,6 @@ public String getCollectionName() {
4951
return collectionName;
5052
}
5153

52-
public boolean equals(Object o) {
53-
if (this == o) {
54-
return true;
55-
} else if (o != null && this.getClass() == o.getClass()) {
56-
MongoNamespaceInfo that = (MongoNamespaceInfo) o;
57-
if (!equals(this.databaseName, that.databaseName)) {
58-
return false;
59-
} else {
60-
return equals(this.collectionName, that.collectionName);
61-
}
62-
} else {
63-
return false;
64-
}
65-
}
66-
67-
private boolean equals(String src, String tgt) {
68-
if (src == null && tgt == null) {
69-
return true;
70-
}
71-
if (src == null && tgt != null) {
72-
return false;
73-
}
74-
if (src != null && tgt == null) {
75-
return false;
76-
}
77-
return src.equals(tgt);
78-
}
79-
8054
public String toString() {
8155
if (StringUtil.isNotBlank(collectionName)) {
8256
return databaseName + '.' + collectionName;
@@ -85,10 +59,4 @@ public String toString() {
8559
}
8660
}
8761

88-
public int hashCode() {
89-
int result = this.databaseName.hashCode();
90-
result = 31 * result + this.collectionName.hashCode();
91-
return result;
92-
}
93-
9462
}

0 commit comments

Comments
 (0)