Class MongoTelemetry

java.lang.Object
io.opentelemetry.instrumentation.mongo.v3_1.MongoTelemetry

public final class MongoTelemetry extends Object
Entrypoint to OpenTelemetry instrumentation of the MongoDB client.
  • Method Details

    • create

      public static MongoTelemetry create(io.opentelemetry.api.OpenTelemetry openTelemetry)
      Returns a new MongoTelemetry configured with the given OpenTelemetry.
    • builder

      public static MongoTelemetryBuilder builder(io.opentelemetry.api.OpenTelemetry openTelemetry)
      Returns a new MongoTelemetryBuilder configured with the given OpenTelemetry.
    • createCommandListener

      public com.mongodb.event.CommandListener createCommandListener(List<com.mongodb.ServerAddress> configuredServerAddresses)
      Returns a new CommandListener using the supplied seed list to derive the client's logical MongoDB server target.

      Use this overload when you have the seed addresses from the client's configuration. Pass the complete seed list used to configure the client.

      The supplied addresses are used to derive the stable server.address and server.port attributes when stable database semantic conventions are enabled.

      Where the old database conventions are emitted, db.connection_string continues to describe the server selected by the driver.

      Parameters:
      configuredServerAddresses - all seed addresses configured for the client
      Returns:
      a command listener
    • createCommandListener

      public com.mongodb.event.CommandListener createCommandListener()
      Returns a new CommandListener that can be used with methods like MongoClientOptions.Builder.addCommandListener(CommandListener).

      Use this method only when the client's configured seed addresses are not available. If they are available, use createCommandListener(List) so that stable database semantic conventions can derive server.address and server.port from the configured target.