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

feat: Add Metrics Trait #480

Closed
wants to merge 15 commits into from
Closed

Conversation

yash30201
Copy link
Contributor

  • Add Metrics Trait
  • Add unit tests for metrics trait

* Add Metrics Trait
* Add unit tests for metrics trait
@yash30201 yash30201 added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. do not merge Indicates a pull request not ready for merge, due to either quality or timing. labels Sep 14, 2023
Copy link
Contributor

@bshaffer bshaffer left a comment

Choose a reason for hiding this comment

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

Great PR! I've left a few initial thoughts, and here are a few more:

Does this need to be in a trait? Traits are only necessary if multiple classes share this functionality. If it's exposed as a trait, but not actually used by classes IN the auth library, it might be better to put it in the library where the classes are which DOES use it (e.g. GAX).

Is there another PR coming which shows how this trait will be implemented? It's hard to review this PR without that one.

public static $credTypeSaAssertion = 'cred-type/sa';
public static $credTypeSaJwt = 'cred-type/jwt';
public static $credTypeSaMds = 'cred-type/mds';
public static $credTypeSaImpersonate = 'cred-type/imp';
Copy link
Contributor

@bshaffer bshaffer Sep 19, 2023

Choose a reason for hiding this comment

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

At least based on their usage in this PR, these should all be private by default. But I think I'd get rid of them all together and just replace their usage with the strings themselves - they're only used in one place each, and they're not variable, so they shouldn't be variables.

They could be constants, but as traits don't allow constants, it won't work here.


// TODO: Find a way to get the auth version
// Auth library version
public static $version = '10.0.0';
Copy link
Contributor

@bshaffer bshaffer Sep 19, 2023

Choose a reason for hiding this comment

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

I'd suggest making this a placeholder function instead, like this:

private static getAuthLiberaryVersion(): string
{
    throw new LogicException('This must be implemented by the class which uses the trait');
}

Also, why is the placeholder 10.0.0?

/**
* Returns header string for metadata server ping request.
*/
public function getMdsPingHeader()
Copy link
Contributor

Choose a reason for hiding this comment

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

It's hard to say without seeing where these methods will be implemented, but I am fairly confident these methods can all be private, as they'll be used internally to whatever class is making these calls.

@yash30201
Copy link
Contributor Author

Will work on a different approach as per design doc.

@yash30201 yash30201 closed this Dec 5, 2023
@yash30201 yash30201 deleted the auth-metrics-1 branch December 14, 2023 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Indicates a pull request not ready for merge, due to either quality or timing. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants