Class: Trace::Annotation

Inherits:
Object
  • Object
show all
Defined in:
lib/finagle-thrift/tracer.rb

Constant Summary collapse

CLIENT_SEND =
"cs"
CLIENT_RECV =
"cr"
SERVER_SEND =
"ss"
SERVER_RECV =
"sr"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, host) ⇒ Annotation

Returns a new instance of Annotation.



151
152
153
154
155
# File 'lib/finagle-thrift/tracer.rb', line 151

def initialize(value, host)
  @timestamp = (Time.now.to_f * 1000 * 1000).to_i # micros
  @value = value
  @host = host
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



150
151
152
# File 'lib/finagle-thrift/tracer.rb', line 150

def host
  @host
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



150
151
152
# File 'lib/finagle-thrift/tracer.rb', line 150

def timestamp
  @timestamp
end

#valueObject (readonly)

Returns the value of attribute value.



150
151
152
# File 'lib/finagle-thrift/tracer.rb', line 150

def value
  @value
end

Instance Method Details

#to_sObject



166
167
168
# File 'lib/finagle-thrift/tracer.rb', line 166

def to_s
  "#{@value} at #{@timestamp} for (#{@host.to_s})"
end

#to_thriftObject



157
158
159
160
161
162
163
164
# File 'lib/finagle-thrift/tracer.rb', line 157

def to_thrift
  thrift_host = host ? host.to_thrift : nil
  FinagleThrift::Annotation.new(
    :value => @value,
    :host => thrift_host,
    :timestamp => @timestamp
  )
end