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

[WIP] Move UsageCollection plugin to a Core Service #69306

Closed
wants to merge 9 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ export interface CoreSetup<TPluginsStart extends object = object, TStart = unkno
| [savedObjects](./kibana-plugin-core-server.coresetup.savedobjects.md) | <code>SavedObjectsServiceSetup</code> | [SavedObjectsServiceSetup](./kibana-plugin-core-server.savedobjectsservicesetup.md) |
| [status](./kibana-plugin-core-server.coresetup.status.md) | <code>StatusServiceSetup</code> | [StatusServiceSetup](./kibana-plugin-core-server.statusservicesetup.md) |
| [uiSettings](./kibana-plugin-core-server.coresetup.uisettings.md) | <code>UiSettingsServiceSetup</code> | [UiSettingsServiceSetup](./kibana-plugin-core-server.uisettingsservicesetup.md) |
| [usageCollection](./kibana-plugin-core-server.coresetup.usagecollection.md) | <code>UsageCollectionSetup</code> | [UsageCollectionSetup](./kibana-plugin-core-server.usagecollectionsetup.md) |
| [uuid](./kibana-plugin-core-server.coresetup.uuid.md) | <code>UuidServiceSetup</code> | [UuidServiceSetup](./kibana-plugin-core-server.uuidservicesetup.md) |

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [CoreSetup](./kibana-plugin-core-server.coresetup.md) &gt; [usageCollection](./kibana-plugin-core-server.coresetup.usagecollection.md)

## CoreSetup.usageCollection property

[UsageCollectionSetup](./kibana-plugin-core-server.usagecollectionsetup.md)

<b>Signature:</b>

```typescript
usageCollection: UsageCollectionSetup;
```
8 changes: 8 additions & 0 deletions docs/development/core/server/kibana-plugin-core-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [SavedObjectsRepository](./kibana-plugin-core-server.savedobjectsrepository.md) | |
| [SavedObjectsSerializer](./kibana-plugin-core-server.savedobjectsserializer.md) | A serializer that can be used to manually convert [raw](./kibana-plugin-core-server.savedobjectsrawdoc.md) or [sanitized](./kibana-plugin-core-server.savedobjectsanitizeddoc.md) documents to the other kind. |
| [SavedObjectTypeRegistry](./kibana-plugin-core-server.savedobjecttyperegistry.md) | Registry holding information about all the registered [saved object types](./kibana-plugin-core-server.savedobjectstype.md)<!-- -->. |
| [UsageCollectionCollector](./kibana-plugin-core-server.usagecollectioncollector.md) | Collector for reporting system stats |
| [UsageCollectionUsageCollector](./kibana-plugin-core-server.usagecollectionusagecollector.md) | Collector for reporting Usage stats |

## Enumerations

Expand Down Expand Up @@ -196,6 +198,8 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [UiSettingsServiceSetup](./kibana-plugin-core-server.uisettingsservicesetup.md) | |
| [UiSettingsServiceStart](./kibana-plugin-core-server.uisettingsservicestart.md) | |
| [URLMeaningfulParts](./kibana-plugin-core-server.urlmeaningfulparts.md) | We define our own typings because the current version of @<!-- -->types/node declares properties to be optional "hostname?: string". Although, parse call returns "hostname: null \| string". |
| [UsageCollectionCollectorOptions](./kibana-plugin-core-server.usagecollectioncollectoroptions.md) | Collector definition |
| [UsageCollectionCollectorSet](./kibana-plugin-core-server.usagecollectioncollectorset.md) | |
| [UserProvidedValues](./kibana-plugin-core-server.userprovidedvalues.md) | Describes the values explicitly set by user. |
| [UuidServiceSetup](./kibana-plugin-core-server.uuidservicesetup.md) | APIs to access the application's instance uuid. |

