-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently we just record the number of flattened fields defined in the mappings.
- Loading branch information
1 parent
33a7f06
commit 0724ca6
Showing
4 changed files
with
159 additions
and
3 deletions.
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
47 changes: 47 additions & 0 deletions
47
...e/src/test/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsageTests.java
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,47 @@ | ||
/* | ||
* 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. | ||
*/ | ||
package org.elasticsearch.xpack.core.flattened; | ||
|
||
import org.elasticsearch.common.io.stream.Writeable; | ||
import org.elasticsearch.test.AbstractWireSerializingTestCase; | ||
|
||
import java.io.IOException; | ||
|
||
public class FlattenedFeatureSetUsageTests extends AbstractWireSerializingTestCase<FlattenedFeatureSetUsage> { | ||
|
||
@Override | ||
protected FlattenedFeatureSetUsage createTestInstance() { | ||
return new FlattenedFeatureSetUsage(randomBoolean(), randomBoolean(), randomIntBetween(0, 1000)); | ||
} | ||
|
||
@Override | ||
protected FlattenedFeatureSetUsage mutateInstance(FlattenedFeatureSetUsage instance) throws IOException { | ||
|
||
boolean available = instance.available(); | ||
boolean enabled = instance.enabled(); | ||
int fieldCount = instance.fieldCount(); | ||
|
||
switch (between(0, 2)) { | ||
case 0: | ||
available = !available; | ||
break; | ||
case 1: | ||
enabled = !enabled; | ||
break; | ||
case 2: | ||
fieldCount = randomValueOtherThan(instance.fieldCount(), () -> randomIntBetween(0, 1000)); | ||
break; | ||
} | ||
|
||
return new FlattenedFeatureSetUsage(available, enabled, fieldCount); | ||
} | ||
|
||
@Override | ||
protected Writeable.Reader<FlattenedFeatureSetUsage> instanceReader() { | ||
return FlattenedFeatureSetUsage::new; | ||
} | ||
|
||
} |
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
41 changes: 41 additions & 0 deletions
41
x-pack/plugin/src/test/resources/rest-api-spec/test/flattened/20_flattened_stats.yml
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,41 @@ | ||
setup: | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: "telemetry for flattened fields was added in 8.0" | ||
|
||
--- | ||
"Usage stats for flattened fields": | ||
- do: | ||
xpack.usage: {} | ||
|
||
- match: { flattened.available: true } | ||
- match: { flattened.enabled: true } | ||
- match: { flattened.field_count: 0 } | ||
|
||
- do: | ||
indices.create: | ||
index: test-index1 | ||
body: | ||
mappings: | ||
properties: | ||
flattened_1: | ||
type: flattened | ||
|
||
- do: | ||
indices.create: | ||
index: test-index2 | ||
body: | ||
mappings: | ||
properties: | ||
flattened_2: | ||
type: flattened | ||
flattened_3: | ||
type: flattened | ||
ignore_above: 10 | ||
|
||
- do: | ||
xpack.usage: {} | ||
|
||
- match: { flattened.available: true } | ||
- match: { flattened.enabled: true } | ||
- match: { flattened.field_count: 3 } |