Skip to content

Commit 3bc214c

Browse files
committed
Make MongoHandlerContext public to leverage contextual information to customize Observations.
Closes #4622
1 parent 9804f88 commit 3bc214c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

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

+8-7
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@
1515
*/
1616
package org.springframework.data.mongodb.observability;
1717

18+
import io.micrometer.observation.Observation;
19+
import io.micrometer.observation.transport.Kind;
20+
import io.micrometer.observation.transport.SenderContext;
21+
1822
import java.util.Arrays;
1923
import java.util.LinkedHashSet;
2024
import java.util.Set;
2125

2226
import org.bson.BsonDocument;
2327
import org.bson.BsonValue;
28+
2429
import org.springframework.lang.Nullable;
2530

2631
import com.mongodb.ConnectionString;
@@ -29,10 +34,6 @@
2934
import com.mongodb.event.CommandStartedEvent;
3035
import com.mongodb.event.CommandSucceededEvent;
3136

32-
import io.micrometer.observation.Observation;
33-
import io.micrometer.observation.transport.Kind;
34-
import io.micrometer.observation.transport.SenderContext;
35-
3637
/**
3738
* A {@link Observation.Context} that contains MongoDB events.
3839
*
@@ -41,7 +42,7 @@
4142
* @author Mark Paluch
4243
* @since 4.0
4344
*/
44-
class MongoHandlerContext extends SenderContext<Object> {
45+
public class MongoHandlerContext extends SenderContext<Object> {
4546

4647
/**
4748
* @see <a href=
@@ -96,11 +97,11 @@ public ConnectionString getConnectionString() {
9697
return connectionString;
9798
}
9899

99-
public void setCommandSucceededEvent(CommandSucceededEvent commandSucceededEvent) {
100+
void setCommandSucceededEvent(CommandSucceededEvent commandSucceededEvent) {
100101
this.commandSucceededEvent = commandSucceededEvent;
101102
}
102103

103-
public void setCommandFailedEvent(CommandFailedEvent commandFailedEvent) {
104+
void setCommandFailedEvent(CommandFailedEvent commandFailedEvent) {
104105
this.commandFailedEvent = commandFailedEvent;
105106
}
106107

0 commit comments

Comments
 (0)