gruf-newrelic 1.0.0 → 1.4.0

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: 8ca810fefb72ce91aff0a9b46571dec40cddd5fe2197304ee2da749a9f9654fe
4
- data.tar.gz: f9fdc33ad99aa1e77dd732dc776ce8bf38595e8bccc6261ecba1d00761a9775c
3
+ metadata.gz: 23c8798651475543448f574e4980de14272ade849f9fa0262accf872f9186710
4
+ data.tar.gz: dbc03cee8379ac1b191c2e4026ef513b410eb9b042210ecda68d22f13a7551df
5
5
  SHA512:
6
- metadata.gz: 8844260ead266fc39fbeaae14abc19d17c2680d3c57f21a588877845e0a11ea2495ef44794e5d0a211c1d80b4dea0ca0264d72a36b26178738724bf0d7a5563c
7
- data.tar.gz: 4bce13092c81a1826ba3af166f39ad5920da0067b43c2eff14bf96a1409646d8f3a644ffab4eb536a1e328097ea90af2ef4da54afec931d2b562031479c0122a
6
+ metadata.gz: '0379035e4162472b53ccfc47d64f7e1802ffdfaba0a3433c33f67920a946c1201e4a6bc10288941461b3023fe8dbd48360736b2471a0e9f34597498d4deba616'
7
+ data.tar.gz: cb0853ad2edeb4d70f10e277e7346d1d5b3d44d3b39bd9ec636facd1e4a0a3ffb225da970781b7513de77c4d4699591c4317a3f619c1b1011d8c58d48930ab71
data/CHANGELOG.md CHANGED
@@ -1,7 +1,31 @@
1
1
  Changelog for the gruf-newrelic gem.
2
2
 
3
- h3. Pending Release
3
+ ### Pending Release
4
4
 
