instana 1.0.3 → 1.1.0
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/.travis.yml +3 -0
- data/Gemfile +3 -0
- data/Rakefile +2 -0
- data/lib/instana/config.rb +1 -0
- data/lib/instana/instrumentation/dalli.rb +78 -0
- data/lib/instana/tracer.rb +15 -0
- data/lib/instana/tracing/span.rb +1 -1
- data/lib/instana/util.rb +2 -1
- data/lib/instana/version.rb +1 -1
- 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: 83702cf490019361b99d4c0096e4e12297a915e4
|
|
4
|
+
data.tar.gz: a7d1b3d505cc1466d1bf5bf784641bf07228f91c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a3950247007e4aa9b70d08257e7b9fbb5ccf99e211f454415edd1a9140840745b11e81e045b3596c22383c3d3405a0d4594a2858419b44bed49d3114af7c0c11
|
|
7
|
+
data.tar.gz: cf9910fa2bfa9bfd5e80b24f64539fadb9d235b523f7f9bf4f6d81ba0daf10627b117d62d6c2502af8ee45e0b4d9064c2cd53af22335c9ceb9d2b0e9359259e5
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/lib/instana/config.rb
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
module Instana
|
|
2
|
+
module Instrumentation
|
|
3
|
+
module Dalli
|
|
4
|
+
def self.included(klass)
|
|
5
|
+
::Instana::Util.method_alias(klass, :perform)
|
|
6
|
+
::Instana::Util.method_alias(klass, :get_multi)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def perform_with_instana(*args, &blk)
|
|
10
|
+
if !::Instana.tracer.tracing? || ::Instana.tracer.tracing_span?(:memcache)
|
|
11
|
+
do_skip = true
|
|
12
|
+
return perform_without_instana(*args, &blk)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
op, key, *_opts = args
|
|
16
|
+
|
|
17
|
+
entry_payload = { :memcache => {} }
|
|
18
|
+
entry_payload[:memcache][:namespace] = @options[:namespace] if @options.key?(:namespace)
|
|
19
|
+
entry_payload[:memcache][:command] = op
|
|
20
|
+
entry_payload[:memcache][:key] = key
|
|
21
|
+
|
|
22
|
+
::Instana.tracer.log_entry(:memcache, entry_payload)
|
|
23
|
+
result = perform_without_instana(*args, &blk)
|
|
24
|
+
|
|
25
|
+
kv_payload = { :memcache => {}}
|
|
26
|
+
if op == :get
|
|
27
|
+
kv_payload[:memcache][:hit] = result ? 1 : 0
|
|
28
|
+
end
|
|
29
|
+
result
|
|
30
|
+
rescue => e
|
|
31
|
+
::Instana.tracer.log_error(e)
|
|
32
|
+
raise
|
|
33
|
+
ensure
|
|
34
|
+
::Instana.tracer.log_exit(:memcache, kv_payload) unless do_skip
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def get_multi_with_instana(*keys)
|
|
38
|
+
entry_payload = { :memcache => {} }
|
|
39
|
+
entry_payload[:memcache][:namespace] = @options[:namespace] if @options.key?(:namespace)
|
|
40
|
+
entry_payload[:memcache][:command] = :get_multi
|
|
41
|
+
entry_payload[:memcache][:keys] = keys.flatten.join(", ")
|
|
42
|
+
|
|
43
|
+
::Instana.tracer.log_entry(:memcache, entry_payload)
|
|
44
|
+
result = get_multi_without_instana(*keys)
|
|
45
|
+
|
|
46
|
+
exit_payload = { :memcache => {} }
|
|
47
|
+
exit_payload[:memcache][:hits] = result.length
|
|
48
|
+
result
|
|
49
|
+
rescue => e
|
|
50
|
+
::Instana.tracer.log_error(e)
|
|
51
|
+
raise
|
|
52
|
+
ensure
|
|
53
|
+
::Instana.tracer.log_exit(:memcache, exit_payload)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
module DalliServer
|
|
58
|
+
def self.included(klass)
|
|
59
|
+
::Instana::Util.method_alias(klass, :request)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def request_with_instana(op, *args)
|
|
63
|
+
if ::Instana.tracer.tracing? || ::Instana.tracer.tracing_span?(:memcache)
|
|
64
|
+
info_payload = { :memcache => {} }
|
|
65
|
+
info_payload[:memcache][:server] = "#{@hostname}:#{@port}"
|
|
66
|
+
::Instana.tracer.log_info(info_payload)
|
|
67
|
+
end
|
|
68
|
+
request_without_instana(op, *args)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
if defined?(::Dalli) && ::Instana.config[:dalli][:enabled]
|
|
75
|
+
::Instana.logger.warn "Instrumenting Dalli"
|
|
76
|
+
::Dalli::Client.send(:include, ::Instana::Instrumentation::Dalli)
|
|
77
|
+
::Dalli::Server.send(:include, ::Instana::Instrumentation::DalliServer)
|
|
78
|
+
end
|
data/lib/instana/tracer.rb
CHANGED
|
@@ -73,6 +73,7 @@ module Instana
|
|
|
73
73
|
#
|
|
74
74
|
def log_start_or_continue(name, kvs = {}, incoming_context = {})
|
|
75
75
|
return unless ::Instana.agent.ready?
|
|
76
|
+
::Instana.logger.debug "#{__method__} passed a block. Use `start_or_continue` instead!" if block_given?
|
|
76
77
|
self.current_trace = ::Instana::Trace.new(name, kvs, incoming_context)
|
|
77
78
|
end
|
|
78
79
|
|
|
@@ -307,6 +308,20 @@ module Instana
|
|
|
307
308
|
self.current_trace ? true : false
|
|
308
309
|
end
|
|
309
310
|
|
|
311
|
+
# Indicates if we're tracing and the current span name matches
|
|
312
|
+
# <name>
|
|
313
|
+
#
|
|
314
|
+
# @param name [Symbol] the name to check against the current span
|
|
315
|
+
#
|
|
316
|
+
# @return [Boolean]
|
|
317
|
+
#
|
|
318
|
+
def tracing_span?(name)
|
|
319
|
+
if self.current_trace
|
|
320
|
+
return self.current_trace.current_span.name == name
|
|
321
|
+
end
|
|
322
|
+
false
|
|
323
|
+
end
|
|
324
|
+
|
|
310
325
|
# Retrieve the current context of the tracer.
|
|
311
326
|
#
|
|
312
327
|
# @return [SpanContext] or nil if not tracing
|
data/lib/instana/tracing/span.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Instana
|
|
2
2
|
class Span
|
|
3
|
-
REGISTERED_SPANS = [ :rack, :'net-http', :excon ].freeze
|
|
3
|
+
REGISTERED_SPANS = [ :rack, :'net-http', :excon, :memcache ].freeze
|
|
4
4
|
ENTRY_SPANS = [ :rack ].freeze
|
|
5
5
|
EXIT_SPANS = [ :'net-http', :excon ].freeze
|
|
6
6
|
HTTP_SPANS = ENTRY_SPANS + EXIT_SPANS
|
data/lib/instana/util.rb
CHANGED
|
@@ -7,7 +7,8 @@ module Instana
|
|
|
7
7
|
# @param method [Symbol] The name of the method to be aliased.
|
|
8
8
|
#
|
|
9
9
|
def method_alias(klass, method)
|
|
10
|
-
if klass.method_defined?(method.to_sym)
|
|
10
|
+
if klass.method_defined?(method.to_sym) ||
|
|
11
|
+
klass.private_method_defined?(method.to_sym)
|
|
11
12
|
|
|
12
13
|
with = "#{method}_with_instana"
|
|
13
14
|
without = "#{method}_without_instana"
|
data/lib/instana/version.rb
CHANGED
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.0
|
|
4
|
+
version: 1.1.0
|
|
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: 2017-01-
|
|
11
|
+
date: 2017-01-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -145,6 +145,7 @@ files:
|
|
|
145
145
|
- lib/instana/frameworks/sinatra.rb
|
|
146
146
|
- lib/instana/helpers.rb
|
|
147
147
|
- lib/instana/instrumentation.rb
|
|
148
|
+
- lib/instana/instrumentation/dalli.rb
|
|
148
149
|
- lib/instana/instrumentation/excon.rb
|
|
149
150
|
- lib/instana/instrumentation/net-http.rb
|
|
150
151
|
- lib/instana/instrumentation/rack.rb
|