-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathaws_sdk_s3.rb
More file actions
55 lines (48 loc) · 1.3 KB
/
aws_sdk_s3.rb
File metadata and controls
55 lines (48 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2021
module Instana
module Instrumentation
class S3 < Seahorse::Client::Plugin
class Handler < Seahorse::Client::Handler
def call(context)
s3_tags = {
op: format_operation(context.operation_name),
bucket: bucket_name_from(context),
key: key_from_context(context)
}.reject { |_, v| v.nil? }
::Instana.tracer.in_span(:s3, attributes: {s3: s3_tags}) { @handler.call(context) }
end
private
def bucket_name_from(context)
context.params[:bucket] || 'Unknown'
end
def key_from_context(context)
context.params[:key]
end
def format_operation(name)
case name
when :create_bucket
'createBucket'
when :delete_bucket
'deleteBucket'
when :delete_object
'delete'
when :get_object
'get'
when :head_object
'metadata'
when :list_objects
'list'
when :put_object
'list'
else
name.to_s
end
end
end
def add_handlers(handlers, _config)
handlers.add(Handler, step: :initialize)
end
end
end
end