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.



154
155
156
157
158
# File 'lib/finagle-thrift/tracer.rb', line 154

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

Instance Attribute Details

#hostObject

write access for tests



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

def host
  @host
end

#timestampObject

write access for tests



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

def timestamp
  @timestamp
end

#valueObject

write access for tests



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

def value
  @value
end

Instance Method Details

#to_sObject



169
170
171
# File 'lib/finagle-thrift/tracer.rb', line 169

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

#to_thriftObject



160
161
162
163
164
165
166
167
# File 'lib/finagle-thrift/tracer.rb', line 160

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