Skip to content

Commit

Permalink
chore(CE): add request response log for Slack
Browse files Browse the repository at this point in the history
  • Loading branch information
TivonB-AI2 committed Aug 12, 2024
1 parent 8222794 commit f0bfaad
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 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.4)
activesupport
async-websocket
aws-sdk-athena
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
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.4"

ENABLED_SOURCES = %w[
Snowflake
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit f0bfaad

Please sign in to comment.