application_insights 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +9 -9
  2. data/LICENSE.txt +7 -18
  3. data/README.md +42 -7
  4. data/Rakefile +6 -1
  5. data/application_insights.gemspec +2 -0
  6. data/lib/application_insights.rb +1 -0
  7. data/lib/application_insights/channel/asynchronous_queue.rb +51 -0
  8. data/lib/application_insights/channel/asynchronous_sender.rb +121 -0
  9. data/lib/application_insights/channel/contracts/application.rb +3 -2
  10. data/lib/application_insights/channel/contracts/data.rb +3 -2
  11. data/lib/application_insights/channel/contracts/data_point.rb +15 -10
  12. data/lib/application_insights/channel/contracts/device.rb +42 -28
  13. data/lib/application_insights/channel/contracts/envelope.rb +39 -27
  14. data/lib/application_insights/channel/contracts/event_data.rb +6 -6
  15. data/lib/application_insights/channel/contracts/exception_data.rb +9 -8
  16. data/lib/application_insights/channel/contracts/exception_details.rb +15 -11
  17. data/lib/application_insights/channel/contracts/internal.rb +6 -4
  18. data/lib/application_insights/channel/contracts/location.rb +3 -2
  19. data/lib/application_insights/channel/contracts/message_data.rb +6 -5
  20. data/lib/application_insights/channel/contracts/metric_data.rb +3 -3
  21. data/lib/application_insights/channel/contracts/operation.rb +12 -8
  22. data/lib/application_insights/channel/contracts/page_view_data.rb +12 -10
  23. data/lib/application_insights/channel/contracts/remote_dependency_data.rb +27 -19
  24. data/lib/application_insights/channel/contracts/request_data.rb +15 -12
  25. data/lib/application_insights/channel/contracts/session.rb +9 -6
  26. data/lib/application_insights/channel/contracts/stack_frame.rb +9 -6
  27. data/lib/application_insights/channel/contracts/user.rb +12 -8
  28. data/lib/application_insights/channel/event.rb +64 -0
  29. data/lib/application_insights/channel/queue_base.rb +24 -10
  30. data/lib/application_insights/channel/sender_base.rb +38 -9
  31. data/lib/application_insights/channel/synchronous_queue.rb +16 -5
  32. data/lib/application_insights/channel/synchronous_sender.rb +4 -2
  33. data/lib/application_insights/channel/telemetry_channel.rb +26 -7
  34. data/lib/application_insights/channel/telemetry_context.rb +29 -10
  35. data/lib/application_insights/telemetry_client.rb +84 -15
  36. data/lib/application_insights/unhandled_exception.rb +48 -0
  37. data/lib/application_insights/version.rb +1 -1
  38. data/test/application_insights/channel/test_asynchronous_queue.rb +68 -0
  39. data/test/application_insights/channel/test_asynchronous_sender.rb +81 -0
  40. data/test/application_insights/channel/test_event.rb +53 -0
  41. data/test/application_insights/channel/test_queue_base.rb +10 -9
  42. data/test/application_insights/channel/test_sender_base.rb +0 -9
  43. data/test/application_insights/test_telemetry_client.rb +5 -0
  44. data/test/application_insights/test_unhandled_exception.rb +42 -0
  45. metadata +44 -3
@@ -2,24 +2,30 @@ require 'thread'
2
2
 
3
3
  module ApplicationInsights
4
4
  module Channel
5
- # The base class for all queues.
5
+ # The base class for all types of queues for use in conjunction with an implementation of {SenderBase}. The queue
6
+ # will notify the sender that it needs to pick up items when it reaches {#max_queue_length}, or when the consumer
7
+ # calls {#flush}.
6
8
  class QueueBase
7
- # Initializes a new instance of the queue class.
9
+ # Initializes a new instance of the class.
10
+ # @param [SenderBase] sender the sender object that will be used in conjunction with this queue.
8
11
  def initialize(sender)