Expand Down Expand Up @@ -289,4 +293,8 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [StartServicesAccessor](./kibana-plugin-core-server.startservicesaccessor.md) | Allows plugins to get access to APIs available in start inside async handlers. Promise will not resolve until Core and plugin dependencies have completed <code>start</code>. This should only be used inside handlers registered during <code>setup</code> that will only be executed after <code>start</code> lifecycle. |
| [StringValidation](./kibana-plugin-core-server.stringvalidation.md) | Allows regex objects or a regex string |
| [UiSettingsType](./kibana-plugin-core-server.uisettingstype.md) | UI element type to represent the settings. |
| [UsageCollectionAllowedSchemaTypes](./kibana-plugin-core-server.usagecollectionallowedschematypes.md) | Allowed types in the schema definition |
| [UsageCollectionMakeSchemaFrom](./kibana-plugin-core-server.usagecollectionmakeschemafrom.md) | Schema definition of the returned object in the fetch method |
| [UsageCollectionPurify](./kibana-plugin-core-server.usagecollectionpurify.md) | |
| [UsageCollectionSetup](./kibana-plugin-core-server.usagecollectionsetup.md) | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionAllowedSchemaTypes](./kibana-plugin-core-server.usagecollectionallowedschematypes.md)

## UsageCollectionAllowedSchemaTypes type

Allowed types in the schema definition

<b>Signature:</b>

```typescript
export declare type AllowedSchemaTypes = 'keyword' | 'text' | 'number' | 'boolean' | 'long' | 'date' | 'float';
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionCollector](./kibana-plugin-core-server.usagecollectioncollector.md) &gt; [(constructor)](./kibana-plugin-core-server.usagecollectioncollector._constructor_.md)

## UsageCollectionCollector.(constructor)

Constructs a new instance of the `Collector` class

<b>Signature:</b>

```typescript
constructor(log: Logger, { type, init, fetch, formatForBulkUpload, isReady, ...options }: CollectorOptions<T, U>);
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| log | <code>Logger</code> | |
| { type, init, fetch, formatForBulkUpload, isReady, ...options } | <code>CollectorOptions&lt;T, U&gt;</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionCollector](./kibana-plugin-core-server.usagecollectioncollector.md) &gt; [fetch](./kibana-plugin-core-server.usagecollectioncollector.fetch.md)

## UsageCollectionCollector.fetch property

<b>Signature:</b>

```typescript
readonly fetch: CollectorOptions<T, U>['fetch'];
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionCollector](./kibana-plugin-core-server.usagecollectioncollector.md) &gt; [init](./kibana-plugin-core-server.usagecollectioncollector.init.md)

## UsageCollectionCollector.init property

<b>Signature:</b>

```typescript
readonly init?: CollectorOptions<T, U>['init'];
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionCollector](./kibana-plugin-core-server.usagecollectioncollector.md) &gt; [isReady](./kibana-plugin-core-server.usagecollectioncollector.isready.md)

## UsageCollectionCollector.isReady property

<b>Signature:</b>

```typescript
readonly isReady: CollectorOptions<T, U>['isReady'];
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionCollector](./kibana-plugin-core-server.usagecollectioncollector.md) &gt; [log](./kibana-plugin-core-server.usagecollectioncollector.log.md)

## UsageCollectionCollector.log property

<b>Signature:</b>

```typescript
protected readonly log: Logger;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionCollector](./kibana-plugin-core-server.usagecollectioncollector.md)

## UsageCollectionCollector class

Collector for reporting system stats

<b>Signature:</b>

```typescript
export declare class Collector<T = unknown, U = T>
```

## Constructors

| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)(log, { type, init, fetch, formatForBulkUpload, isReady, ...options })](./kibana-plugin-core-server.usagecollectioncollector._constructor_.md) | | Constructs a new instance of the <code>Collector</code> class |

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [fetch](./kibana-plugin-core-server.usagecollectioncollector.fetch.md) | | <code>CollectorOptions&lt;T, U&gt;['fetch']</code> | |
| [init](./kibana-plugin-core-server.usagecollectioncollector.init.md) | | <code>CollectorOptions&lt;T, U&gt;['init']</code> | |
| [isReady](./kibana-plugin-core-server.usagecollectioncollector.isready.md) | | <code>CollectorOptions&lt;T, U&gt;['isReady']</code> | |
| [log](./kibana-plugin-core-server.usagecollectioncollector.log.md) | | <code>Logger</code> | |
| [type](./kibana-plugin-core-server.usagecollectioncollector.type.md) | | <code>CollectorOptions&lt;T, U&gt;['type']</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionCollector](./kibana-plugin-core-server.usagecollectioncollector.md) &gt; [type](./kibana-plugin-core-server.usagecollectioncollector.type.md)

