Skip to content

add creation and last updated timestamps #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
2 changes: 1 addition & 1 deletion hypertrace-graphql-platform/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ dependencies {
api("org.hypertrace.config.service:spaces-config-service-api:0.1.1")
api("org.hypertrace.config.service:labels-config-service-api:0.1.15")
api("org.hypertrace.config.service:label-application-rule-config-service-api:0.1.16")
api("org.hypertrace.config.service:span-processing-config-service-api:0.1.23")
api("org.hypertrace.config.service:span-processing-config-service-api:0.1.25")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.hypertrace.graphql.spanprocessing.request.mutation.ExcludeSpanUpdateRuleRequest;
import org.hypertrace.graphql.spanprocessing.schema.mutation.ExcludeSpanRuleCreate;
import org.hypertrace.graphql.spanprocessing.schema.mutation.ExcludeSpanRuleUpdate;
import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRuleFilter;
import org.hypertrace.span.processing.config.service.v1.CreateExcludeSpanRuleRequest;
import org.hypertrace.span.processing.config.service.v1.DeleteExcludeSpanRuleRequest;
import org.hypertrace.span.processing.config.service.v1.ExcludeSpanRuleInfo;
Expand All @@ -32,6 +31,7 @@ private ExcludeSpanRuleInfo convertInput(ExcludeSpanRuleCreate excludeSpanRuleCr
return ExcludeSpanRuleInfo.newBuilder()
.setName(excludeSpanRuleCreate.name())
.setFilter(this.filterConverter.convert(excludeSpanRuleCreate.spanFilter()))
.setDisabled(excludeSpanRuleCreate.disabled())
.build();
}

Expand All @@ -42,20 +42,12 @@ UpdateExcludeSpanRuleRequest convert(ExcludeSpanUpdateRuleRequest request) {
}

private UpdateExcludeSpanRule convertInput(ExcludeSpanRuleUpdate excludeSpanRuleUpdate) {
UpdateExcludeSpanRule.Builder updateExcludeSpanRuleBuilder =
UpdateExcludeSpanRule.newBuilder().setId(excludeSpanRuleUpdate.id());
String name = excludeSpanRuleUpdate.name();
SpanProcessingRuleFilter filter = excludeSpanRuleUpdate.spanFilter();
if (name != null) {
updateExcludeSpanRuleBuilder =
updateExcludeSpanRuleBuilder.setName(excludeSpanRuleUpdate.name());
}
if (filter != null) {
updateExcludeSpanRuleBuilder =
updateExcludeSpanRuleBuilder.setFilter(
this.filterConverter.convert(excludeSpanRuleUpdate.spanFilter()));
}
return updateExcludeSpanRuleBuilder.build();
return UpdateExcludeSpanRule.newBuilder()
.setId(excludeSpanRuleUpdate.id())
.setName(excludeSpanRuleUpdate.name())
.setFilter(this.filterConverter.convert(excludeSpanRuleUpdate.spanFilter()))
.setDisabled(excludeSpanRuleUpdate.disabled())
.build();
}

DeleteExcludeSpanRuleRequest convert(ExcludeSpanDeleteRuleRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,31 @@ public class ConfigServiceSpanProcessingResponseConverter {
}

Single<ExcludeSpanRuleResultSet> convert(GetAllExcludeSpanRulesResponse response) {
return this.convertResultSet(response.getRulesList());
return this.convertResultSet(response.getRuleDetailsList());
}

private Maybe<ExcludeSpanRule> convertOrDrop(
org.hypertrace.span.processing.config.service.v1.ExcludeSpanRule rule) {
org.hypertrace.span.processing.config.service.v1.ExcludeSpanRuleDetails ruleDetails) {
return this.ruleConverter
.convert(rule)
.convert(ruleDetails)
.doOnError(error -> log.error("Error converting ExcludeSpanRule", error))
.onErrorComplete();
}

private Single<ExcludeSpanRuleResultSet> convertResultSet(
List<org.hypertrace.span.processing.config.service.v1.ExcludeSpanRule> rules) {
return Observable.fromIterable(rules)
List<org.hypertrace.span.processing.config.service.v1.ExcludeSpanRuleDetails> ruleDetails) {
return Observable.fromIterable(ruleDetails)
.concatMapMaybe(this::convertOrDrop)
.toList()
.map(ConvertedExcludeSpanRuleResultSet::new);
}

Single<ExcludeSpanRule> convert(CreateExcludeSpanRuleResponse response) {
return this.ruleConverter.convert(response.getRule());
return this.ruleConverter.convert(response.getRuleDetails());
}

Single<ExcludeSpanRule> convert(UpdateExcludeSpanRuleResponse response) {
return this.ruleConverter.convert(response.getRule());
return this.ruleConverter.convert(response.getRuleDetails());
}

Single<DeleteSpanProcessingRuleResponse> convert(DeleteExcludeSpanRuleResponse response) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.hypertrace.graphql.spanprocessing.dao;

import io.reactivex.rxjava3.core.Single;
import java.time.Instant;
import javax.inject.Inject;
import lombok.Value;
import lombok.experimental.Accessors;
Expand All @@ -10,7 +11,7 @@

class ConfigServiceSpanProcessingRuleConverter
implements Converter<
org.hypertrace.span.processing.config.service.v1.ExcludeSpanRule, ExcludeSpanRule> {
org.hypertrace.span.processing.config.service.v1.ExcludeSpanRuleDetails, ExcludeSpanRule> {

private final ConfigServiceSpanFilterConverter filterConverter;

Expand All @@ -21,13 +22,22 @@ class ConfigServiceSpanProcessingRuleConverter

@Override
public Single<ExcludeSpanRule> convert(
org.hypertrace.span.processing.config.service.v1.ExcludeSpanRule rule) {
org.hypertrace.span.processing.config.service.v1.ExcludeSpanRuleDetails ruleDetails) {
return this.filterConverter
.convert(rule.getRuleInfo().getFilter())
.convert(ruleDetails.getRule().getRuleInfo().getFilter())
.map(
spanProcessingRuleFilter ->
new ConvertedExcludeSpanRule(
rule.getId(), rule.getRuleInfo().getName(), spanProcessingRuleFilter));
ruleDetails.getRule().getId(),
ruleDetails.getRule().getRuleInfo().getName(),
spanProcessingRuleFilter,
ruleDetails.getRule().getRuleInfo().getDisabled(),
Instant.ofEpochSecond(
ruleDetails.getMetadata().getCreationTimestamp().getSeconds(),
ruleDetails.getMetadata().getCreationTimestamp().getNanos()),
Instant.ofEpochSecond(
ruleDetails.getMetadata().getLastUpdatedTimestamp().getSeconds(),
ruleDetails.getMetadata().getLastUpdatedTimestamp().getNanos())));
}

@Value
Expand All @@ -36,5 +46,8 @@ private static class ConvertedExcludeSpanRule implements ExcludeSpanRule {
String id;
String name;
SpanProcessingRuleFilter spanFilter;
boolean disabled;
Instant creationTime;
Instant lastUpdatedTime;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public List<Module> jacksonModules() {
private static class DefaultExcludeSpanRuleCreate implements ExcludeSpanRuleCreate {
String name;
SpanProcessingRuleFilter spanFilter;
boolean disabled;
}

@Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ private static class DefaultExcludeSpanRuleUpdate implements ExcludeSpanRuleUpda
String id;
String name;
SpanProcessingRuleFilter spanFilter;
boolean disabled;
}

@Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ static final class SpanProcessingCreateRuleMutatorImpl

@Override
public CompletableFuture<ExcludeSpanRule> get(DataFetchingEnvironment environment) {

return this.requestBuilder
.build(environment.getContext(), environment.getArguments())
.flatMap(this.spanProcessingRuleDao::createRule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ static final class SpanProcessingUpdateRuleMutatorImpl

@Override
public CompletableFuture<ExcludeSpanRule> get(DataFetchingEnvironment environment) {

return this.requestBuilder
.build(environment.getContext(), environment.getArguments())
.flatMap(this.spanProcessingRuleDao::updateRule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import graphql.annotations.annotationTypes.GraphQLField;
import graphql.annotations.annotationTypes.GraphQLName;
import graphql.annotations.annotationTypes.GraphQLNonNull;
import org.hypertrace.core.graphql.common.schema.id.Identifiable;
import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRuleFilter;

Expand All @@ -12,6 +13,7 @@ public interface ExcludeSpanRuleUpdate extends Identifiable {

String NAME_KEY = "name";
String SPAN_PROCESSING_FILTER_KEY = "spanFilter";
String DISABLED_KEY = "disabled";

@GraphQLField
@GraphQLName(NAME_KEY)
Expand All @@ -20,4 +22,9 @@ public interface ExcludeSpanRuleUpdate extends Identifiable {
@GraphQLField
@GraphQLName(SPAN_PROCESSING_FILTER_KEY)
SpanProcessingRuleFilter spanFilter();

@GraphQLField
@GraphQLName(DISABLED_KEY)
@GraphQLNonNull
boolean disabled();
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
package org.hypertrace.graphql.spanprocessing.schema.rule;

import graphql.annotations.annotationTypes.GraphQLField;
import graphql.annotations.annotationTypes.GraphQLName;
import graphql.annotations.annotationTypes.GraphQLNonNull;
import java.time.Instant;
import org.hypertrace.core.graphql.common.schema.id.Identifiable;

@GraphQLName(ExcludeSpanRule.TYPE_NAME)
public interface ExcludeSpanRule extends Identifiable, ExcludeSpanRuleInfo {
String TYPE_NAME = "ExcludeSpanRule";

String CREATION_TIME_KEY = "creationTime";
String LAST_UPDATED_TIME_KEY = "lastUpdatedTime";

@GraphQLField
@GraphQLName(CREATION_TIME_KEY)
@GraphQLNonNull
Instant creationTime();

@GraphQLField
@GraphQLName(LAST_UPDATED_TIME_KEY)
@GraphQLNonNull
Instant lastUpdatedTime();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public interface ExcludeSpanRuleInfo {

String NAME_KEY = "name";
String SPAN_FILTER_KEY = "spanFilter";
String DISABLED_KEY = "disabled";

@GraphQLField
@GraphQLName(NAME_KEY)
Expand All @@ -21,4 +22,9 @@ public interface ExcludeSpanRuleInfo {
@GraphQLName(SPAN_FILTER_KEY)
@GraphQLNonNull
SpanProcessingRuleFilter spanFilter();

@GraphQLField
@GraphQLName(DISABLED_KEY)
@GraphQLNonNull
boolean disabled();
}