9
- raise ArgumentError, 'Sender was required but not provided' unless sender
10
12
  @queue = Queue.new
11
13
  @max_queue_length = 500
12
14
  @sender = sender
13
- @sender.queue = self
15
+ @sender.queue = self if sender
14
16
  end
15
17
 
16
- # Gets or sets the maximum number of items that will be held by the queue before we force a send.
18
+ # The maximum number of items that will be held by the queue before the queue will call the {#flush} method.
19
+ # @return [Fixnum] the maximum queue size. (defaults to: 500)
17
20
  attr_accessor :max_queue_length
18
21
 
19
- # Gets the sender associated with this queue
22
+ # The sender that is associated with this queue that this queue will use to send data to the service.
23
+ # @return [SenderBase] the sender object.
20
24
  attr_reader :sender
21
25
 
22
- # Adds a single item to the queue.
26
+ # Adds the passed in item object to the queue and calls {#flush} if the size of the queue is larger
27
+ # than {#max_queue_length}. This method does nothing if the passed in item is nil.
28
+ # @param [Contracts::Envelope] item the telemetry envelope object to send to the service.
23
29
  def push(item)
24
30
  unless item
25
31
  return
@@ -27,11 +33,12 @@ module ApplicationInsights
27
33
 
28
34
  @queue.push(item)
29
35
  if @queue.length >= @max_queue_length
30
- flush()
36
+ flush
31
37
  end
32
38
  end
33
39
 
34
- # Gets a single item from the queue. If no item is available, return nil.
40
+ # Pops a single item from the queue and returns it. If the queue is empty, this method will return nil.
41
+ # @return [Contracts::Envelope] a telemetry envelope object or nil if the queue is empty.
35
42
  def pop
36
43
  begin
37
44
  return @queue.pop(TRUE)
@@ -40,9 +47,16 @@ module ApplicationInsights
40
47
  end
41
48
  end
42
49
 
43
- # Flushes the current queue to the passed in sender.
50
+ # Flushes the current queue by notifying the {#sender}. This method needs to be overridden by a concrete
51
+ # implementations of the queue class.
44
52
  def flush
45
53
  end
54
+
55
+ # Indicates whether the queue is empty.
56
+ # @return [true, false] true if the queue is empty
57
+ def empty?
58
+ @queue.empty?
59
+ end
46
60
  end
47
61
  end
48
62
  end
@@ -1,32 +1,50 @@
1
1
  require 'json'
2
2
  require 'net/http'
3
+ require 'stringio'
4
+ require 'zlib'
3
5
 
4
6
  module ApplicationInsights
5
7
  module Channel
6
- # The base class for all of our senders.
8
+ # The base class for all types of senders for use in conjunction with an implementation of {QueueBase}. The queue
9
+ # will notify the sender that it needs to pick up items. The concrete sender implementation will listen to these
10
+ # notifications and will pull items from the queue using {QueueBase#pop} getting at most {#send_buffer_size} items.
11
+ # It will then call {#send} using the list of items pulled from the queue.
7
12
  class SenderBase
8
- # Initializes a new instance of the sender class.
13
+ # Initializes a new instance of the class.
14
+ # @param [String] service_endpoint_uri the address of the service to send telemetry data to.
9
15
  def initialize(service_endpoint_uri)
10
- raise ArgumentError, 'Service endpoint URI was required but not provided' unless service_endpoint_uri
11
16
  @service_endpoint_uri = service_endpoint_uri
12
17
  @queue = nil
13
18
  @send_buffer_size = 100
14
19
  end
15
20
 
16
- # Gets the service endpoint URI property. This is where we send data to.
21
+ # The service endpoint URI where this sender will send data to.
22
+ # @return [String] the service endpoint URI.
17
23
  attr_accessor :service_endpoint_uri
18
24
 
19
- # The queue that we will be draining
25
+ # The queue that this sender is draining. While {SenderBase} doesn't implement any means of doing so, derivations
26
+ # of this class do.
27
+ # @return [QueueBase] the queue instance that this sender is draining.
20
28
  attr_accessor :queue
