-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [ML] Re-enabling file upload telemetry * small refactor * removing exported function * removing commented out code * removing commented out include * cleaning up types
- Loading branch information
1 parent
32ba66a
commit 98fdd3d
Showing
14 changed files
with
217 additions
and
275 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
41 changes: 0 additions & 41 deletions
41
x-pack/plugins/ml/server/lib/ml_telemetry/make_ml_usage_collector.ts
This file was deleted.
Oops, something went wrong.
128 changes: 0 additions & 128 deletions
128
x-pack/plugins/ml/server/lib/ml_telemetry/ml_telemetry.test.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export { initMlTelemetry } from './ml_usage_collector'; | ||
export { updateTelemetry } from './telemetry'; |
15 changes: 15 additions & 0 deletions
15
x-pack/plugins/ml/server/lib/telemetry/internal_repository.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,15 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { SavedObjectsServiceStart, ISavedObjectsRepository } from 'kibana/server'; | ||
|
||
let internalRepository: ISavedObjectsRepository | null = null; | ||
export const setInternalRepository = ( | ||
createInternalRepository: SavedObjectsServiceStart['createInternalRepository'] | ||
) => { | ||
internalRepository = createInternalRepository(); | ||
}; | ||
export const getInternalRepository = () => internalRepository; |
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,25 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { SavedObjectsType } from 'src/core/server'; | ||
import { TELEMETRY_DOC_ID } from './telemetry'; | ||
|
||
export const mlTelemetryMappingsType: SavedObjectsType = { | ||
name: TELEMETRY_DOC_ID, | ||
hidden: false, | ||
namespaceAgnostic: true, | ||
mappings: { | ||
properties: { | ||
file_data_visualizer: { | ||
properties: { | ||
index_creation_count: { | ||
type: 'long', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; |
32 changes: 32 additions & 0 deletions
32
x-pack/plugins/ml/server/lib/telemetry/ml_usage_collector.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,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { CoreSetup } from 'kibana/server'; | ||
|
||
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; | ||
import { getTelemetry, initTelemetry } from './telemetry'; | ||
import { mlTelemetryMappingsType } from './mappings'; | ||
import { setInternalRepository } from './internal_repository'; | ||
|
||
const TELEMETRY_TYPE = 'mlTelemetry'; | ||
|
||
export function initMlTelemetry(coreSetup: CoreSetup, usageCollection: UsageCollectionSetup) { | ||
coreSetup.savedObjects.registerType(mlTelemetryMappingsType); | ||
registerMlUsageCollector(usageCollection); | ||
coreSetup.getStartServices().then(([core]) => { | ||
setInternalRepository(core.savedObjects.createInternalRepository); | ||
}); | ||
} | ||
|
||
function registerMlUsageCollector(usageCollection: UsageCollectionSetup): void { | ||
const mlUsageCollector = usageCollection.makeUsageCollector({ | ||
type: TELEMETRY_TYPE, | ||
isReady: () => true, | ||
fetch: async () => (await getTelemetry()) || initTelemetry(), | ||
}); | ||
|
||
usageCollection.registerCollector(mlUsageCollector); | ||
} |
Oops, something went wrong.