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

[7.7] [Uptime] Update uptime ml job id to limit to 64 char #64397

Merged
merged 11 commits into from
Apr 28, 2020

Conversation

shahzad31
Copy link
Contributor

Backport the following PR:
#64394

@shahzad31 shahzad31 requested a review from andrewvc April 24, 2020 06:44
@shahzad31 shahzad31 self-assigned this Apr 24, 2020
@shahzad31 shahzad31 added the Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability label Apr 24, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/uptime (Team:uptime)

@shahzad31 shahzad31 changed the title [7.x] [Uptime] Update uptime ml job id to limit to 64 char [7.7] [Uptime] Update uptime ml job id to limit to 64 char Apr 24, 2020
import { getMLJobId } from '../ml_anomaly';

describe('ML Anomaly API', () => {
it('it generates a valid ML job ID', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we break these out into different test cases? In an ideal world we'd do one it per test.

In some situations, where setup is complex and slow (like functional tests) breaking this rule makes sense. For simple fast pure functions like this one it really cleans up the code to break the tests up more.

So, you'd have a single block like:

it("should truncate long monitor IDs", () => {
  expect(getMLJobId(longAndWeirdMonitorId)).toHaveLength(64)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i have updated the test.

// ML Job ID can't be greater than 64 length, so will be substring it, and hope
// At such big length, there is minimum chance of having duplicate monitor id
// Subtracting ML_JOB_ID constant and _ char as well
if ((lowerCaseMonitorId + ML_JOB_ID + 1).length > 64) {
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 somewhat awkward in that in accounts for the extra _ we add. It feels like this function should just add the _ to the end itself. Is there a reason not to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it's an awkward code, i have further tried simplifing it.

@shahzad31
Copy link
Contributor Author

@elasticmachine merge upstream

@andrewvc
Copy link
Contributor

The code looks good, but running this branch, I'm not sure why, I can't ML to detect any anomalies. I'd like to figure out why that's the case before merging this.

@shahzad31
Copy link
Contributor Author

The code looks good, but running this branch, I'm not sure why, I can't ML to detect any anomalies. I'd like to figure out why that's the case before merging this.

@andrewvc let me try producing Anomaly.

On another thought should we increase the time from 24h to bit longer period in the past for records to be processed?

@shahzad31
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@shahzad31
Copy link
Contributor Author

@andrewvc i can see anomalies in this branch as well
image

Copy link
Contributor

@andrewvc andrewvc left a comment

Choose a reason for hiding this comment

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

LGTM

@shahzad31 shahzad31 merged commit 825ce2c into elastic:7.7 Apr 28, 2020
@shahzad31 shahzad31 deleted the ml-job-id branch April 28, 2020 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants