Class: OpenTelemetry::Instrumentation::Mongo::CommandSerializer
- Inherits:
-
Object
- Object
- OpenTelemetry::Instrumentation::Mongo::CommandSerializer
- Defined in:
- lib/opentelemetry/instrumentation/mongo/command_serializer.rb
Overview
Serializes a Mongo command object to be added to the trace
Constant Summary collapse
- MASK_VALUE =
'?'
- ELLIPSES =
'...'
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#command_name ⇒ Object
readonly
Returns the value of attribute command_name.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Instance Method Summary collapse
-
#initialize(command) ⇒ CommandSerializer
constructor
A new instance of CommandSerializer.
- #serialize ⇒ Object
Constructor Details
#initialize(command) ⇒ CommandSerializer
Returns a new instance of CommandSerializer.
17 18 19 20 21 22 |
# File 'lib/opentelemetry/instrumentation/mongo/command_serializer.rb', line 17 def initialize(command) @command = command @command_name, @collection = command.first @collection = MASK_VALUE unless @collection.is_a?(String) || @collection.is_a?(Integer) @payload = {} end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
15 16 17 |
# File 'lib/opentelemetry/instrumentation/mongo/command_serializer.rb', line 15 def collection @collection end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
15 16 17 |
# File 'lib/opentelemetry/instrumentation/mongo/command_serializer.rb', line 15 def command @command end |
#command_name ⇒ Object (readonly)
Returns the value of attribute command_name.
15 16 17 |
# File 'lib/opentelemetry/instrumentation/mongo/command_serializer.rb', line 15 def command_name @command_name end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
15 16 17 |
# File 'lib/opentelemetry/instrumentation/mongo/command_serializer.rb', line 15 def payload @payload end |
Instance Method Details
#serialize ⇒ Object
24 25 26 27 |
# File 'lib/opentelemetry/instrumentation/mongo/command_serializer.rb', line 24 def serialize build_payload payload.to_json.freeze unless payload.empty? end |