diff --git a/hypertrace-graphql-platform/build.gradle.kts b/hypertrace-graphql-platform/build.gradle.kts index 5743b796..c2734516 100644 --- a/hypertrace-graphql-platform/build.gradle.kts +++ b/hypertrace-graphql-platform/build.gradle.kts @@ -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.25") + api("org.hypertrace.config.service:span-processing-config-service-api:0.1.26") } } diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/ConfigServiceSpanProcessingRequestConverter.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/ConfigServiceSpanProcessingRequestConverter.java index 685f9210..4a46403d 100644 --- a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/ConfigServiceSpanProcessingRequestConverter.java +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/ConfigServiceSpanProcessingRequestConverter.java @@ -1,14 +1,25 @@ package org.hypertrace.graphql.spanprocessing.dao; import javax.inject.Inject; +import org.hypertrace.graphql.spanprocessing.request.mutation.ApiNamingCreateRuleRequest; +import org.hypertrace.graphql.spanprocessing.request.mutation.ApiNamingDeleteRuleRequest; +import org.hypertrace.graphql.spanprocessing.request.mutation.ApiNamingUpdateRuleRequest; import org.hypertrace.graphql.spanprocessing.request.mutation.ExcludeSpanCreateRuleRequest; import org.hypertrace.graphql.spanprocessing.request.mutation.ExcludeSpanDeleteRuleRequest; import org.hypertrace.graphql.spanprocessing.request.mutation.ExcludeSpanUpdateRuleRequest; +import org.hypertrace.graphql.spanprocessing.schema.mutation.ApiNamingRuleCreate; +import org.hypertrace.graphql.spanprocessing.schema.mutation.ApiNamingRuleUpdate; import org.hypertrace.graphql.spanprocessing.schema.mutation.ExcludeSpanRuleCreate; import org.hypertrace.graphql.spanprocessing.schema.mutation.ExcludeSpanRuleUpdate; +import org.hypertrace.span.processing.config.service.v1.ApiNamingRuleConfig; +import org.hypertrace.span.processing.config.service.v1.ApiNamingRuleInfo; +import org.hypertrace.span.processing.config.service.v1.CreateApiNamingRuleRequest; import org.hypertrace.span.processing.config.service.v1.CreateExcludeSpanRuleRequest; +import org.hypertrace.span.processing.config.service.v1.DeleteApiNamingRuleRequest; import org.hypertrace.span.processing.config.service.v1.DeleteExcludeSpanRuleRequest; import org.hypertrace.span.processing.config.service.v1.ExcludeSpanRuleInfo; +import org.hypertrace.span.processing.config.service.v1.UpdateApiNamingRule; +import org.hypertrace.span.processing.config.service.v1.UpdateApiNamingRuleRequest; import org.hypertrace.span.processing.config.service.v1.UpdateExcludeSpanRule; import org.hypertrace.span.processing.config.service.v1.UpdateExcludeSpanRuleRequest; @@ -53,4 +64,48 @@ private UpdateExcludeSpanRule convertInput(ExcludeSpanRuleUpdate excludeSpanRule DeleteExcludeSpanRuleRequest convert(ExcludeSpanDeleteRuleRequest request) { return DeleteExcludeSpanRuleRequest.newBuilder().setId(request.id()).build(); } + + CreateApiNamingRuleRequest convert(ApiNamingCreateRuleRequest request) { + return CreateApiNamingRuleRequest.newBuilder() + .setRuleInfo(convertInput(request.createInput())) + .build(); + } + + private org.hypertrace.span.processing.config.service.v1.ApiNamingRuleInfo convertInput( + ApiNamingRuleCreate apiNamingRuleCreate) { + return ApiNamingRuleInfo.newBuilder() + .setName(apiNamingRuleCreate.name()) + .setFilter(this.filterConverter.convert(apiNamingRuleCreate.spanFilter())) + .setDisabled(apiNamingRuleCreate.disabled()) + .setRuleConfig( + ApiNamingRuleConfig.newBuilder() + .setRegex(apiNamingRuleCreate.regex()) + .setValue(apiNamingRuleCreate.value()) + .build()) + .build(); + } + + UpdateApiNamingRuleRequest convert(ApiNamingUpdateRuleRequest request) { + return UpdateApiNamingRuleRequest.newBuilder() + .setRule(convertInput(request.updateInput())) + .build(); + } + + private UpdateApiNamingRule convertInput(ApiNamingRuleUpdate apiNamingRuleUpdate) { + return UpdateApiNamingRule.newBuilder() + .setId(apiNamingRuleUpdate.id()) + .setName(apiNamingRuleUpdate.name()) + .setFilter(this.filterConverter.convert(apiNamingRuleUpdate.spanFilter())) + .setDisabled(apiNamingRuleUpdate.disabled()) + .setRuleConfig( + ApiNamingRuleConfig.newBuilder() + .setRegex(apiNamingRuleUpdate.regex()) + .setValue(apiNamingRuleUpdate.value()) + .build()) + .build(); + } + + DeleteApiNamingRuleRequest convert(ApiNamingDeleteRuleRequest request) { + return DeleteApiNamingRuleRequest.newBuilder().setId(request.id()).build(); + } } diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/ConfigServiceSpanProcessingResponseConverter.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/ConfigServiceSpanProcessingResponseConverter.java index 7eb44fa8..1e37f318 100644 --- a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/ConfigServiceSpanProcessingResponseConverter.java +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/ConfigServiceSpanProcessingResponseConverter.java @@ -9,11 +9,17 @@ import lombok.experimental.Accessors; import lombok.extern.slf4j.Slf4j; import org.hypertrace.graphql.spanprocessing.schema.mutation.DeleteSpanProcessingRuleResponse; +import org.hypertrace.graphql.spanprocessing.schema.query.ApiNamingRuleResultSet; import org.hypertrace.graphql.spanprocessing.schema.query.ExcludeSpanRuleResultSet; +import org.hypertrace.graphql.spanprocessing.schema.rule.ApiNamingRule; import org.hypertrace.graphql.spanprocessing.schema.rule.ExcludeSpanRule; +import org.hypertrace.span.processing.config.service.v1.CreateApiNamingRuleResponse; import org.hypertrace.span.processing.config.service.v1.CreateExcludeSpanRuleResponse; +import org.hypertrace.span.processing.config.service.v1.DeleteApiNamingRuleResponse; import org.hypertrace.span.processing.config.service.v1.DeleteExcludeSpanRuleResponse; +import org.hypertrace.span.processing.config.service.v1.GetAllApiNamingRulesResponse; import org.hypertrace.span.processing.config.service.v1.GetAllExcludeSpanRulesResponse; +import org.hypertrace.span.processing.config.service.v1.UpdateApiNamingRuleResponse; import org.hypertrace.span.processing.config.service.v1.UpdateExcludeSpanRuleResponse; @Slf4j @@ -28,7 +34,11 @@ public class ConfigServiceSpanProcessingResponseConverter { } Single convert(GetAllExcludeSpanRulesResponse response) { - return this.convertResultSet(response.getRuleDetailsList()); + return this.convertExcludeSpanRuleResultSet(response.getRuleDetailsList()); + } + + Single convert(GetAllApiNamingRulesResponse response) { + return this.convertApiNamingRuleResultSet(response.getRuleDetailsList()); } private Maybe convertOrDrop( @@ -39,7 +49,15 @@ private Maybe convertOrDrop( .onErrorComplete(); } - private Single convertResultSet( + private Maybe convertOrDrop( + org.hypertrace.span.processing.config.service.v1.ApiNamingRuleDetails ruleDetails) { + return this.ruleConverter + .convert(ruleDetails) + .doOnError(error -> log.error("Error converting ExcludeSpanRule", error)) + .onErrorComplete(); + } + + private Single convertExcludeSpanRuleResultSet( List ruleDetails) { return Observable.fromIterable(ruleDetails) .concatMapMaybe(this::convertOrDrop) @@ -47,6 +65,14 @@ private Single convertResultSet( .map(ConvertedExcludeSpanRuleResultSet::new); } + private Single convertApiNamingRuleResultSet( + List ruleDetails) { + return Observable.fromIterable(ruleDetails) + .concatMapMaybe(this::convertOrDrop) + .toList() + .map(ConvertedApiNamingRuleResultSet::new); + } + Single convert(CreateExcludeSpanRuleResponse response) { return this.ruleConverter.convert(response.getRuleDetails()); } @@ -59,6 +85,18 @@ Single convert(DeleteExcludeSpanRuleResponse r return Single.just(new DefaultDeleteSpanProcessingRuleResponse(true)); } + Single convert(CreateApiNamingRuleResponse response) { + return this.ruleConverter.convert(response.getRuleDetails()); + } + + Single convert(UpdateApiNamingRuleResponse response) { + return this.ruleConverter.convert(response.getRuleDetails()); + } + + Single convert(DeleteApiNamingRuleResponse response) { + return Single.just(new DefaultDeleteSpanProcessingRuleResponse(true)); + } + @Value @Accessors(fluent = true) private static class DefaultDeleteSpanProcessingRuleResponse @@ -79,4 +117,18 @@ private ConvertedExcludeSpanRuleResultSet(List results) { this.total = results.size(); } } + + @Value + @Accessors(fluent = true) + private static class ConvertedApiNamingRuleResultSet implements ApiNamingRuleResultSet { + List results; + long total; + long count; + + private ConvertedApiNamingRuleResultSet(List results) { + this.results = results; + this.count = results.size(); + this.total = results.size(); + } + } } diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/ConfigServiceSpanProcessingRuleConverter.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/ConfigServiceSpanProcessingRuleConverter.java index fb076791..d83e5532 100644 --- a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/ConfigServiceSpanProcessingRuleConverter.java +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/ConfigServiceSpanProcessingRuleConverter.java @@ -5,13 +5,12 @@ import javax.inject.Inject; import lombok.Value; import lombok.experimental.Accessors; -import org.hypertrace.core.graphql.common.utils.Converter; +import org.hypertrace.graphql.spanprocessing.schema.rule.ApiNamingRule; import org.hypertrace.graphql.spanprocessing.schema.rule.ExcludeSpanRule; import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRuleFilter; +import org.hypertrace.span.processing.config.service.v1.ApiNamingRuleDetails; -class ConfigServiceSpanProcessingRuleConverter - implements Converter< - org.hypertrace.span.processing.config.service.v1.ExcludeSpanRuleDetails, ExcludeSpanRule> { +class ConfigServiceSpanProcessingRuleConverter { private final ConfigServiceSpanFilterConverter filterConverter; @@ -20,7 +19,6 @@ class ConfigServiceSpanProcessingRuleConverter this.filterConverter = filterConverter; } - @Override public Single convert( org.hypertrace.span.processing.config.service.v1.ExcludeSpanRuleDetails ruleDetails) { return this.filterConverter @@ -40,6 +38,26 @@ public Single convert( ruleDetails.getMetadata().getLastUpdatedTimestamp().getNanos()))); } + public Single convert(ApiNamingRuleDetails ruleDetails) { + return this.filterConverter + .convert(ruleDetails.getRule().getRuleInfo().getFilter()) + .map( + spanProcessingRuleFilter -> + new ConvertedApiNamingRule( + ruleDetails.getRule().getId(), + ruleDetails.getRule().getRuleInfo().getName(), + spanProcessingRuleFilter, + ruleDetails.getRule().getRuleInfo().getDisabled(), + ruleDetails.getRule().getRuleInfo().getRuleConfig().getRegex(), + ruleDetails.getRule().getRuleInfo().getRuleConfig().getValue(), + Instant.ofEpochSecond( + ruleDetails.getMetadata().getCreationTimestamp().getSeconds(), + ruleDetails.getMetadata().getCreationTimestamp().getNanos()), + Instant.ofEpochSecond( + ruleDetails.getMetadata().getLastUpdatedTimestamp().getSeconds(), + ruleDetails.getMetadata().getLastUpdatedTimestamp().getNanos()))); + } + @Value @Accessors(fluent = true) private static class ConvertedExcludeSpanRule implements ExcludeSpanRule { @@ -50,4 +68,17 @@ private static class ConvertedExcludeSpanRule implements ExcludeSpanRule { Instant creationTime; Instant lastUpdatedTime; } + + @Value + @Accessors(fluent = true) + private static class ConvertedApiNamingRule implements ApiNamingRule { + String id; + String name; + SpanProcessingRuleFilter spanFilter; + boolean disabled; + String regex; + String value; + Instant creationTime; + Instant lastUpdatedTime; + } } diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/ConfigServiceSpanProcessingRuleDao.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/ConfigServiceSpanProcessingRuleDao.java index 6da5e3d2..d11e51fd 100644 --- a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/ConfigServiceSpanProcessingRuleDao.java +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/ConfigServiceSpanProcessingRuleDao.java @@ -9,12 +9,18 @@ import org.hypertrace.core.graphql.utils.grpc.GrpcChannelRegistry; import org.hypertrace.core.graphql.utils.grpc.GrpcContextBuilder; import org.hypertrace.graphql.config.HypertraceGraphQlServiceConfig; +import org.hypertrace.graphql.spanprocessing.request.mutation.ApiNamingCreateRuleRequest; +import org.hypertrace.graphql.spanprocessing.request.mutation.ApiNamingDeleteRuleRequest; +import org.hypertrace.graphql.spanprocessing.request.mutation.ApiNamingUpdateRuleRequest; import org.hypertrace.graphql.spanprocessing.request.mutation.ExcludeSpanCreateRuleRequest; import org.hypertrace.graphql.spanprocessing.request.mutation.ExcludeSpanDeleteRuleRequest; import org.hypertrace.graphql.spanprocessing.request.mutation.ExcludeSpanUpdateRuleRequest; import org.hypertrace.graphql.spanprocessing.schema.mutation.DeleteSpanProcessingRuleResponse; +import org.hypertrace.graphql.spanprocessing.schema.query.ApiNamingRuleResultSet; import org.hypertrace.graphql.spanprocessing.schema.query.ExcludeSpanRuleResultSet; +import org.hypertrace.graphql.spanprocessing.schema.rule.ApiNamingRule; import org.hypertrace.graphql.spanprocessing.schema.rule.ExcludeSpanRule; +import org.hypertrace.span.processing.config.service.v1.GetAllApiNamingRulesRequest; import org.hypertrace.span.processing.config.service.v1.GetAllExcludeSpanRulesRequest; import org.hypertrace.span.processing.config.service.v1.SpanProcessingConfigServiceGrpc; @@ -46,7 +52,7 @@ public class ConfigServiceSpanProcessingRuleDao implements SpanProcessingRuleDao } @Override - public Single getRules(ContextualRequest request) { + public Single getExcludeSpanRules(ContextualRequest request) { return Single.fromFuture( this.grpcContextBuilder .build(request.context()) @@ -61,7 +67,7 @@ public Single getRules(ContextualRequest request) { } @Override - public Single createRule(ExcludeSpanCreateRuleRequest request) { + public Single createExcludeSpanRule(ExcludeSpanCreateRuleRequest request) { return Single.fromFuture( this.grpcContextBuilder .build(request.context()) @@ -75,7 +81,7 @@ public Single createRule(ExcludeSpanCreateRuleRequest request) } @Override - public Single updateRule(ExcludeSpanUpdateRuleRequest request) { + public Single updateExcludeSpanRule(ExcludeSpanUpdateRuleRequest request) { return Single.fromFuture( this.grpcContextBuilder .build(request.context()) @@ -89,7 +95,8 @@ public Single updateRule(ExcludeSpanUpdateRuleRequest request) } @Override - public Single deleteRule(ExcludeSpanDeleteRuleRequest request) { + public Single deleteExcludeSpanRule( + ExcludeSpanDeleteRuleRequest request) { return Single.fromFuture( this.grpcContextBuilder .build(request.context()) @@ -101,4 +108,62 @@ public Single deleteRule(ExcludeSpanDeleteRule .deleteExcludeSpanRule(this.requestConverter.convert(request)))) .flatMap(this.responseConverter::convert); } + + @Override + public Single getApiNamingRules(ContextualRequest request) { + return Single.fromFuture( + this.grpcContextBuilder + .build(request.context()) + .call( + () -> + this.configStub + .withDeadlineAfter( + serviceConfig.getConfigServiceTimeout().toMillis(), MILLISECONDS) + .getAllApiNamingRules( + GetAllApiNamingRulesRequest.getDefaultInstance()))) + .flatMap(this.responseConverter::convert); + } + + @Override + public Single createApiNamingRule(ApiNamingCreateRuleRequest request) { + return Single.fromFuture( + this.grpcContextBuilder + .build(request.context()) + .call( + () -> + this.configStub + .withDeadlineAfter( + serviceConfig.getConfigServiceTimeout().toMillis(), MILLISECONDS) + .createApiNamingRule(this.requestConverter.convert(request)))) + .flatMap(this.responseConverter::convert); + } + + @Override + public Single updateApiNamingRule(ApiNamingUpdateRuleRequest request) { + return Single.fromFuture( + this.grpcContextBuilder + .build(request.context()) + .call( + () -> + this.configStub + .withDeadlineAfter( + serviceConfig.getConfigServiceTimeout().toMillis(), MILLISECONDS) + .updateApiNamingRule(this.requestConverter.convert(request)))) + .flatMap(this.responseConverter::convert); + } + + @Override + public Single deleteApiNamingRule( + ApiNamingDeleteRuleRequest request) { + return Single.fromFuture( + this.grpcContextBuilder + .build(request.context()) + .call( + () -> + this.configStub + .withDeadlineAfter( + serviceConfig.getConfigServiceTimeout().toMillis(), MILLISECONDS) + .deleteApiNamingRule(this.requestConverter.convert(request)))) + .flatMap(this.responseConverter::convert); + } } diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/SpanProcessingRuleDao.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/SpanProcessingRuleDao.java index 8117614e..f55015c3 100644 --- a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/SpanProcessingRuleDao.java +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/dao/SpanProcessingRuleDao.java @@ -2,19 +2,33 @@ import io.reactivex.rxjava3.core.Single; import org.hypertrace.core.graphql.common.request.ContextualRequest; +import org.hypertrace.graphql.spanprocessing.request.mutation.ApiNamingCreateRuleRequest; +import org.hypertrace.graphql.spanprocessing.request.mutation.ApiNamingDeleteRuleRequest; +import org.hypertrace.graphql.spanprocessing.request.mutation.ApiNamingUpdateRuleRequest; import org.hypertrace.graphql.spanprocessing.request.mutation.ExcludeSpanCreateRuleRequest; import org.hypertrace.graphql.spanprocessing.request.mutation.ExcludeSpanDeleteRuleRequest; import org.hypertrace.graphql.spanprocessing.request.mutation.ExcludeSpanUpdateRuleRequest; import org.hypertrace.graphql.spanprocessing.schema.mutation.DeleteSpanProcessingRuleResponse; +import org.hypertrace.graphql.spanprocessing.schema.query.ApiNamingRuleResultSet; import org.hypertrace.graphql.spanprocessing.schema.query.ExcludeSpanRuleResultSet; +import org.hypertrace.graphql.spanprocessing.schema.rule.ApiNamingRule; import org.hypertrace.graphql.spanprocessing.schema.rule.ExcludeSpanRule; public interface SpanProcessingRuleDao { - Single getRules(ContextualRequest request); + Single getExcludeSpanRules(ContextualRequest request); - Single createRule(ExcludeSpanCreateRuleRequest request); + Single createExcludeSpanRule(ExcludeSpanCreateRuleRequest request); - Single updateRule(ExcludeSpanUpdateRuleRequest request); + Single updateExcludeSpanRule(ExcludeSpanUpdateRuleRequest request); - Single deleteRule(ExcludeSpanDeleteRuleRequest request); + Single deleteExcludeSpanRule( + ExcludeSpanDeleteRuleRequest request); + + Single getApiNamingRules(ContextualRequest request); + + Single createApiNamingRule(ApiNamingCreateRuleRequest request); + + Single updateApiNamingRule(ApiNamingUpdateRuleRequest request); + + Single deleteApiNamingRule(ApiNamingDeleteRuleRequest request); } diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/ApiNamingCreateInputDeserializationConfig.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/ApiNamingCreateInputDeserializationConfig.java new file mode 100644 index 00000000..503aad40 --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/ApiNamingCreateInputDeserializationConfig.java @@ -0,0 +1,51 @@ +package org.hypertrace.graphql.spanprocessing.deserialization; + +import com.fasterxml.jackson.databind.Module; +import com.fasterxml.jackson.databind.module.SimpleModule; +import java.util.List; +import lombok.Builder; +import lombok.Value; +import lombok.experimental.Accessors; +import lombok.extern.jackson.Jacksonized; +import org.hypertrace.core.graphql.deserialization.ArgumentDeserializationConfig; +import org.hypertrace.graphql.spanprocessing.schema.mutation.ApiNamingRuleCreate; +import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingLogicalFilter; +import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRelationalFilter; +import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRuleFilter; + +public class ApiNamingCreateInputDeserializationConfig implements ArgumentDeserializationConfig { + @Override + public String getArgumentKey() { + return ApiNamingRuleCreate.ARGUMENT_NAME; + } + + @Override + public Class getArgumentSchema() { + return ApiNamingRuleCreate.class; + } + + @Override + public List jacksonModules() { + return List.of( + new SimpleModule() + .addAbstractTypeMapping(ApiNamingRuleCreate.class, DefaultApiNamingRuleCreate.class) + .addAbstractTypeMapping( + SpanProcessingRuleFilter.class, DefaultSpanProcessingRuleFilter.class) + .addAbstractTypeMapping( + SpanProcessingRelationalFilter.class, DefaultSpanProcessingRelationalFilter.class) + .addAbstractTypeMapping( + SpanProcessingLogicalFilter.class, DefaultSpanProcessingLogicalFilter.class)); + } + + @Value + @Accessors(fluent = true) + @Jacksonized + @Builder + private static class DefaultApiNamingRuleCreate implements ApiNamingRuleCreate { + String name; + SpanProcessingRuleFilter spanFilter; + String regex; + String value; + boolean disabled; + } +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/ApiNamingDeleteInputDeserializationConfig.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/ApiNamingDeleteInputDeserializationConfig.java new file mode 100644 index 00000000..8e230834 --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/ApiNamingDeleteInputDeserializationConfig.java @@ -0,0 +1,39 @@ +package org.hypertrace.graphql.spanprocessing.deserialization; + +import com.fasterxml.jackson.databind.Module; +import com.fasterxml.jackson.databind.module.SimpleModule; +import java.util.List; +import lombok.Builder; +import lombok.Value; +import lombok.experimental.Accessors; +import lombok.extern.jackson.Jacksonized; +import org.hypertrace.core.graphql.deserialization.ArgumentDeserializationConfig; +import org.hypertrace.graphql.spanprocessing.schema.mutation.ApiNamingRuleDelete; +import org.hypertrace.graphql.spanprocessing.schema.mutation.ExcludeSpanRuleDelete; + +public class ApiNamingDeleteInputDeserializationConfig implements ArgumentDeserializationConfig { + @Override + public String getArgumentKey() { + return ExcludeSpanRuleDelete.ARGUMENT_NAME; + } + + @Override + public Class getArgumentSchema() { + return ApiNamingRuleDelete.class; + } + + @Override + public List jacksonModules() { + return List.of( + new SimpleModule() + .addAbstractTypeMapping(ApiNamingRuleDelete.class, DefaultApiNamingRuleDelete.class)); + } + + @Value + @Accessors(fluent = true) + @Jacksonized + @Builder + private static class DefaultApiNamingRuleDelete implements ApiNamingRuleDelete { + String id; + } +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/ApiNamingUpdateInputDeserializationConfig.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/ApiNamingUpdateInputDeserializationConfig.java new file mode 100644 index 00000000..0152c780 --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/ApiNamingUpdateInputDeserializationConfig.java @@ -0,0 +1,52 @@ +package org.hypertrace.graphql.spanprocessing.deserialization; + +import com.fasterxml.jackson.databind.Module; +import com.fasterxml.jackson.databind.module.SimpleModule; +import java.util.List; +import lombok.Builder; +import lombok.Value; +import lombok.experimental.Accessors; +import lombok.extern.jackson.Jacksonized; +import org.hypertrace.core.graphql.deserialization.ArgumentDeserializationConfig; +import org.hypertrace.graphql.spanprocessing.schema.mutation.ApiNamingRuleUpdate; +import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingLogicalFilter; +import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRelationalFilter; +import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRuleFilter; + +public class ApiNamingUpdateInputDeserializationConfig implements ArgumentDeserializationConfig { + @Override + public String getArgumentKey() { + return ApiNamingRuleUpdate.ARGUMENT_NAME; + } + + @Override + public Class getArgumentSchema() { + return ApiNamingRuleUpdate.class; + } + + @Override + public List jacksonModules() { + return List.of( + new SimpleModule() + .addAbstractTypeMapping(ApiNamingRuleUpdate.class, DefaultApiNamingRuleUpdate.class) + .addAbstractTypeMapping( + SpanProcessingRuleFilter.class, DefaultSpanProcessingRuleFilter.class) + .addAbstractTypeMapping( + SpanProcessingRelationalFilter.class, DefaultSpanProcessingRelationalFilter.class) + .addAbstractTypeMapping( + SpanProcessingLogicalFilter.class, DefaultSpanProcessingLogicalFilter.class)); + } + + @Value + @Accessors(fluent = true) + @Jacksonized + @Builder + private static class DefaultApiNamingRuleUpdate implements ApiNamingRuleUpdate { + String id; + String name; + SpanProcessingRuleFilter spanFilter; + boolean disabled; + String regex; + String value; + } +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/DefaultSpanProcessingLogicalFilter.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/DefaultSpanProcessingLogicalFilter.java new file mode 100644 index 00000000..dfe016ae --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/DefaultSpanProcessingLogicalFilter.java @@ -0,0 +1,19 @@ +package org.hypertrace.graphql.spanprocessing.deserialization; + +import java.util.List; +import lombok.Builder; +import lombok.Value; +import lombok.experimental.Accessors; +import lombok.extern.jackson.Jacksonized; +import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingLogicalFilter; +import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingLogicalOperator; +import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRuleFilter; + +@Value +@Accessors(fluent = true) +@Jacksonized +@Builder +public class DefaultSpanProcessingLogicalFilter implements SpanProcessingLogicalFilter { + SpanProcessingLogicalOperator logicalOperator; + List spanFilters; +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/DefaultSpanProcessingRelationalFilter.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/DefaultSpanProcessingRelationalFilter.java new file mode 100644 index 00000000..21dea9a6 --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/DefaultSpanProcessingRelationalFilter.java @@ -0,0 +1,20 @@ +package org.hypertrace.graphql.spanprocessing.deserialization; + +import lombok.Builder; +import lombok.Value; +import lombok.experimental.Accessors; +import lombok.extern.jackson.Jacksonized; +import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingFilterField; +import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRelationalFilter; +import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRelationalOperator; + +@Value +@Accessors(fluent = true) +@Jacksonized +@Builder +public class DefaultSpanProcessingRelationalFilter implements SpanProcessingRelationalFilter { + String key; + SpanProcessingFilterField field; + SpanProcessingRelationalOperator relationalOperator; + Object value; +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/DefaultSpanProcessingRuleFilter.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/DefaultSpanProcessingRuleFilter.java new file mode 100644 index 00000000..1afa99fe --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/DefaultSpanProcessingRuleFilter.java @@ -0,0 +1,18 @@ +package org.hypertrace.graphql.spanprocessing.deserialization; + +import lombok.Builder; +import lombok.Value; +import lombok.experimental.Accessors; +import lombok.extern.jackson.Jacksonized; +import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingLogicalFilter; +import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRelationalFilter; +import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRuleFilter; + +@Value +@Accessors(fluent = true) +@Jacksonized +@Builder +public class DefaultSpanProcessingRuleFilter implements SpanProcessingRuleFilter { + SpanProcessingLogicalFilter logicalSpanFilter; + SpanProcessingRelationalFilter relationalSpanFilter; +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/ExcludeSpanCreateInputDeserializationConfig.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/ExcludeSpanCreateInputDeserializationConfig.java index 58760d6c..34245765 100644 --- a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/ExcludeSpanCreateInputDeserializationConfig.java +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/ExcludeSpanCreateInputDeserializationConfig.java @@ -9,11 +9,8 @@ import lombok.extern.jackson.Jacksonized; import org.hypertrace.core.graphql.deserialization.ArgumentDeserializationConfig; import org.hypertrace.graphql.spanprocessing.schema.mutation.ExcludeSpanRuleCreate; -import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingFilterField; import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingLogicalFilter; -import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingLogicalOperator; import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRelationalFilter; -import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRelationalOperator; import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRuleFilter; public class ExcludeSpanCreateInputDeserializationConfig implements ArgumentDeserializationConfig { @@ -49,34 +46,4 @@ private static class DefaultExcludeSpanRuleCreate implements ExcludeSpanRuleCrea SpanProcessingRuleFilter spanFilter; boolean disabled; } - - @Value - @Accessors(fluent = true) - @Jacksonized - @Builder - private static class DefaultSpanProcessingRuleFilter implements SpanProcessingRuleFilter { - SpanProcessingLogicalFilter logicalSpanFilter; - SpanProcessingRelationalFilter relationalSpanFilter; - } - - @Value - @Accessors(fluent = true) - @Jacksonized - @Builder - private static class DefaultSpanProcessingLogicalFilter implements SpanProcessingLogicalFilter { - SpanProcessingLogicalOperator logicalOperator; - List spanFilters; - } - - @Value - @Accessors(fluent = true) - @Jacksonized - @Builder - private static class DefaultSpanProcessingRelationalFilter - implements SpanProcessingRelationalFilter { - String key; - SpanProcessingFilterField field; - SpanProcessingRelationalOperator relationalOperator; - Object value; - } } diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/ExcludeSpanUpdateInputDeserializationConfig.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/ExcludeSpanUpdateInputDeserializationConfig.java index f1226d7c..c8d56eb4 100644 --- a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/ExcludeSpanUpdateInputDeserializationConfig.java +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/ExcludeSpanUpdateInputDeserializationConfig.java @@ -9,11 +9,8 @@ import lombok.extern.jackson.Jacksonized; import org.hypertrace.core.graphql.deserialization.ArgumentDeserializationConfig; import org.hypertrace.graphql.spanprocessing.schema.mutation.ExcludeSpanRuleUpdate; -import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingFilterField; import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingLogicalFilter; -import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingLogicalOperator; import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRelationalFilter; -import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRelationalOperator; import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRuleFilter; public class ExcludeSpanUpdateInputDeserializationConfig implements ArgumentDeserializationConfig { @@ -50,34 +47,4 @@ private static class DefaultExcludeSpanRuleUpdate implements ExcludeSpanRuleUpda SpanProcessingRuleFilter spanFilter; boolean disabled; } - - @Value - @Accessors(fluent = true) - @Jacksonized - @Builder - private static class DefaultSpanProcessingRuleFilter implements SpanProcessingRuleFilter { - SpanProcessingLogicalFilter logicalSpanFilter; - SpanProcessingRelationalFilter relationalSpanFilter; - } - - @Value - @Accessors(fluent = true) - @Jacksonized - @Builder - private static class DefaultSpanProcessingLogicalFilter implements SpanProcessingLogicalFilter { - SpanProcessingLogicalOperator logicalOperator; - List spanFilters; - } - - @Value - @Accessors(fluent = true) - @Jacksonized - @Builder - private static class DefaultSpanProcessingRelationalFilter - implements SpanProcessingRelationalFilter { - String key; - SpanProcessingFilterField field; - SpanProcessingRelationalOperator relationalOperator; - Object value; - } } diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/SpanProcessingDeserializationModule.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/SpanProcessingDeserializationModule.java index 5ab927a2..52b4ff01 100644 --- a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/SpanProcessingDeserializationModule.java +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/deserialization/SpanProcessingDeserializationModule.java @@ -13,5 +13,9 @@ protected void configure() { multibinder.addBinding().to(ExcludeSpanCreateInputDeserializationConfig.class); multibinder.addBinding().to(ExcludeSpanUpdateInputDeserializationConfig.class); multibinder.addBinding().to(ExcludeSpanDeleteInputDeserializationConfig.class); + + multibinder.addBinding().to(ApiNamingCreateInputDeserializationConfig.class); + multibinder.addBinding().to(ApiNamingUpdateInputDeserializationConfig.class); + multibinder.addBinding().to(ApiNamingDeleteInputDeserializationConfig.class); } } diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ApiNamingCreateRuleMutator.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ApiNamingCreateRuleMutator.java new file mode 100644 index 00000000..37769b66 --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ApiNamingCreateRuleMutator.java @@ -0,0 +1,40 @@ +package org.hypertrace.graphql.spanprocessing.fetcher.mutation; + +import graphql.schema.DataFetcher; +import graphql.schema.DataFetchingEnvironment; +import java.util.concurrent.CompletableFuture; +import javax.inject.Inject; +import org.hypertrace.core.graphql.common.fetcher.InjectableDataFetcher; +import org.hypertrace.graphql.spanprocessing.dao.SpanProcessingRuleDao; +import org.hypertrace.graphql.spanprocessing.request.mutation.ApiNamingCreateRuleRequestBuilder; +import org.hypertrace.graphql.spanprocessing.schema.rule.ApiNamingRule; + +public class ApiNamingCreateRuleMutator extends InjectableDataFetcher { + + public ApiNamingCreateRuleMutator() { + super(ApiNamingCreateRuleMutatorImpl.class); + } + + static final class ApiNamingCreateRuleMutatorImpl + implements DataFetcher> { + private final SpanProcessingRuleDao spanProcessingRuleDao; + private final ApiNamingCreateRuleRequestBuilder requestBuilder; + + @Inject + ApiNamingCreateRuleMutatorImpl( + ApiNamingCreateRuleRequestBuilder requestBuilder, + SpanProcessingRuleDao spanProcessingRuleDao) { + this.requestBuilder = requestBuilder; + this.spanProcessingRuleDao = spanProcessingRuleDao; + } + + @Override + public CompletableFuture get(DataFetchingEnvironment environment) { + return this.requestBuilder + .build(environment.getContext(), environment.getArguments()) + .flatMap(this.spanProcessingRuleDao::createApiNamingRule) + .toCompletionStage() + .toCompletableFuture(); + } + } +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ApiNamingDeleteRuleMutator.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ApiNamingDeleteRuleMutator.java new file mode 100644 index 00000000..0e618c6d --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ApiNamingDeleteRuleMutator.java @@ -0,0 +1,42 @@ +package org.hypertrace.graphql.spanprocessing.fetcher.mutation; + +import graphql.schema.DataFetcher; +import graphql.schema.DataFetchingEnvironment; +import java.util.concurrent.CompletableFuture; +import javax.inject.Inject; +import org.hypertrace.core.graphql.common.fetcher.InjectableDataFetcher; +import org.hypertrace.graphql.spanprocessing.dao.SpanProcessingRuleDao; +import org.hypertrace.graphql.spanprocessing.request.mutation.ApiNamingDeleteRuleRequestBuilder; +import org.hypertrace.graphql.spanprocessing.schema.mutation.DeleteSpanProcessingRuleResponse; + +public class ApiNamingDeleteRuleMutator + extends InjectableDataFetcher { + + public ApiNamingDeleteRuleMutator() { + super(ApiNamingDeleteRuleMutatorImpl.class); + } + + static final class ApiNamingDeleteRuleMutatorImpl + implements DataFetcher> { + private final SpanProcessingRuleDao spanProcessingRuleDao; + private final ApiNamingDeleteRuleRequestBuilder requestBuilder; + + @Inject + ApiNamingDeleteRuleMutatorImpl( + ApiNamingDeleteRuleRequestBuilder requestBuilder, + SpanProcessingRuleDao spanProcessingRuleDao) { + this.requestBuilder = requestBuilder; + this.spanProcessingRuleDao = spanProcessingRuleDao; + } + + @Override + public CompletableFuture get( + DataFetchingEnvironment environment) { + return this.requestBuilder + .build(environment.getContext(), environment.getArguments()) + .flatMap(this.spanProcessingRuleDao::deleteApiNamingRule) + .toCompletionStage() + .toCompletableFuture(); + } + } +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ApiNamingUpdateRuleMutator.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ApiNamingUpdateRuleMutator.java new file mode 100644 index 00000000..89ae9b07 --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ApiNamingUpdateRuleMutator.java @@ -0,0 +1,40 @@ +package org.hypertrace.graphql.spanprocessing.fetcher.mutation; + +import graphql.schema.DataFetcher; +import graphql.schema.DataFetchingEnvironment; +import java.util.concurrent.CompletableFuture; +import javax.inject.Inject; +import org.hypertrace.core.graphql.common.fetcher.InjectableDataFetcher; +import org.hypertrace.graphql.spanprocessing.dao.SpanProcessingRuleDao; +import org.hypertrace.graphql.spanprocessing.request.mutation.ApiNamingUpdateRuleRequestBuilder; +import org.hypertrace.graphql.spanprocessing.schema.rule.ApiNamingRule; + +public class ApiNamingUpdateRuleMutator extends InjectableDataFetcher { + + public ApiNamingUpdateRuleMutator() { + super(ApiNamingUpdateRuleMutatorImpl.class); + } + + static final class ApiNamingUpdateRuleMutatorImpl + implements DataFetcher> { + private final SpanProcessingRuleDao spanProcessingRuleDao; + private final ApiNamingUpdateRuleRequestBuilder requestBuilder; + + @Inject + ApiNamingUpdateRuleMutatorImpl( + ApiNamingUpdateRuleRequestBuilder requestBuilder, + SpanProcessingRuleDao spanProcessingRuleDao) { + this.requestBuilder = requestBuilder; + this.spanProcessingRuleDao = spanProcessingRuleDao; + } + + @Override + public CompletableFuture get(DataFetchingEnvironment environment) { + return this.requestBuilder + .build(environment.getContext(), environment.getArguments()) + .flatMap(this.spanProcessingRuleDao::updateApiNamingRule) + .toCompletionStage() + .toCompletableFuture(); + } + } +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ExcludeSpanCreateRuleMutator.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ExcludeSpanCreateRuleMutator.java index f3095049..d2a3e632 100644 --- a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ExcludeSpanCreateRuleMutator.java +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ExcludeSpanCreateRuleMutator.java @@ -12,16 +12,16 @@ public class ExcludeSpanCreateRuleMutator extends InjectableDataFetcher { public ExcludeSpanCreateRuleMutator() { - super(SpanProcessingCreateRuleMutatorImpl.class); + super(ExcludeSpanCreateRuleMutatorImpl.class); } - static final class SpanProcessingCreateRuleMutatorImpl + static final class ExcludeSpanCreateRuleMutatorImpl implements DataFetcher> { private final SpanProcessingRuleDao spanProcessingRuleDao; private final ExcludeSpanCreateRuleRequestBuilder requestBuilder; @Inject - SpanProcessingCreateRuleMutatorImpl( + ExcludeSpanCreateRuleMutatorImpl( ExcludeSpanCreateRuleRequestBuilder requestBuilder, SpanProcessingRuleDao spanProcessingRuleDao) { this.requestBuilder = requestBuilder; @@ -32,7 +32,7 @@ static final class SpanProcessingCreateRuleMutatorImpl public CompletableFuture get(DataFetchingEnvironment environment) { return this.requestBuilder .build(environment.getContext(), environment.getArguments()) - .flatMap(this.spanProcessingRuleDao::createRule) + .flatMap(this.spanProcessingRuleDao::createExcludeSpanRule) .toCompletionStage() .toCompletableFuture(); } diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ExcludeSpanDeleteRuleMutator.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ExcludeSpanDeleteRuleMutator.java index 607768b0..a770d5c9 100644 --- a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ExcludeSpanDeleteRuleMutator.java +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ExcludeSpanDeleteRuleMutator.java @@ -13,16 +13,16 @@ public class ExcludeSpanDeleteRuleMutator extends InjectableDataFetcher { public ExcludeSpanDeleteRuleMutator() { - super(SpanProcessingDeleteRuleMutatorImpl.class); + super(ExcludeSpanDeleteRuleMutatorImpl.class); } - static final class SpanProcessingDeleteRuleMutatorImpl + static final class ExcludeSpanDeleteRuleMutatorImpl implements DataFetcher> { private final SpanProcessingRuleDao spanProcessingRuleDao; private final ExcludeSpanDeleteRuleRequestBuilder requestBuilder; @Inject - SpanProcessingDeleteRuleMutatorImpl( + ExcludeSpanDeleteRuleMutatorImpl( ExcludeSpanDeleteRuleRequestBuilder requestBuilder, SpanProcessingRuleDao spanProcessingRuleDao) { this.requestBuilder = requestBuilder; @@ -34,7 +34,7 @@ public CompletableFuture get( DataFetchingEnvironment environment) { return this.requestBuilder .build(environment.getContext(), environment.getArguments()) - .flatMap(this.spanProcessingRuleDao::deleteRule) + .flatMap(this.spanProcessingRuleDao::deleteExcludeSpanRule) .toCompletionStage() .toCompletableFuture(); } diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ExcludeSpanUpdateRuleMutator.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ExcludeSpanUpdateRuleMutator.java index fcb5a226..509cb2e2 100644 --- a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ExcludeSpanUpdateRuleMutator.java +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/mutation/ExcludeSpanUpdateRuleMutator.java @@ -12,16 +12,16 @@ public class ExcludeSpanUpdateRuleMutator extends InjectableDataFetcher { public ExcludeSpanUpdateRuleMutator() { - super(SpanProcessingUpdateRuleMutatorImpl.class); + super(ExcludeSpanUpdateRuleMutatorImpl.class); } - static final class SpanProcessingUpdateRuleMutatorImpl + static final class ExcludeSpanUpdateRuleMutatorImpl implements DataFetcher> { private final SpanProcessingRuleDao spanProcessingRuleDao; private final ExcludeSpanUpdateRuleRequestBuilder requestBuilder; @Inject - SpanProcessingUpdateRuleMutatorImpl( + ExcludeSpanUpdateRuleMutatorImpl( ExcludeSpanUpdateRuleRequestBuilder requestBuilder, SpanProcessingRuleDao spanProcessingRuleDao) { this.requestBuilder = requestBuilder; @@ -32,7 +32,7 @@ static final class SpanProcessingUpdateRuleMutatorImpl public CompletableFuture get(DataFetchingEnvironment environment) { return this.requestBuilder .build(environment.getContext(), environment.getArguments()) - .flatMap(this.spanProcessingRuleDao::updateRule) + .flatMap(this.spanProcessingRuleDao::updateExcludeSpanRule) .toCompletionStage() .toCompletableFuture(); } diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/query/ApiNamingRulesFetcher.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/query/ApiNamingRulesFetcher.java new file mode 100644 index 00000000..b44f091d --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/query/ApiNamingRulesFetcher.java @@ -0,0 +1,38 @@ +package org.hypertrace.graphql.spanprocessing.fetcher.query; + +import graphql.schema.DataFetcher; +import graphql.schema.DataFetchingEnvironment; +import java.util.concurrent.CompletableFuture; +import javax.inject.Inject; +import org.hypertrace.core.graphql.common.fetcher.InjectableDataFetcher; +import org.hypertrace.core.graphql.common.request.ContextualRequestBuilder; +import org.hypertrace.graphql.spanprocessing.dao.SpanProcessingRuleDao; +import org.hypertrace.graphql.spanprocessing.schema.query.ApiNamingRuleResultSet; + +public class ApiNamingRulesFetcher extends InjectableDataFetcher { + + public ApiNamingRulesFetcher() { + super(ApiNamingRulesFetcherImpl.class); + } + + static final class ApiNamingRulesFetcherImpl + implements DataFetcher> { + private final SpanProcessingRuleDao spanProcessingRuleDao; + private final ContextualRequestBuilder requestBuilder; + + @Inject + ApiNamingRulesFetcherImpl( + ContextualRequestBuilder requestBuilder, SpanProcessingRuleDao spanProcessingRuleDao) { + this.requestBuilder = requestBuilder; + this.spanProcessingRuleDao = spanProcessingRuleDao; + } + + @Override + public CompletableFuture get(DataFetchingEnvironment environment) { + return this.spanProcessingRuleDao + .getApiNamingRules(this.requestBuilder.build(environment.getContext())) + .toCompletionStage() + .toCompletableFuture(); + } + } +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/query/ExcludeSpanRulesFetcher.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/query/ExcludeSpanRulesFetcher.java index 896b29c5..c7465a53 100644 --- a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/query/ExcludeSpanRulesFetcher.java +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/fetcher/query/ExcludeSpanRulesFetcher.java @@ -12,16 +12,16 @@ public class ExcludeSpanRulesFetcher extends InjectableDataFetcher { public ExcludeSpanRulesFetcher() { - super(SpanProcessingRulesFetcherImpl.class); + super(ExcludeSpanRulesFetcherImpl.class); } - static final class SpanProcessingRulesFetcherImpl + static final class ExcludeSpanRulesFetcherImpl implements DataFetcher> { private final SpanProcessingRuleDao spanProcessingRuleDao; private final ContextualRequestBuilder requestBuilder; @Inject - SpanProcessingRulesFetcherImpl( + ExcludeSpanRulesFetcherImpl( ContextualRequestBuilder requestBuilder, SpanProcessingRuleDao spanProcessingRuleDao) { this.requestBuilder = requestBuilder; this.spanProcessingRuleDao = spanProcessingRuleDao; @@ -29,9 +29,8 @@ static final class SpanProcessingRulesFetcherImpl @Override public CompletableFuture get(DataFetchingEnvironment environment) { - return this.spanProcessingRuleDao - .getRules(this.requestBuilder.build(environment.getContext())) + .getExcludeSpanRules(this.requestBuilder.build(environment.getContext())) .toCompletionStage() .toCompletableFuture(); } diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/ApiNamingCreateRuleRequest.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/ApiNamingCreateRuleRequest.java new file mode 100644 index 00000000..febb4d7a --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/ApiNamingCreateRuleRequest.java @@ -0,0 +1,10 @@ +package org.hypertrace.graphql.spanprocessing.request.mutation; + +import org.hypertrace.core.graphql.context.GraphQlRequestContext; +import org.hypertrace.graphql.spanprocessing.schema.mutation.ApiNamingRuleCreate; + +public interface ApiNamingCreateRuleRequest { + GraphQlRequestContext context(); + + ApiNamingRuleCreate createInput(); +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/ApiNamingCreateRuleRequestBuilder.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/ApiNamingCreateRuleRequestBuilder.java new file mode 100644 index 00000000..0ad05f14 --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/ApiNamingCreateRuleRequestBuilder.java @@ -0,0 +1,10 @@ +package org.hypertrace.graphql.spanprocessing.request.mutation; + +import io.reactivex.rxjava3.core.Single; +import java.util.Map; +import org.hypertrace.core.graphql.context.GraphQlRequestContext; + +public interface ApiNamingCreateRuleRequestBuilder { + Single build( + GraphQlRequestContext context, Map arguments); +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/ApiNamingDeleteRuleRequest.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/ApiNamingDeleteRuleRequest.java new file mode 100644 index 00000000..651b811e --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/ApiNamingDeleteRuleRequest.java @@ -0,0 +1,9 @@ +package org.hypertrace.graphql.spanprocessing.request.mutation; + +import org.hypertrace.core.graphql.context.GraphQlRequestContext; + +public interface ApiNamingDeleteRuleRequest { + GraphQlRequestContext context(); + + String id(); +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/ApiNamingDeleteRuleRequestBuilder.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/ApiNamingDeleteRuleRequestBuilder.java new file mode 100644 index 00000000..51423ab3 --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/ApiNamingDeleteRuleRequestBuilder.java @@ -0,0 +1,10 @@ +package org.hypertrace.graphql.spanprocessing.request.mutation; + +import io.reactivex.rxjava3.core.Single; +import java.util.Map; +import org.hypertrace.core.graphql.context.GraphQlRequestContext; + +public interface ApiNamingDeleteRuleRequestBuilder { + Single build( + GraphQlRequestContext context, Map arguments); +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/ApiNamingUpdateRuleRequest.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/ApiNamingUpdateRuleRequest.java new file mode 100644 index 00000000..c4541fc4 --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/ApiNamingUpdateRuleRequest.java @@ -0,0 +1,10 @@ +package org.hypertrace.graphql.spanprocessing.request.mutation; + +import org.hypertrace.core.graphql.context.GraphQlRequestContext; +import org.hypertrace.graphql.spanprocessing.schema.mutation.ApiNamingRuleUpdate; + +public interface ApiNamingUpdateRuleRequest { + GraphQlRequestContext context(); + + ApiNamingRuleUpdate updateInput(); +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/ApiNamingUpdateRuleRequestBuilder.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/ApiNamingUpdateRuleRequestBuilder.java new file mode 100644 index 00000000..7dbebeba --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/ApiNamingUpdateRuleRequestBuilder.java @@ -0,0 +1,10 @@ +package org.hypertrace.graphql.spanprocessing.request.mutation; + +import io.reactivex.rxjava3.core.Single; +import java.util.Map; +import org.hypertrace.core.graphql.context.GraphQlRequestContext; + +public interface ApiNamingUpdateRuleRequestBuilder { + Single build( + GraphQlRequestContext context, Map arguments); +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/DefaultApiNamingCreateRuleRequestBuilder.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/DefaultApiNamingCreateRuleRequestBuilder.java new file mode 100644 index 00000000..d478c2bf --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/DefaultApiNamingCreateRuleRequestBuilder.java @@ -0,0 +1,37 @@ +package org.hypertrace.graphql.spanprocessing.request.mutation; + +import io.reactivex.rxjava3.core.Single; +import java.util.Map; +import javax.inject.Inject; +import lombok.Value; +import lombok.experimental.Accessors; +import org.hypertrace.core.graphql.context.GraphQlRequestContext; +import org.hypertrace.core.graphql.deserialization.ArgumentDeserializer; +import org.hypertrace.graphql.spanprocessing.schema.mutation.ApiNamingRuleCreate; + +public class DefaultApiNamingCreateRuleRequestBuilder implements ApiNamingCreateRuleRequestBuilder { + + private final ArgumentDeserializer argumentDeserializer; + + @Inject + DefaultApiNamingCreateRuleRequestBuilder(ArgumentDeserializer argumentDeserializer) { + this.argumentDeserializer = argumentDeserializer; + } + + @Override + public Single build( + GraphQlRequestContext context, Map arguments) { + ApiNamingRuleCreate apiNamingRuleCreateInput = + this.argumentDeserializer + .deserializeObject(arguments, ApiNamingRuleCreate.class) + .orElseThrow(); + return Single.just(new DefaultApiNamingCreateRuleRequest(context, apiNamingRuleCreateInput)); + } + + @Value + @Accessors(fluent = true) + private static class DefaultApiNamingCreateRuleRequest implements ApiNamingCreateRuleRequest { + GraphQlRequestContext context; + ApiNamingRuleCreate createInput; + } +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/DefaultApiNamingDeleteRuleRequestBuilder.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/DefaultApiNamingDeleteRuleRequestBuilder.java new file mode 100644 index 00000000..8abb15cb --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/DefaultApiNamingDeleteRuleRequestBuilder.java @@ -0,0 +1,38 @@ +package org.hypertrace.graphql.spanprocessing.request.mutation; + +import io.reactivex.rxjava3.core.Single; +import java.util.Map; +import javax.inject.Inject; +import lombok.Value; +import lombok.experimental.Accessors; +import org.hypertrace.core.graphql.context.GraphQlRequestContext; +import org.hypertrace.core.graphql.deserialization.ArgumentDeserializer; +import org.hypertrace.graphql.spanprocessing.schema.mutation.ApiNamingRuleDelete; + +public class DefaultApiNamingDeleteRuleRequestBuilder implements ApiNamingDeleteRuleRequestBuilder { + + private final ArgumentDeserializer argumentDeserializer; + + @Inject + DefaultApiNamingDeleteRuleRequestBuilder(ArgumentDeserializer argumentDeserializer) { + this.argumentDeserializer = argumentDeserializer; + } + + @Override + public Single build( + GraphQlRequestContext context, Map arguments) { + String idToDelete = + this.argumentDeserializer + .deserializeObject(arguments, ApiNamingRuleDelete.class) + .map(ApiNamingRuleDelete::id) + .orElseThrow(); + return Single.just(new DefaultApiNamingDeleteRuleRequest(context, idToDelete)); + } + + @Value + @Accessors(fluent = true) + private static class DefaultApiNamingDeleteRuleRequest implements ApiNamingDeleteRuleRequest { + GraphQlRequestContext context; + String id; + } +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/DefaultApiNamingUpdateRuleRequestBuilder.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/DefaultApiNamingUpdateRuleRequestBuilder.java new file mode 100644 index 00000000..cf035f31 --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/request/mutation/DefaultApiNamingUpdateRuleRequestBuilder.java @@ -0,0 +1,37 @@ +package org.hypertrace.graphql.spanprocessing.request.mutation; + +import io.reactivex.rxjava3.core.Single; +import java.util.Map; +import javax.inject.Inject; +import lombok.Value; +import lombok.experimental.Accessors; +import org.hypertrace.core.graphql.context.GraphQlRequestContext; +import org.hypertrace.core.graphql.deserialization.ArgumentDeserializer; +import org.hypertrace.graphql.spanprocessing.schema.mutation.ApiNamingRuleUpdate; + +public class DefaultApiNamingUpdateRuleRequestBuilder implements ApiNamingUpdateRuleRequestBuilder { + + private final ArgumentDeserializer argumentDeserializer; + + @Inject + DefaultApiNamingUpdateRuleRequestBuilder(ArgumentDeserializer argumentDeserializer) { + this.argumentDeserializer = argumentDeserializer; + } + + @Override + public Single build( + GraphQlRequestContext context, Map arguments) { + ApiNamingRuleUpdate ApiNamingRuleUpdateInput = + this.argumentDeserializer + .deserializeObject(arguments, ApiNamingRuleUpdate.class) + .orElseThrow(); + return Single.just(new DefaultApiNamingUpdateRuleRequest(context, ApiNamingRuleUpdateInput)); + } + + @Value + @Accessors(fluent = true) + private static class DefaultApiNamingUpdateRuleRequest implements ApiNamingUpdateRuleRequest { + GraphQlRequestContext context; + ApiNamingRuleUpdate updateInput; + } +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/mutation/ApiNamingRuleCreate.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/mutation/ApiNamingRuleCreate.java new file mode 100644 index 00000000..5b9b8bc3 --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/mutation/ApiNamingRuleCreate.java @@ -0,0 +1,10 @@ +package org.hypertrace.graphql.spanprocessing.schema.mutation; + +import graphql.annotations.annotationTypes.GraphQLName; +import org.hypertrace.graphql.spanprocessing.schema.rule.ApiNamingRuleInfo; + +@GraphQLName(ApiNamingRuleCreate.TYPE_NAME) +public interface ApiNamingRuleCreate extends ApiNamingRuleInfo { + String TYPE_NAME = "ApiNamingRuleCreate"; + String ARGUMENT_NAME = "input"; +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/mutation/ApiNamingRuleDelete.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/mutation/ApiNamingRuleDelete.java new file mode 100644 index 00000000..623c5ae3 --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/mutation/ApiNamingRuleDelete.java @@ -0,0 +1,10 @@ +package org.hypertrace.graphql.spanprocessing.schema.mutation; + +import graphql.annotations.annotationTypes.GraphQLName; +import org.hypertrace.core.graphql.common.schema.id.Identifiable; + +@GraphQLName(ApiNamingRuleDelete.TYPE_NAME) +public interface ApiNamingRuleDelete extends Identifiable { + String TYPE_NAME = "ApiNamingRuleDelete"; + String ARGUMENT_NAME = "input"; +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/mutation/ApiNamingRuleUpdate.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/mutation/ApiNamingRuleUpdate.java new file mode 100644 index 00000000..aa11d98f --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/mutation/ApiNamingRuleUpdate.java @@ -0,0 +1,44 @@ +package org.hypertrace.graphql.spanprocessing.schema.mutation; + +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; + +@GraphQLName(ApiNamingRuleUpdate.TYPE_NAME) +public interface ApiNamingRuleUpdate extends Identifiable { + String TYPE_NAME = "ApiNamingRuleUpdate"; + String ARGUMENT_NAME = "input"; + + String NAME_KEY = "name"; + String SPAN_PROCESSING_FILTER_KEY = "spanFilter"; + String DISABLED_KEY = "disabled"; + String REGEX_KEY = "regex"; + String VALUE_KEY = "value"; + + @GraphQLField + @GraphQLName(NAME_KEY) + @GraphQLNonNull + String name(); + + @GraphQLField + @GraphQLName(SPAN_PROCESSING_FILTER_KEY) + @GraphQLNonNull + SpanProcessingRuleFilter spanFilter(); + + @GraphQLField + @GraphQLName(DISABLED_KEY) + @GraphQLNonNull + boolean disabled(); + + @GraphQLField + @GraphQLName(REGEX_KEY) + @GraphQLNonNull + String regex(); + + @GraphQLField + @GraphQLName(VALUE_KEY) + @GraphQLNonNull + String value(); +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/mutation/ExcludeSpanRuleUpdate.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/mutation/ExcludeSpanRuleUpdate.java index 2eeb61a2..0c593bb9 100644 --- a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/mutation/ExcludeSpanRuleUpdate.java +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/mutation/ExcludeSpanRuleUpdate.java @@ -17,10 +17,12 @@ public interface ExcludeSpanRuleUpdate extends Identifiable { @GraphQLField @GraphQLName(NAME_KEY) + @GraphQLNonNull String name(); @GraphQLField @GraphQLName(SPAN_PROCESSING_FILTER_KEY) + @GraphQLNonNull SpanProcessingRuleFilter spanFilter(); @GraphQLField diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/mutation/SpanProcessingMutationSchema.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/mutation/SpanProcessingMutationSchema.java index 7fc0f980..ba9eea2a 100644 --- a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/mutation/SpanProcessingMutationSchema.java +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/mutation/SpanProcessingMutationSchema.java @@ -4,15 +4,22 @@ import graphql.annotations.annotationTypes.GraphQLField; import graphql.annotations.annotationTypes.GraphQLName; import graphql.annotations.annotationTypes.GraphQLNonNull; +import org.hypertrace.graphql.spanprocessing.fetcher.mutation.ApiNamingCreateRuleMutator; +import org.hypertrace.graphql.spanprocessing.fetcher.mutation.ApiNamingDeleteRuleMutator; +import org.hypertrace.graphql.spanprocessing.fetcher.mutation.ApiNamingUpdateRuleMutator; import org.hypertrace.graphql.spanprocessing.fetcher.mutation.ExcludeSpanCreateRuleMutator; import org.hypertrace.graphql.spanprocessing.fetcher.mutation.ExcludeSpanDeleteRuleMutator; import org.hypertrace.graphql.spanprocessing.fetcher.mutation.ExcludeSpanUpdateRuleMutator; +import org.hypertrace.graphql.spanprocessing.schema.rule.ApiNamingRule; import org.hypertrace.graphql.spanprocessing.schema.rule.ExcludeSpanRule; public interface SpanProcessingMutationSchema { String CREATE_EXCLUDE_SPAN_RULE_MUTATION_NAME = "createExcludeSpanRule"; String UPDATE_EXCLUDE_SPAN_RULE_MUTATION_NAME = "updateExcludeSpanRule"; String DELETE_EXCLUDE_SPAN_RULE_MUTATION_NAME = "deleteExcludeSpanRule"; + String CREATE_API_NAMING_RULE_MUTATION_NAME = "createApiNamingRule"; + String UPDATE_API_NAMING_RULE_MUTATION_NAME = "updateApiNamingRule"; + String DELETE_API_NAMING_RULE_MUTATION_NAME = "deleteApiNamingRule"; @GraphQLField @GraphQLName(CREATE_EXCLUDE_SPAN_RULE_MUTATION_NAME) @@ -34,7 +41,28 @@ ExcludeSpanRule updateExcludeSpanRule( @GraphQLName(DELETE_EXCLUDE_SPAN_RULE_MUTATION_NAME) @GraphQLNonNull @GraphQLDataFetcher(ExcludeSpanDeleteRuleMutator.class) - DeleteSpanProcessingRuleResponse deleteSpanProcessingRule( + DeleteSpanProcessingRuleResponse deleteExcludeSpanRule( @GraphQLName(ExcludeSpanRuleDelete.ARGUMENT_NAME) @GraphQLNonNull ExcludeSpanRuleDelete input); + + @GraphQLField + @GraphQLName(CREATE_API_NAMING_RULE_MUTATION_NAME) + @GraphQLNonNull + @GraphQLDataFetcher(ApiNamingCreateRuleMutator.class) + ApiNamingRule createApiNamingRule( + @GraphQLName(ApiNamingRuleCreate.ARGUMENT_NAME) @GraphQLNonNull ApiNamingRuleCreate input); + + @GraphQLField + @GraphQLName(UPDATE_API_NAMING_RULE_MUTATION_NAME) + @GraphQLNonNull + @GraphQLDataFetcher(ApiNamingUpdateRuleMutator.class) + ApiNamingRule updateApiNamingRule( + @GraphQLName(ApiNamingRuleUpdate.ARGUMENT_NAME) @GraphQLNonNull ApiNamingRuleUpdate input); + + @GraphQLField + @GraphQLName(DELETE_API_NAMING_RULE_MUTATION_NAME) + @GraphQLNonNull + @GraphQLDataFetcher(ApiNamingDeleteRuleMutator.class) + DeleteSpanProcessingRuleResponse deleteApiNamingRule( + @GraphQLName(ApiNamingRuleDelete.ARGUMENT_NAME) @GraphQLNonNull ApiNamingRuleDelete input); } diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/query/ApiNamingRuleResultSet.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/query/ApiNamingRuleResultSet.java new file mode 100644 index 00000000..380d5873 --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/query/ApiNamingRuleResultSet.java @@ -0,0 +1,19 @@ +package org.hypertrace.graphql.spanprocessing.schema.query; + +import graphql.annotations.annotationTypes.GraphQLField; +import graphql.annotations.annotationTypes.GraphQLName; +import graphql.annotations.annotationTypes.GraphQLNonNull; +import java.util.List; +import org.hypertrace.core.graphql.common.schema.results.ResultSet; +import org.hypertrace.graphql.spanprocessing.schema.rule.ApiNamingRule; + +@GraphQLName(ApiNamingRuleResultSet.TYPE_NAME) +public interface ApiNamingRuleResultSet extends ResultSet { + String TYPE_NAME = "ApiNamingRuleResultSet"; + + @Override + @GraphQLField + @GraphQLNonNull + @GraphQLName(RESULT_SET_RESULTS_NAME) + List results(); +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/query/SpanProcessingQuerySchema.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/query/SpanProcessingQuerySchema.java index 60aa3e52..5163ff51 100644 --- a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/query/SpanProcessingQuerySchema.java +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/query/SpanProcessingQuerySchema.java @@ -4,14 +4,22 @@ import graphql.annotations.annotationTypes.GraphQLField; import graphql.annotations.annotationTypes.GraphQLName; import graphql.annotations.annotationTypes.GraphQLNonNull; +import org.hypertrace.graphql.spanprocessing.fetcher.query.ApiNamingRulesFetcher; import org.hypertrace.graphql.spanprocessing.fetcher.query.ExcludeSpanRulesFetcher; public interface SpanProcessingQuerySchema { String EXCLUDE_SPAN_RULES_QUERY_NAME = "excludeSpanRules"; + String API_NAMING_RULES_QUERY_NAME = "apiNamingRules"; @GraphQLField @GraphQLNonNull @GraphQLName(EXCLUDE_SPAN_RULES_QUERY_NAME) @GraphQLDataFetcher(ExcludeSpanRulesFetcher.class) ExcludeSpanRuleResultSet excludeSpanRules(); + + @GraphQLField + @GraphQLNonNull + @GraphQLName(API_NAMING_RULES_QUERY_NAME) + @GraphQLDataFetcher(ApiNamingRulesFetcher.class) + ApiNamingRuleResultSet apiNamingRules(); } diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/rule/ApiNamingRule.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/rule/ApiNamingRule.java new file mode 100644 index 00000000..c88ddff3 --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/rule/ApiNamingRule.java @@ -0,0 +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(ApiNamingRule.TYPE_NAME) +public interface ApiNamingRule extends Identifiable, ApiNamingRuleInfo { + String TYPE_NAME = "ApiNamingRule"; + + 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(); +} diff --git a/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/rule/ApiNamingRuleInfo.java b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/rule/ApiNamingRuleInfo.java new file mode 100644 index 00000000..18e8b157 --- /dev/null +++ b/hypertrace-graphql-span-processing-schema/src/main/java/org/hypertrace/graphql/spanprocessing/schema/rule/ApiNamingRuleInfo.java @@ -0,0 +1,42 @@ +package org.hypertrace.graphql.spanprocessing.schema.rule; + +import graphql.annotations.annotationTypes.GraphQLField; +import graphql.annotations.annotationTypes.GraphQLName; +import graphql.annotations.annotationTypes.GraphQLNonNull; +import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRuleFilter; + +@GraphQLName(ExcludeSpanRuleInfo.TYPE_NAME) +public interface ApiNamingRuleInfo { + String TYPE_NAME = "ApiNamingRuleInfo"; + + String NAME_KEY = "name"; + String SPAN_FILTER_KEY = "spanFilter"; + String DISABLED_KEY = "disabled"; + String REGEX_KEY = "regex"; + String VALUE_KEY = "value"; + + @GraphQLField + @GraphQLName(NAME_KEY) + @GraphQLNonNull + String name(); + + @GraphQLField + @GraphQLName(SPAN_FILTER_KEY) + @GraphQLNonNull + SpanProcessingRuleFilter spanFilter(); + + @GraphQLField + @GraphQLName(REGEX_KEY) + @GraphQLNonNull + String regex(); + + @GraphQLField + @GraphQLName(VALUE_KEY) + @GraphQLNonNull + String value(); + + @GraphQLField + @GraphQLName(DISABLED_KEY) + @GraphQLNonNull + boolean disabled(); +}