21
29
 
22
- # Gets or sets the buffer size for a single batch of telemetry. This is the maximum number of items in a single service request we are going to send.
30
+ # The buffer size for a single batch of telemetry. This is the maximum number of items in a single service
31
+ # request that this sender is going to send.
32
+ # @return [Fixnum] the maximum number of items in a telemetry batch.
23
33
  attr_accessor :send_buffer_size
24
34
 
25
- # Sends the data to send list to the service immediately.
35
+ # Immediately sends the data passed in to {#service_endpoint_uri}. If the service request fails, the passed in items
36
+ # are pushed back to the {#queue}.
37
+ # @param [Array<Contracts::Envelope>] data_to_send an array of {Contracts::Envelope} objects to send to the service.
26
38
  def send(data_to_send)
27
39
  uri = URI(@service_endpoint_uri)
28
- request = Net::HTTP::Post.new(uri.path, { 'Accept' => 'application/json', 'Content-Type' => 'application/json; charset=utf-8' })
29
- request.body = data_to_send.to_json
40
+ headers = {
41
+ 'Accept' => 'application/json',
42
+ 'Content-Type' => 'application/json; charset=utf-8',
43
+ 'Content-Encoding' => 'gzip'
44
+ }
45
+ request = Net::HTTP::Post.new(uri.path, headers)
46
+ compressed_data = compress(data_to_send.to_json)
47
+ request.body = compressed_data
30
48
 
31
49
  http = Net::HTTP.new uri.hostname, uri.port
32
50
  if uri.scheme.downcase == 'https'
@@ -44,6 +62,17 @@ module ApplicationInsights
44
62
  end
45
63
  end
46
64
  end
65
+
66
+ private
67
+
68
+ def compress(string)
69
+ wio = StringIO.new("w")
70
+ w_gz = Zlib::GzipWriter.new wio, nil, nil
71
+ w_gz.write(string)
72
+ w_gz.close
73
+ wio.string
74
+ end
75
+
47
76
  end
48
77
  end
49
78
  end
@@ -2,25 +2,36 @@ require_relative 'queue_base'
2
2
 
3
3
  module ApplicationInsights
4
4
  module Channel
5
- # A synchronous queue for use in conjunction with the SynchronousSender. The queue will flush either when it reaches max_queue_length or when someone calls flush().
5
+ # A synchronous queue for use in conjunction with the {SynchronousSender}. The queue
6
+ # will call {SenderBase#send} when it reaches {#max_queue_length}, or when the consumer
7
+ # calls {#flush}.
8
+ # @example
9
+ # require 'application_insights'
10
+ # require 'thread'
11
+ # queue = ApplicationInsights::Channel::SynchronousQueue.new nil
12
+ # queue.max_queue_length = 1
13
+ # queue.push 1
6
14
  class SynchronousQueue < QueueBase
7
- # Initializes a new instance of the synchronous queue class.
15
+ # Initializes a new instance of the class.
16
+ # @param [SenderBase] sender the sender object that will be used in conjunction with this queue.
8
17
  def initialize(sender)
9
18
  super sender
10
19
  end
11
20
 
12
- # Flushes the current queue to the passed in sender.
21
+ # Flushes the current queue by by calling {#sender}'s {SenderBase#send} method.
13
22
  def flush
23
+ local_sender = @sender
24
+ return unless local_sender
14
25
  while TRUE
15
26
  # get at most send_buffer_size items and send them
16
27
  data = []
17
- while data.length < @sender.send_buffer_size
28
+ while data.length < local_sender.send_buffer_size
18
29
  item = pop()
19
30
  break if not item
20
31
  data.push item
21
32
  end
22
33
  break if data.length == 0
23
- @sender.send(data)
34
+ local_sender.send(data)
24
35
  end
25
36
  end
26
37
  end
