Skip to content
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

Actualize Prometheus metrics collecting #632

Merged
merged 7 commits into from
Feb 9, 2023

Conversation

Zhaars
Copy link
Contributor

@Zhaars Zhaars commented Feb 7, 2023

Actualizing Prometheus metrics collection.

Added new metrics:

  • acra_decryptions_total labels {"status": [ "success", "fail"], "type": [ "acrastruct", "acrablock", "acrablock_searchable", "acrastruct_searchable"],}
  • acra_encryptions_total labels {"status": [ "success", "fail"], "type": [ "acrastruct", "acrablock", "acrablock_searchable", "acrastruct_searchable"],}
  • acra_tokenizations_total labels {"status": [ "success", "fail"], "token_type": "{token_type}"}
  • acra_detokenizations_total abels {"status": [ "success", "fail"], "token_type": "{token_type}"}

Previously used metrics are left as they are to save backward compatibility and marked as deprecated.

Checklist

@Zhaars Zhaars requested a review from Lagovas February 7, 2023 18:37
cmd/acra-translator/common/service.go Show resolved Hide resolved
cmd/acra-translator/grpc_api/service.go Show resolved Hide resolved
@@ -50,6 +52,7 @@ func (handler AcraStructHandler) Decrypt(data []byte, context *base.DataProcesso
privateKeys, err := context.Keystore.GetServerDecryptionPrivateKeys(accessContext.GetClientID())
defer utils.ZeroizePrivateKeys(privateKeys)
if err != nil {
base.AcrastructDecryptionCounter.WithLabelValues(base.LabelStatusFail).Inc()
Copy link
Collaborator

Choose a reason for hiding this comment

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

hm, as I understand, it will increment twice for the acra-translator for its decrypt methods? If AT uses cryptohandler that uses this handler under the hood, then it will increment twice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it will, nut these are two different metrics. One is a newly added one, and the second is to support backward compatibility.

tests/test.py Outdated
@@ -2176,6 +2176,7 @@ def testAcraServer(self):
'acraserver_request_processing_seconds_bucket': {'min_value': 0},

'acra_acrastruct_decryptions_total': {'min_value': 1},
'acra_decryptions_total': {'min_value': 1},
Copy link
Collaborator

Choose a reason for hiding this comment

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

will be great to add tests where all these metrics are used and we can validate them. Make a request to the table that is configured for all types of tokenization, for all types of encryption and decryption and validate, that all appropriate metrics were incremented. And same for acra-translator and its API. As I see, previously it just called HexFormatTest test case which forced simple acrastruct decryption. Now we have much more features) But to simplify tests, we can re-use some existing tests, imho.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added test additional cases for AcraSever. Left todo for AcraTranslator, as we are not supporting /v2 queries for AcraTranslator in integration tests.

Added quard check for searchable tokenization observer
Added TODO for adding more metrics to track once we support v2 queries for translator in tests
@Zhaars Zhaars requested a review from Lagovas February 9, 2023 10:44
tests/test.py Outdated Show resolved Hide resolved
@@ -69,6 +70,10 @@ func (encryptor *TokenizeQuery) OnQuery(ctx context.Context, query base.OnQueryO
clientSession := base.ClientSessionFromContext(ctx)
bindSettings := queryEncryptor.PlaceholderSettingsFromClientSession(clientSession)
for _, item := range items {
if !item.Setting.IsTokenized() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we add the same for searchable encryption?

Added quard case for searchable QueryObserver
@Zhaars Zhaars requested a review from Lagovas February 9, 2023 14:40
Removed unnecessary teardown call
Copy link
Collaborator

@Lagovas Lagovas left a comment

Choose a reason for hiding this comment

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

great. remains only to update documentation about new added metrics

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.

2 participants