## UsageCollectionCollector.type property

<b>Signature:</b>

```typescript
readonly type: CollectorOptions<T, U>['type'];
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionCollectorOptions](./kibana-plugin-core-server.usagecollectioncollectoroptions.md) &gt; [fetch](./kibana-plugin-core-server.usagecollectioncollectoroptions.fetch.md)

## UsageCollectionCollectorOptions.fetch property

Method to fetch the stats to report. The returned object is embedded in the final telemetry payload

<b>Signature:</b>

```typescript
fetch: (callCluster: LegacyAPICaller) => Promise<T> | T;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionCollectorOptions](./kibana-plugin-core-server.usagecollectioncollectoroptions.md) &gt; [init](./kibana-plugin-core-server.usagecollectioncollectoroptions.init.md)

## UsageCollectionCollectorOptions.init property

Optional init function to set up the collector during startup. Only called once at the time of registering

<b>Signature:</b>

```typescript
init?: Function;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionCollectorOptions](./kibana-plugin-core-server.usagecollectioncollectoroptions.md) &gt; [isReady](./kibana-plugin-core-server.usagecollectioncollectoroptions.isready.md)

## UsageCollectionCollectorOptions.isReady property

A method that must return `true` when ready to report stats.

<b>Signature:</b>

```typescript
isReady: () => Promise<boolean> | boolean;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionCollectorOptions](./kibana-plugin-core-server.usagecollectioncollectoroptions.md)

## UsageCollectionCollectorOptions interface

Collector definition

<b>Signature:</b>

```typescript
export interface CollectorOptions<T = unknown, U = T>
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [fetch](./kibana-plugin-core-server.usagecollectioncollectoroptions.fetch.md) | <code>(callCluster: LegacyAPICaller) =&gt; Promise&lt;T&gt; &#124; T</code> | Method to fetch the stats to report. The returned object is embedded in the final telemetry payload |
| [init](./kibana-plugin-core-server.usagecollectioncollectoroptions.init.md) | <code>Function</code> | Optional init function to set up the collector during startup. Only called once at the time of registering |
| [isReady](./kibana-plugin-core-server.usagecollectioncollectoroptions.isready.md) | <code>() =&gt; Promise&lt;boolean&gt; &#124; boolean</code> | A method that must return <code>true</code> when ready to report stats. |
| [schema](./kibana-plugin-core-server.usagecollectioncollectoroptions.schema.md) | <code>MakeSchemaFrom&lt;T&gt;</code> | Schema definition of the returned object in the fetch method |
| [type](./kibana-plugin-core-server.usagecollectioncollectoroptions.type.md) | <code>string</code> | The name of the collector (it will be reported under stack\_stats.kibana.plugins\[type\]) |

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionCollectorOptions](./kibana-plugin-core-server.usagecollectioncollectoroptions.md) &gt; [schema](./kibana-plugin-core-server.usagecollectioncollectoroptions.schema.md)

## UsageCollectionCollectorOptions.schema property

Schema definition of the returned object in the fetch method

<b>Signature:</b>

```typescript
schema?: MakeSchemaFrom<T>;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionCollectorOptions](./kibana-plugin-core-server.usagecollectioncollectoroptions.md) &gt; [type](./kibana-plugin-core-server.usagecollectioncollectoroptions.type.md)

## UsageCollectionCollectorOptions.type property

The name of the collector (it will be reported under stack\_stats.kibana.plugins\[type\])

<b>Signature:</b>