@@ -2,9 +2,11 @@ require_relative 'sender_base'
2
2
 
3
3
  module ApplicationInsights
4
4
  module Channel
5
- # A synchronous sender that works in conjunction with SynchronousQueue.
5
+ # A synchronous sender that works in conjunction with the {SynchronousQueue}. The queue will call {#send} on the
6
+ # current instance with the data to send.
6
7
  class SynchronousSender < SenderBase
7
- # Initializes a new instance of the synchronous sender class.
8
+ # Initializes a new instance of the class.
9
+ # @param [String] service_endpoint_uri the address of the service to send telemetry data to.
8
10
  def initialize(service_endpoint_uri='https://dc.services.visualstudio.com/v2/track')
9
11
  super service_endpoint_uri
10
12
  end
@@ -1,3 +1,5 @@
1
+ require_relative 'asynchronous_queue'
2
+ require_relative 'asynchronous_sender'
1
3
  require_relative 'telemetry_context'
2
4
  require_relative 'synchronous_queue'
3
5
  require_relative 'synchronous_sender'
@@ -7,31 +9,48 @@ require_relative 'contracts/internal'
7
9
 
8
10
  module ApplicationInsights
9
11
  module Channel
10
- # The telemetry channel is responsible for constructing an envelope an sending it.
12
+ # The telemetry channel is responsible for constructing a {Contracts::Envelope} object from the passed in
13
+ # data and specified telemetry context.
14
+ # @example
15
+ # require 'application_insights'
16
+ # channel = ApplicationInsights::Channel::TelemetryChannel.new
17
+ # event = ApplicationInsights::Channel::Contracts::EventData.new :name => 'My event'
18
+ # channel.write event
11
19
  class TelemetryChannel
12
- # Initializes a new instance of the telemetry channel class.
20
+ # Initializes a new instance of the class.
21
+ # @param [TelemetryContext] context the telemetry context to use when sending telemetry data.
22
+ # @param [QueueBase] queue the queue to enqueue the resulting {Contracts::Envelope} to.
13
23
  def initialize(context=nil, queue=nil)
14
24
  @context = context || TelemetryContext.new
15
25
  @queue = queue || SynchronousQueue.new(SynchronousSender.new)
16
26
  end
17
27
 
18
- # Gets the context associated with this channel.
28
+ # The context associated with this channel. All {Contracts::Envelope} objects created by this channel will use
29
+ # this value if it's present or if none is specified as part of the {#write} call.
30
+ # @return [TelemetryContext] the context instance (defaults to: TelemetryContext.new)
19
31
  attr_reader :context
20
32
 
21
- # Gets the queue associated with this channel.
33
+ # The queue associated with this channel. All {Contracts::Envelope} objects created by this channel will be
34
+ # pushed to this queue.
35
+ # @return [QueueBase] the queue instance (defaults to: SynchronousQueue.new)
22
36
  attr_reader :queue
23
37
 
24
- # Gets the sender associated with this channel.
38
+ # The sender associated with this channel. This instance will be used to transmit telemetry to the service.
39
+ # @return [SenderBase] the sender instance (defaults to: SynchronousSender.new)
25
40
  def sender
26
41
  @queue.sender
27
42
  end
28
43
 
29
- # Flushes the current queue.
44
+ # Flushes the enqueued data by calling {QueueBase#flush}.
30
45
  def flush
31
46
  @queue.flush
32
47
  end
33
48
 
34
- # Writes the passed in data to the sending queue.
49
+ # Enqueues the passed in data to the {#queue}. If the caller specifies a context as well, it will take precedence
50
+ # over the instance in {#context}.
51
+ # @param [Object] data the telemetry data to send. This will be wrapped in an {Contracts::Envelope} before being
52
+ # enqueued to the {#queue}.
53
+ # @param [TelemetryContext] context the override context to use when constructing the {Contracts::Envelope}.
35
54
  def write(data, context=nil)
36
55
  local_context = context || @context
