Type alias DataAPIClientEventMap

DataAPIClientEventMap: AdminCommandEventMap & CommandEventMap

Overview

An enumeration of the events that may be emitted by the DataAPIClient, or any of its children classes, when logging is enabled.

See LoggingConfig for more information on how to configure logging, and enable/disable specific events.

When to prefer events

Events can be thought of as a "generic logging interface" for Data API & DevOps operations.

Though the LoggingConfig, you can also enable logging to the console, but:

  • You're forced to use stdout/stderr as outputs
  • You can't programmatically interact with the log data
  • You can't filter the logs

BaseClientEvents are a more flexible way to interact with the logs, allowing you to basically plug in, or even build, your own logging system around them.

And, of course, you're free to use both events and console logging in tandem, if you so choose.

Disclaimer

Note that these emit real commands, not any abstracted commands, such as insertMany or updateMany, which may be split into multiple of those commands under the hood.

Event types

There are two major categories of events emitted by the DataAPIClient:

  • CommandEvents - Events related to the execution of a command
    • i.e. Db, Collection, Table operations
  • AdminCommandEvents - Events related to the execution of an admin command
    • i.e. AstraAdmin, DbAdmin operations

Every event may be enabled/disabled individually, independent of one another.

View each command's documentation for more information on the specific events they emit.

Commands
Name Description Default behavior if enabled
commandStarted Emitted when a command is started, before the initial HTTP request is made. Emit as event; does not log
commandSucceeded Emitted when a command has succeeded (i.e. the status code is 200, and no errors are returned). Emit as event; does not log
commandFailed Emitted when a command has errored (i.e. the status code is not 200, or errors are returned). Emit as event; logs to stderr
commandWarnings Emitted when a command has warnings (i.e. when the status.warnings field is present). Emit as event; logs to stderr
Admin commands
Name Description Default behavior if enabled
adminCommandStarted Emitted when an admin command is started, before the initial HTTP request is made. Emits the event; logs to stderr
adminCommandPolling Emitted when a command is polling in a long-running operation (i.e. AstraAdmin.createDatabase). Emits the event; logs to stderr
adminCommandSucceeded Emitted when an admin command has succeeded, after any necessary polling (i.e. when an HTTP 200 is returned). Emits the event; logs to stderr
adminCommandFailed Emitted when an admin command has failed (i.e. when an HTTP 4xx/5xx is returned, even if while polling). Emits the event; logs to stderr
adminCommandWarnings Emitted when an admin command has warnings (i.e. when the status.warnings field is present). Emits the event; logs to stderr

See

  • LoggingConfig
  • CommandEventMap
  • AdminCommandEventMap