def ExportModelOperationsMixin(model_name):
<EOL>model_inserts.labels(model_name)<EOL>model_updates.labels(model_name)<EOL>model_deletes.labels(model_name)<EOL>class Mixin(object):<EOL><INDENT>def _do_insert(self, *args, **kwargs):<EOL><INDENT>model_inserts.labels(model_name).inc()<EOL>return super(Mixin, self)._do_insert(*args, **kwargs)<EOL><DEDENT>def _do_update(self, *args, **kwargs):<EOL><INDENT>model_updates.labels(model_name).inc()<EOL>return super(Mixin, self)._do_update(*args, **kwargs)<EOL><DEDENT>def delete(self, *args, **kwargs):<EOL><INDENT>model_deletes.labels(model_name).inc()<EOL>return super(Mixin, self).delete(*args, **kwargs)<EOL><DEDENT><DEDENT>return Mixin<EOL>
Returns a mixin for models to export counters for lifecycle operations.

    Usage:
      class User(ExportModelOperationsMixin('user'), Model):
          ...