37
56
  raise ArgumentError, 'Context was required but not provided' unless local_context
@@ -7,9 +7,20 @@ require_relative 'contracts/location'
7
7
 
8
8
  module ApplicationInsights
9
9
  module Channel
10
- # Represents a context for sending telemetry to the Application Insights service.
10
+ # Represents the context for sending telemetry to the Application Insights service.
11
+ # @example
12
+ # require 'application_insights'
13
+ # context = ApplicationInsights::Channel::TelemetryContext.new
14
+ # context.instrumentation_key = '<YOUR INSTRUMENTATION KEY GOES HERE>'
15
+ # context.application.id = 'My application'
16
+ # context.application.ver = '1.2.3'
17
+ # context.device.id = 'My current device'
18
+ # context.device.oem_name = 'Asus'
19
+ # context.device.model = 'X31A'
20
+ # context.device.type = "Other"
21
+ # context.user.id = 'santa@northpole.net'
11
22
  class TelemetryContext
12
- # Initializes a new instance of the TelemetryContext class.
23
+ # Initializes a new instance of the class.
13
24
  def initialize
14
25
  @instrumentation_key = nil
15
26
  @application = Contracts::Application.new
@@ -21,28 +32,36 @@ module ApplicationInsights
21
32
  @properties = {}
22
33
  end
23
34
 
24
- # Gets or sets the instrumentation key.
35
+ # The instrumentation key that is used to identify which Application Insights application this data is for.
36
+ # @return [String] the instrumentation key.
25
37
  attr_accessor :instrumentation_key
26
38
 
27
- # Gets or sets the application context.
39
+ # The application context. This contains properties of the application you are running.
40
+ # @return [Contracts::Application] the context object.
28
41
  attr_accessor :application
29
42
 
30
- # Gets or sets the device context.
43
+ # The device context. This contains properties of the device you are running on.
44
+ # @return [Contracts::Device] the context object.
31
45
  attr_accessor :device
32
46
 
33
- # Gets or sets the user context.
47
+ # The user context. This contains properties of the user you are generating telemetry for.
48
+ # @return [Contracts::User] the context object.
34
49
  attr_accessor :user
35
50
 
36
- # Gets or sets the session context.
51
+ # The session context. This contains properties of the session you are generating telemetry for.
52
+ # @return [Contracts::Session] the context object.
37
53
  attr_accessor :session
38
54
 
39
- # Gets or sets the operation context.
55
+ # The operation context. This contains properties of the operation you are generating telemetry for.
56
+ # @return [Contracts::Operation] the context object.
40
57
  attr_accessor :operation
41
58
 
42
- # Gets or sets the location context.
59
+ # The location context. This contains properties of the location you are generating telemetry from.
60
+ # @return [Contracts::Location] the context object.
43
61
  attr_accessor :location
44
62
 
45
- # Gets a dictionary of application-defined property values.
63
+ # The property context. This contains free-form properties that you can add to your telemetry.
64
+ # @return [Hash<String, String>] the context object.
46
65
  attr_reader :properties
47
66
  end
48
67
  end
@@ -8,23 +8,39 @@ require_relative 'channel/contracts/data_point'
8
8
  require_relative 'channel/contracts/data_point_type'
9
9
  require_relative 'channel/contracts/metric_data'
10
10
  require_relative 'channel/contracts/message_data'
11
+ require_relative 'channel/contracts/stack_frame'
11
12
 
12
13
  module ApplicationInsights
13
- # The telemetry client used for sending all types of telemetry.
14
+ # The telemetry client used for sending all types of telemetry. It serves as the main entry point for
15
+ # interacting with the Application Insights service.
14
16
  class TelemetryClient
15
- # Initializes a new instance of the TelemetryClient class.
17
+ # Initializes a new instance of the class.
18
+ # @param [Channel::TelemetryChannel] telemetry_channel the optional telemetry channel to be used instead of
19
+ # constructing a default one.
16
20
  def initialize(telemetry_channel = nil)
