-
Notifications
You must be signed in to change notification settings - Fork 19
Add extension_data to QueryDetailsTracker for query registry logging #981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
elasticgraph-graphql/spec/unit/elastic_graph/graphql/query_details_tracker_spec.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # Copyright 2024 - 2026 Block, Inc. | ||
| # | ||
| # Use of this source code is governed by an MIT-style | ||
| # license that can be found in the LICENSE file or at | ||
| # https://opensource.org/licenses/MIT. | ||
| # | ||
| # frozen_string_literal: true | ||
|
|
||
| require "elastic_graph/graphql/query_details_tracker" | ||
|
|
||
| module ElasticGraph | ||
| class GraphQL | ||
| RSpec.describe QueryDetailsTracker do | ||
| describe "#[]=" do | ||
| let(:tracker) { QueryDetailsTracker.empty } | ||
|
|
||
| it "allows extensions to set custom data in extension_data" do | ||
| tracker["custom_key"] = "custom_value" | ||
myronmarston marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| expect(tracker.extension_data).to eq("custom_key" => "custom_value") | ||
| end | ||
|
|
||
| it "allows multiple values to be set" do | ||
| tracker["key1"] = "value1" | ||
| tracker["key2"] = "value2" | ||
|
|
||
| expect(tracker.extension_data).to eq( | ||
| "key1" => "value1", | ||
| "key2" => "value2" | ||
| ) | ||
| end | ||
|
|
||
| it "allows overwriting existing extension data" do | ||
| tracker["key"] = "original_value" | ||
| tracker["key"] = "new_value" | ||
|
|
||
| expect(tracker.extension_data).to eq("key" => "new_value") | ||
| end | ||
|
|
||
| it "allows non-string values (per RBS signature)" do | ||
| tracker["int_key"] = 42 | ||
| tracker["array_key"] = [1, 2, 3] | ||
|
|
||
| expect(tracker.extension_data).to eq( | ||
| "int_key" => 42, | ||
| "array_key" => [1, 2, 3] | ||
| ) | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
elasticgraph-query_registry/lib/elastic_graph/query_registry/registration_status.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Copyright 2024 - 2026 Block, Inc. | ||
| # | ||
| # Use of this source code is governed by an MIT-style | ||
| # license that can be found in the LICENSE file or at | ||
| # https://opensource.org/licenses/MIT. | ||
| # | ||
| # frozen_string_literal: true | ||
|
|
||
| module ElasticGraph | ||
| module QueryRegistry | ||
| # Constants for query registration status values logged in `ElasticGraphQueryExecutorQueryDuration`. | ||
| module RegistrationStatus | ||
| # Query exactly matched a registered query (used from cache). | ||
| MATCHED_REGISTERED_QUERY = "matched_registered_query" | ||
|
|
||
| # Query has same operation name as a registered query but query body differs. | ||
| DIFFERING_REGISTERED_QUERY = "differing_registered_query" | ||
|
|
||
| # Client is registered but has no query with this operation name. | ||
| UNREGISTERED_QUERY = "unregistered_query" | ||
|
|
||
| # Client is not registered in the query registry. | ||
| UNREGISTERED_CLIENT = "unregistered_client" | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
elasticgraph-query_registry/sig/elastic_graph/query_registry/registration_status.rbs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| module ElasticGraph | ||
| module QueryRegistry | ||
| module RegistrationStatus | ||
| MATCHED_REGISTERED_QUERY: ::String | ||
| DIFFERING_REGISTERED_QUERY: ::String | ||
| UNREGISTERED_QUERY: ::String | ||
| UNREGISTERED_CLIENT: ::String | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.