cassie 1.0.0.beta.7 → 1.0.0.beta.8
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/lib/cassie/queries/instrumentation/execution.rb +15 -0
- data/lib/cassie/queries/instrumentation/loading.rb +15 -0
- data/lib/cassie/queries/instrumentation.rb +5 -11
- data/lib/cassie/queries/logging/cql_execution_event.rb +1 -0
- data/lib/cassie/queries/logging/cql_execution_loading_event.rb +36 -0
- data/lib/cassie/queries/logging/subscription.rb +10 -8
- data/lib/cassie/queries/statement/execution.rb +2 -0
- data/lib/cassie/queries/statement/fetching.rb +3 -0
- data/lib/cassie/queries/statement.rb +0 -2
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49c8a1b3bd425573a87262ce9039546092ae8cdd
|
4
|
+
data.tar.gz: 21be67660a39aaad7c1dad0bc7e64a90400668bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae12ca81c7063c1f149624b722830d0a1d3cb4c420fa3ecf71d26895b154b866dc84711d4361642994c5eb99351730df26cb3f896b02c4316c2ad93d79dc8f9c
|
7
|
+
data.tar.gz: cb1543b03d2e7a85f8cd1f3e18566b1920681f603bdc239d212b11d74dcc7dbcfacf2737d26e356fc50afb722f0b0bff1a9eaca572ccae9f677691a5570e4deb
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Cassie::Queries::Instrumentation
|
2
|
+
module Execution
|
3
|
+
|
4
|
+
def execute
|
5
|
+
instrumenter.instrument("cassie.cql.execution") do |payload|
|
6
|
+
execution_val = super #execution populates #result
|
7
|
+
|
8
|
+
payload[:execution_info] = result.execution_info if result.respond_to?(:execution_info)
|
9
|
+
execution_val
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Cassie::Queries::Instrumentation
|
2
|
+
module Loading
|
3
|
+
|
4
|
+
protected
|
5
|
+
|
6
|
+
def build_resources(rows)
|
7
|
+
instrumenter.instrument("cassie.cql.execution.loading") do |payload|
|
8
|
+
payload[:count] = rows.count if rows.respond_to?(:count)
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
@@ -1,18 +1,12 @@
|
|
1
|
+
require_relative 'instrumentation/execution'
|
2
|
+
require_relative 'instrumentation/loading'
|
3
|
+
|
1
4
|
module Cassie::Queries
|
2
5
|
module Instrumentation
|
3
6
|
extend ::ActiveSupport::Concern
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
def instrument #:nodoc:
|
10
|
-
instrumenter.instrument("cql.execute") do |payload|
|
11
|
-
execution_val = yield # execution populates #result
|
12
|
-
|
13
|
-
payload[:execution_info] = result.execution_info if result.respond_to?(:execution_info)
|
14
|
-
execution_val
|
15
|
-
end
|
8
|
+
included do
|
9
|
+
include Execution
|
16
10
|
end
|
17
11
|
|
18
12
|
protected
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Cassie::Queries::Logging
|
2
|
+
class CqlExecutionLoadingEvent < ActiveSupport::Notifications::Event
|
3
|
+
|
4
|
+
def count
|
5
|
+
payload[:count]
|
6
|
+
end
|
7
|
+
|
8
|
+
def message
|
9
|
+
{
|
10
|
+
event: "cassie.cql.execution.loading",
|
11
|
+
duration: duration.round(1),
|
12
|
+
count: count
|
13
|
+
}.extend(Inspector)
|
14
|
+
end
|
15
|
+
|
16
|
+
module Inspector
|
17
|
+
def inspect
|
18
|
+
indent(1, color("(#{fetch(:duration).round(1)}ms) #{fetch(:count)} #{'resource'.pluralize(fetch(:count))} built from query result"))
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
inspect
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
def color(message)
|
28
|
+
"\e[1m\e[37m#{message}\e[0m\e[22m"
|
29
|
+
end
|
30
|
+
|
31
|
+
def indent(count=1, str)
|
32
|
+
" " * count + str
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,22 +1,24 @@
|
|
1
1
|
require_relative 'cql_execution_event'
|
2
|
+
require_relative 'cql_execution_loading_event'
|
2
3
|
|
3
4
|
module Cassie::Queries::Logging
|
4
5
|
module Subscription
|
5
6
|
extend ::ActiveSupport::Concern
|
6
7
|
|
7
8
|
included do
|
8
|
-
ActiveSupport::Notifications.subscribe('cql.
|
9
|
-
#
|
10
|
-
# name # => String, name of the event (such as 'render' from above)
|
11
|
-
# start # => Time, when the instrumented block started execution
|
12
|
-
# finish # => Time, when the instrumented block ended execution
|
13
|
-
# id # => String, unique ID for this notification
|
14
|
-
# payload # => Hash, the payload
|
15
|
-
# [:exception] => if raised during event
|
9
|
+
ActiveSupport::Notifications.subscribe('cassie.cql.execution') do |*args|
|
10
|
+
# don't log if instrumentation failed
|
16
11
|
unless args.last[:exception]
|
17
12
|
logger.debug(CqlExecutionEvent.new(*args).message)
|
18
13
|
end
|
19
14
|
end
|
15
|
+
|
16
|
+
ActiveSupport::Notifications.subscribe('cassie.cql.execution.loading') do |*args|
|
17
|
+
# don't log if instrumentation failed
|
18
|
+
unless args.last[:exception]
|
19
|
+
logger.debug(CqlExecutionLoadingEvent.new(*args).message)
|
20
|
+
end
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
@@ -11,6 +11,9 @@ module Cassie::Queries::Statement
|
|
11
11
|
included do
|
12
12
|
include Loading
|
13
13
|
include Batches
|
14
|
+
#TODO: should this be loaded from instrumentation
|
15
|
+
# by using notifications when fetching is loaded?
|
16
|
+
include Cassie::Queries::Instrumentation::Loading
|
14
17
|
end
|
15
18
|
|
16
19
|
# Returns array of rows or empty array
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cassie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.beta.
|
4
|
+
version: 1.0.0.beta.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Prothro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cassandra-driver
|
@@ -126,8 +126,11 @@ files:
|
|
126
126
|
- lib/cassie/logger.rb
|
127
127
|
- lib/cassie/queries/README.md
|
128
128
|
- lib/cassie/queries/instrumentation.rb
|
129
|
+
- lib/cassie/queries/instrumentation/execution.rb
|
130
|
+
- lib/cassie/queries/instrumentation/loading.rb
|
129
131
|
- lib/cassie/queries/logging.rb
|
130
132
|
- lib/cassie/queries/logging/cql_execution_event.rb
|
133
|
+
- lib/cassie/queries/logging/cql_execution_loading_event.rb
|
131
134
|
- lib/cassie/queries/logging/subscription.rb
|
132
135
|
- lib/cassie/queries/statement.rb
|
133
136
|
- lib/cassie/queries/statement/assignment.rb
|