Module: TraceView::Inst::CurlEasy

Includes:
CurlUtility
Defined in:
lib/traceview/inst/curb.rb

Overview

Instrumentation specific to ::Curl::Easy

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CurlUtility

#profile_curb_method, #traceview_collect

Class Method Details

.included(klass) ⇒ Object



108
109
110
111
112
113
# File 'lib/traceview/inst/curb.rb', line 108

def self.included(klass)
  ::TraceView::Util.method_alias(klass, :http, ::Curl::Easy)
  ::TraceView::Util.method_alias(klass, :perform, ::Curl::Easy)
  ::TraceView::Util.method_alias(klass, :http_put, ::Curl::Easy)
  ::TraceView::Util.method_alias(klass, :http_post, ::Curl::Easy)
end

Instance Method Details

#http_post_with_traceview(*args, &block) ⇒ Object

http_post_with_traceview

::Curl::Easy.new.http_post wrapper



120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/traceview/inst/curb.rb', line 120

def http_post_with_traceview(*args, &block)
  # If we're not tracing, just do a fast return.
  if !TraceView.tracing? || TraceView.tracing_layer?(:curb)
    return http_post_without_traceview(*args)
  end

  kvs = {}
  if TraceView::Config[:curb][:cross_host]
    kvs[:HTTPMethod] = :POST
  end

  profile_curb_method(kvs, :http_post_without_traceview, args, &block)
end

#http_put_with_traceview(*args, &block) ⇒ Object

http_put_with_traceview

::Curl::Easy.new.http_put wrapper



139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/traceview/inst/curb.rb', line 139

def http_put_with_traceview(*args, &block)
  # If we're not tracing, just do a fast return.
  if !TraceView.tracing? || TraceView.tracing_layer?(:curb)
    return http_put_without_traceview(data)
  end

  kvs = {}
  if TraceView::Config[:curb][:cross_host]
    kvs[:HTTPMethod] = :PUT
  end

  profile_curb_method(kvs, :http_post_without_traceview, args, &block)
end

#http_with_traceview(verb, &block) ⇒ Object

http_with_traceview

::Curl::Easy.new.http wrapper



184
185
186
187
188
189
190
191
192
193
194
# File 'lib/traceview/inst/curb.rb', line 184

def http_with_traceview(verb, &block)
  # If we're not tracing, just do a fast return.
  return http_without_traceview(verb) if !TraceView.tracing?

  kvs = {}
  if TraceView::Config[:curb][:cross_host]
    kvs[:HTTPMethod] = verb
  end

  profile_curb_method(kvs, :http_without_traceview, [verb], &block)
end

#perform_with_traceview(&block) ⇒ Object

perform_with_traceview

::Curl::Easy.new.perform wrapper



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/traceview/inst/curb.rb', line 158

def perform_with_traceview(&block)
  # If we're not tracing, just do a fast return.
  if !TraceView.tracing? || TraceView.tracing_layer?(:curb)
    return perform_without_traceview(&block)
  end

  kvs = {}
  # This perform gets called from two places, ::Curl::Easy.new.perform
  # and Curl::Easy.new.http_head. In the case of http_head we detect the
  # HTTP verb via get info.
  if TraceView::Config[:curb][:cross_host]
    if self.getinfo(self.sym2curl(:nobody))
      kvs[:HTTPMethod] = :HEAD
    else
      kvs[:HTTPMethod] = :GET
    end
  end

  return profile_curb_method(kvs, :perform_without_traceview, nil, &block)
end