-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Usage Collection] [schema] Support spreads +
canvas
definition (#7…
- Loading branch information
Showing
14 changed files
with
457 additions
and
55 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
...kbn-telemetry-tools/src/tools/__fixture__/parsed_schema_defined_with_spreads_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,69 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { SyntaxKind } from 'typescript'; | ||
import { ParsedUsageCollection } from '../ts_parser'; | ||
|
||
export const parsedSchemaDefinedWithSpreadsCollector: ParsedUsageCollection = [ | ||
'src/fixtures/telemetry_collectors/schema_defined_with_spreads_collector.ts', | ||
{ | ||
collectorName: 'schema_defined_with_spreads', | ||
schema: { | ||
value: { | ||
flat: { | ||
type: 'keyword', | ||
}, | ||
my_str: { | ||
type: 'text', | ||
}, | ||
my_objects: { | ||
total: { | ||
type: 'number', | ||
}, | ||
type: { | ||
type: 'boolean', | ||
}, | ||
}, | ||
}, | ||
}, | ||
fetch: { | ||
typeName: 'Usage', | ||
typeDescriptor: { | ||
flat: { | ||
kind: SyntaxKind.StringKeyword, | ||
type: 'StringKeyword', | ||
}, | ||
my_str: { | ||
kind: SyntaxKind.StringKeyword, | ||
type: 'StringKeyword', | ||
}, | ||
my_objects: { | ||
total: { | ||
kind: SyntaxKind.NumberKeyword, | ||
type: 'NumberKeyword', | ||
}, | ||
type: { | ||
kind: SyntaxKind.BooleanKeyword, | ||
type: 'BooleanKeyword', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
]; |
47 changes: 47 additions & 0 deletions
47
packages/kbn-telemetry-tools/src/tools/__snapshots__/extract_collectors.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 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
77 changes: 77 additions & 0 deletions
77
src/fixtures/telemetry_collectors/schema_defined_with_spreads_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,77 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import { CollectorSet, MakeSchemaFrom } from '../../plugins/usage_collection/server/collector'; | ||
import { loggerMock } from '../../core/server/logging/logger.mock'; | ||
|
||
const { makeUsageCollector } = new CollectorSet({ | ||
logger: loggerMock.create(), | ||
maximumWaitTimeForAllCollectorsInS: 0, | ||
}); | ||
|
||
interface MyObject { | ||
total: number; | ||
type: boolean; | ||
} | ||
|
||
interface Usage { | ||
flat?: string; | ||
my_str?: string; | ||
my_objects: MyObject; | ||
} | ||
|
||
const SOME_NUMBER: number = 123; | ||
|
||
const someSchema: MakeSchemaFrom<Pick<Usage, 'flat' | 'my_str'>> = { | ||
flat: { | ||
type: 'keyword', | ||
}, | ||
my_str: { | ||
type: 'text', | ||
}, | ||
}; | ||
|
||
const someOtherSchema: MakeSchemaFrom<Pick<Usage, 'my_objects'>> = { | ||
my_objects: { | ||
total: { | ||
type: 'number', | ||
}, | ||
type: { type: 'boolean' }, | ||
}, | ||
}; | ||
|
||
export const myCollector = makeUsageCollector<Usage>({ | ||
type: 'schema_defined_with_spreads', | ||
isReady: () => true, | ||
fetch() { | ||
const testString = '123'; | ||
|
||
return { | ||
flat: 'hello', | ||
my_str: testString, | ||
my_objects: { | ||
total: SOME_NUMBER, | ||
type: true, | ||
}, | ||
}; | ||
}, | ||
schema: { | ||
...someSchema, | ||
...someOtherSchema, | ||
}, | ||
}); |
Oops, something went wrong.