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

Add a type label to metric hookshot_connections #682

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Half-Shot
Copy link
Contributor

No description provided.

@Half-Shot Half-Shot requested a review from a team as a code owner March 24, 2023 11:56
Comment on lines +65 to +66
const cd: ConnectionDeclaration = Object.getPrototypeOf(connection).constructor;
const canonicalEvent = cd?.EventTypes?.[0] ?? 'unknown';
Copy link
Contributor

Choose a reason for hiding this comment

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

Object.getPrototypeOf(connection).constructor

Just because JavaScript allows you to do this, doesn't mean you should.
If there's no other simple way to accomplish this, please add an inline comment of what this is doing.

The following things are uncommon about this (aka. I've never seen them used in a JavaScript project):

  • getting the prototype of an object
  • assigning the constructor of a class to a new variable
  • not executing a constructor, but instead using it like an object variable to get data from the class

Copy link
Contributor

@tadzik tadzik Jul 6, 2023

Choose a reason for hiding this comment

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

This does feel like a bit of ETOOMUCHMAGIC. A lot of fancy footwork to basically dodge the interface boundary and pull EventTypes out of the class itself. Feels like if we need to do this then EventTypes (or CanonicalEventType) should just be a public property of IConnection.

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.

None yet

3 participants