From f0bfaaddcff6d96ff76dfdc1781ea6a2d57f7e6e Mon Sep 17 00:00:00 2001 From: TivonB-AI2 Date: Mon, 12 Aug 2024 12:16:12 -0400 Subject: [PATCH] chore(CE): add request response log for Slack --- integrations/Gemfile.lock | 2 +- .../integrations/destination/slack/client.rb | 16 +++++++--------- .../lib/multiwoven/integrations/rollout.rb | 2 +- .../destination/slack/client_spec.rb | 12 ++++++++++++ 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/integrations/Gemfile.lock b/integrations/Gemfile.lock index 846de3fe..3819c212 100644 --- a/integrations/Gemfile.lock +++ b/integrations/Gemfile.lock @@ -7,7 +7,7 @@ GIT PATH remote: . specs: - multiwoven-integrations (0.7.1) + multiwoven-integrations (0.7.4) activesupport async-websocket aws-sdk-athena diff --git a/integrations/lib/multiwoven/integrations/destination/slack/client.rb b/integrations/lib/multiwoven/integrations/destination/slack/client.rb index 5cf85884..1dd464fd 100644 --- a/integrations/lib/multiwoven/integrations/destination/slack/client.rb +++ b/integrations/lib/multiwoven/integrations/destination/slack/client.rb @@ -57,11 +57,13 @@ def configure_slack(api_token) end def process_records(records, stream) + log_message_array = [] write_success = 0 write_failure = 0 records.each do |record_object| - process_record(stream, record_object.with_indifferent_access) + request, response = *process_record(stream, record_object.with_indifferent_access) write_success += 1 + log_message_array << log_request_response("info", request, response) rescue StandardError => e write_failure += 1 handle_exception(e, { @@ -70,8 +72,9 @@ def process_records(records, stream) sync_id: @sync_config.sync_id, sync_run_id: @sync_config.sync_run_id }) + log_message_array << log_request_response("error", request, e.message) end - tracking_message(write_success, write_failure) + tracking_message(write_success, write_failure, log_message_array) end def process_record(stream, record) @@ -80,7 +83,8 @@ def process_record(stream, record) def send_data_to_slack(stream_name, record = {}) args = build_args(stream_name, record) - @client.send(stream_name, **args) + response = @client.send(stream_name, **args) + [args, response] end def build_args(stream_name, record) @@ -114,12 +118,6 @@ def failure_status(error) def load_catalog read_json(CATALOG_SPEC_PATH) end - - def tracking_message(success, failure) - Multiwoven::Integrations::Protocol::TrackingMessage.new( - success: success, failed: failure - ).to_multiwoven_message - end end end end diff --git a/integrations/lib/multiwoven/integrations/rollout.rb b/integrations/lib/multiwoven/integrations/rollout.rb index dd0b7129..9f9792f4 100644 --- a/integrations/lib/multiwoven/integrations/rollout.rb +++ b/integrations/lib/multiwoven/integrations/rollout.rb @@ -2,7 +2,7 @@ module Multiwoven module Integrations - VERSION = "0.7.1" + VERSION = "0.7.4" ENABLED_SOURCES = %w[ Snowflake diff --git a/integrations/spec/multiwoven/integrations/destination/slack/client_spec.rb b/integrations/spec/multiwoven/integrations/destination/slack/client_spec.rb index 0278a196..491f78ce 100644 --- a/integrations/spec/multiwoven/integrations/destination/slack/client_spec.rb +++ b/integrations/spec/multiwoven/integrations/destination/slack/client_spec.rb @@ -125,6 +125,12 @@ 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 @@ -142,6 +148,12 @@ 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