17
21
  @context = Channel::TelemetryContext.new
18
22
  @channel = telemetry_channel || Channel::TelemetryChannel.new
19
23
  end
20
24
 
21
- # Gets the context associated with this telemetry client.
25
+ # The context associated with this client. All data objects created by this client will be accompanied by
26
+ # this value.
27
+ # @return [Channel::TelemetryContext] the context instance.
22
28
  attr_reader :context
23
29
 
24
- # Gets the channel associated with this telemetry client.
30
+ # The channel associated with this telemetry client. All data created by this client will be passed along with
31
+ # the {#context} object to {Channel::TelemetryChannel#write}
32
+ # @return [Channel::TelemetryChannel] the channel instance.
25
33
  attr_reader :channel
26
34
 
27
- # Send information about the page viewed in the application.
35
+ # Send information about the page viewed in the application (a web page for instance).
36
+ # @param [String] name the name of the page that was viewed.
37
+ # @param [String] url the URL of the page that was viewed.
38
+ # @param [Hash] options the options to create the {Channel::Contracts::PageViewData} object.
39
+ # @option options [Fixnum] :duration the duration of the page view in milliseconds. (defaults to: 0)
40
+ # @option options [Hash] :properties the set of custom properties the client wants attached to this
41
+ # data item. (defaults to: {})
42
+ # @option options [Hash] :measurements the set of custom measurements the client wants to attach to
43
+ # this data item (defaults to: {})
28
44
  def track_page_view(name, url, options={})
