Skip to content

Log metadata about Attempts API events (LG-7562)#6963

Merged
zachmargolis merged 4 commits intomainfrom
margolis-log-attempts-payload-size
Sep 15, 2022
Merged

Log metadata about Attempts API events (LG-7562)#6963
zachmargolis merged 4 commits intomainfrom
margolis-log-attempts-payload-size

Conversation

@zachmargolis
Copy link
Contributor

Also adds a feature flag in case we discover this has some sort of performance hit to generate and JSONify and throw away all these strings

changelog: Internal, Logging, Log metadata about Attempts API
@zachmargolis zachmargolis requested a review from a team September 14, 2022 23:40
Copy link
Contributor

@n1zyy n1zyy left a comment

Choose a reason for hiding this comment

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

I love it!


def track_event(event_type, metadata = {})
return unless enabled?
return if !enabled? && !IdentityConfig.store.irs_attempt_api_payload_size_logging_enabled
Copy link
Contributor

Choose a reason for hiding this comment

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

This is perhaps the only case where unless ... || ... would read cleanly to me since we're negating both.

That's generally seen as a cardinal sin, though, so I'm fine with this as-is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's my personal vendetta against unless. Another idea was an explicit negation/or. What do you think of this?

Suggested change
return if !enabled? && !IdentityConfig.store.irs_attempt_api_payload_size_logging_enabled
return if !(enabled? || IdentityConfig.store.irs_attempt_api_payload_size_logging_enabled)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

going to leave it as is for the time being but open to changing later if this confuses folks!

Copy link
Contributor

Choose a reason for hiding this comment

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

My brain has a hard time with !( ... || ... ) / !( ... && ... ) doing mental De Morgan's to decipher the logic, so I'm happier with it as is, and would have also been fine with unless (I don't share the same vendetta 😄 ).

@zachmargolis zachmargolis merged commit ab625d7 into main Sep 15, 2022
@zachmargolis zachmargolis deleted the margolis-log-attempts-payload-size branch September 15, 2022 16:36
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.

3 participants