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.
Scripting: Per context stats in
script
in _nodes/stats (elastic#59266)
Updated `_nodes/stats`: * Update `script` in `_node/stats` to include stats per context: ``` "script": { "compilations": 1, "cache_evictions": 0, "compilation_limit_triggered": 0, "contexts":[ { "context": "aggregation_selector", "compilations": 0, "cache_evictions": 0, "compilation_limit_triggered": 0 }, ``` Refs: elastic#50152 Backport: elastic#59625
- Loading branch information
1 parent
f4caadd
commit 94e213d
Showing
9 changed files
with
196 additions
and
44 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
97 changes: 97 additions & 0 deletions
97
server/src/main/java/org/elasticsearch/script/ScriptContextStats.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,97 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch 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. | ||
*/ | ||
|
||
package org.elasticsearch.script; | ||
|
||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.common.io.stream.Writeable; | ||
import org.elasticsearch.common.xcontent.ToXContentFragment; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
public class ScriptContextStats implements Writeable, ToXContentFragment, Comparable<ScriptContextStats> { | ||
private final String context; | ||
private final long compilations; | ||
private final long cacheEvictions; | ||
private final long compilationLimitTriggered; | ||
|
||
public ScriptContextStats(String context, long compilations, long cacheEvictions, long compilationLimitTriggered) { | ||
this.context = Objects.requireNonNull(context); | ||
this.compilations = compilations; | ||
this.cacheEvictions = cacheEvictions; | ||
this.compilationLimitTriggered = compilationLimitTriggered; | ||
} | ||
|
||
public ScriptContextStats(StreamInput in) throws IOException { | ||
context = in.readString(); | ||
compilations = in.readVLong(); | ||
cacheEvictions = in.readVLong(); | ||
compilationLimitTriggered = in.readVLong(); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(context); | ||
out.writeVLong(compilations); | ||
out.writeVLong(cacheEvictions); | ||
out.writeVLong(compilationLimitTriggered); | ||
} | ||
|
||
public String getContext() { | ||
return context; | ||
} | ||
|
||
public long getCompilations() { | ||
return compilations; | ||
} | ||
|
||
public long getCacheEvictions() { | ||
return cacheEvictions; | ||
} | ||
|
||
public long getCompilationLimitTriggered() { | ||
return compilationLimitTriggered; | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
builder.field(Fields.CONTEXT, getContext()); | ||
builder.field(Fields.COMPILATIONS, getCompilations()); | ||
builder.field(Fields.CACHE_EVICTIONS, getCacheEvictions()); | ||
builder.field(Fields.COMPILATION_LIMIT_TRIGGERED, getCompilationLimitTriggered()); | ||
builder.endObject(); | ||
return builder; | ||
} | ||
|
||
@Override | ||
public int compareTo(ScriptContextStats o) { | ||
return this.context.compareTo(o.context); | ||
} | ||
|
||
static final class Fields { | ||
static final String CONTEXT = "context"; | ||
static final String COMPILATIONS = "compilations"; | ||
static final String CACHE_EVICTIONS = "cache_evictions"; | ||
static final String COMPILATION_LIMIT_TRIGGERED = "compilation_limit_triggered"; | ||
} | ||
} |
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