29
45
  data_attributes = {
30
46
  :name => name || 'Null',
@@ -37,21 +53,46 @@ module ApplicationInsights
37
53
  self.channel.write(data, self.context)
38
54
  end
39
55
 
40
- # Send an ExceptionTelemetry object for display in Diagnostic Search.
56
+ # Send information about a single exception that occurred in the application.
57
+ # @param [Exception] exception the exception that the client wants to send.
58
+ # @param [Hash] options the options to create the {Channel::Contracts::ExceptionData} object.
59
+ # @option options [String] :handled_at the type of exception (defaults to: 'UserCode')
60
+ # @option options [Hash] :properties the set of custom properties the client wants attached to this
61
+ # data item. (defaults to: {})
62
+ # @option options [Hash] :measurements the set of custom measurements the client wants to attach to
63
+ # this data item (defaults to: {})
41
64
  def track_exception(exception, options={})
42
65
  if exception.is_a? Exception
66
+ parsed_stack = []
67
+ if exception.backtrace
68
+ frame_pattern = /^(?<file>.*):(?<line>\d+)(\.|:in `((?<method>.*)'$))/
69
+ counter = 0;
70
+ exception.backtrace.each do |frame|
71
+ match = frame_pattern.match frame
72
+ stack_frame = Channel::Contracts::StackFrame.new
73
+ stack_frame.assembly = 'Unknown'
74
+ stack_frame.file_name = match['file']
75
+ stack_frame.level = counter
76
+ stack_frame.line = match['line']
77
+ stack_frame.method = match['method']
78
+ parsed_stack << stack_frame
79
+ counter += 1
80
+ end
81
+ end
82
+
43
83
  details_attributes = {
44
84
  :id => 1,
45
85
  :outer_id => 0,
46
86
  :type_name => exception.class,
47
87
  :message => exception.message,
48
- :has_full_stack => true,
49
- :stack => exception.backtrace.join("\n")
88
+ :has_full_stack => exception.backtrace != nil,
89
+ :stack => (exception.backtrace.join("\n") if exception.backtrace),
90
+ :parsed_stack => parsed_stack
50
91
  }
51
92
  details = Channel::Contracts::ExceptionDetails.new details_attributes
52
93
 
53
94
  data_attributes = {
54
- :handled_at => 'UserCode',
95
+ :handled_at => options.fetch(:handled_at,'UserCode'),
55
96
  :exceptions => [ details ],
56
97
  :properties => options.fetch(:properties) { {} },
57
98
  :measurements => options.fetch(:measurements) { {} }
@@ -61,7 +102,13 @@ module ApplicationInsights
61
102
  end
62
103
  end
63
104
 
64
- # Send an EventTelemetry object for display in Diagnostic Search and aggregation in Metrics Explorer.
105
+ # Send information about a single event that has occurred in the context of the application.
106
+ # @param [String] name the data to associate to this event.
107
+ # @param [Hash] options the options to create the {Channel::Contracts::EventData} object.
108
+ # @option options [Hash] :properties the set of custom properties the client wants attached to this
109
+ # data item. (defaults to: {})
110
+ # @option options [Hash] :measurements the set of custom measurements the client wants to attach to
111
+ # this data item (defaults to: {})
65
112
  def track_event(name, options={})
66
113
  data_attributes = {
67
114
  :name => name || 'Null',
@@ -72,7 +119,24 @@ module ApplicationInsights
72
119
  self.channel.write(data, self.context)
73
120
  end
74
121
 
75
- # Send a MetricTelemetry object for aggregation in Metric Explorer.
122
+ # Send information about a single metric data point that was captured for the application.
123
+ # @param [String] name the name of the metric that was captured.
124
+ # @param [Fixnum] value the value of the metric that was captured.
125
+ # @param [Hash] options the options to create the {Channel::Contracts::MetricData} object.
126
+ # @option options [Channel::Contracts::DataPointType] :type the type of the metric (defaults to:
127
+ # {Channel::Contracts::DataPointType::AGGREGATION})
128
+ # @option options [Fixnum] :count the number of metrics that were aggregated into this data point
129
+ # (defaults to: 0)
130
+ # @option options [Fixnum] :min the minimum of all metrics collected that were aggregated into this
131
+ # data point (defaults to: 0)
132
+ # @option options [Fixnum] :max the maximum of all metrics collected that were aggregated into this
133
+ # data point (defaults to: 0)
134
+ # @option options [Fixnum] :std_dev the standard deviation of all metrics collected that were aggregated
135
+ # into this data point (defaults to: 0)
136
+ # @option options [Hash] :properties the set of custom properties the client wants attached to this
137
+ # data item. (defaults to: {})
138
+ # @option options [Hash] :measurements the set of custom measurements the client wants to attach to
139
+ # this data item (defaults to: {})
76
140
  def track_metric(name, value, options={})
77
141
  data_point_attributes = {
78
142
  :name => name || 'Null',
@@ -87,23 +151,28 @@ module ApplicationInsights
87
151
 
88
152
  data_attributes = {
89
153
  :metrics => [ data_point ],
90
- :properties => options.fetch(:measurements) { {} }
154
+ :properties => options.fetch(:properties) { {} }
91
155
  }
92
156
  data = Channel::Contracts::MetricData.new data_attributes
93
157
  self.channel.write(data, self.context)
94
158
  end
95
159
 
96
- # Send a trace message for display in Diagnostic Search.
160
+ # Sends a single trace statement.
161
+ # @param [String] name the trace statement.
162
+ # @param [Hash] options the options to create the {Channel::Contracts::EventData} object.
163
+ # @option options [Hash] :properties the set of custom properties the client wants attached to this
164
+ # data item. (defaults to: {})
97
165
  def track_trace(name, options={})
98
166
  data_attributes = {
99
167
  :message => name || 'Null',
100
- :properties => options.fetch(:measurements) { {} }
168
+ :properties => options.fetch(:properties) { {} }
101
169
  }
102
170
  data = Channel::Contracts::MessageData.new data_attributes
103
171
  self.channel.write(data, self.context)
104
172
  end
105
173
 
106
- # Flushes the current queue.
174
+ # Flushes data in the queue. Data in the queue will be sent either immediately irrespective of what sender is
175
+ # being used.
107
176
  def flush
108
177
  self.channel.flush
109
178
  end