lib/opentelemetry/instrumentation/mongo/subscriber.rb in opentelemetry-instrumentation-mongo-0.16.0 vs lib/opentelemetry/instrumentation/mongo/subscriber.rb in opentelemetry-instrumentation-mongo-0.17.0
- old
+ new
@@ -62,17 +62,21 @@
"#{collection}.#{command_name}"
end
def build_attributes(event)
- {
+ attrs = {
'db.system' => 'mongodb',
'db.name' => event.database_name,
'db.operation' => event.command_name,
'db.statement' => CommandSerializer.new(event.command).serialize,
'net.peer.name' => event.address.host,
'net.peer.port' => event.address.port
- }.compact
+ }
+ config = Mongo::Instrumentation.instance.config
+ attrs['peer.service'] = config[:peer_service] if config[:peer_service]
+ attrs.compact!
+ attrs
end
def get_collection(command)
collection = command.values.first
collection if collection.is_a?(String)