newrelic-manticore 0.1.1.rc1-java → 1.0.2.pre-java

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
  SHA256:
3
- metadata.gz: 1b38c4ab104bc852c4ed3577ef140bb789d94b2c90dbc5eff9731f02b53c9b5c
4
- data.tar.gz: fdc50f491ff45a927dd4f7e6c9de73082abcea07499924de32a254d12bbacbd7
3
+ metadata.gz: 1bf33579cc4d71ac85bdf3d6f36bc7cfc97891ebb4f2d55a1ad7c1c0a95d6fde
4
+ data.tar.gz: cbef564cdce00a60bb2fd6cd708335da9521ee6581733fa1bde75aaa1a5545b2
5
5
  SHA512:
6
- metadata.gz: 73aad16695870625c6fe3d73264abe1e84c7d9b23d49bf6707bc20e4ec4d2a6f0fbcd2ba95cea354aeb790c7f23e3a9e8a2f7aaff33a78dd6e205716f362fbf8
7
- data.tar.gz: ec437b319a31643f9851a1b27f79744cc74942deea6bf203fa07a2708c715c86c6fccf65abc4332db2c67412200bf4d41fd4b8f42e56108aed6cce5cb9cf4bd9
6
+ metadata.gz: 14e02510cd18b6a1f031a2617b1d8a5be2ea2c0bc49814f94f4cc033c7c174708bdc7614c6396eebbf8b8ad98bacd029d1651bd5c413330be87f4ee11cc0b3e9
7
+ data.tar.gz: 4c15d9b9d71de09831cf057e98e28c9e4e7a3776a53c5b5a578bd063db9c15b639a8fc6b0a7f92529cbab724c939a8bf9ef85008d4618b4bc075788e8e4e4e7b
@@ -1,9 +1,12 @@
1
1
  require: rt_rubocop_defaults
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: 2.2
4
+ TargetRubyVersion: 2.4
5
5
 
6
6
  Metrics/BlockLength:
7
7
  Exclude:
8
8
  - test/**/*
9
9
 
10
+ Metrics/ClassLength:
11
+ Exclude:
12
+ - test/**/*
@@ -1,6 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - jruby-9.1.17.0 # ruby 2.3
4
3
  - jruby-9.2.0.0 # ruby 2.5
5
4
  jobs:
6
5
  include:
@@ -0,0 +1,69 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Project maintainers who do not follow or enforce the Code of Conduct in good
58
+ faith may face temporary or permanent repercussions as determined by other
59
+ members of the project's leadership.
60
+
61
+ ## Attribution
62
+
63
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
64
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
65
+
66
+ [homepage]: https://www.contributor-covenant.org
67
+
68
+ For answers to common questions about this code of conduct, see
69
+ https://www.contributor-covenant.org/faq
@@ -4,6 +4,28 @@ 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
+ ## Unreleased
8
+ ### Fixed
9
+ - Added manticore as dependency
10
+
11
+ ## [1.0.1] - 2020-04-30
12
+ ### Added
13
+ - Compatibility with agent versions ~> 6.10
14
+
15
+ ## [1.0.0] - 2019-03-12
16
+ ### Changed
17
+ - Update newrelic agent dependency to major version 6.
18
+ - Replace deprecated calls to internal agent API.
19
+
20
+ ## [0.1.2] - 2018-10-11
21
+ ### Fixed
22
+ Detection whether manticore is used inside a database segment was not reliable and is now more robust
23
+
24
+ ## [0.1.1] - 2018-10-09
25
+ ### Fixed
26
+ - Time spent inside Manticore requests inside database calls where not included in the exclusive time stats of the database request.
27
+ - Fixed instrumentation when using manticore with faraday adapter.
28
+
7
29
  ## [0.1.0] - 2018-10-09
8
30
  ### Added
9
- Basic manticore instrumentation
31
+ - Basic manticore instrumentation.
data/README.md CHANGED
@@ -1,33 +1,54 @@
1
- [travis]: https://travis-ci.org/runtastic/newrelic-manticore
2
- [rubygems]: https://rubygems.org/gems/newrelic-manticore
3
- [manticore]: https://gitlab.com/cheald/manticore
4
- [mit]: http://opensource.org/licenses/MIT
5
- [cc]: http://contributor-covenant.org
6
-
7
- # NewrelicManticore
1
+ # Newrelic-Manticore
8
2
 
