Skip to content

Create consistent AppUsageEvent records#1601

Merged
sethboyles merged 1 commit intocloudfoundry:masterfrom
joyvuu-dave:master
May 6, 2020
Merged

Create consistent AppUsageEvent records#1601
sethboyles merged 1 commit intocloudfoundry:masterfrom
joyvuu-dave:master

Conversation

@joyvuu-dave
Copy link
Copy Markdown
Contributor

@joyvuu-dave joyvuu-dave commented Apr 29, 2020

When a user makes a POST to
/v2/app_usage_events/destructively_purge_all_and_reseed_started_apps,
all existing AppUsageEvent records are purged from the database and new
AppUsageEvent records are created for any running processes. This action
is taken by clients who may have missed previous events that have now
been pruned from the database as part of routeine mainteance and now
need a new starting spot for tracking usage.

All AppUsageEvent records created outside of a purge and reseed action
will have their parent_app_name and parent_app_guid fields set. This
change makes AppUsageEvent recoreds created as a result of a purge
consistent with all other records in that respect.

Not having the parent_app_name and parent_app_guid fields set was
causing 3rd party usage monitoring systems that expected their presence
to break.

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the master branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

@cf-gitbot
Copy link
Copy Markdown

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/172592163

The labels on this github issue will be updated when the story is started.

@sannidhi
Copy link
Copy Markdown
Contributor

Thanks for the PR @joyvuu-dave. We will take a look and merge once checks complete.

@sannidhi
Copy link
Copy Markdown
Contributor

ah you're getting robocoped @joyvuu-dave
https://travis-ci.org/github/cloudfoundry/cloud_controller_ng/jobs/681201719

Looks like its just a trailing whitespace but it will fail the units.

org_guid: "#{Organization.table_name}__guid".to_sym,
created_at: Sequel.datetime_class.now,
parent_app_name: :parent_app__name,
parent_app_guid: "#{ProcessModel.table_name}__guid".to_sym,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should this be #{AppModel.table_name}__guid?

Copy link
Copy Markdown
Contributor Author

@joyvuu-dave joyvuu-dave Apr 29, 2020

Choose a reason for hiding this comment

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

I don't think the reference to AppModel resolves (at least it didn't when I tried). However, it looks like we can just reference parent_app__guid directly. I updated the PR and also added a test to confirm parent_app_guid and app_guid end up being equal.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

One last change -- I updated the test to show that parent_app_name and parent_app_guid are set to the values of the App name and guid.

@joyvuu-dave joyvuu-dave force-pushed the master branch 3 times, most recently from 7693f47 to 3e44a21 Compare May 4, 2020 19:09
When a user makes a POST to
/v2/app_usage_events/destructively_purge_all_and_reseed_started_apps,
all existing AppUsageEvent records are purged from the database and new
AppUsageEvent records are created for any running processes. This action
is taken by clients who may have missed previous events that have now
been pruned from the database as part of routeine mainteance and now
need a new starting spot for tracking usage.

All AppUsageEvent records created outside of a purge and reseed action
will have their parent_app_name and parent_app_guid fields set. This
change makes AppUsageEvent recoreds created as a result of a purge
consistent with all other records in that respect.

Not having the parent_app_name and parent_app_guid fields set was
causing 3rd party usage monitoring systems that expected their presence
to break.

Authored-by: Dave Riddle <driddle@pivotal.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants