Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/en/changes/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
* `Scope` in the Entity of Metrics query v1 protocol is not required and automatical correction. The scope is determined based on the metric itself.
* Add explicit `ReadTimeout` for ConsulConfigurationWatcher to avoid `IllegalArgumentException: Cache watchInterval=10sec >= networkClientReadTimeout=10000ms`.
* Fix `DurationUtils.getDurationPoints` exceed, when `startTimeBucket` equals `endTimeBucket`.
* Read the name and properties of the instance only in `getInstance` service.

#### UI

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@

package org.apache.skywalking.library.elasticsearch.requests.search;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.ImmutableMap;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.skywalking.library.elasticsearch.requests.search.aggregation.Aggregation;

import java.util.Set;

/**
* Represents the criteria when searching documents in ElasticSearch.
*
Expand All @@ -36,6 +39,8 @@ public final class Search {
private final Query query;
private final Sorts sort;
private final ImmutableMap<String, Aggregation> aggregations;
@JsonProperty("_source")
private final Set<String> source;

public static SearchBuilder builder() {
return new SearchBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.apache.skywalking.library.elasticsearch.requests.search.aggregation.Aggregation;
import org.apache.skywalking.library.elasticsearch.requests.search.aggregation.AggregationBuilder;

import java.util.Set;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;
Expand All @@ -32,11 +34,19 @@ public final class SearchBuilder {
private Integer size;
private QueryBuilder queryBuilder;
private ImmutableList.Builder<Sort> sort;
private Set<String> source;
private ImmutableMap.Builder<String, Aggregation> aggregations;

SearchBuilder() {
}

public SearchBuilder source(Set<String> source) {
requireNonNull(source, "source");
checkArgument(source.size() > 0, "source size must be > 0, but was %s", source.size());
this.source = source;
return this;
}

public SearchBuilder from(Integer from) {
requireNonNull(from, "from");
checkArgument(from >= 0, "from must be >= 0, but was %s", from);
Expand Down Expand Up @@ -97,7 +107,7 @@ public Search build() {
}

return new Search(
from, size, query, sorts, aggregations
from, size, query, sorts, aggregations, source
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query;

import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
Expand Down Expand Up @@ -72,6 +73,9 @@ public class MetadataQueryEsDAO extends EsDAO implements IMetadataQueryDAO {
private boolean aliasNameInit = false;
private final int layerSize;

private static final Set<String> INSTANCE_TRAFFIC_COMPACT_TAGS = ImmutableSet.of(InstanceTraffic.NAME,
InstanceTraffic.PROPERTIES);

public MetadataQueryEsDAO(
ElasticSearchClient client,
StorageModuleElasticsearchConfig config) {
Expand Down Expand Up @@ -189,7 +193,8 @@ public ServiceInstance getInstance(final String instanceId) throws IOException {
final BoolQueryBuilder query =
Query.bool()
.must(Query.term("_id", id));
final SearchBuilder search = Search.builder().query(query).size(1);
final SearchBuilder search = Search.builder().query(query).size(1)
.source(INSTANCE_TRAFFIC_COMPACT_TAGS);

final SearchResponse response = getClient().search(index, search.build());
final List<ServiceInstance> instances = buildInstances(response);
Expand Down