Просмотр исходного кода

fix: make mysql action rendered trace include parameters

When doing non-batch inserts with the MySQL action, prepared statements
are used. We therefore need to include the parameters to the prepared
statement when tracing the rendered templates.

Fixes:
https://emqx.atlassian.net/browse/EMQX-12335
Kjell Winblad 1 год назад
Родитель
Сommit
246bce85ec
1 измененных файлов с 7 добавлено и 1 удалено
  1. 7 1
      apps/emqx_mysql/src/emqx_mysql.erl

+ 7 - 1
apps/emqx_mysql/src/emqx_mysql.erl

@@ -507,7 +507,13 @@ on_sql_query(
     LogMeta = #{connector => InstId, sql => SQLOrKey, state => State},
     ?TRACE("QUERY", "mysql_connector_received", LogMeta),
     ChannelID = maps:get(channel_id, State, no_channel),
-    emqx_trace:rendered_action_template(ChannelID, #{sql => SQLOrKey}),
+    emqx_trace:rendered_action_template(
+        ChannelID,
+        #{
+            sql_or_key => SQLOrKey,
+            parameters => Params
+        }
+    ),
     Worker = ecpool:get_client(PoolName),
     case ecpool_worker:client(Worker) of
         {ok, Conn} ->