Class: Appsignal::EventFormatter::Moped::QueryFormatter Private

Inherits:
Appsignal::EventFormatter show all
Defined in:
lib/appsignal/event_formatter/moped/query_formatter.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary

Constants inherited from Appsignal::EventFormatter

DEFAULT, SQL_BODY_FORMAT

Instance Method Summary collapse

Methods inherited from Appsignal::EventFormatter

format, formatter_classes, formatters, initialize_formatters, register, registered?, unregister

Instance Method Details

#format(payload) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/appsignal/event_formatter/moped/query_formatter.rb', line 8

def format(payload)
  if payload[:ops] && !payload[:ops].empty?
    op = payload[:ops].first
    case op.class.to_s
    when "Moped::Protocol::Command"
      [
        "Command", {
          :database => op.full_collection_name,
          :selector => sanitize(op.selector, true, :mongodb)
        }.inspect
      ]
    when "Moped::Protocol::Query"
      [
        "Query", {
          :database => op.full_collection_name,
          :selector => sanitize(op.selector, false, :mongodb),
          :flags    => op.flags,
          :limit    => op.limit,
          :skip     => op.skip,
          :fields   => op.fields
        }.inspect
      ]
    when "Moped::Protocol::Delete"
      [
        "Delete", {
          :database => op.full_collection_name,
          :selector => sanitize(op.selector, false, :mongodb),
          :flags    => op.flags
        }.inspect
      ]
    when "Moped::Protocol::Insert"
      [
        "Insert", {
          :database   => op.full_collection_name,
          :documents  => sanitize(op.documents, true, :mongodb),
          :count      => op.documents.count,
          :flags      => op.flags
        }.inspect
      ]
    when "Moped::Protocol::Update"
      [
        "Update",
        {
          :database => op.full_collection_name,
          :selector => sanitize(op.selector, false, :mongodb),
          :update   => sanitize(op.update, true, :mongodb),
          :flags    => op.flags
        }.inspect
      ]
    when "Moped::Protocol::KillCursors"
      [
        "KillCursors",
        { :number_of_cursor_ids => op.number_of_cursor_ids }.inspect
      ]
    else
      [
        op.class.to_s.sub("Moped::Protocol::", ""),
        { :database => op.full_collection_name }.inspect
      ]
    end
  end
end