cassie 1.0.0.beta.29 → 1.0.0.beta.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cassie/connection_handler/cluster/instrumentation.rb +15 -0
- data/lib/cassie/connection_handler/cluster.rb +11 -11
- data/lib/cassie/connection_handler/logging/cluster_connect_event.rb +31 -0
- data/lib/cassie/connection_handler/logging/cluster_connect_subscriber.rb +19 -0
- data/lib/cassie/connection_handler/logging/session_connect_event.rb +26 -0
- data/lib/cassie/connection_handler/logging/session_connect_subscriber.rb +19 -0
- data/lib/cassie/connection_handler/logging.rb +7 -0
- data/lib/cassie/connection_handler/sessions/instrumentation.rb +12 -0
- data/lib/cassie/connection_handler/sessions.rb +10 -13
- data/lib/cassie/connection_handler.rb +1 -0
- data/lib/cassie/{statements/instrumenting.rb → instrumentation.rb} +1 -2
- data/lib/cassie/statements/execution/instrumentation.rb +1 -5
- data/lib/cassie/statements/execution/partition_linking/cursoring_policy.rb +6 -6
- data/lib/cassie/statements/execution/results/instrumentation.rb +1 -5
- data/lib/cassie/statements.rb +0 -1
- data/lib/cassie/version.rb +1 -1
- data/lib/cassie.rb +1 -0
- metadata +10 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: faffda9455104b05f68acd9313cbc3ba48ba0f47
|
4
|
+
data.tar.gz: 24bc30a2b15426d1ff225f23284b0683fc8de7b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e7efbf49fbf44bb0f76694fc8d8fb600463fc3886872ba68d9806626cc96ff430c668fad6fcbe430dd14344d9d0055eb6dc82677c409d36e6435ac71f71fca0
|
7
|
+
data.tar.gz: 1c023dc9ef689426606452abdd438649635ad3078437f77b401b16d52a422affcd0072e8977b3f6efd378d9f29e54526b8bdc96199d2504aad51288a9ed09fe6
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Cassie::ConnectionHandler::Cluster
|
2
|
+
module Instrumentation
|
3
|
+
|
4
|
+
protected
|
5
|
+
|
6
|
+
def initialize_cluster
|
7
|
+
Cassie.instrumenter.instrument("cassie.cluster.connect") do |payload|
|
8
|
+
super.tap do |cluster|
|
9
|
+
payload[:hosts] = cluster.hosts
|
10
|
+
payload[:name] = cluster.name
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'benchmark'
|
2
|
-
|
3
1
|
module Cassie::ConnectionHandler
|
4
2
|
# ## Cassie::ConnectionHandler::Cluster
|
5
3
|
#
|
@@ -8,22 +6,24 @@ module Cassie::ConnectionHandler
|
|
8
6
|
# Include in any class or module that responds to `configuration` with
|
9
7
|
# a cassandra cluster options hash.
|
10
8
|
module Cluster
|
9
|
+
require_relative 'cluster/instrumentation'
|
10
|
+
extend ActiveSupport::Concern
|
11
|
+
|
12
|
+
included do
|
13
|
+
include Instrumentation
|
14
|
+
end
|
11
15
|
|
12
16
|
def cluster
|
13
17
|
# Cassandra::cluster parses suppored
|
14
18
|
# options from the passed hash, no need
|
15
19
|
# to validate/transform ourselves yet
|
16
|
-
@cluster ||=
|
17
|
-
|
18
|
-
config = configuration.try(:symbolize_keys)
|
20
|
+
@cluster ||= initialize_cluster
|
21
|
+
end
|
19
22
|
|
20
|
-
|
21
|
-
_cluster = Cassandra.cluster(config)
|
22
|
-
end
|
23
|
+
protected
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
end
|
25
|
+
def initialize_cluster
|
26
|
+
Cassandra.cluster(configuration.try(:symbolize_keys))
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Cassie::ConnectionHandler::Logging
|
2
|
+
class ClusterConnectEvent < ActiveSupport::Notifications::Event
|
3
|
+
|
4
|
+
def hosts
|
5
|
+
payload[:hosts] || []
|
6
|
+
end
|
7
|
+
|
8
|
+
def ips
|
9
|
+
hosts.map{ |h| h.ip.to_s }
|
10
|
+
end
|
11
|
+
|
12
|
+
def message
|
13
|
+
{
|
14
|
+
event: "cassie.cluster.connect",
|
15
|
+
duration: duration.round(1),
|
16
|
+
hosts: ips,
|
17
|
+
name: payload[:name]
|
18
|
+
}.extend(Inspector)
|
19
|
+
end
|
20
|
+
|
21
|
+
module Inspector
|
22
|
+
def inspect
|
23
|
+
"(#{fetch(:duration).round(1)}ms) Connected to Cassandra cluster. #{fetch(:name)}: #{fetch(:hosts)}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_s
|
27
|
+
inspect
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'cluster_connect_event'
|
2
|
+
|
3
|
+
module Cassie::ConnectionHandler::Logging
|
4
|
+
class ClusterConnectSubscriber
|
5
|
+
|
6
|
+
def call(*args)
|
7
|
+
# don't log if instrumentation failed
|
8
|
+
unless args.last[:exception]
|
9
|
+
logger.info(ClusterConnectEvent.new(*args).message)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def logger
|
14
|
+
Cassie::Statements.logger
|
15
|
+
end
|
16
|
+
|
17
|
+
ActiveSupport::Notifications.subscribe('cassie.cluster.connect', new)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Cassie::ConnectionHandler::Logging
|
2
|
+
class SessionConnectEvent < ActiveSupport::Notifications::Event
|
3
|
+
|
4
|
+
def keyspace
|
5
|
+
payload[:keyspace] || "[none]"
|
6
|
+
end
|
7
|
+
|
8
|
+
def message
|
9
|
+
{
|
10
|
+
event: "cassie.session.connect",
|
11
|
+
duration: duration.round(1),
|
12
|
+
keyspace: keyspace
|
13
|
+
}.extend(Inspector)
|
14
|
+
end
|
15
|
+
|
16
|
+
module Inspector
|
17
|
+
def inspect
|
18
|
+
"(#{fetch(:duration).round(1)}ms) Session opened to Cassandra cluster. Keyspace: #{fetch(:keyspace)}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
inspect
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'session_connect_event'
|
2
|
+
|
3
|
+
module Cassie::ConnectionHandler::Logging
|
4
|
+
class SessionConnectSubscriber
|
5
|
+
|
6
|
+
def call(*args)
|
7
|
+
# don't log if instrumentation failed
|
8
|
+
unless args.last[:exception]
|
9
|
+
logger.info(SessionConnectEvent.new(*args).message)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def logger
|
14
|
+
Cassie::Statements.logger
|
15
|
+
end
|
16
|
+
|
17
|
+
ActiveSupport::Notifications.subscribe('cassie.session.connect', new)
|
18
|
+
end
|
19
|
+
end
|
@@ -1,27 +1,24 @@
|
|
1
|
-
require 'benchmark'
|
2
|
-
|
3
1
|
module Cassie::ConnectionHandler
|
4
2
|
module Sessions
|
3
|
+
require_relative 'sessions/instrumentation'
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
include Instrumentation
|
8
|
+
end
|
5
9
|
|
6
10
|
def sessions
|
7
11
|
@sessions ||= {}
|
8
12
|
end
|
9
13
|
|
10
|
-
def session(
|
11
|
-
sessions[
|
14
|
+
def session(keyspace=self.keyspace)
|
15
|
+
sessions[keyspace] || initialize_session(keyspace)
|
12
16
|
end
|
13
17
|
|
14
18
|
protected
|
15
19
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
sec = Benchmark.realtime do
|
20
|
-
_session = cluster.connect(_keyspace)
|
21
|
-
end
|
22
|
-
|
23
|
-
logger.info "(#{(sec*1000).round(2)}ms) Session opened to Cassandra[#{_keyspace}]"
|
24
|
-
@sessions[_keyspace] = _session
|
20
|
+
def initialize_session(keyspace)
|
21
|
+
@sessions[keyspace] = cluster.connect(keyspace)
|
25
22
|
end
|
26
23
|
end
|
27
24
|
end
|
@@ -2,17 +2,13 @@ module Cassie::Statements::Execution
|
|
2
2
|
module Instrumentation
|
3
3
|
|
4
4
|
def execute
|
5
|
-
instrumenter.instrument("cassie.cql.execution") do |payload|
|
5
|
+
Cassie.instrumenter.instrument("cassie.cql.execution") do |payload|
|
6
6
|
execution_val = super #execution populates #result
|
7
7
|
|
8
8
|
payload[:execution_info] = result.execution_info if result.respond_to?(:execution_info)
|
9
9
|
execution_val
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
13
|
-
def instrumenter
|
14
|
-
Cassie::Statements.instrumenter
|
15
|
-
end
|
16
12
|
end
|
17
13
|
end
|
18
14
|
|
@@ -2,12 +2,12 @@ require_relative 'simple_policy'
|
|
2
2
|
|
3
3
|
module Cassie::Statements::Execution::PartitionLinking
|
4
4
|
class CursoringPolicy < SimplePolicy
|
5
|
-
|
5
|
+
|
6
6
|
def combine_rows(rows_a, rows_b)
|
7
7
|
return super unless peeking_execution.since_cursor
|
8
8
|
rows_b
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def adjust_limit
|
12
12
|
return super unless peeking_execution.since_cursor
|
13
13
|
# leave the limit to return all results
|
@@ -17,18 +17,18 @@ module Cassie::Statements::Execution::PartitionLinking
|
|
17
17
|
def seek_partition?
|
18
18
|
return super unless peeking_execution.since_cursor
|
19
19
|
raise "linking partitions only supported for descending orderings. Open an issue if you need this!" if ascending?
|
20
|
-
|
20
|
+
|
21
21
|
# linking while cursoring with since
|
22
22
|
# should return latest results
|
23
23
|
current_key != last_key
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def previous_key(current_key)
|
27
27
|
return super unless peeking_execution.since_cursor
|
28
|
-
|
28
|
+
|
29
29
|
# linking while cursoring with since
|
30
30
|
# should return results from latest partition
|
31
|
-
last_key
|
31
|
+
last_key
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -4,15 +4,11 @@ module Cassie::Statements::Results
|
|
4
4
|
protected
|
5
5
|
|
6
6
|
def records
|
7
|
-
instrumenter.instrument("cassie.deserialize") do |payload|
|
7
|
+
Cassie.instrumenter.instrument("cassie.deserialize") do |payload|
|
8
8
|
records = super
|
9
9
|
payload[:count] = records.count if records.respond_to?(:count)
|
10
10
|
records
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
14
|
-
def instrumenter
|
15
|
-
Cassie::Statements.instrumenter
|
16
|
-
end
|
17
13
|
end
|
18
14
|
end
|
data/lib/cassie/statements.rb
CHANGED
data/lib/cassie/version.rb
CHANGED
data/lib/cassie.rb
CHANGED
@@ -14,6 +14,7 @@ require 'cassandra'
|
|
14
14
|
module Cassie
|
15
15
|
require_relative 'cassie/support'
|
16
16
|
require_relative 'cassie/logger'
|
17
|
+
require_relative 'cassie/instrumentation'
|
17
18
|
require_relative 'cassie/configuration'
|
18
19
|
require_relative 'cassie/connection_handler'
|
19
20
|
require_relative 'cassie/connection'
|
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.30
|
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-
|
11
|
+
date: 2016-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cassandra-driver
|
@@ -100,8 +100,16 @@ files:
|
|
100
100
|
- lib/cassie/connection_handler.rb
|
101
101
|
- lib/cassie/connection_handler/README.md
|
102
102
|
- lib/cassie/connection_handler/cluster.rb
|
103
|
+
- lib/cassie/connection_handler/cluster/instrumentation.rb
|
104
|
+
- lib/cassie/connection_handler/logging.rb
|
105
|
+
- lib/cassie/connection_handler/logging/cluster_connect_event.rb
|
106
|
+
- lib/cassie/connection_handler/logging/cluster_connect_subscriber.rb
|
107
|
+
- lib/cassie/connection_handler/logging/session_connect_event.rb
|
108
|
+
- lib/cassie/connection_handler/logging/session_connect_subscriber.rb
|
103
109
|
- lib/cassie/connection_handler/sessions.rb
|
110
|
+
- lib/cassie/connection_handler/sessions/instrumentation.rb
|
104
111
|
- lib/cassie/definition.rb
|
112
|
+
- lib/cassie/instrumentation.rb
|
105
113
|
- lib/cassie/logger.rb
|
106
114
|
- lib/cassie/migration.rb
|
107
115
|
- lib/cassie/migration/README.md
|
@@ -144,7 +152,6 @@ files:
|
|
144
152
|
- lib/cassie/statements/execution/results/query_result.rb
|
145
153
|
- lib/cassie/statements/execution/results/querying.rb
|
146
154
|
- lib/cassie/statements/execution/results/result.rb
|
147
|
-
- lib/cassie/statements/instrumenting.rb
|
148
155
|
- lib/cassie/statements/logging.rb
|
149
156
|
- lib/cassie/statements/logging/deserialize_event.rb
|
150
157
|
- lib/cassie/statements/logging/deserialize_subscriber.rb
|