```typescript
type: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionCollectorSet](./kibana-plugin-core-server.usagecollectioncollectorset.md) &gt; [makeStatsCollector](./kibana-plugin-core-server.usagecollectioncollectorset.makestatscollector.md)

## UsageCollectionCollectorSet.makeStatsCollector property

Create a Collector to report system stats

<b>Signature:</b>

```typescript
makeStatsCollector: <T, U>(options: CollectorOptions<T, U>) => Collector<T, U>;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionCollectorSet](./kibana-plugin-core-server.usagecollectioncollectorset.md) &gt; [makeUsageCollector](./kibana-plugin-core-server.usagecollectioncollectorset.makeusagecollector.md)

## UsageCollectionCollectorSet.makeUsageCollector property

Create a Collector to report usage stats

<b>Signature:</b>

```typescript
makeUsageCollector: <T, U = T>(options: CollectorOptions<T, U>) => UsageCollector<T, U>;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionCollectorSet](./kibana-plugin-core-server.usagecollectioncollectorset.md)

## UsageCollectionCollectorSet interface


<b>Signature:</b>

```typescript
export interface UsageCollectionCollectorSet
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [makeStatsCollector](./kibana-plugin-core-server.usagecollectioncollectorset.makestatscollector.md) | <code>&lt;T, U&gt;(options: CollectorOptions&lt;T, U&gt;) =&gt; Collector&lt;T, U&gt;</code> | Create a Collector to report system stats |
| [makeUsageCollector](./kibana-plugin-core-server.usagecollectioncollectorset.makeusagecollector.md) | <code>&lt;T, U = T&gt;(options: CollectorOptions&lt;T, U&gt;) =&gt; UsageCollector&lt;T, U&gt;</code> | Create a Collector to report usage stats |
| [registerCollector](./kibana-plugin-core-server.usagecollectioncollectorset.registercollector.md) | <code>&lt;T, U&gt;(collector: Collector&lt;T, U&gt;) =&gt; void</code> | Register the collector generated by either of the <code>makeStatsCollector</code> or <code>makeUsageCollector</code> methods |

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionCollectorSet](./kibana-plugin-core-server.usagecollectioncollectorset.md) &gt; [registerCollector](./kibana-plugin-core-server.usagecollectioncollectorset.registercollector.md)

## UsageCollectionCollectorSet.registerCollector property

Register the collector generated by either of the `makeStatsCollector` or `makeUsageCollector` methods

<b>Signature:</b>

```typescript
registerCollector: <T, U>(collector: Collector<T, U>) => void;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionMakeSchemaFrom](./kibana-plugin-core-server.usagecollectionmakeschemafrom.md)

## UsageCollectionMakeSchemaFrom type

Schema definition of the returned object in the fetch method

<b>Signature:</b>

```typescript
export declare type MakeSchemaFrom<Base> = {
[Key in Purify<Extract<keyof Base, string>>]: Base[Key] extends Array<infer U> ? {
type: AllowedSchemaTypes;
} : Base[Key] extends object ? MakeSchemaFrom<Base[Key]> : {
type: AllowedSchemaTypes;
};
};
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionPurify](./kibana-plugin-core-server.usagecollectionpurify.md)

## UsageCollectionPurify type


<b>Signature:</b>

```typescript
export declare type Purify<T extends string> = {
[P in T]: T;
}[T];
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionSetup](./kibana-plugin-core-server.usagecollectionsetup.md)

## UsageCollectionSetup type


<b>Signature:</b>

```typescript
export declare type UsageCollectionSetup = Pick<UsageCollectionCollectorSet, 'makeStatsCollector' | 'makeUsageCollector' | 'registerCollector' | 'areAllCollectorsReady' | 'bulkFetchUsage' | 'toObject' | 'toApiFieldNames' | 'getFilteredCollectorSet' | 'isUsageCollector' | 'getCollectorByType'>;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [UsageCollectionUsageCollector](./kibana-plugin-core-server.usagecollectionusagecollector.md)

## UsageCollectionUsageCollector class

Collector for reporting Usage stats

<b>Signature:</b>

```typescript
export declare class UsageCollector<T = unknown, U = {
usage: {
[key: string]: T;
};
}> extends Collector<T, U>
```
Loading