-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Fleet] Package policy upgrade telemetry with sender #115180
Merged
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
def871d
draft of upgrade usage collector
juliaElastic d17c611
Merge branch 'elastic:master' into upgrade-telemetry
juliaElastic 4957690
telemetry sender service
juliaElastic 1d2deff
fixed tests and types
juliaElastic 719be2d
cleanup
juliaElastic 0434d46
type fix
juliaElastic d4b01a3
Merge branch 'elastic:master' into upgrade-telemetry
juliaElastic 0e8fa09
removed collector
juliaElastic d6d11df
Merge branch 'master' into upgrade-telemetry
juliaElastic 316ff8b
made required field message generic, added test
juliaElastic 8ff9797
Merge branch 'upgrade-telemetry' of https://github.com/juliaElastic/k…
juliaElastic 217ef55
cleanup
juliaElastic d0620df
cleanup
juliaElastic 03d39ad
cleanup
juliaElastic 1fe58f1
removed v3-dev as outdated
juliaElastic 9f18ad3
removed conditional from telemetry url creation
juliaElastic a3b1011
supporting multiple channels in sender
juliaElastic caef79a
fix types
juliaElastic ae3b673
refactor
juliaElastic 0b8072e
Merge branch 'master' into upgrade-telemetry
kibanamachine 3798547
using json content type
juliaElastic b210f64
fix test
juliaElastic 0181b6a
Merge branch 'master' into upgrade-telemetry
kibanamachine 786b63f
simplified telemetry url
juliaElastic ec3b977
fixed type
juliaElastic b0bf43b
added back ndjson
juliaElastic 1572d89
Merge branch 'master' into upgrade-telemetry
juliaElastic 7c7a8d8
Merge branch 'master' into upgrade-telemetry
kibanamachine c77d7f6
moved telemetry to update, added dryrun
juliaElastic ee2c916
fix types
juliaElastic 5914a61
Merge branch 'master' into upgrade-telemetry
juliaElastic 74b6c1f
fix prettier
juliaElastic cb591ad
updated after review
juliaElastic bfc09a0
Merge branch 'master' into upgrade-telemetry
kibanamachine b4a89d9
fix imports
juliaElastic f0a8cd2
added error_message field
juliaElastic eafad0a
Merge branch 'main' into upgrade-telemetry
juliaElastic 1d876cd
review fixes
juliaElastic f7dcd64
Merge branch 'main' into upgrade-telemetry
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
x-pack/plugins/fleet/server/services/upgrade_usage.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { Logger } from 'src/core/server'; | ||
import { loggingSystemMock } from 'src/core/server/mocks'; | ||
|
||
import type { TelemetryEventsSender } from '../telemetry/sender'; | ||
import { createMockTelemetryEventsSender } from '../telemetry/__mocks__'; | ||
|
||
import { sendTelemetryEvents, capErrorSize } from './upgrade_usage'; | ||
import type { PackagePolicyUpgradeUsage } from './upgrade_usage'; | ||
|
||
describe('sendTelemetryEvents', () => { | ||
let eventsTelemetryMock: jest.Mocked<TelemetryEventsSender>; | ||
let loggerMock: jest.Mocked<Logger>; | ||
|
||
beforeEach(() => { | ||
eventsTelemetryMock = createMockTelemetryEventsSender(); | ||
loggerMock = loggingSystemMock.createLogger(); | ||
}); | ||
|
||
it('should queue telemetry events with generic error', () => { | ||
const upgardeMessage: PackagePolicyUpgradeUsage = { | ||
package_name: 'aws', | ||
current_version: '0.6.1', | ||
new_version: '1.3.0', | ||
status: 'failure', | ||
error: [ | ||
{ key: 'queueUrl', message: ['Queue URL is required'] }, | ||
{ message: 'Invalid format' }, | ||
], | ||
dryRun: true, | ||
}; | ||
|
||
sendTelemetryEvents(loggerMock, eventsTelemetryMock, upgardeMessage); | ||
|
||
expect(eventsTelemetryMock.queueTelemetryEvents).toHaveBeenCalledWith('fleet-upgrades', [ | ||
{ | ||
current_version: '0.6.1', | ||
error: [ | ||
{ | ||
key: 'queueUrl', | ||
message: ['Queue URL is required'], | ||
}, | ||
{ | ||
message: 'Invalid format', | ||
}, | ||
], | ||
error_message: ['Field is required', 'Invalid format'], | ||
new_version: '1.3.0', | ||
package_name: 'aws', | ||
status: 'failure', | ||
dryRun: true, | ||
}, | ||
]); | ||
}); | ||
|
||
it('should cap error size', () => { | ||
const maxSize = 2; | ||
const errors = [{ message: '1' }, { message: '2' }, { message: '3' }]; | ||
|
||
const result = capErrorSize(errors, maxSize); | ||
|
||
expect(result.length).toEqual(maxSize); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we switch to named parameters / object on this API? The list is quite long and it's not obvious what each arg is for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit cautious of changing this, the
update
method is being called from a few plugins outside of fleet like apm and security_solution.