BaseMetricsConfiguration

pydantic settings safir.metrics.BaseMetricsConfiguration

Metrics configuration, including the required Kafka configuration.

Currently, this only configures events, but if additional types of metrics are added in the future, that configuration will be added here.

This is the recommended configuration approach if you don’t need to use Kafka, the schema manager, or the schema registry in any other parts of your application. Applications that also use Kafka directly should instead create a EventManager with externally-managed Kafka clients.

Parameters:

Show JSON schema
{
   "title": "BaseMetricsConfiguration",
   "description": "Metrics configuration, including the required Kafka configuration.\n\nCurrently, this only configures events, but if additional types of metrics\nare added in the future, that configuration will be added here.\n\nThis is the recommended configuration approach if you don't need to use\nKafka, the schema manager, or the schema registry in any other parts of\nyour application. Applications that also use Kafka directly should instead\ncreate a `~safir.metrics.EventManager` with externally-managed Kafka\nclients.",
   "type": "object",
   "properties": {
      "appName": {
         "description": "The name of the application that is emitting these metrics",
         "title": "Application name",
         "type": "string"
      },
      "events": {
         "$ref": "#/$defs/EventsConfiguration",
         "title": "Events configuration"
      }
   },
   "$defs": {
      "EventsConfiguration": {
         "additionalProperties": false,
         "description": "Configuration for emitting events.",
         "properties": {
            "topicPrefix": {
               "default": "lsst.square.metrics.events",
               "description": "You probably should use the default here. It could be useful in development scenarios to change this.",
               "title": "Metrics topic prefix",
               "type": "string"
            }
         },
         "title": "EventsConfiguration",
         "type": "object"
      }
   },
   "additionalProperties": false,
   "required": [
      "appName"
   ]
}

Config:
  • alias_generator: function = <function to_camel at 0x7f06183e2160>

  • populate_by_name: bool = True

Fields:
field application: str [Required]

The name of the application that is emitting these metrics

field events: EventsConfiguration [Optional]
abstract make_manager(logger=None)

Construct an EventManager.

Parameters:

logger (BoundLogger | None, default: None) – Logger to use for internal logging. If not given, the safir.metrics logger will be used.

Returns:

An event manager appropriate to the configuration.

Return type:

EventManager