apollo-federation 3.6.4 → 3.6.6

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: 4cd2e7169071acfad2efc91a881ff435f2769d2512a77bc898687742238ccf0f
4
- data.tar.gz: 0a18f66aecfa94e7b653503812d464f4900d5a0ba89a9f06e598cebc1a5e8990
3
+ metadata.gz: 8f68278723526fb35e83d13b471c1fb75461ddf8e292910acf9d864c1a4b8a6e
4
+ data.tar.gz: e381e8472bfde3eedd714a66d1f10c546b871c7670c4519c692a0b59e5322e23
5
5
  SHA512:
6
- metadata.gz: 0c3b8e04e0091382af8da1661b0f9d8dc2d9174321048991fee0eff357859c40588e83b99426407d852a9eb640e4b781506e49ba8abaa6acb55c2c5fe8e43798
7
- data.tar.gz: f9ddc5ef1a13af0d247c8a90a62d48f292517a33c6cd8c6b1057aea8942f531005424e5fb89c22b7fe6f4769eae4dbf702bc8c4da69767bbd25bc9941e9ba143
6
+ metadata.gz: 148083333795ac56d528a90a6e508095af5261b5a63621f26b6446e7d8edfc8ac2f81ce779ab913e07977681a2125e145efd86fb4cedbb030dd779a692921bab
7
+ data.tar.gz: f25fd810613dd4042b39e314cf58fc1919f1065c2aacdde50a33057ba93a53f5f7ed950be800c94c2fb9e07a24ffa78399cd7951e777f6345aeb2b539a12a7cd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [3.6.6](https://github.com/Gusto/apollo-federation-ruby/compare/v3.6.5...v3.6.6) (2023-04-26)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * ApolloFederation::Tracing.should_add_traces() looks for correct headers ([#240](https://github.com/Gusto/apollo-federation-ruby/issues/240)) ([d609977](https://github.com/Gusto/apollo-federation-ruby/commit/d609977869721c168b33e50e3823cd97a7f81ae5))
7
+
8
+ ## [3.6.5](https://github.com/Gusto/apollo-federation-ruby/compare/v3.6.4...v3.6.5) (2023-04-25)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **tracer:** add support for multiplex ([#243](https://github.com/Gusto/apollo-federation-ruby/issues/243)) ([c4f2eae](https://github.com/Gusto/apollo-federation-ruby/commit/c4f2eaed0b283c188f2fb932d5308dd3240bb2ec))
14
+
1
15
  ## [3.6.4](https://github.com/Gusto/apollo-federation-ruby/compare/v3.6.3...v3.6.4) (2023-04-19)
2
16
 
3
17
 
data/README.md CHANGED
@@ -333,7 +333,9 @@ To support [federated tracing](https://www.apollographql.com/docs/apollo-server/
333
333
  def execute
334
334
  # ...
335
335
  context = {
336
- tracing_enabled: ApolloFederation::Tracing.should_add_traces(headers)
336
+ # Pass in the headers from your web framework. For Rails this will be request.headers
337
+ # but for other frameworks you can pass the Rack env.
338
+ tracing_enabled: ApolloFederation::Tracing.should_add_traces(request.headers)
337
339
  }
338
340
  # ...
339
341
  end
@@ -83,7 +83,19 @@ module ApolloFederation
83
83
  result = block.call
84
84
 
85
85
  query = data.fetch(:query)
86
- return result unless query.context && query.context[:tracing_enabled]
86
+ multiplex = data.fetch(:multiplex)
87
+
88
+ if query
89
+ record_trace_end_time(query)
90
+ elsif multiplex
91
+ multiplex.queries.each { |q| record_trace_end_time(q) }
92
+ end
93
+
94
+ result
95
+ end
96
+
97
+ def self.record_trace_end_time(query)
98
+ return unless query.context && query.context[:tracing_enabled]
87
99
 
88
100
  trace = query.context.namespace(ApolloFederation::Tracing::KEY)
89
101
 
@@ -91,8 +103,6 @@ module ApolloFederation
91
103
  end_time: Time.now.utc,
92
104
  end_time_nanos: Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond),
93
105
  )
94
-
95
- result
96
106
  end
97
107
 
98
108
  # Step 2:
@@ -2,6 +2,7 @@
2
2
 
3
3
  module ApolloFederation
4
4
  module Tracing
5
+ HEADER_NAME = 'HTTP_APOLLO_FEDERATION_INCLUDE_TRACE'
5
6
  KEY = :ftv1
6
7
  DEBUG_KEY = "#{KEY}_debug".to_sym
7
8
 
@@ -12,7 +13,7 @@ module ApolloFederation
12
13
  end
13
14
 
14
15
  def should_add_traces(headers)
15
- headers && headers['apollo-federation-include-trace'] == KEY.to_s
16
+ headers && headers[HEADER_NAME] == KEY.to_s
16
17
  end
17
18
 
18
19
  # @deprecated There is no need to call this method. Traces are added to the result automatically
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ApolloFederation
4
- VERSION = '3.6.4'
4
+ VERSION = '3.6.6'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apollo-federation
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.4
4
+ version: 3.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noa Elad
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-04-19 00:00:00.000000000 Z
12
+ date: 2023-04-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: graphql