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.
[ML] Create and inject APM Inference Metrics (elastic#111293)
We are migrating from in-memory cumulative counter to an Time Series Data Stream delta counter. The goal is to avoid metrics suddenly dropping to zero when a node restarts, hopefully increasing accuracy of the metric. Co-authored-by: Jonathan Buttner <[email protected]>
- Loading branch information
1 parent
38f301a
commit 1a939e9
Showing
12 changed files
with
142 additions
and
307 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
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
49 changes: 49 additions & 0 deletions
49
...nference/src/main/java/org/elasticsearch/xpack/inference/telemetry/ApmInferenceStats.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,49 @@ | ||
/* | ||
* 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.inference.telemetry; | ||
|
||
import org.elasticsearch.inference.Model; | ||
import org.elasticsearch.telemetry.metric.LongCounter; | ||
import org.elasticsearch.telemetry.metric.MeterRegistry; | ||
|
||
import java.util.HashMap; | ||
import java.util.Objects; | ||
|
||
public class ApmInferenceStats implements InferenceStats { | ||
private final LongCounter inferenceAPMRequestCounter; | ||
|
||
public ApmInferenceStats(LongCounter inferenceAPMRequestCounter) { | ||
this.inferenceAPMRequestCounter = Objects.requireNonNull(inferenceAPMRequestCounter); | ||
} | ||
|
||
@Override | ||
public void incrementRequestCount(Model model) { | ||
var service = model.getConfigurations().getService(); | ||
var taskType = model.getTaskType(); | ||
var modelId = model.getServiceSettings().modelId(); | ||
|
||
var attributes = new HashMap<String, Object>(5); | ||
attributes.put("service", service); | ||
attributes.put("task_type", taskType.toString()); | ||
if (modelId != null) { | ||
attributes.put("model_id", modelId); | ||
} | ||
|
||
inferenceAPMRequestCounter.incrementBy(1, attributes); | ||
} | ||
|
||
public static ApmInferenceStats create(MeterRegistry meterRegistry) { | ||
return new ApmInferenceStats( | ||
meterRegistry.registerLongCounter( | ||
"es.inference.requests.count.total", | ||
"Inference API request counts for a particular service, task type, model ID", | ||
"operations" | ||
) | ||
); | ||
} | ||
} |
47 changes: 0 additions & 47 deletions
47
...nference/src/main/java/org/elasticsearch/xpack/inference/telemetry/InferenceAPMStats.java
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
30 changes: 0 additions & 30 deletions
30
x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/telemetry/Stats.java
This file was deleted.
Oops, something went wrong.
57 changes: 0 additions & 57 deletions
57
.../plugin/inference/src/main/java/org/elasticsearch/xpack/inference/telemetry/StatsMap.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.