forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge 'main' into lucene_snapshot_9_9
- Loading branch information
Showing
24 changed files
with
519 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 102877 | ||
summary: Add basic telelemetry for the inference feature | ||
area: Machine Learning | ||
type: enhancement | ||
issues: [] |
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,7 @@ | ||
pr: 102891 | ||
summary: "[Query Rules] Fix bug where combining the same metadata with text/numeric\ | ||
\ values leads to error" | ||
area: Application | ||
type: bug | ||
issues: | ||
- 102827 |
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
116 changes: 116 additions & 0 deletions
116
...n/core/src/main/java/org/elasticsearch/xpack/core/inference/InferenceFeatureSetUsage.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,116 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.inference; | ||
|
||
import org.elasticsearch.TransportVersion; | ||
import org.elasticsearch.TransportVersions; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.common.io.stream.Writeable; | ||
import org.elasticsearch.inference.TaskType; | ||
import org.elasticsearch.xcontent.ToXContentObject; | ||
import org.elasticsearch.xcontent.XContentBuilder; | ||
import org.elasticsearch.xpack.core.XPackFeatureSet; | ||
import org.elasticsearch.xpack.core.XPackField; | ||
|
||
import java.io.IOException; | ||
import java.util.Collection; | ||
import java.util.Objects; | ||
|
||
public class InferenceFeatureSetUsage extends XPackFeatureSet.Usage { | ||
|
||
public static class ModelStats implements ToXContentObject, Writeable { | ||
|
||
private final String service; | ||
private final TaskType taskType; | ||
private long count; | ||
|
||
public ModelStats(String service, TaskType taskType) { | ||
this(service, taskType, 0L); | ||
} | ||
|
||
public ModelStats(String service, TaskType taskType, long count) { | ||
this.service = service; | ||
this.taskType = taskType; | ||
this.count = count; | ||
} | ||
|
||
public ModelStats(ModelStats stats) { | ||
this(stats.service, stats.taskType, stats.count); | ||
} | ||
|
||
public ModelStats(StreamInput in) throws IOException { | ||
this.service = in.readString(); | ||
this.taskType = in.readEnum(TaskType.class); | ||
this.count = in.readLong(); | ||
} | ||
|
||
public void add() { | ||
count++; | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
builder.field("service", service); | ||
builder.field("task_type", taskType.name()); | ||
builder.field("count", count); | ||
builder.endObject(); | ||
return builder; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(service); | ||
out.writeEnum(taskType); | ||
out.writeLong(count); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
ModelStats that = (ModelStats) o; | ||
return count == that.count && Objects.equals(service, that.service) && taskType == that.taskType; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(service, taskType, count); | ||
} | ||
} | ||
|
||
private final Collection<ModelStats> modelStats; | ||
|
||
public InferenceFeatureSetUsage(Collection<ModelStats> modelStats) { | ||
super(XPackField.INFERENCE, true, true); | ||
this.modelStats = modelStats; | ||
} | ||
|
||
public InferenceFeatureSetUsage(StreamInput in) throws IOException { | ||
super(in); | ||
this.modelStats = in.readCollectionAsList(ModelStats::new); | ||
} | ||
|
||
@Override | ||
protected void innerXContent(XContentBuilder builder, Params params) throws IOException { | ||
super.innerXContent(builder, params); | ||
builder.xContentList("models", modelStats); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeCollection(modelStats); | ||
} | ||
|
||
@Override | ||
public TransportVersion getMinimalSupportedVersion() { | ||
return TransportVersions.INFERENCE_USAGE_ADDED; | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
...e/src/test/java/org/elasticsearch/xpack/core/inference/InferenceFeatureSetUsageTests.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,41 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.inference; | ||
|
||
import com.carrotsearch.randomizedtesting.generators.RandomStrings; | ||
|
||
import org.elasticsearch.common.io.stream.Writeable; | ||
import org.elasticsearch.inference.TaskType; | ||
import org.elasticsearch.test.AbstractWireSerializingTestCase; | ||
|
||
import java.io.IOException; | ||
|
||
public class InferenceFeatureSetUsageTests extends AbstractWireSerializingTestCase<InferenceFeatureSetUsage.ModelStats> { | ||
|
||
@Override | ||
protected Writeable.Reader<InferenceFeatureSetUsage.ModelStats> instanceReader() { | ||
return InferenceFeatureSetUsage.ModelStats::new; | ||
} | ||
|
||
@Override | ||
protected InferenceFeatureSetUsage.ModelStats createTestInstance() { | ||
RandomStrings.randomAsciiLettersOfLength(random(), 10); | ||
return new InferenceFeatureSetUsage.ModelStats( | ||
randomIdentifier(), | ||
TaskType.values()[randomInt(TaskType.values().length - 1)], | ||
randomInt(10) | ||
); | ||
} | ||
|
||
@Override | ||
protected InferenceFeatureSetUsage.ModelStats mutateInstance(InferenceFeatureSetUsage.ModelStats modelStats) throws IOException { | ||
InferenceFeatureSetUsage.ModelStats newModelStats = new InferenceFeatureSetUsage.ModelStats(modelStats); | ||
newModelStats.add(); | ||
return newModelStats; | ||
} | ||
} |
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
Oops, something went wrong.