5
- h3. 1.0.0
5
+ ### 1.4.0
6
+
7
+ - Ruby 3 support, remove support for Ruby < 2.6
8
+ - Loosen gem dependencies, add bundler 2 support
9
+
10
+ ### 1.3.0
11
+
12
+ - Allow customization of transaction name prefix [#7]
13
+
14
+ ### 1.2.1
15
+
16
+ - Fix issue with NewRelic trace headers when they are arrays
17
+
18
+ ### 1.2.0
19
+
20
+ - Added ClientInterceptor with New Relic Distributed tracing support
21
+ - Refactored ServerInterceptor with New Relic Distributed tracing support
22
+
23
+ ### 1.1.0
24
+
25
+ - Bump newrelic gem dependency to ~> 6
26
+ - Drop Ruby 2.2 support
27
+ - Update bundler support
28
+
29
+ ### 1.0.0
6
30
 
7
31
  - Initial public release
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # gruf-newrelic - New Relic support for gruf
2
2
 
3
- [![Build Status](https://travis-ci.com/bigcommerce/gruf-newrelic.svg?branch=master)](https://travis-ci.com/bigcommerce/gruf-newrelic) [![Gem Version](https://badge.fury.io/rb/gruf-newrelic.svg)](https://badge.fury.io/rb/gruf-newrelic) [![Inline docs](http://inch-ci.org/github/bigcommerce/gruf-newrelic.svg?branch=master)](http://inch-ci.org/github/bigcommerce/gruf-newrelic)
3
+ [![CircleCI](https://circleci.com/gh/bigcommerce/gruf-newrelic/tree/main.svg?style=svg)](https://circleci.com/gh/bigcommerce/gruf-newrelic/tree/main) [![Gem Version](https://badge.fury.io/rb/gruf-newrelic.svg)](https://badge.fury.io/rb/gruf-newrelic) [![Inline docs](http://inch-ci.org/github/bigcommerce/gruf-newrelic.svg?branch=main)](http://inch-ci.org/github/bigcommerce/gruf-newrelic)
4
4
 
5
5
  Adds New Relic support for [gruf](https://github.com/bigcommerce/gruf) 2.0.0+.
6
6
 
@@ -20,6 +20,22 @@ end
20
20
 
21
21
  This will add New Relic tracing support to all gruf controllers.
22
22
 
23
+ ### Distributed Tracing
24
+ When controller receives gRPC request, it will automatically apply NewRelic distributed tracing information to current
25
+ request if it is present in `newrelic` header. Make sure request has `newrelic` header with tracing payload (see below)
26
+ and that your account and application settings have distributed tracing enabled
27
+
28
+ If you are using `::Gruf::Client` to make gRPC request, you need to explicitly add NewRelic Client Interceptor
29
+ in `client_options`:
30
+ ```ruby
31
+ client = ::Gruf::Client.new(
32
+ service: ::Demo::ThingService,
33
+ client_options: {
34
+ interceptors: [::Gruf::Newrelic::ClientInterceptor.new]
35
+ }
36
+ )
37
+ ```
38
+
23
39
  ## License
24
40
 
25
41
  Copyright (c) 2018-present, BigCommerce Pty. Ltd. All rights reserved
data/lib/gruf/newrelic.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (c) 2018-present, BigCommerce Pty. Ltd. All rights reserved
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
@@ -16,6 +18,7 @@
16
18
  require_relative 'newrelic/version'
17
19
  require_relative 'newrelic/configuration'
18
20
  require_relative 'newrelic/server_interceptor'
21
+ require_relative 'newrelic/client_interceptor'
19
22
 
20
23
  ##
21
24
  # Gruf main base module
@@ -24,6 +27,8 @@ module Gruf
24
27
  # Newrelic gruf module
25
28
  #
26
29
  module Newrelic
30
+ NEWRELIC_TRACE_HEADER = 'newrelic'
31
+
27
32
  extend Configuration
28
33
  end
29
34
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2018-present, BigCommerce Pty. Ltd. All rights reserved
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6
+ # documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7
+ # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ # persons to whom the Software is furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11
+ # Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14
+ # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
+ # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
+ require 'new_relic/agent'
18
+
19
+ module Gruf
20
+ module Newrelic
21
+ ##
22
+ # New Relic transaction tracing for Gruf endpoints
23
+ #
24
+ class ClientInterceptor < ::Gruf::Interceptors::ClientInterceptor
25
+ def call(request_context:)
26
+ metadata = request_context.metadata
27
+ payload = ::NewRelic::Agent::DistributedTracing.create_distributed_trace_payload
28
+
29
+ metadata[NEWRELIC_TRACE_HEADER] = payload.http_safe if payload
30
+
31
+ yield
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (c) 2018-present, BigCommerce Pty. Ltd. All rights reserved
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
@@ -20,7 +22,8 @@ module Gruf
20
22
  #
21
23
  module Configuration
22
24
  VALID_CONFIG_KEYS = {
23
- server_category: :controller
25
+ server_category: :controller,
26
+ transaction_name_prefixes: []
24
27
  }.freeze
25
28
 
26
29
  attr_accessor *VALID_CONFIG_KEYS.keys
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (c) 2018-present, BigCommerce Pty. Ltd. All rights reserved
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
@@ -13,6 +15,7 @@
13
15
  # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
14
16
  # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
17
  require 'new_relic/agent'
18
+ require 'new_relic/agent/distributed_tracing'
16
19
 
17
20
  module Gruf
18
21
  module Newrelic
@@ -23,18 +26,28 @@ module Gruf
23
26
  include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
24
27
 
25
28
  def call
29
+ class_name_components = Gruf::Newrelic.transaction_name_prefixes + [request.service]
26
30
  opts = {
27
31
  category: Gruf::Newrelic.server_category,
28
- class_name: request.service,
32
+ class_name: class_name_components.join('/'),
29
33
  name: request.method_key
30
34
  }
31
35
 
32
36
  # Yield to the given block with NewRelic tracing.
33
37
  # http://www.rubydoc.info/github/newrelic/rpm/NewRelic%2FAgent%2FInstrumentation%2FControllerInstrumentation:perform_action_with_newrelic_trace
34
38
  perform_action_with_newrelic_trace(opts) do
39
+ accept_distributed_tracing
35
40
  yield
36
41
  end
37
42
  end
43
+
44
+ private
45
+
46
+ def accept_distributed_tracing
47
+ payload = request.active_call.metadata[NEWRELIC_TRACE_HEADER]
48
+ payload = payload.first if payload.is_a?(Enumerable)
49
+ ::NewRelic::Agent::DistributedTracing.accept_distributed_trace_payload(payload)
50
+ end
38
51
  end
39
52
  end
40
53
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (c) 2018-present, BigCommerce Pty. Ltd. All rights reserved
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
@@ -15,6 +17,6 @@
15
17
  #
16
18
  module Gruf
17
19
  module Newrelic
18
- VERSION = '1.0.0'.freeze
20
+ VERSION = '1.4.0'
19
21
  end
20
22
  end
metadata CHANGED
@@ -1,85 +1,141 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gruf-newrelic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shaun McCormick
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-05 00:00:00.000000000 Z
11
+ date: 2021-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: bundler-audit
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.11'
19
+ version: '0.6'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.11'
26
+ version: '0.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '3.7'
47
+ version: '3.8'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '3.7'
54
+ version: '3.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec_junit_formatter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0.82'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0.82'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0.18'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0.18'
55
97
  - !ruby/object:Gem::Dependency
56
98
  name: pry
57
99
  requirement: !ruby/object:Gem::Requirement
58
100
  requirements:
59
101
  - - ">="
60
102
  - !ruby/object:Gem::Version
61
- version: '0'
103
+ version: '0.12'
62
104
  type: :development
63
105
  prerelease: false
64
106
  version_requirements: !ruby/object:Gem::Requirement
65
107
  requirements:
66
108
  - - ">="
67
109
  - !ruby/object:Gem::Version
68
- version: '0'
110
+ version: '0.12'
111
+ - !ruby/object:Gem::Dependency
112
+ name: gruf
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '2.6'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '2.6'
69
125
  - !ruby/object:Gem::Dependency
70
126
  name: newrelic_rpm
71
127
  requirement: !ruby/object:Gem::Requirement
72
128
  requirements:
73
129
  - - "~>"
74
130
  - !ruby/object:Gem::Version
75
- version: '5'
131
+ version: '6'
76
132
  type: :runtime
77
133
  prerelease: false
78
134
  version_requirements: !ruby/object:Gem::Requirement
79
135
  requirements:
80
136
  - - "~>"
81
137
  - !ruby/object:Gem::Version
82
- version: '5'
138
+ version: '6'
83
139
  description: Plugin for New Relic for gruf
84
140
  email:
85
141
  - splittingred@gmail.com
@@ -91,6 +147,7 @@ files:
91
147
  - CODE_OF_CONDUCT.md
92
148
  - README.md
93
149
  - lib/gruf/newrelic.rb
150
+ - lib/gruf/newrelic/client_interceptor.rb
94
151
  - lib/gruf/newrelic/configuration.rb
95
152
  - lib/gruf/newrelic/server_interceptor.rb
96
153
  - lib/gruf/newrelic/version.rb
@@ -98,7 +155,7 @@ homepage: https://github.com/bigcommerce/gruf-new-relic
98
155
  licenses:
99
156
  - MIT
100
157
  metadata: {}
101
- post_install_message:
158
+ post_install_message:
102
159
  rdoc_options: []
103
160
  require_paths:
104
161
  - lib
@@ -106,16 +163,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
163
  requirements:
107
164
  - - ">="
108
165
  - !ruby/object:Gem::Version
109
- version: '0'
166
+ version: '2.6'
110
167
  required_rubygems_version: !ruby/object:Gem::Requirement
111
168
  requirements:
112
169
  - - ">="
113
170
  - !ruby/object:Gem::Version
114
171
  version: '0'
115
172
  requirements: []
116
- rubyforge_project:
117
- rubygems_version: 2.7.7
118
- signing_key:
173
+ rubygems_version: 3.2.16
174
+ signing_key:
119
175
  specification_version: 4
120
176
  summary: Plugin for New Relic for gruf
121
177
  test_files: []