Class MongodbObservationContext
java.lang.Object
io.micrometer.observation.Observation.Context
io.micrometer.observation.transport.SenderContext<Object>
com.mongodb.observability.micrometer.MongodbObservationContext
- All Implemented Interfaces:
io.micrometer.observation.Observation.ContextView
public class MongodbObservationContext
extends io.micrometer.observation.transport.SenderContext<Object>
A MongoDB-specific
SenderContext for Micrometer observations.
Extends SenderContext with Kind.CLIENT to preserve the client span kind
in the tracing bridge. Provides a MongoDB-specific type that users can filter on
when registering ObservationHandler or ObservationConvention instances.
Domain fields (commandName, databaseName, etc.) are populated by the driver after
the observation is started and before it is stopped. The ObservationConvention
reads these fields at stop time to produce the final tag key-values.
- Since:
- 5.7
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newMongodbObservationContextwithKind.CLIENTkind. -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidsetCollectionName(String collectionName) voidsetCommandName(String commandName) voidsetConnectionId(ConnectionId connectionId) voidsetCursorId(Long cursorId) voidsetDatabaseName(String databaseName) voidsetObservationType(MongodbObservation observationType) voidsetQueryText(String queryText) voidsetResponseStatusCode(String responseStatusCode) voidsetServerAddress(ServerAddress serverAddress) voidsetSessionId(String sessionId) voidsetTransactionNumber(Long transactionNumber) voidsetUnixSocket(boolean unixSocket) Methods inherited from class io.micrometer.observation.transport.SenderContext
getCarrier, getKind, getRemoteServiceAddress, getRemoteServiceName, getSetter, setCarrier, setRemoteServiceAddress, setRemoteServiceNameMethods inherited from class io.micrometer.observation.Observation.Context
addHighCardinalityKeyValue, addHighCardinalityKeyValues, addLowCardinalityKeyValue, addLowCardinalityKeyValues, clear, computeIfAbsent, containsKey, get, getAllKeyValues, getContextualName, getError, getHighCardinalityKeyValue, getHighCardinalityKeyValues, getLowCardinalityKeyValue, getLowCardinalityKeyValues, getName, getOrDefault, getParentObservation, getRequired, put, remove, removeHighCardinalityKeyValue, removeHighCardinalityKeyValues, removeLowCardinalityKeyValue, removeLowCardinalityKeyValues, setContextualName, setError, setName, setParentObservation, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.micrometer.observation.Observation.ContextView
getOrDefault
-
Constructor Details
-
MongodbObservationContext
public MongodbObservationContext()Creates a newMongodbObservationContextwithKind.CLIENTkind.
-
-
Method Details
-
getCommandName
- Returns:
- the command name, or null if not set
-
setCommandName
- Parameters:
commandName- the command name
-
getDatabaseName
- Returns:
- the database name, or null if not set
-
setDatabaseName
- Parameters:
databaseName- the database name
-
getCollectionName
- Returns:
- the collection name, or null if not set
-
setCollectionName
- Parameters:
collectionName- the collection name
-
getServerAddress
- Returns:
- the server address, or null if not set
-
setServerAddress
- Parameters:
serverAddress- the server address
-
getConnectionId
- Returns:
- the connection ID, or null if not set
-
setConnectionId
- Parameters:
connectionId- the connection ID
-
getObservationType
- Returns:
- the observation type, or null if not set
-
setObservationType
- Parameters:
observationType- the observation type
-
getCursorId
- Returns:
- the cursor ID, or null if not set
-
setCursorId
- Parameters:
cursorId- the cursor ID
-
getTransactionNumber
- Returns:
- the transaction number, or null if not set
-
setTransactionNumber
- Parameters:
transactionNumber- the transaction number
-
getSessionId
- Returns:
- the logical session ID, or null if not set
-
setSessionId
- Parameters:
sessionId- the logical session ID
-
isUnixSocket
public boolean isUnixSocket()- Returns:
- true if the connection uses a Unix domain socket
-
setUnixSocket
public void setUnixSocket(boolean unixSocket) - Parameters:
unixSocket- whether the connection uses a Unix domain socket
-
getQueryText
- Returns:
- the query text, or null if not set
-
setQueryText
- Parameters:
queryText- the query text
-
getResponseStatusCode
- Returns:
- the response status code, or null if not set
-
setResponseStatusCode
- Parameters:
responseStatusCode- the response status code
-