Class: LogStash::Outputs::Application_insights::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/outputs/application_insights/channel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(intrumentation_key, table_id) ⇒ Channel

Returns a new instance of Channel.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/logstash/outputs/application_insights/channel.rb', line 34

def initialize ( intrumentation_key, table_id )
  @closing = false
  configuration = Config.current

  @logger = configuration[:logger]

  @logger.debug { "Create a new channel, intrumentation_key / table_id : #{intrumentation_key} / #{table_id}" }
  @intrumentation_key = intrumentation_key
  @table_id = table_id
  set_table_properties( configuration )
  @semaphore = Mutex.new
  @failed_on_upload_retry_Q = Queue.new
  @failed_on_notify_retry_Q = Queue.new
  @workers_channel = {  }
  @active_blobs = [ Blob.new( self, 1 ) ]
  @state = State.instance

  launch_upload_recovery_thread
  launch_notify_recovery_thread
end

Instance Attribute Details

#blob_max_delayObject (readonly)

Returns the value of attribute blob_max_delay.



30
31
32
# File 'lib/logstash/outputs/application_insights/channel.rb', line 30

def blob_max_delay
  @blob_max_delay
end

#event_format_extObject (readonly)

Returns the value of attribute event_format_ext.



29
30
31
# File 'lib/logstash/outputs/application_insights/channel.rb', line 29

def event_format_ext
  @event_format_ext
end

#failed_on_notify_retry_QObject (readonly)

Returns the value of attribute failed_on_notify_retry_Q.



28
29
30
# File 'lib/logstash/outputs/application_insights/channel.rb', line 28

def failed_on_notify_retry_Q
  @failed_on_notify_retry_Q
end

#failed_on_upload_retry_QObject (readonly)

Returns the value of attribute failed_on_upload_retry_Q.



27
28
29
# File 'lib/logstash/outputs/application_insights/channel.rb', line 27

def failed_on_upload_retry_Q
  @failed_on_upload_retry_Q
end

#intrumentation_keyObject (readonly)

Returns the value of attribute intrumentation_key.



25
26
27
# File 'lib/logstash/outputs/application_insights/channel.rb', line 25

def intrumentation_key
  @intrumentation_key
end

#table_idObject (readonly)

Returns the value of attribute table_id.



26
27
28
# File 'lib/logstash/outputs/application_insights/channel.rb', line 26

def table_id
  @table_id
end

Instance Method Details

#<<(event) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/logstash/outputs/application_insights/channel.rb', line 66

def << ( event )
  if @serialized_event_field && event[@serialized_event_field]
    serialized_event = serialize_serialized_event_field( event[@serialized_event_field] )
  else
    serialized_event = ( EXT_EVENT_FORMAT_CSV == @serialization ? serialize_to_csv( event ) : serialize_to_json( event ) )
  end

  if serialized_event
    sub_channel = @workers_channel[Thread.current] || @semaphore.synchronize { @workers_channel[Thread.current] = Sub_channel.new( @event_separator ) }
    sub_channel << serialized_event
  else
    @logger.warn { "event not uploaded, no relevant data in event. table_id: #{table_id}, event: #{event}" }
  end
end

#closeObject



55
56
57
58
59
60
# File 'lib/logstash/outputs/application_insights/channel.rb', line 55

def close
  @closing = true
  @active_blobs.each do |blob|
    blob.close
  end
end

#flushObject



81
82
83
84
# File 'lib/logstash/outputs/application_insights/channel.rb', line 81

def flush
  block_list = collect_blocks
  enqueue_blocks( block_list )
end

#stopped?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/logstash/outputs/application_insights/channel.rb', line 62

def stopped?
  @closing
end