Skip to content

Commit

Permalink
chore(CE): add request response log for MariaDB (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
TivonB-AI2 authored Aug 12, 2024
1 parent 8222794 commit 5ac0b63
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion integrations/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GIT
PATH
remote: .
specs:
multiwoven-integrations (0.7.1)
multiwoven-integrations (0.7.2)
activesupport
async-websocket
aws-sdk-athena
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def write(sync_config, records, action = "destination_insert")
primary_key = sync_config.model.primary_key
db = create_connection(connection_config)

log_message_array = []
write_success = 0
write_failure = 0

Expand All @@ -50,6 +51,7 @@ def write(sync_config, records, action = "destination_insert")
begin
db.run(query)
write_success += 1
log_message_array << log_request_response("info", query, "Successful")
rescue StandardError => e
handle_exception(e, {
context: "MARIA:DB:RECORD:WRITE:EXCEPTION",
Expand All @@ -58,9 +60,10 @@ def write(sync_config, records, action = "destination_insert")
sync_run_id: sync_config.sync_run_id
})
write_failure += 1
log_message_array << log_request_response("error", query, e.message)
end
end
tracking_message(write_success, write_failure)
tracking_message(write_success, write_failure, log_message_array)
rescue StandardError => e
handle_exception(e, {
context: "MARIA:DB:RECORD:WRITE:EXCEPTION",
Expand Down Expand Up @@ -106,12 +109,6 @@ def group_by_table(records)
{ tablename: entries.first[:tablename], columns: entries.flat_map { |entry| entry[:columns] } }
end
end

def tracking_message(success, failure)
Multiwoven::Integrations::Protocol::TrackingMessage.new(
success: success, failed: failure
).to_multiwoven_message
end
end
end
end
2 changes: 1 addition & 1 deletion integrations/lib/multiwoven/integrations/rollout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Multiwoven
module Integrations
VERSION = "0.7.1"
VERSION = "0.7.2"

ENABLED_SOURCES = %w[
Snowflake
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@
response = client.write(sync_config, records)
expect(response.tracking.success).to eq(records.size)
expect(response.tracking.failed).to eq(0)
log_message = response.tracking.logs.first
expect(log_message).to be_a(Multiwoven::Integrations::Protocol::LogMessage)
expect(log_message.level).to eql("info")

expect(log_message.message).to include("request")
expect(log_message.message).to include("response")
end
end

Expand All @@ -135,6 +141,12 @@
response = client.write(sync_config, records)
expect(response.tracking.failed).to eq(records.size)
expect(response.tracking.success).to eq(0)
log_message = response.tracking.logs.first
expect(log_message).to be_a(Multiwoven::Integrations::Protocol::LogMessage)
expect(log_message.level).to eql("error")

expect(log_message.message).to include("request")
expect(log_message.message).to include("response")
end
end
end
Expand Down

0 comments on commit 5ac0b63

Please sign in to comment.