Class: LogStash::Filters::TransactionTime::Transaction
- Inherits:
-
Object
- Object
- LogStash::Filters::TransactionTime::Transaction
- Defined in:
- lib/logstash/filters/transaction_time.rb
Instance Attribute Summary collapse
-
#age ⇒ Object
Returns the value of attribute age.
-
#data ⇒ Object
Returns the value of attribute data.
-
#diff ⇒ Object
Returns the value of attribute diff.
-
#firstEvent ⇒ Object
Returns the value of attribute firstEvent.
-
#firstTimestamp ⇒ Object
Returns the value of attribute firstTimestamp.
-
#lastEvent ⇒ Object
Returns the value of attribute lastEvent.
-
#secondTimestamp ⇒ Object
Returns the value of attribute secondTimestamp.
-
#uid ⇒ Object
Returns the value of attribute uid.
Instance Method Summary collapse
- #addSecond(lastEvent, storeEvent = false) ⇒ Object
- #calculateDiff ⇒ Object
- #getData(oldestKeys, newestKeys) ⇒ Object
- #getEvents ⇒ Object
-
#getNewestEvent ⇒ Object
Gets the newest (based on timestamp) event Or the first if they are equal.
- #getNewestTimestamp ⇒ Object
-
#getOldestEvent ⇒ Object
Gets the oldest (based on timestamp) event Or the second if they are equal.
- #getOldestTimestamp ⇒ Object
-
#initialize(firstEvent, uid, storeEvent = false) ⇒ Transaction
constructor
A new instance of Transaction.
- #invalidTransaction ⇒ Object
- #storeData(subDataName, dataKeys, dataEvent) ⇒ Object
- #tag(value) ⇒ Object
Constructor Details
#initialize(firstEvent, uid, storeEvent = false) ⇒ Transaction
Returns a new instance of Transaction.
305 306 307 308 309 310 311 312 |
# File 'lib/logstash/filters/transaction_time.rb', line 305 def initialize(firstEvent, uid, storeEvent = false) if(storeEvent) @firstEvent = firstEvent end @firstTimestamp = firstEvent.get(LogStash::Filters::TransactionTime.) @uid = uid @age = 0 end |
Instance Attribute Details
#age ⇒ Object
Returns the value of attribute age.
303 304 305 |
# File 'lib/logstash/filters/transaction_time.rb', line 303 def age @age end |
#data ⇒ Object
Returns the value of attribute data.
303 304 305 |
# File 'lib/logstash/filters/transaction_time.rb', line 303 def data @data end |
#diff ⇒ Object
Returns the value of attribute diff.
303 304 305 |
# File 'lib/logstash/filters/transaction_time.rb', line 303 def diff @diff end |
#firstEvent ⇒ Object
Returns the value of attribute firstEvent.
303 304 305 |
# File 'lib/logstash/filters/transaction_time.rb', line 303 def firstEvent @firstEvent end |
#firstTimestamp ⇒ Object
Returns the value of attribute firstTimestamp.
303 304 305 |
# File 'lib/logstash/filters/transaction_time.rb', line 303 def firstTimestamp @firstTimestamp end |
#lastEvent ⇒ Object
Returns the value of attribute lastEvent.
303 304 305 |
# File 'lib/logstash/filters/transaction_time.rb', line 303 def lastEvent @lastEvent end |
#secondTimestamp ⇒ Object
Returns the value of attribute secondTimestamp.
303 304 305 |
# File 'lib/logstash/filters/transaction_time.rb', line 303 def secondTimestamp @secondTimestamp end |
#uid ⇒ Object
Returns the value of attribute uid.
303 304 305 |
# File 'lib/logstash/filters/transaction_time.rb', line 303 def uid @uid end |
Instance Method Details
#addSecond(lastEvent, storeEvent = false) ⇒ Object
341 342 343 344 345 346 347 |
# File 'lib/logstash/filters/transaction_time.rb', line 341 def addSecond(lastEvent,storeEvent = false) if(storeEvent) @lastEvent = lastEvent end @secondTimestamp = lastEvent.get(LogStash::Filters::TransactionTime.) @diff = calculateDiff() end |
#calculateDiff ⇒ Object
388 389 390 391 392 393 394 |
# File 'lib/logstash/filters/transaction_time.rb', line 388 def calculateDiff() if invalidTransaction() return nil end return getNewestTimestamp() - getOldestTimestamp() end |
#getData(oldestKeys, newestKeys) ⇒ Object
314 315 316 317 318 319 320 321 322 |
# File 'lib/logstash/filters/transaction_time.rb', line 314 def getData(oldestKeys, newestKeys) if(oldestKeys.any?) storeData("oldest",oldestKeys,getOldestEvent()) end if(newestKeys.any?) storeData("newest",newestKeys,getNewestEvent()) end return @data end |
#getEvents ⇒ Object
405 406 407 408 409 410 411 412 413 414 |
# File 'lib/logstash/filters/transaction_time.rb', line 405 def getEvents() events = [] if(!firstEvent.nil?) events << firstEvent end if(!lastEvent.nil?) events << lastEvent end return events end |
#getNewestEvent ⇒ Object
Gets the newest (based on timestamp) event Or the first if they are equal
369 370 371 372 373 374 375 376 377 378 |
# File 'lib/logstash/filters/transaction_time.rb', line 369 def getNewestEvent() if invalidTransaction() return nil end if(@firstTimestamp >= @secondTimestamp) return @firstEvent else return @lastEvent end end |
#getNewestTimestamp ⇒ Object
380 381 382 |
# File 'lib/logstash/filters/transaction_time.rb', line 380 def getNewestTimestamp() return [@firstTimestamp,@secondTimestamp].max end |
#getOldestEvent ⇒ Object
Gets the oldest (based on timestamp) event Or the second if they are equal
351 352 353 354 355 356 357 358 359 360 361 |
# File 'lib/logstash/filters/transaction_time.rb', line 351 def getOldestEvent() if invalidTransaction() return nil end if(@firstTimestamp < @secondTimestamp) return @firstEvent else return @lastEvent end end |
#getOldestTimestamp ⇒ Object
363 364 365 |
# File 'lib/logstash/filters/transaction_time.rb', line 363 def getOldestTimestamp() return [@firstTimestamp,@secondTimestamp].min end |
#invalidTransaction ⇒ Object
384 385 386 |
# File 'lib/logstash/filters/transaction_time.rb', line 384 def invalidTransaction() return firstTimestamp.nil? || secondTimestamp.nil? end |
#storeData(subDataName, dataKeys, dataEvent) ⇒ Object
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/logstash/filters/transaction_time.rb', line 324 def storeData(subDataName, dataKeys, dataEvent) if(@data.nil?) @data = Hash.new end if(@data[subDataName].nil?) hashData = Hash.new else hashData = @data.get(subDataName) end dataKeys.each do |dataKey| hashData[dataKey] = dataEvent.get(dataKey) @data[subDataName] = hashData end end |
#tag(value) ⇒ Object
396 397 398 399 400 401 402 403 |
# File 'lib/logstash/filters/transaction_time.rb', line 396 def tag(value) if(!firstEvent.nil?) firstEvent.tag(value) end if(!lastEvent.nil?) lastEvent.tag(value) end end |