-
Notifications
You must be signed in to change notification settings - Fork 225
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
feat: add metric headers #1503
Merged
feat: add metric headers #1503
Changes from 10 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
49b7c1b
add metrics for user credential.
zhumin8 4b4cfa8
metrics for sa.
zhumin8 ea04051
metrics for ImpersonatedCredentials
zhumin8 62bcfe5
metrics for compute engine credentials.
zhumin8 a9b6327
remove redundant util method. fix ImpersonatedCredentials overiding e…
zhumin8 e05558f
create a CredentialType enum class. rm redundant getter from UserCred…
zhumin8 973218d
some test cleanups.
zhumin8 3222930
Merge branch 'main' into metrics
zhumin8 adca794
Merge branch 'main' into metrics
zhumin8 1c8dc27
Merge branch 'main' into metrics
zhumin8 8742cc7
change name CredentialType to CredentialTypeForMetrics.
zhumin8 dd90f83
add request type untracked.
zhumin8 fa2f3f5
add javadoc comment, rename for readability, rename UNKNOWN to DO_NOT…
zhumin8 58b6072
extract constants from metrics string.
zhumin8 cb6bb84
add case for request type unspecified and credenty type do not send.
zhumin8 225a42b
simplify getGoogleCredentialsMetricsHeader logic and deal with additi…
zhumin8 8fe4d71
extract helper function setMetricsHeader. Add tests. Add mockito-inline.
zhumin8 6c50e3c
remove mockito-inline.
zhumin8 d0b40f7
add comments. change DO_NOT_SEND label.
zhumin8 35e63b2
fix typo in name.
zhumin8 226e3e3
remove setMetricsCredentialType()
zhumin8 5242f34
review feedback: refactor, introduce shouldSendMetricsHeader flag.
zhumin8 daca76f
lint fix.
zhumin8 d1f66ee
Merge branch 'main' into metrics
zhumin8 670dd23
update test check condition to be consistent.
zhumin8 36cb40d
Merge branch 'main' into metrics
zhumin8 3df3035
Merge branch 'main' into metrics
zhumin8 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 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 Google LLC | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are | ||
* met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following disclaimer | ||
* in the documentation and/or other materials provided with the | ||
* distribution. | ||
* | ||
* * Neither the name of Google LLC nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
package com.google.auth; | ||
|
||
public enum CredentialType { | ||
USER_CREDENTIALS("u"), | ||
SERVICE_ACCOUNT_CREDENTIALS_AT("sa"), | ||
SERVICE_ACCOUNT_CREDENTIALS_JWT("jwt"), | ||
VM_CREDENTIALS("mds"), | ||
IMPERSONATED_CREDENTIALS("imp"), | ||
UNKNOWN("unknown"); | ||
|
||
private String label; | ||
|
||
private CredentialType(String label) { | ||
this.label = label; | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
} |
This file contains 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 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 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 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 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 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these are strictly defined by our metrics implementation, can we make that more clear everywhere?
For instance we might call this "CredentialNameForMetrics" (or something better than that).
That way we know that we can't add enum items without a definition that is established elsewhere, and there won't be Credentials that have a CredentialType of Unknown (when we actually do know the type, we just don't want to score it for metrics.)