Class: ElasticAPM::Spies::S3Spy Private

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_apm/spies/s3.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Modules: Ext

Constant Summary collapse

TYPE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'storage'
SUBTYPE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

's3'
AP_REGION_REGEX =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

/^(?:[^:]+:){3}([^:]+).*/
AP_REGEX =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

/:accesspoint.*/
MUTEX =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Mutex.new
@@formatted_op_names =

This classvariable is part of a private API. You should avoid using this classvariable if possible, as it may be removed or be changed in the future.

{}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.accesspoint_region(params) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



50
51
52
53
54
# File 'lib/elastic_apm/spies/s3.rb', line 50

def self.accesspoint_region(params)
  if params[:bucket] && (match = AP_REGION_REGEX.match(params[:bucket]))
    match[1]
  end
end

.bucket_name(params) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



43
44
45
46
47
48
# File 'lib/elastic_apm/spies/s3.rb', line 43

def self.bucket_name(params)
  return unless (bucket = params[:bucket]&.to_s)
  return bucket unless (index = bucket.rindex(AP_REGEX))

  bucket[index+1..-1]
end

.formatted_op_name(operation_name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/elastic_apm/spies/s3.rb', line 61

def self.formatted_op_name(operation_name)
  if @@formatted_op_names[operation_name]
    return @@formatted_op_names[operation_name]
  end

  MUTEX.synchronize do
    if @@formatted_op_names[operation_name]
      return @@formatted_op_names[operation_name]
    end

    @@formatted_op_names[operation_name] =
      operation_name.to_s.split('_').collect(&:capitalize).join
  end

  @@formatted_op_names[operation_name]
end

.span_name(operation_name, bucket_name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



56
57
58
59
# File 'lib/elastic_apm/spies/s3.rb', line 56

def self.span_name(operation_name, bucket_name)
  bucket_name ? "S3 #{formatted_op_name(operation_name)} #{bucket_name}" :
    "S3 #{formatted_op_name(operation_name)}"
end

.without_net_httpObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



33
34
35
36
37
38
39
40
41
# File 'lib/elastic_apm/spies/s3.rb', line 33

def self.without_net_http
  return yield unless defined?(NetHTTPSpy)

  # rubocop:disable Style/ExplicitBlockArgument
  ElasticAPM::Spies::NetHTTPSpy.disable_in do
    yield
  end
  # rubocop:enable Style/ExplicitBlockArgument
end

Instance Method Details

#installObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



121
122
123
# File 'lib/elastic_apm/spies/s3.rb', line 121

def install
  ::Aws::S3::Client.prepend(Ext)
end