fluent-plugin-application-insights 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bfa9d92dcee9f67b521133f83b7381e1a73d6b35
4
- data.tar.gz: c8a69e7f304425e4f915dd17e8ad979399333af9
3
+ metadata.gz: 16cd7a0fed351fcf6f1c5c9030454658ea2bb1e6
4
+ data.tar.gz: '08af822420fb65b336283d29cd4fb23800aa3b10'
5
5
  SHA512:
6
- metadata.gz: 6794875d0ae52ea3f9d97da680958902c20dd187471312d6332b889148c7c00f0c20102b5f6e75ba4532a0ab282e12c95bfb188410abc4de70fcb8816c3566a8
7
- data.tar.gz: ed67f84b150d180cbb43e6301c93b9031a004f4515184203575f3678190f98967be764ba44ee0bef15e7e24a97ce1591b46ba5fcdac27035a9c20a80e4a02df4
6
+ metadata.gz: 73ff2242c21c5be630d7a10e15e406e9f517856261be253fa055fcd02dc66674b0f4d42882676d0612f17fef820612fccc5a22f2507675b6e68122c047b64071
7
+ data.tar.gz: e0933edfcbd3ff4f4c56185a166f506ddf47e7e74d107acb3f72051484f18546f2c943c8f0242e42b6af05232d1e4b3b04b536147a79d06522baab8f89f75f38
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "fluent-plugin-application-insights"
6
- spec.version = "0.2.0"
6
+ spec.version = "0.2.1"
7
7
  spec.authors = ["Microsoft Corporation"]
8
8
  spec.email = ["ctdiagcore@microsoft.com"]
9
9
 
@@ -123,9 +123,13 @@ module Fluent::Plugin
123
123
 
124
124
  envelope = Channel::Contracts::Envelope.new
125
125
  Channel::Contracts::Envelope.json_mappings.each do |attr, name|
126
- envelope.send(:"#{attr}=", record[name]) if record[name]
126
+ property = record.delete(name)
127
+ envelope.send(:"#{attr}=", property) if property
127
128
  end
128
129
 
130
+ # There could be extra properties added during the fluentd pipeline. Merge the extra properties so they are not lost.
131
+ merge_extra_properties_standard_schema record, envelope
132
+
129
133
  @tc.channel.queue.push(envelope)
130
134
  else
131
135
  log.warn "Unknown telemetry type #{base_type}. Event will be treated as as non standard schema event."
@@ -147,6 +151,14 @@ module Fluent::Plugin
147
151
  end
148
152
  end
149
153
 
154
+ def merge_extra_properties_standard_schema(record, envelope)
155
+ return if record.empty?
156
+
157
+ envelope.data["baseData"]["properties"] ||= {}
158
+ envelope.data["baseData"]["properties"].merge!(record)
159
+ stringify_properties(envelope.data["baseData"]["properties"])
160
+ end
161
+
150
162
  def process_non_standard_schema_log(record, time)
151
163
  time = record.delete(@time_property) || time
152
164
  context = get_context_non_standard_schema(record)
@@ -83,6 +83,15 @@ class ApplicationInsightsOutputTest < Test::Unit::TestCase
83
83
  assert_true logs.all?{ |log| log.include?("Unknown telemetry type unknown") }
84
84
  end
85
85
 
86
+ test 'extra properties are not lost after processing' do
87
+ time = event_time("2011-01-02 13:14:15 UTC")
88
+ @d.run(default_tag: 'test', shutdown: false) do
89
+ @d.feed(time, {"name" => "telemetry name", "data" => { "baseType" => "RequestData", "baseData" => {} }, "kubernetes" => { "pod_name" => "frontend" }})
90
+ end
91
+
92
+ envelope = @d.instance.tc.channel.queue[0]
93
+ assert_equal({ "kubernetes" => "{\"pod_name\":\"frontend\"}" }, envelope.data["baseData"]["properties"])
94
+ end
86
95
  end
87
96
 
88
97
  sub_test_case 'set context on standard schema event' do
@@ -149,8 +158,12 @@ class ApplicationInsightsOutputTest < Test::Unit::TestCase
149
158
  envelope = d.instance.tc.channel.queue[0]
150
159
  assert_not_nil envelope.tags
151
160
  assert_equal "frontend", envelope.tags["ai.cloud.role"]
152
- # Extra property that is not part of Envelope (kubernetes_container_name, other_prop) is ignored
153
- assert_nil envelope.data["baseData"]["properties"]
161
+
162
+ extra_properties = {
163
+ "kubernetes_container_name" => "frontend",
164
+ "other_prop" => "prop value"
165
+ }
166
+ assert_equal extra_properties, envelope.data["baseData"]["properties"]
154
167
  end
155
168
 
156
169
  test 'context tag source is nested property path' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-application-insights
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Microsoft Corporation
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-04 00:00:00.000000000 Z
11
+ date: 2018-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubyforge_project:
128
- rubygems_version: 2.5.2
128
+ rubygems_version: 2.6.14.1
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: This is the fluentd output plugin for Azure Application Insights.