|
134 | 134 | peer_cert_validity, auth_mechanism, ssl_protocol, |
135 | 135 | ssl_key_exchange, ssl_cipher, ssl_hash, protocol, user, vhost, |
136 | 136 | timeout, frame_max, channel_max, client_properties, connected_at, |
137 | | - node, user_who_performed_action, connection_user_provided_name]). |
| 137 | + node, user_who_performed_action]). |
138 | 138 |
|
139 | 139 | -define(INFO_KEYS, ?CREATION_EVENT_KEYS ++ ?STATISTICS_KEYS -- [pid]). |
140 | 140 |
|
@@ -393,17 +393,17 @@ start_connection(Parent, HelperSup, Deb, Sock) -> |
393 | 393 | Properties -> |
394 | 394 | Properties |
395 | 395 | end, |
396 | | - ConnectionUserProvidedName = case get(connection_user_provided_name) of |
397 | | - undefined -> |
398 | | - ''; |
399 | | - ConnectionName -> |
400 | | - ConnectionName |
| 396 | + EventProperties = [{name, Name}, |
| 397 | + {pid, self()}, |
| 398 | + {node, node()}, |
| 399 | + {client_properties, ClientProperties}], |
| 400 | + EventProperties1 = case get(connection_user_provided_name) of |
| 401 | + undefined -> |
| 402 | + EventProperties; |
| 403 | + ConnectionUserProvidedName -> |
| 404 | + [{user_provided_name, ConnectionUserProvidedName} | EventProperties] |
401 | 405 | end, |
402 | | - rabbit_event:notify(connection_closed, [{name, Name}, |
403 | | - {pid, self()}, |
404 | | - {node, node()}, |
405 | | - {client_properties, ClientProperties}, |
406 | | - {connection_user_provided_name, ConnectionUserProvidedName}]) |
| 406 | + rabbit_event:notify(connection_closed, EventProperties1) |
407 | 407 | end, |
408 | 408 | done. |
409 | 409 |
|
@@ -620,7 +620,9 @@ handle_other({'$gen_cast', {force_event_refresh, Ref}}, State) |
620 | 620 | when ?IS_RUNNING(State) -> |
621 | 621 | rabbit_event:notify( |
622 | 622 | connection_created, |
623 | | - [{type, network} | infos(?CREATION_EVENT_KEYS, State)], Ref), |
| 623 | + augment_infos_with_user_provided_connection_name( |
| 624 | + [{type, network} | infos(?CREATION_EVENT_KEYS, State)], State), |
| 625 | + Ref), |
624 | 626 | rabbit_event:init_stats_timer(State, #v1.stats_timer); |
625 | 627 | handle_other({'$gen_cast', {force_event_refresh, _Ref}}, State) -> |
626 | 628 | %% Ignore, we will emit a created event once we start running. |
@@ -1146,7 +1148,12 @@ handle_method0(#'connection.start_ok'{mechanism = Mechanism, |
1146 | 1148 | % adding client properties to process dictionary to send them later |
1147 | 1149 | % in the connection_closed event |
1148 | 1150 | put(client_properties, ClientProperties), |
1149 | | - put(connection_user_provided_name, user_provided_connection_name(Connection2)), |
| 1151 | + case user_provided_connection_name(Connection2) of |
| 1152 | + undefined -> |
| 1153 | + undefined; |
| 1154 | + UserProvidedConnectionName -> |
| 1155 | + put(connection_user_provided_name, UserProvidedConnectionName) |
| 1156 | + end, |
1150 | 1157 | auth_phase(Response, State); |
1151 | 1158 |
|
1152 | 1159 | handle_method0(#'connection.secure_ok'{response = Response}, |
@@ -1219,7 +1226,10 @@ handle_method0(#'connection.open'{virtual_host = VHost}, |
1219 | 1226 | connection = NewConnection, |
1220 | 1227 | channel_sup_sup_pid = ChannelSupSupPid, |
1221 | 1228 | throttle = Throttle1}), |
1222 | | - Infos = [{type, network} | infos(?CREATION_EVENT_KEYS, State1)], |
| 1229 | + Infos = augment_infos_with_user_provided_connection_name( |
| 1230 | + [{type, network} | infos(?CREATION_EVENT_KEYS, State1)], |
| 1231 | + State1 |
| 1232 | + ), |
1223 | 1233 | rabbit_core_metrics:connection_created(proplists:get_value(pid, Infos), |
1224 | 1234 | Infos), |
1225 | 1235 | rabbit_event:notify(connection_created, Infos), |
@@ -1476,13 +1486,6 @@ ic(client_properties, #connection{client_properties = CP}) -> CP; |
1476 | 1486 | ic(auth_mechanism, #connection{auth_mechanism = none}) -> none; |
1477 | 1487 | ic(auth_mechanism, #connection{auth_mechanism = {Name, _Mod}}) -> Name; |
1478 | 1488 | ic(connected_at, #connection{connected_at = T}) -> T; |
1479 | | -ic(connection_user_provided_name, C) -> |
1480 | | - case user_provided_connection_name(C) of |
1481 | | - undefined -> |
1482 | | - ''; |
1483 | | - ConnectionUserProvidedName -> |
1484 | | - ConnectionUserProvidedName |
1485 | | - end; |
1486 | 1489 | ic(Item, #connection{}) -> throw({bad_argument, Item}). |
1487 | 1490 |
|
1488 | 1491 | socket_info(Get, Select, #v1{sock = Sock}) -> |
@@ -1696,6 +1699,14 @@ augment_connection_log_name(#connection{name = Name} = Connection) -> |
1696 | 1699 | Connection#connection{log_name = LogName} |
1697 | 1700 | end. |
1698 | 1701 |
|
| 1702 | +augment_infos_with_user_provided_connection_name(Infos, #v1{connection = Connection}) -> |
| 1703 | + case user_provided_connection_name(Connection) of |
| 1704 | + undefined -> |
| 1705 | + Infos; |
| 1706 | + UserProvidedConnectionName -> |
| 1707 | + [{user_provided_name, UserProvidedConnectionName} | Infos] |
| 1708 | + end. |
| 1709 | + |
1699 | 1710 | user_provided_connection_name(#connection{client_properties = ClientProperties}) -> |
1700 | 1711 | case rabbit_misc:table_lookup(ClientProperties, <<"connection_name">>) of |
1701 | 1712 | {longstr, UserSpecifiedName} -> |
|
0 commit comments