lib/sensu/server/mutate.rb
# Mutate event data for a handler. By default, the "json"
# mutator is used, unless the handler specifies another mutator.
# If a mutator does not exist, not defined or a missing
# extension, an error will be logged and the
# `@in_progress[:events]` is decremented by `1`. This method
# first checks for the existence of a standard mutator, then
# checks for an extension if a standard mutator is not defined.
#
# @param handler [Hash] definition.
# @param event [Hash] data.
# @param callback [Proc] to call when the mutator executes/runs
#   successfully (event handler).
Mutate event data for a handler. By default, the "json"
mutator is used, unless the handler specifies another mutator.
If a mutator does not exist, not defined or a missing
extension, an error will be logged and the
`@in_progress[:events]` is decremented by `1`. This method
first checks for the existence of a standard mutator, then
checks for an extension if a standard mutator is not defined.
Mutate event data for a handler . By default the " json " mutator is used unless the handler specifies another mutator . If a mutator does not exist not defined or a missing extension an error will be logged and the ` @in_progress [ : events ] ` is decremented by ` 1 ` . This method first checks for the existence of a standard mutator then checks for an extension if a standard mutator is not defined .
def mutate_event(handler, event, &callback)
        mutator_name = handler[:mutator] || "json"
        case
        when @settings.mutator_exists?(mutator_name)
          mutator = @settings[:mutators][mutator_name]
          pipe_mutator(mutator, event, &callback)
        when @extensions.mutator_exists?(mutator_name)
          mutator = @extensions[:mutators][mutator_name]
          mutator_extension(mutator, event, &callback)
        else
          @logger.error("unknown mutator", {
            :mutator_name => mutator_name
          })
          @in_progress[:events] -= 1 if @in_progress
        end
      end
def mutate_event ( handler , event , & callback ) mutator_name = handler [ :mutator ] || "json" case when @settings . mutator_exists? ( mutator_name ) mutator = @settings [ :mutators ] [ mutator_name ] pipe_mutator ( mutator , event , & callback ) when @extensions . mutator_exists? ( mutator_name ) mutator = @extensions [ :mutators ] [ mutator_name ] mutator_extension ( mutator , event , & callback ) else @logger . error ( "unknown mutator" , { :mutator_name => mutator_name } ) @in_progress [ :events ] -= 1 if @in_progress end end
Mutate event data for a handler.
Mutate event data for a handler .
handler
None
event
None
callback
to call when the mutator executes/runs successfully (event handler).
to call when the mutator executes / runs successfully ( event handler ) .