instana 1.7.8 → 1.7.9
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 +4 -4
- data/examples/opentracing.rb +31 -0
- data/examples/tracing.rb +7 -4
- data/lib/instana/tracing/span.rb +19 -5
- data/lib/instana/version.rb +1 -1
- data/test/instrumentation/net-http_test.rb +4 -3
- data/test/test_helper.rb +4 -3
- data/test/tracing/custom_test.rb +10 -7
- data/test/tracing/opentracing_test.rb +4 -1
- data/test/tracing/tracer_async_test.rb +14 -14
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af911c681182db8726372c73e8fd2560374b8508
|
4
|
+
data.tar.gz: 230dcaa3a019e7c571a1b10726fc33550092de54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b80e44dcdeaaed59c3b3f1ee2f4b8b7984b22a5b81ae17a1470de2d6c8a34a8b106ef9e07b2b46cc3a086ce292f10ffe40cc24e60a7530f2d16ea5dcae54dda
|
7
|
+
data.tar.gz: f62f4130454c5affedfcf5c322ed2cb83a2ca0ebf48fbd1c846529c2e9bacbe9fd1098a8feedcd5f9c1e0be45530ba91310defdbeacca909d3ec599be6a84875
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# This file contains a basic OpenTracing example.
|
2
|
+
#
|
3
|
+
# Note: The instana gem automatically sets the Instana tracer
|
4
|
+
# to `OpenTracing.global_tracer`. Once the gem is loaded, you can
|
5
|
+
# immediately start making OpenTracing calls.
|
6
|
+
#
|
7
|
+
require "opentracing"
|
8
|
+
|
9
|
+
entry_span = OpenTracing.start_span("HandMadeRackServer")
|
10
|
+
|
11
|
+
entry_span.set_tag(:'http.method', :get)
|
12
|
+
entry_span.set_tag(:'http.url', "/users")
|
13
|
+
entry_span.set_tag(:'span.kind', "entry")
|
14
|
+
|
15
|
+
intermediate_span = OpenTracing.start_span("myintermediate", :child_of => entry_span)
|
16
|
+
intermediate_span.finish()
|
17
|
+
|
18
|
+
db_span = OpenTracing.start_span('mydbspan', :child_of => entry_span)
|
19
|
+
db_span.set_tag(:'db.instance', "users")
|
20
|
+
db_span.set_tag(:'db.statement', "SELECT * FROM user_table")
|
21
|
+
db_span.set_tag(:'db.type', "mysql")
|
22
|
+
db_span.set_tag(:'db.user', "mysql_login")
|
23
|
+
db_span.set_tag(:'span.kind', "exit")
|
24
|
+
db_span.finish()
|
25
|
+
|
26
|
+
intermediate_span = OpenTracing.start_span("myintermediate", :child_of => entry_span)
|
27
|
+
intermediate_span.log("ALLOK", :message => "All seems ok")
|
28
|
+
intermediate_span.finish()
|
29
|
+
|
30
|
+
entry_span.set_tag(:'http.status_code', 200)
|
31
|
+
entry_span.finish()
|
data/examples/tracing.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
# This file outlines
|
2
|
-
#
|
3
|
-
#
|
1
|
+
# This file outlines the Instana Ruby Tracing API.
|
2
|
+
#
|
3
|
+
# This same tracer also supports OpenTracing. See `opentracing.rb` for
|
4
|
+
# separate documentation.
|
5
|
+
|
6
|
+
# This API is also documented on rubydoc:
|
7
|
+
# http://www.rubydoc.info/gems/instana/1.7.8/Instana/Tracer
|
4
8
|
|
5
9
|
#######################################
|
6
10
|
## Block tracing
|
@@ -74,4 +78,3 @@ ensure
|
|
74
78
|
end
|
75
79
|
|
76
80
|
Instana::Tracer.log_end(:mywebserver)
|
77
|
-
|
data/lib/instana/tracing/span.rb
CHANGED
@@ -98,7 +98,7 @@ module Instana
|
|
98
98
|
if HTTP_SPANS.include?(@data[:n])
|
99
99
|
set_tags(:http => { :error => "#{e.class}: #{e.message}" })
|
100
100
|
else
|
101
|
-
|
101
|
+
log(:error, Time.now, { :message => e.message, :parameters => e.class.to_s })
|
102
102
|
end
|
103
103
|
e.instance_variable_set(:@instana_logged, true)
|
104
104
|
end
|
@@ -115,6 +115,7 @@ module Instana
|
|
115
115
|
def configure_custom(name)
|
116
116
|
@data[:n] = :sdk
|
117
117
|
@data[:data] = { :sdk => { :name => name.to_sym } }
|
118
|
+
@data[:data][:sdk][:custom] = { :tags => {}, :logs => {} }
|
118
119
|
self
|
119
120
|
end
|
120
121
|
|
@@ -243,6 +244,10 @@ module Instana
|
|
243
244
|
@data[:n] == :sdk
|
244
245
|
end
|
245
246
|
|
247
|
+
def inspect
|
248
|
+
@data.inspect
|
249
|
+
end
|
250
|
+
|
246
251
|
#############################################################
|
247
252
|
# OpenTracing Compatibility Methods
|
248
253
|
#############################################################
|
@@ -266,7 +271,8 @@ module Instana
|
|
266
271
|
def set_tag(key, value)
|
267
272
|
if custom?
|
268
273
|
@data[:data][:sdk][:custom] ||= {}
|
269
|
-
@data[:data][:sdk][:custom][
|
274
|
+
@data[:data][:sdk][:custom][:tags] ||= {}
|
275
|
+
@data[:data][:sdk][:custom][:tags][key] = value
|
270
276
|
|
271
277
|
if key.to_sym == :'span.kind'
|
272
278
|
case value.to_sym
|
@@ -333,7 +339,7 @@ module Instana
|
|
333
339
|
#
|
334
340
|
def tags(key = nil)
|
335
341
|
if custom?
|
336
|
-
tags = @data[:data][:sdk][:custom]
|
342
|
+
tags = @data[:data][:sdk][:custom][:tags]
|
337
343
|
else
|
338
344
|
tags = @data[:data][key]
|
339
345
|
end
|
@@ -347,8 +353,16 @@ module Instana
|
|
347
353
|
# @param timestamp [Time] time of the log
|
348
354
|
# @param fields [Hash] Additional information to log
|
349
355
|
#
|
350
|
-
def log(event = nil,
|
351
|
-
|
356
|
+
def log(event = nil, timestamp = Time.now, **fields)
|
357
|
+
ts = ::Instana::Util.time_to_ms(timestamp).to_s
|
358
|
+
if custom?
|
359
|
+
@data[:data][:sdk][:custom][:logs][ts] = fields
|
360
|
+
@data[:data][:sdk][:custom][:logs][ts][:event] = event
|
361
|
+
else
|
362
|
+
set_tags(:log => fields)
|
363
|
+
end
|
364
|
+
rescue StandardError => e
|
365
|
+
Instana.logger.debug "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
|
352
366
|
end
|
353
367
|
|
354
368
|
# Finish the {Span}
|
data/lib/instana/version.rb
CHANGED
@@ -131,9 +131,10 @@ class NetHTTPTest < Minitest::Test
|
|
131
131
|
|
132
132
|
assert_equal :'net-http-error-test', first_span.name
|
133
133
|
assert first_span.custom?
|
134
|
-
|
135
|
-
assert first_span[:data][:sdk][:custom][:
|
136
|
-
assert first_span[:data][:sdk][:custom][:
|
134
|
+
ts_key = first_span[:data][:sdk][:custom][:logs].keys.first
|
135
|
+
assert first_span[:data][:sdk][:custom][:logs].key?(ts_key)
|
136
|
+
assert first_span[:data][:sdk][:custom][:logs][ts_key].key?(:event)
|
137
|
+
assert first_span[:data][:sdk][:custom][:logs][ts_key].key?(:parameters)
|
137
138
|
|
138
139
|
WebMock.disable_net_connect!
|
139
140
|
end
|
data/test/test_helper.rb
CHANGED
@@ -8,8 +8,8 @@ require "minitest/spec"
|
|
8
8
|
require "minitest/autorun"
|
9
9
|
require "minitest/reporters"
|
10
10
|
require "minitest/debugger" if ENV['DEBUG']
|
11
|
-
require 'webmock/minitest'
|
12
11
|
require "minitest/benchmark"
|
12
|
+
require 'webmock/minitest'
|
13
13
|
|
14
14
|
require "instana/test"
|
15
15
|
::Instana::Test.setup_environment
|
@@ -17,10 +17,11 @@ require "instana/test"
|
|
17
17
|
# Boot background webservers to test against.
|
18
18
|
require "./test/servers/rackapp_6511"
|
19
19
|
|
20
|
+
# Allow localhost calls to the internal rails servers
|
21
|
+
::WebMock.disable_net_connect!(allow_localhost: true)
|
22
|
+
|
20
23
|
case File.basename(ENV['BUNDLE_GEMFILE'])
|
21
24
|
when /rails50|rails42|rails32/
|
22
|
-
# Allow localhost calls to the internal rails servers
|
23
|
-
::WebMock.disable_net_connect!(allow_localhost: true)
|
24
25
|
require './test/servers/rails_3205'
|
25
26
|
when /libraries/
|
26
27
|
# Configure gRPC
|
data/test/tracing/custom_test.rb
CHANGED
@@ -30,8 +30,9 @@ class CustomTracingTest < Minitest::Test
|
|
30
30
|
assert first_span.key?(:data)
|
31
31
|
assert first_span[:data].key?(:sdk)
|
32
32
|
assert first_span[:data][:sdk].key?(:custom)
|
33
|
+
assert first_span[:data][:sdk][:custom].key?(:tags)
|
33
34
|
assert_equal :custom_trace, first_span[:data][:sdk][:name]
|
34
|
-
assert_equal 1, first_span[:data][:sdk][:custom][:one]
|
35
|
+
assert_equal 1, first_span[:data][:sdk][:custom][:tags][:one]
|
35
36
|
assert_equal :ruby, first_span[:ta]
|
36
37
|
|
37
38
|
assert first_span.key?(:f)
|
@@ -85,13 +86,14 @@ class CustomTracingTest < Minitest::Test
|
|
85
86
|
assert second_span.key?(:data)
|
86
87
|
assert second_span[:data].key?(:sdk)
|
87
88
|
assert second_span[:data][:sdk].key?(:custom)
|
89
|
+
assert second_span[:data][:sdk][:custom].key?(:tags)
|
88
90
|
assert :custom_span, second_span[:data][:sdk][:name]
|
89
91
|
assert :unknown, second_span[:data][:sdk][:type]
|
90
92
|
assert [[1, 2, 3], "test_arg", :ok], second_span[:data][:sdk][:arguments]
|
91
93
|
assert true, second_span[:data][:sdk][:return]
|
92
|
-
assert_equal 1, second_span[:data][:sdk][:custom][:on_entry_kv]
|
93
|
-
assert_equal 1, second_span[:data][:sdk][:custom][:on_info_kv]
|
94
|
-
assert_equal 1, second_span[:data][:sdk][:custom][:on_exit_kv]
|
94
|
+
assert_equal 1, second_span[:data][:sdk][:custom][:tags][:on_entry_kv]
|
95
|
+
assert_equal 1, second_span[:data][:sdk][:custom][:tags][:on_info_kv]
|
96
|
+
assert_equal 1, second_span[:data][:sdk][:custom][:tags][:on_exit_kv]
|
95
97
|
end
|
96
98
|
|
97
99
|
def test_custom_tracing_with_error
|
@@ -148,13 +150,14 @@ class CustomTracingTest < Minitest::Test
|
|
148
150
|
assert second_span.key?(:data)
|
149
151
|
assert second_span[:data].key?(:sdk)
|
150
152
|
assert second_span[:data][:sdk].key?(:custom)
|
153
|
+
assert second_span[:data][:sdk][:custom].key?(:tags)
|
151
154
|
assert :custom_span, second_span[:data][:sdk][:name]
|
152
155
|
assert :unknown, second_span[:data][:sdk][:type]
|
153
156
|
assert [[1, 2, 3], "test_arg", :ok], second_span[:data][:sdk][:arguments]
|
154
157
|
assert true, second_span[:data][:sdk][:return]
|
155
|
-
assert_equal 1, second_span[:data][:sdk][:custom][:on_entry_kv]
|
156
|
-
assert !second_span[:data][:sdk][:custom].key?(:on_info_kv)
|
157
|
-
assert_equal 1, second_span[:data][:sdk][:custom][:on_exit_kv]
|
158
|
+
assert_equal 1, second_span[:data][:sdk][:custom][:tags][:on_entry_kv]
|
159
|
+
assert !second_span[:data][:sdk][:custom][:tags].key?(:on_info_kv)
|
160
|
+
assert_equal 1, second_span[:data][:sdk][:custom][:tags][:on_exit_kv]
|
158
161
|
|
159
162
|
# Check the error
|
160
163
|
assert_equal true, second_span[:error]
|
@@ -213,7 +213,7 @@ class OpenTracerTest < Minitest::Test
|
|
213
213
|
span[:data][:sdk].delete(:type)
|
214
214
|
span.set_tag(:'span.kind', :blah)
|
215
215
|
assert_equal false, span[:data][:sdk].key?(:type)
|
216
|
-
assert_equal :blah, span[:data][:sdk][:custom][:'span.kind']
|
216
|
+
assert_equal :blah, span[:data][:sdk][:custom][:tags][:'span.kind']
|
217
217
|
|
218
218
|
span.finish
|
219
219
|
end
|
@@ -250,6 +250,9 @@ class OpenTracerTest < Minitest::Test
|
|
250
250
|
|
251
251
|
assert_equal ts_start_ms, span[:ts]
|
252
252
|
assert_equal (ts_finish_ms - ts_start_ms), span[:d]
|
253
|
+
|
254
|
+
assert_equal 1234, span[:data][:sdk][:custom][:tags][:start_tag]
|
255
|
+
assert_equal 'tag_value', span[:data][:sdk][:custom][:tags][:another_tag]
|
253
256
|
end
|
254
257
|
|
255
258
|
def test_nested_spans_using_child_of
|
@@ -45,8 +45,8 @@ class TracerAsyncTest < Minitest::Test
|
|
45
45
|
# KV checks
|
46
46
|
assert_equal 1, first_span[:data][:rack_start_kv]
|
47
47
|
assert_equal 1, first_span[:data][:rack_end_kv]
|
48
|
-
assert_equal 1, second_span[:data][:sdk][:custom][:entry_kv]
|
49
|
-
assert_equal 1, second_span[:data][:sdk][:custom][:exit_kv]
|
48
|
+
assert_equal 1, second_span[:data][:sdk][:custom][:tags][:entry_kv]
|
49
|
+
assert_equal 1, second_span[:data][:sdk][:custom][:tags][:exit_kv]
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_diff_thread_async_tracing
|
@@ -103,14 +103,14 @@ class TracerAsyncTest < Minitest::Test
|
|
103
103
|
# first span in second trace
|
104
104
|
assert_equal :async_thread, first_span.name
|
105
105
|
assert first_span.duration
|
106
|
-
assert_equal 1, first_span[:data][:sdk][:custom][:async_start]
|
107
|
-
assert_equal 1, first_span[:data][:sdk][:custom][:async_end]
|
106
|
+
assert_equal 1, first_span[:data][:sdk][:custom][:tags][:async_start]
|
107
|
+
assert_equal 1, first_span[:data][:sdk][:custom][:tags][:async_end]
|
108
108
|
|
109
109
|
# second span in second trace
|
110
110
|
assert_equal :sleepy_time, second_span.name
|
111
111
|
assert second_span.duration
|
112
|
-
assert_equal 1, second_span[:data][:sdk][:custom][:tired]
|
113
|
-
assert_equal 1, second_span[:data][:sdk][:custom][:wake_up]
|
112
|
+
assert_equal 1, second_span[:data][:sdk][:custom][:tags][:tired]
|
113
|
+
assert_equal 1, second_span[:data][:sdk][:custom][:tags][:wake_up]
|
114
114
|
|
115
115
|
# Validate linkage
|
116
116
|
# first_span is the parent of first_span
|
@@ -169,8 +169,8 @@ class TracerAsyncTest < Minitest::Test
|
|
169
169
|
|
170
170
|
# second span validation
|
171
171
|
assert_equal :my_async_op, second_span.name
|
172
|
-
assert_equal 1, second_span[:data][:sdk][:custom][:async_entry_kv]
|
173
|
-
assert !second_span[:data][:sdk][:custom].key?(:async_exit_kv)
|
172
|
+
assert_equal 1, second_span[:data][:sdk][:custom][:tags][:async_entry_kv]
|
173
|
+
assert !second_span[:data][:sdk][:custom][:tags].key?(:async_exit_kv)
|
174
174
|
assert_equal nil, second_span.duration
|
175
175
|
|
176
176
|
# first_span is the parent of first_span
|
@@ -252,12 +252,12 @@ class TracerAsyncTest < Minitest::Test
|
|
252
252
|
# KV checks
|
253
253
|
assert_equal 1, first_span[:data][:rack_start_kv]
|
254
254
|
assert_equal 1, first_span[:data][:rack_end_kv]
|
255
|
-
assert_equal 1, second_span[:data][:sdk][:custom][:entry_kv]
|
256
|
-
assert_equal 1, second_span[:data][:sdk][:custom][:exit_kv]
|
257
|
-
assert_equal 2, third_span[:data][:sdk][:custom][:entry_kv]
|
258
|
-
assert_equal 2, third_span[:data][:sdk][:custom][:exit_kv]
|
259
|
-
assert_equal 3, fourth_span[:data][:sdk][:custom][:entry_kv]
|
260
|
-
assert_equal 3, fourth_span[:data][:sdk][:custom][:exit_kv]
|
255
|
+
assert_equal 1, second_span[:data][:sdk][:custom][:tags][:entry_kv]
|
256
|
+
assert_equal 1, second_span[:data][:sdk][:custom][:tags][:exit_kv]
|
257
|
+
assert_equal 2, third_span[:data][:sdk][:custom][:tags][:entry_kv]
|
258
|
+
assert_equal 2, third_span[:data][:sdk][:custom][:tags][:exit_kv]
|
259
|
+
assert_equal 3, fourth_span[:data][:sdk][:custom][:tags][:entry_kv]
|
260
|
+
assert_equal 3, fourth_span[:data][:sdk][:custom][:tags][:exit_kv]
|
261
261
|
end
|
262
262
|
|
263
263
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: instana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Giacomo Lombardo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -192,6 +192,7 @@ files:
|
|
192
192
|
- benchmarks/time_processing.rb
|
193
193
|
- bin/console
|
194
194
|
- bin/setup
|
195
|
+
- examples/opentracing.rb
|
195
196
|
- examples/tracing.rb
|
196
197
|
- gemfiles/libraries.gemfile
|
197
198
|
- gemfiles/rails32.gemfile
|