gruf-newrelic 1.1.0 → 1.2.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: cdc080aacbaafab66ee48b01bdfa6eb315a6da69ca015a8d4db194b998069e16
4
- data.tar.gz: bffc7e5a1eed941f1b0fdac3d096eea7850af77f85db2f24c28287424d812ea8
3
+ metadata.gz: deba735ffe98ebe35b2ab3fa056221a61066e6843e51f43b97790c4ae257348b
4
+ data.tar.gz: 52775f8d3b4d26328c62dcb4254678701a711fe5407a625d2b49261218e24e41
5
5
  SHA512:
6
- metadata.gz: 6b475149e7faaffea8dd07b2a8a0145adc67eefd4be158ab7f2c425cdb6e9c6cddf4b04e9fd8bb760d9e5f6ee8b9a4d2aaf951497e432b68490b31261de931c6
7
- data.tar.gz: bdc900fff461bcc01a0b2d398151973d0e6730dca468197afd4e2b250e067c4897dfaed461a86a6e88bdc0e422fbf9533cabaf7713f7b5789f7f823c7ff0708b
6
+ metadata.gz: 3f3bceaf7121734f7d3712c569212a93fc75ba42c6efd6d4aa10c17b24dc6efeb0dcfa64fcaf4aab94204a5aeb6d894d028bf178064875c86590b23b0277527a
7
+ data.tar.gz: 9a5b38372d1883c2e28e4861a5957da9c48049ff5baceaf681343b2488432ceaa1475857ad449aa7e3d8db8b947c9d369572810e0c1e36bc744c20f2db9ba391
@@ -2,6 +2,11 @@ Changelog for the gruf-newrelic gem.
2
2
 
3
3
  h3. Pending Release
4
4
 
5
+ h3. 1.2.0
6
+
7
+ - Added ClientInterceptor with New Relic Distributed tracing support
8
+ - Refactored ServerInterceptor with New Relic Distributed tracing support
9
+
5
10
  h3. 1.1.0
6
11
 
7
12
  - Bump newrelic gem dependency to ~> 6
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/master.svg?style=svg)](https://circleci.com/gh/bigcommerce/gruf-newrelic/tree/master) [![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)
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
@@ -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
@@ -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
@@ -32,9 +35,17 @@ module Gruf
32
35
  # Yield to the given block with NewRelic tracing.
33
36
  # http://www.rubydoc.info/github/newrelic/rpm/NewRelic%2FAgent%2FInstrumentation%2FControllerInstrumentation:perform_action_with_newrelic_trace
34
37
  perform_action_with_newrelic_trace(opts) do
38
+ accept_distributed_tracing
35
39
  yield
36
40
  end
37
41
  end
42
+
43
+ private
44
+
45
+ def accept_distributed_tracing
46
+ payload = request.active_call.metadata[NEWRELIC_TRACE_HEADER]
47
+ ::NewRelic::Agent::DistributedTracing.accept_distributed_trace_payload(payload)
48
+ end
38
49
  end
39
50
  end
40
51
  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.1.0'.freeze
20
+ VERSION = '1.2.0'
19
21
  end
20
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gruf-newrelic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shaun McCormick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-25 00:00:00.000000000 Z
11
+ date: 2019-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,6 +91,7 @@ files:
91
91
  - CODE_OF_CONDUCT.md
92
92
  - README.md
93
93
  - lib/gruf/newrelic.rb
94
+ - lib/gruf/newrelic/client_interceptor.rb
94
95
  - lib/gruf/newrelic/configuration.rb
95
96
  - lib/gruf/newrelic/server_interceptor.rb
96
97
  - lib/gruf/newrelic/version.rb
@@ -113,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
114
  - !ruby/object:Gem::Version
114
115
  version: '0'
115
116
  requirements: []
116
- rubygems_version: 3.0.2
117
+ rubygems_version: 3.0.6
117
118
  signing_key:
118
119
  specification_version: 4
119
120
  summary: Plugin for New Relic for gruf