Skip to content

reformat dynamic metadata emitted by Mongo proxy#5117

Merged
mattklein123 merged 3 commits intoenvoyproxy:masterfrom
rshriram:mongo_metadata_fix
Nov 27, 2018
Merged

reformat dynamic metadata emitted by Mongo proxy#5117
mattklein123 merged 3 commits intoenvoyproxy:masterfrom
rshriram:mongo_metadata_fix

Conversation

@rshriram
Copy link
Copy Markdown
Member

Description: Emit metadata as map<resource, list(operations> so that it can be used in metadata matchers easily. The existing format (messages:list(structs)) is too hard to represent in metadata matchers.
Risk Level: LOW
Testing: Unit tests

Signed-off-by: Shriram Rajagopalan shriramr@vmware.com

cc @venilnoronha

Signed-off-by: Shriram Rajagopalan <shriramr@vmware.com>

operation, string, The operation to be executed.
resource, string, The resource name in *db.collection* format on which the operation is to be executed.
<db.collection>, string, The resource name in *db.collection* format.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<db.collection>, string, The resource name in *db.collection* format.
key, string, The resource name in *db.collection* format.

operation, string, The operation to be executed.
resource, string, The resource name in *db.collection* format on which the operation is to be executed.
<db.collection>, string, The resource name in *db.collection* format.
[], list, A list of strings, representing the operations executed on the resource. Operation is either insert,update,query,delete.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[], list, A list of strings, representing the operations executed on the resource. Operation is either insert,update,query,delete.
value, array, A list of strings representing the operations executed on the resource.

The docs job doesn't like too many commas in a table. A backslash escape may work.

EXPECT_TRUE(nullptr != metadata.fields().at("db.test1"));
EXPECT_EQ("query", metadata.fields().at("db.test1").list_value().values(0).string_value());
EXPECT_TRUE(nullptr != metadata.fields().at("db.test2"));
EXPECT_EQ("insert", metadata.fields().at("db.test1").list_value().values(0).string_value());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

db.test1 -> db.test2

Shriram Rajagopalan added 2 commits November 26, 2018 17:45
Signed-off-by: Shriram Rajagopalan <shriramr@vmware.com>
Signed-off-by: Shriram Rajagopalan <shriramr@vmware.com>
@htuch htuch requested a review from dio November 26, 2018 18:02
Copy link
Copy Markdown
Member

@venilnoronha venilnoronha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Member

@dio dio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. But I think adding a version history entry will be helpful.


message[DynamicMetadataKeysSingleton::get().OperationField].set_string_value(operation);
message[DynamicMetadataKeysSingleton::get().ResourceField].set_string_value(resource);
// TODO(rshriram): reverse the resource string (table.db)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super nit, add period at the end of the sentence (and also the other TODOs/comments).

@rshriram
Copy link
Copy Markdown
Member Author

@dio the PR that implemented this was merged yesterday :). So users have not seen this stuff yet. So version history doesn't exist..

Copy link
Copy Markdown
Member

@dio dio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that.

Thank you! LGTM!

operation, string, The operation to be executed.
resource, string, The resource name in *db.collection* format on which the operation is to be executed.
key, string, The resource name in *db.collection* format.
value, array, A list of strings representing the operations executed on the resource (insert/update/query/delete).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per our offline convo, FYI, in order for this to be actually useful you are going to have to log/store query commands.

@mattklein123 mattklein123 merged commit 3c0984b into envoyproxy:master Nov 27, 2018
fredlas pushed a commit to fredlas/envoy that referenced this pull request Mar 5, 2019
Signed-off-by: Shriram Rajagopalan <shriramr@vmware.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants