cassie 1.0.0.beta.7 → 1.0.0.beta.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9bbb50f81c0b640ebea73e406a3bbeb7b5136b4d
4
- data.tar.gz: 692eab44def99331fb152f9a71aed257c80ae1a9
3
+ metadata.gz: 49c8a1b3bd425573a87262ce9039546092ae8cdd
4
+ data.tar.gz: 21be67660a39aaad7c1dad0bc7e64a90400668bc
5
5
  SHA512:
6
- metadata.gz: eb4ceb81237d249ed4d7ca3fb81d7e957a82a535e35998f8636da779c60153f381213f77d648ed248859f4bb333743f0b6e3cfd422a286b27b337221d6714c0e
7
- data.tar.gz: 4a278a5c82d8e893a487c58f8b641cb2bb40808f0812b187ede5575f06e4c8c6df53a4681a6d45957233dbf4c5027bb3eeeb7a26c263c5087bed35d43fb80955
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
- def execute
6
- instrument { super }
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
@@ -10,6 +10,7 @@ module Cassie::Queries::Logging
10
10
 
11
11
  def message
12
12
  {
13
+ event: "cassie.cql.execution",
13
14
  duration: duration.round(1),
14
15
  query: statement,
15
16
  consistency: consistency.upcase
@@ -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.execute') do |*args|
9
- # args:
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
@@ -5,6 +5,8 @@ module Cassie::Queries::Statement
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
+ attr_reader :result
9
+
8
10
  include Consistency
9
11
  end
10
12
 
@@ -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
@@ -29,8 +29,6 @@ module Cassie::Queries
29
29
  include Updating
30
30
  include Inserting
31
31
 
32
- attr_reader :result
33
-
34
32
  class << self
35
33
  attr_accessor :table
36
34
  attr_accessor :type
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.7
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-24 00:00:00.000000000 Z
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