newrelic-manticore 0.1.1.rc1-java → 0.1.1.rc2-java

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b38c4ab104bc852c4ed3577ef140bb789d94b2c90dbc5eff9731f02b53c9b5c
4
- data.tar.gz: fdc50f491ff45a927dd4f7e6c9de73082abcea07499924de32a254d12bbacbd7
3
+ metadata.gz: a90206bab165ef353e02a1584fce0aff9c3194737eb25e4add978320da5cbe65
4
+ data.tar.gz: 2d8fde246e4b9269e310910e4a2a25ba68b8a3f66b2039bb5ba000a4efd0743c
5
5
  SHA512:
6
- metadata.gz: 73aad16695870625c6fe3d73264abe1e84c7d9b23d49bf6707bc20e4ec4d2a6f0fbcd2ba95cea354aeb790c7f23e3a9e8a2f7aaff33a78dd6e205716f362fbf8
7
- data.tar.gz: ec437b319a31643f9851a1b27f79744cc74942deea6bf203fa07a2708c715c86c6fccf65abc4332db2c67412200bf4d41fd4b8f42e56108aed6cce5cb9cf4bd9
6
+ metadata.gz: a61432c09b74eb8828ce728d3e21c83f2b79b965a9c468f9ad29836235f65e517900e217ad46fdc1f62c57821b2805f5a8a6c17ec60fac690e2f7c985bfac1a8
7
+ data.tar.gz: 8df4a94cccf09d2129c6646f9c856a98dba70288a7cbeada550be95f5681e52793577ad627c31747b6cda7a2e78535ca199a1f6426f8acbbb87c42783ff40af5
data/.rubocop.yml CHANGED
@@ -7,3 +7,6 @@ Metrics/BlockLength:
7
7
  Exclude:
8
8
  - test/**/*
9
9
 
10
+ Metrics/ClassLength:
11
+ Exclude:
12
+ - test/**/*
data/Changelog.md CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.1.1] - 2018-10-09
8
+ ### Fixed
9
+ Time spent inside Manticore requests inside database calls where not included in the exclusive time stats of the database request
10
+
7
11
  ## [0.1.0] - 2018-10-09
8
12
  ### Added
9
13
  Basic manticore instrumentation
@@ -10,6 +10,25 @@ require "new_relic/manticore/wrapped_response"
10
10
 
11
11
  module NewRelic
12
12
  module Manticore
13
+ # We do not want to create a segment if there is no newrelic
14
+ # transaction or if we are inside a database segment.
15
+ #
16
+ # An external call segment inside a database segment would
17
+ # deduct the time needed in manticore from the database call,
18
+ # which we want to be the total time needed for the database
19
+ # operation
20
+ def self.create_segment?
21
+ state = NewRelic::Agent::TransactionState.tl_get
22
+ return false unless state && state.current_transaction
23
+
24
+ existing_segments = state.current_transaction.segments
25
+
26
+ existing_segments.empty? ||
27
+ !existing_segments.last.is_a?(
28
+ ::NewRelic::Agent::Transaction::DatastoreSegment
29
+ )
30
+ end
31
+
13
32
  # rubocop:disable Metrics/BlockLength
14
33
  DependencyDetection.defer do
15
34
  @name = :manticore
@@ -31,38 +50,50 @@ module NewRelic
31
50
  )
32
51
 
33
52
  ::Manticore::Client.class_eval do
53
+ # This is called for parallel requests that are executed in
54
+ # a batch
55
+ #
56
+ # rubocop:disable Metrics/MethodLength
34
57
  def execute_with_newrelic_trace!
35
- segment = NewRelic::Agent::External.start_segment(
36
- library: "Manticore",
37
- uri: @async_requests.first.request.uri.to_s,
38
- procedure: "Parallel batch"
39
- )
40
- segment.add_request_headers(PARALLEL_REQUEST_DUMMY)
58
+ if NewRelic::Manticore.create_segment?
59
+ segment = NewRelic::Agent::External.start_segment(
60
+ library: "Manticore",
61
+ uri: @async_requests.first.request.uri.to_s,
62
+ procedure: "Parallel batch"
63
+ )
64
+ segment.add_request_headers(PARALLEL_REQUEST_DUMMY)
65
+ end
41
66
  execute_without_newrelic_trace!
42
67
  ensure
43
- segment.finish if segment
68
+ segment.finish if defined?(segment) && segment
44
69
  end
70
+ # rubocop:enable Metrics/MethodLength
45
71
 
46
72
  alias_method :execute_without_newrelic_trace!, :execute!
47
73
  alias_method :execute!, :execute_with_newrelic_trace!
48
74
  end
49
75
 
50
76
  ::Manticore::Response.class_eval do
77
+ # This is called for every request, also parallel and async
78
+ # requests.
79
+ #
51
80
  # rubocop:disable Metrics/MethodLength
52
81
  def call_with_newrelic_trace
53
- segment = create_newrelic_segment
54
-
55
- segment.add_request_headers(WrappedRequest.new(@request))
56
- on_complete do |response|
57
- begin
58
- segment.read_response_headers(WrappedResponse.new(response))
59
- ensure
60
- segment.finish
82
+ if NewRelic::Manticore.create_segment?
83
+ segment = create_newrelic_segment
84
+
85
+ segment.add_request_headers(WrappedRequest.new(@request))
86
+ on_complete do |response|
87
+ begin
88
+ segment.read_response_headers(WrappedResponse.new(response))
89
+ ensure
90
+ segment.finish
91
+ end
61
92
  end
62
93
  end
63
94
  call_without_newrelic_trace
64
95
  rescue StandardError => e
65
- segment.finish if segment
96
+ segment.finish if defined?(segment) && segment
66
97
  raise e
67
98
  end
68
99
  # rubocop:enable Metrics/MethodLength
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Newrelic
4
4
  module Manticore
5
- VERSION = "0.1.1.rc1".freeze
5
+ VERSION = "0.1.1.rc2".freeze
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic-manticore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.rc1
4
+ version: 0.1.1.rc2
5
5
  platform: java
6
6
  authors:
7
7
  - Dominik Goltermann
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  version: 1.3.1
198
198
  requirements: []
199
199
  rubyforge_project:
200
- rubygems_version: 2.6.13
200
+ rubygems_version: 2.7.6
201
201
  signing_key:
202
202
  specification_version: 4
203
203
  summary: Newrelic support for manticore