Skip to content

Commit be8cf57

Browse files
Added more docs
1 parent 112039f commit be8cf57

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/observability/MongoHandlerContext.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
import com.mongodb.event.CommandSucceededEvent;
2222
import io.micrometer.core.instrument.Timer;
2323

24+
/**
25+
* A {@link Timer.HandlerContext} that contains Mongo events.
26+
*
27+
* @author Marcin Grzejszczak
28+
* @since 3.0.0
29+
*/
2430
public abstract class MongoHandlerContext extends Timer.HandlerContext {
2531

2632
private final CommandStartedEvent commandStartedEvent;
@@ -53,5 +59,12 @@ public void setCommandFailedEvent(CommandFailedEvent commandFailedEvent) {
5359
this.commandFailedEvent = commandFailedEvent;
5460
}
5561

62+
/**
63+
* The contextual name is a name that describes an implementation of this class
64+
* that is more precise within this context. This can be used e.g. as a
65+
* more human-readable span name.
66+
*
67+
* @return contextual name
68+
*/
5669
public abstract String getContextualName();
5770
}

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/observability/MongoTracingRecordingHandler.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,16 @@
3131

3232
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
3333

34+
/**
35+
* A {@link TracingRecordingHandler} that handles {@link MongoHandlerContext}.
36+
* It configures a span specific for Mongo communication.
37+
*
38+
* @author Marcin Grzejszczak
39+
* @since 3.0.0
40+
*/
3441
public class MongoTracingRecordingHandler implements TracingRecordingHandler<MongoHandlerContext> {
3542

36-
private static final Log LOGGER = LogFactory.getLog(MappingMongoConverter.class);
43+
private static final Log LOGGER = LogFactory.getLog(MongoTracingRecordingHandler.class);
3744

3845
private final Tracer tracer;
3946

@@ -88,6 +95,11 @@ private void setRemoteIpAndPort(CommandStartedEvent event, Span.Builder spanBuil
8895
return context instanceof MongoHandlerContext;
8996
}
9097

98+
/**
99+
* Should remote ip and port be set on the span.
100+
*
101+
* @return {@code true} when the remote ip and port should be set
102+
*/
91103
public boolean isSetRemoteIpAndPortEnabled() {
92104
return this.setRemoteIpAndPortEnabled;
93105
}

0 commit comments

Comments
 (0)