9
- [![Build Status](https://travis-ci.org/runtastic/newrelic-manticore.svg?branch=master)][travis] [![Gem Version](https://badge.fury.io/rb/newrelic-manticore.svg)][rubygems]
3
+ [![Build Status](https://travis-ci.org/runtastic/newrelic-manticore.svg?branch=master)][travis]
4
+ [![Gem Version](https://badge.fury.io/rb/newrelic-manticore.svg)][rubygems]
10
5
 
11
6
  Adds NewRelic instrumentation for the [Manticore JRuby HTTP client][manticore].
12
7
 
13
8
  ## Installation
14
9
  Add this line to your application's Gemfile:
15
10
 
16
- `$ gem 'newrelic-manticore'`
11
+ ```ruby
12
+ gem 'newrelic-manticore'
13
+ ```
17
14
 
18
15
  And then execute:
19
16
 
20
- `$ bundle`
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install newrelic-manticore
22
+
23
+ ## Usage
21
24
 
22
- ## How it works
23
25
  When `newrelic/manticore` is required (e.g. automatically by Bundler), the gem becomes active.
24
- It hooks itself into `Manticore::Client#request` and traces your HTTP calls as external requests,
26
+ It wraps `Manticore::Response#call` and traces your HTTP calls as external requests,
25
27
  adding also the necessary headers for cross application tracing.
26
28
 
29
+ ### What about parallel requests?
30
+ The NewRelic agent is currently not set up to support multithreaded requests. As [any of the other client integrations](https://docs.newrelic.com/docs/agents/ruby-agent/features/http-client-tracing-ruby#typhoeus),
31
+ _newrelic-manticore_ will trace all parallel requests as [one external service call](https://github.com/runtastic/newrelic-manticore/blob/master/test/new_relic/manticore/instrumentation_test.rb#L50).
32
+
33
+ ### What about async "background" requests?
34
+ Those are traced normally as any other request would be.
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
+
40
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
+
27
42
  ## Contributing
28
43
  Bug reports and pull requests are welcome on GitHub at https://github.com/runtastic/newrelic-manticore.
29
- This project is intended to be a safe, welcoming space for collaboration, and contributors are expected
30
- to adhere to the [Contributor Covenant code of conduct][cc].
44
+ This project is intended to be a safe, welcoming space for collaboration, and
45
+ contributors are expected to adhere to the [code of conduct][cc].
31
46
 
32
47
  ## License
33
48
  The gem is available as open source under [the terms of the MIT License][mit].
49
+
50
+ [travis]: https://travis-ci.org/runtastic/newrelic-manticore
51
+ [rubygems]: https://rubygems.org/gems/newrelic-manticore
52
+ [manticore]: https://gitlab.com/cheald/manticore
53
+ [mit]: http://opensource.org/licenses/MIT
54
+ [cc]: ../CODE_OF_CONDUCT.md
@@ -3,13 +3,30 @@
3
3
  require "ostruct"
4
4
 
5
5
  require "new_relic/agent/method_tracer"
6
- require "new_relic/agent/http_clients/abstract_request"
7
6
 
8
7
  require "new_relic/manticore/wrapped_request"
9
8
  require "new_relic/manticore/wrapped_response"
10
9
 
11
10
  module NewRelic
12
11
  module Manticore
12
+ # We do not want to create a segment if there is no newrelic
13
+ # transaction or if we are inside a database segment.
14
+ #
15
+ # An external call segment inside a database segment would
16
+ # deduct the time needed in manticore from the database call,
17
+ # which we want to be the total time needed for the database
18
+ # operation
19
+ def self.create_segment?
20
+ state = NewRelic::Agent::TransactionState.tl_get
21
+ return false unless state&.current_transaction
22
+
23
+ return true unless state.current_transaction.current_segment
24
+
25
+ !state.current_transaction.current_segment.is_a?(
26
+ ::NewRelic::Agent::Transaction::DatastoreSegment
27
+ )
28
+ end
29
+
13
30
  # rubocop:disable Metrics/BlockLength
14
31
  DependencyDetection.defer do
15
32
  @name = :manticore
@@ -31,38 +48,49 @@ module NewRelic
31
48
  )
32
49
 
33
50
  ::Manticore::Client.class_eval do
51
+ # This is called for parallel requests that are executed in
52
+ # a batch
53
+ #
54
+ # rubocop:disable Metrics/MethodLength
34
55
  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)
56
+ if NewRelic::Manticore.create_segment?
57
+ segment = NewRelic::Agent::External.start_segment(
58
+ library: "Manticore",
59
+ uri: @async_requests.first.request.uri.to_s,
60
+ procedure: "Parallel batch"
61
+ )
62
+ segment.add_request_headers(PARALLEL_REQUEST_DUMMY)
63
+ end
41
64
  execute_without_newrelic_trace!
42
65
  ensure
43
- segment.finish if segment
66
+ segment.finish if defined?(segment) && segment
44
67
  end
68
+ # rubocop:enable Metrics/MethodLength
45
69
 
46
70
  alias_method :execute_without_newrelic_trace!, :execute!
47
71
  alias_method :execute!, :execute_with_newrelic_trace!
48
72
  end
49
73
 
50
74
  ::Manticore::Response.class_eval do
75
+ # This is called for every request, also parallel and async
76
+ # requests.
77
+ #
51
78
  # rubocop:disable Metrics/MethodLength
52
79
  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
80
+ if NewRelic::Manticore.create_segment?
81
+ segment = create_newrelic_segment
82
+ segment.add_request_headers(WrappedRequest.new(@request))
83
+ on_complete do |response|
84
+ begin
85
+ segment.read_response_headers(WrappedResponse.new(response))
86
+ ensure
87
+ segment.finish
88
+ end
61
89
  end
62
90
  end
63
91
  call_without_newrelic_trace
64
92
  rescue StandardError => e
65
- segment.finish if segment
93
+ segment.finish if defined?(segment) && segment
66
94
  raise e
67
95
  end
68
96
  # rubocop:enable Metrics/MethodLength
@@ -71,9 +99,9 @@ module NewRelic
71
99
  alias_method :call, :call_with_newrelic_trace
72
100
 
73
101
  def create_newrelic_segment
74
- NewRelic::Agent::External.start_segment(
75
- library: "Manticore",
76
- uri: @request.uri.to_s,
102
+ NewRelic::Agent::Tracer.start_external_request_segment(
103
+ library: "Manticore",
104
+ uri: @request.uri.to_s,
77
105
  procedure: @request.method
78
106
  ).tap do |segment|
79
107
  segment.record_metrics = false if segment.parent.is_a?(::NewRelic::Agent::Transaction::DatastoreSegment)
@@ -1,3 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Check version to account for a breaking path change
4
+ # introduced in 6.10
5
+ #
6
+ if NewRelic::VERSION::MAJOR == 6 && NewRelic::VERSION::MINOR < 10
7
+ require "new_relic/agent/http_clients/abstract_request"
8
+ else
9
+ require "new_relic/agent/http_clients/abstract"
10
+ end
11
+
1
12
  module NewRelic
2
13
  module Manticore
3
14
  class WrappedRequest < Agent::HTTPClients::AbstractRequest
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NewRelic
2
4
  module Manticore
3
5
  class WrappedResponse
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Necessary for bundler auto require (as gem name does not match namespace)
2
4
  require "new_relic/manticore"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Newrelic
4
4
  module Manticore
5
- VERSION = "0.1.1.rc1".freeze
5
+ VERSION = "1.0.2.pre"
6
6
  end
7
7
  end
@@ -27,9 +27,10 @@ Gem::Specification.new do |gem|
27
27
  gem.executables = gem.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  gem.require_paths = ["lib"]
29
29
 
30
- gem.add_runtime_dependency "newrelic_rpm", "~> 5"
30
+ gem.add_runtime_dependency "newrelic_rpm", "~> 6"
31
+ gem.add_runtime_dependency "manticore", "~> 0.6", ">= 0.6.4"
31
32
 
32
- gem.add_development_dependency "bundler", "~> 1.13"
33
+ gem.add_development_dependency "bundler"
33
34
  gem.add_development_dependency "faraday", "~> 0"
34
35
  gem.add_development_dependency "manticore", "~> 0"
35
36
  gem.add_development_dependency "minitest"
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: 1.0.2.pre
5
5
  platform: java
6
6
  authors:
7
7
  - Dominik Goltermann
@@ -9,36 +9,56 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-10-11 00:00:00.000000000 Z
12
+ date: 2020-08-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '5'
19
+ version: '6'
20
20
  name: newrelic_rpm
21
- prerelease: false
22
21
  type: :runtime
22
+ prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '5'
27
+ version: '6'
28
28
  - !ruby/object:Gem::Dependency
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.13'
34
- name: bundler
33
+ version: '0.6'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.6.4
37
+ name: manticore
38
+ type: :runtime
35
39
  prerelease: false
36
- type: :development
37
40
  version_requirements: !ruby/object:Gem::Requirement
38
41
  requirements:
39
42
  - - "~>"
40
43
  - !ruby/object:Gem::Version
41
- version: '1.13'
44
+ version: '0.6'
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.6.4
48
+ - !ruby/object:Gem::Dependency
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ name: bundler
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
42
62
  - !ruby/object:Gem::Dependency
43
63
  requirement: !ruby/object:Gem::Requirement
44
64
  requirements:
@@ -46,8 +66,8 @@ dependencies:
46
66
  - !ruby/object:Gem::Version
47
67
  version: '0'
48
68
  name: faraday
49
- prerelease: false
50
69
  type: :development
70
+ prerelease: false
51
71
  version_requirements: !ruby/object:Gem::Requirement
52
72
  requirements:
53
73
  - - "~>"
@@ -60,8 +80,8 @@ dependencies:
60
80
  - !ruby/object:Gem::Version
61
81
  version: '0'
62
82
  name: manticore
63
- prerelease: false
64
83
  type: :development
84
+ prerelease: false
65
85
  version_requirements: !ruby/object:Gem::Requirement
66
86
  requirements:
67
87
  - - "~>"
@@ -74,8 +94,8 @@ dependencies:
74
94
  - !ruby/object:Gem::Version
75
95
  version: '0'
76
96
  name: minitest
77
- prerelease: false
78
97
  type: :development
98
+ prerelease: false
79
99
  version_requirements: !ruby/object:Gem::Requirement
80
100
  requirements:
81
101
  - - ">="
@@ -88,8 +108,8 @@ dependencies:
88
108
  - !ruby/object:Gem::Version
89
109
  version: '0'
90
110
  name: pry
91
- prerelease: false
92
111
  type: :development
112
+ prerelease: false
93
113
  version_requirements: !ruby/object:Gem::Requirement
94
114
  requirements:
95
115
  - - ">="
@@ -102,8 +122,8 @@ dependencies:
102
122
  - !ruby/object:Gem::Version
103
123
  version: '10.0'
104
124
  name: rake
105
- prerelease: false
106
125
  type: :development
126
+ prerelease: false
107
127
  version_requirements: !ruby/object:Gem::Requirement
108
128
  requirements:
109
129
  - - "~>"
@@ -116,8 +136,8 @@ dependencies:
116
136
  - !ruby/object:Gem::Version
117
137
  version: '3.0'
118
138
  name: rspec
119
- prerelease: false
120
139
  type: :development
140
+ prerelease: false
121
141
  version_requirements: !ruby/object:Gem::Requirement
122
142
  requirements:
123
143
  - - "~>"
@@ -130,8 +150,8 @@ dependencies:
130
150
  - !ruby/object:Gem::Version
131
151
  version: '1'
132
152
  name: rt_rubocop_defaults
133
- prerelease: false
134
153
  type: :development
154
+ prerelease: false
135
155
  version_requirements: !ruby/object:Gem::Requirement
136
156
  requirements:
137
157
  - - "~>"
@@ -144,8 +164,8 @@ dependencies:
144
164
  - !ruby/object:Gem::Version
145
165
  version: '2'
146
166
  name: rubocop_runner
147
- prerelease: false
148
167
  type: :development
168
+ prerelease: false
149
169
  version_requirements: !ruby/object:Gem::Requirement
150
170
  requirements:
151
171
  - - "~>"
@@ -163,6 +183,7 @@ files:
163
183
  - ".rspec"
164
184
  - ".rubocop.yml"
165
185
  - ".travis.yml"
186
+ - CODE_OF_CONDUCT.md
166
187
  - Changelog.md
167
188
  - Gemfile
168
189
  - LICENSE
@@ -196,8 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
217
  - !ruby/object:Gem::Version
197
218
  version: 1.3.1
198
219
  requirements: []
199
- rubyforge_project:
200
- rubygems_version: 2.6.13
220
+ rubygems_version: 3.0.6
201
221
  signing_key:
202
222
  specification_version: 4
203
223
  summary: Newrelic support for manticore