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

aedara/APPEALS-26087 Setup monitoring for deprecation warnings #19078

Merged
merged 16 commits into from
Aug 15, 2023

Conversation

AnandEdara
Copy link
Contributor

@AnandEdara AnandEdara commented Jul 28, 2023

Resolves Jira Issue Title

Description

Please explain the changes you made here.

Acceptance Criteria

  • Code compiles correctly

Testing Plan

  1. Go to Jira Issue/Test Plan Link or list them below
  • For feature branches merging into master: Was this deployed to UAT?

Frontend

User Facing Changes

  • Screenshots of UI changes added to PR & Original Issue
BEFORE AFTER

Storybook Story

For Frontend (Presentation) Components

  • Add a Storybook file alongside the component file (e.g. create MyComponent.stories.js alongside MyComponent.jsx)
  • Give it a title that reflects the component's location within the overall Caseflow hierarchy
  • Write a separate story (within the same file) for each discrete variation of the component

Backend

Database Changes

Only for Schema Changes

  • Add typical timestamps (created_at, updated_at) for new tables
  • Update column comments; include a "PII" prefix to indicate definite or potential PII data content
  • Have your migration classes inherit from Caseflow::Migration, especially when adding indexes (use add_safe_index) (see Writing DB migrations)
  • Verify that migrate:rollback works as desired (change supported functions)
  • Perform query profiling (eyeball Rails log, check bullet and fasterer output)
  • For queries using raw sql was an explain plan run by System Team
  • Add appropriate indexes (especially for foreign keys, polymorphic columns, unique constraints, and Rails scopes)
  • Run make check-fks; add any missing foreign keys or add to config/initializers/immigrant.rb (see Record associations and Foreign Keys)
  • Add belongs_to for associations to enable the schema diagrams to be automatically updated
  • Document any non-obvious semantics or logic useful for interpreting database data at Caseflow Data Model and Dictionary

Integrations: Adding endpoints for external APIs

  • Check that Caseflow's external API code for the endpoint matches the code in the relevant integration repo
    • Request: Service name, method name, input field names
    • Response: Check expected data structure
    • Check that calls are wrapped in MetricService record block
  • Check that all configuration is coming from ENV variables
    • Listed all new ENV variables in description
    • Worked with or notified System Team that new ENV variables need to be set
  • Update Fakes
  • For feature branches: Was this tested in Caseflow UAT

Best practices

Code Documentation Updates

  • Add or update code comments at the top of the class, module, and/or component.

Tests

Test Coverage

Did you include any test coverage for your code? Check below:

  • RSpec
  • Jest
  • Other

Code Climate

Your code does not add any new code climate offenses? If so why?

  • No new code climate issues added

Monitoring, Logging, Auditing, Error, and Exception Handling Checklist

Monitoring

  • Are performance metrics (e.g., response time, throughput) being tracked?
  • Are key application components monitored (e.g., database, cache, queues)?
  • Is there a system in place for setting up alerts based on performance thresholds?

Logging

  • Are logs being produced at appropriate log levels (debug, info, warn, error, fatal)?
  • Are logs structured (e.g., using log tags) for easier querying and analysis?
  • Are sensitive data (e.g., passwords, tokens) redacted or omitted from logs?
  • Is log retention and rotation configured correctly?
  • Are logs being forwarded to a centralized logging system if needed?

Auditing

  • Are user actions being logged for audit purposes?
  • Are changes to critical data being tracked ?
  • Are logs being securely stored and protected from tampering or exposing protected data?

Error Handling

  • Are errors being caught and handled gracefully?
  • Are appropriate error messages being displayed to users?
  • Are critical errors being reported to an error tracking system (e.g., Sentry, ELK)?
  • Are unhandled exceptions being caught at the application level ?

Exception Handling

  • Are custom exceptions defined and used where appropriate?
  • Is exception handling consistent throughout the codebase?
  • Are exceptions logged with relevant context and stack trace information?
  • Are exceptions being grouped and categorized for easier analysis and resolution?

@AnandEdara AnandEdara changed the title Adding a rails initializer for monitoring deprecation warnings Monitoring deprecation warnings in production Jul 28, 2023
@codeclimate
Copy link

codeclimate bot commented Jul 28, 2023

Code Climate has analyzed commit a645a40 and detected 0 issues on this pull request.

View more on Code Climate.

Copy link
Contributor

@jcroteau jcroteau left a comment

Choose a reason for hiding this comment

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

First off, really nice work on this! 👏

  • I was not aware of ActiveSupport::Deprecation.behavior , so thank you for brining it to my attention! 💚
  • I also think you made a good decision to emit a warning to the application log as well, since messages to Sentry and/or Slack could fail.

Instead of polluting your PR with a bunch of comments, I've pushed up a branch with a refactor and a spec for your consideration. Happy to go through it with you and the reasons behind my decisions. After that, you're welcome to incorporate our agreed changes into your PR here.

A few more overall suggestions:

  • The PR title should have format devname/APPEALS-XXXX <description>.
    • So in this case aedara/APPEALS-26087 Setup monitoring for deprecation warnings.
  • I think it would be good to finish filling out the template in the PR description.
  • A Jira Test issue (Xray test) is required on all new code (per our contract)
    • In preparation for that, it would be good if you were to write out the manual steps for your test plan under the Testing Plan section.
      • For this, a simple test of accessing the Rails console, executing ActiveSupport::Deprecation.warn("test deprecation warning"), and checking that Sentry and the #appeals-deprecation-alerts Slack channel received messages should be sufficient.
    • I can work with you on creating a Jira Test story if you haven't done this before.
  • It's generally good practice to add test coverage whenever possible, even for "little things" like this. It helps keeps our SimpleCov score high, so that future Rails upgraders will thank us 😄

Also, before we test this in UAT, I think we'll need to wait until we have a resolution to the UAT no-op guard clause in SlackService #send_notification:

app/services/slack_service.rb

def send_notification(msg, title = "", channel = DEFAULT_CHANNEL)
  return unless url && (aws_env != "uat")

@AnandEdara AnandEdara changed the title Monitoring deprecation warnings in production aedara/APPEALS-26087 Setup monitoring for deprecation warnings Jul 31, 2023
@jcroteau jcroteau self-requested a review August 3, 2023 17:46
Copy link
Contributor

@jcroteau jcroteau left a comment

Choose a reason for hiding this comment

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

We tested successfully in UAT, but there is one small improvement we can make to the Slack alert titles...

config/initializers/deprecation_warning_subscriber.rb Outdated Show resolved Hide resolved
config/initializers/deprecation_warning_subscriber.rb Outdated Show resolved Hide resolved
AnandEdara and others added 2 commits August 7, 2023 11:04
Co-authored-by: Jeremy Croteau <jcroteau@users.noreply.github.com>
@jcroteau jcroteau self-requested a review August 7, 2023 18:34
Copy link
Contributor

@jcroteau jcroteau left a comment

Choose a reason for hiding this comment

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

@jcroteau
Copy link
Contributor

jcroteau commented Aug 8, 2023

UAT Results

This was tested successfully in UAT.
See resultant Sentry event at https://sentry.uat.appeals.va.gov/sentry/caseflow-uat/issues/4298

Also, a message was posted successfully to DSVA #appeals-deprecation-alerts channel:

image

@sbashamoni sbashamoni merged commit 0e4fdbf into master Aug 15, 2023
18 of 29 checks passed
@andrecolinone andrecolinone deleted the aedara/APPEALS-26087 branch November 22, 2023 17:21
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