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

91828: Create general monitor classes #19078

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

balexandr
Copy link
Contributor

@balexandr balexandr commented Oct 24, 2024

Create a general monitor class for vets-api for overall general tracking and sidekiq jobs with claims involved.

Summary

  • Create Logging::Monitor class to hold simple request tracking
  • Create Logging::Monitor::Sidekiq for general Claim-based Sidekiq jobs
  • Create unit tests for both new classes
  • include general classes to Pensions and Burials

Related issue(s)

Testing done

  • New code is covered by unit tests

What areas of the site does it impact?

N/a just new logging classes

This comment was marked as resolved.

@va-vfs-bot va-vfs-bot temporarily deployed to 91828-create-general-monitors/main/main October 25, 2024 18:09 Inactive
def track_request(message, metric, form_type = 'Unknown Form Type', user_account_uuid = nil, call_location: nil)
function, file, line = parse_caller(call_location)

StatsD.increment(metric)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we leave the metric to whatever the team wants or should we add a bit more structure so they can only pass in the prefix?
i.e. {STATS_KEY}.error

Copy link
Contributor

Choose a reason for hiding this comment

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

For these functions I would let the metric be passed to the function. Also, possibly the 'log level' [info, warn, error] unless you want to split out or specify that it will log as an error in the function name.

Copy link

1 Warning
⚠️ This PR changes 202 LoC (not counting whitespace/newlines).

In order to ensure each PR receives the proper attention it deserves, we recommend not exceeding
200. Expect some delays getting reviews.

File Summary

Files

  • .github/CODEOWNERS (+2/-2)

  • lib/burials/monitor.rb (+2/-1)

  • lib/logging/monitor.rb (+20/-0)

  • lib/logging/sidekiq.rb (+59/-0)

  • lib/zero_silent_failures/monitor.rb (+2/-2)

  • modules/pensions/lib/pensions/monitor.rb (+2/-1)

  • spec/lib/logging/monitor_spec.rb (+30/-0)

  • spec/lib/logging/sidekiq_spec.rb (+79/-0)

    Note: We exclude files matching the following when considering PR size:

    *.csv, *.json, *.tsv, *.txt, *.md, Gemfile.lock, app/swagger, modules/mobile/docs, spec/fixtures/, spec/support/vcr_cassettes/, modules/mobile/spec/support/vcr_cassettes/, db/seeds, modules/vaos/app/docs, modules/meb_api/app/docs, modules/appeals_api/app/swagger/, *.bru, *.pdf
    

Big PRs are difficult to review, often become stale, and cause delays.

Generated by 🚫 Danger

Copy link
Contributor

@wayne-weibel wayne-weibel left a comment

Choose a reason for hiding this comment

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

There is a confusing overlap with the ZSF monitor. Arguments for and against this logging module being agnostic versus inheriting ZSF.
I thought this library was going to live under lib/common?
Your thoughts/opinion on making a subclass to controller and sidekiq for saved_claim (since there are things which are not saved_claim which could potentially want to use this library)?

@@ -7,6 +7,8 @@ module Burials
# Monitor functions for Rails logging and StatsD
#
class Monitor < ::ZeroSilentFailures::Monitor
include Logging::Monitor
Copy link
Contributor

Choose a reason for hiding this comment

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

will this cause issues since there would now be 2 constructors? and also a double include/inherit

# frozen_string_literal: true

module Logging
class Monitor < ::ZeroSilentFailures::Monitor
Copy link
Contributor

Choose a reason for hiding this comment

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

probably should not inherit the ZSF monitor. try and keep this a module/include/mixin with standalone functions
i think this will cause confusion too with 'circular inheritance'

def track_request(message, metric, form_type = 'Unknown Form Type', user_account_uuid = nil, call_location: nil)
function, file, line = parse_caller(call_location)

StatsD.increment(metric)
Copy link
Contributor

Choose a reason for hiding this comment

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

For these functions I would let the metric be passed to the function. Also, possibly the 'log level' [info, warn, error] unless you want to split out or specify that it will log as an error in the function name.

# @param form_type [String]
# @param user_account_uuid [User]
#
def track_request(message, metric, form_type = 'Unknown Form Type', user_account_uuid = nil, call_location: nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of form_type have it be 'context' so what ever gets sent will just be appended to the logger payload.
also probably will need to allow 'tags' to be given, but those should be required

Comment on lines +17 to +37
FactoryBot.create(
:pensions_module_pension_claim,
form: {
veteranFullName: {
first: 'Test',
last: 'User'
},
email: 'foo@foo.com',
veteranDateOfBirth: '1989-12-13',
veteranSocialSecurityNumber: '111223333',
veteranAddress: {
country: 'USA',
state: 'CA',
postalCode: '90210',
street: '123 Main St',
city: 'Anytown'
},
statementOfTruthCertified: true,
statementOfTruthSignature: 'Test User'
}.to_json
)
Copy link
Contributor

Choose a reason for hiding this comment

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

try to avoid using a specific form to test (i recently added a basic generic SaveClaim factory in my pr)
minimally - why not just FactoryBot.build(:pension_module_pension_claim)?

# frozen_string_literal: true

require 'rails_helper'
require 'zero_silent_failures/monitor'
Copy link
Contributor

Choose a reason for hiding this comment

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

is this needed here?

Comment on lines +78 to +80
private

attr_reader :service
Copy link
Contributor

Choose a reason for hiding this comment

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

inherited private functions should be callable from the subclass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants