Skip to content
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.38")
api("org.hypertrace.config.service:span-processing-config-service-api:0.1.41")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
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.graphql.spanprocessing.schema.rule.ExcludeSpanRuleRuleType;
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.RuleType;
import org.hypertrace.span.processing.config.service.v1.SegmentMatchingBasedConfig;
import org.hypertrace.span.processing.config.service.v1.UpdateApiNamingRule;
import org.hypertrace.span.processing.config.service.v1.UpdateApiNamingRuleRequest;
Expand All @@ -45,6 +47,7 @@ private ExcludeSpanRuleInfo convertInput(ExcludeSpanRuleCreate excludeSpanRuleCr
.setName(excludeSpanRuleCreate.name())
.setFilter(this.filterConverter.convert(excludeSpanRuleCreate.spanFilter()))
.setDisabled(excludeSpanRuleCreate.disabled())
.setType(convertExcludeSpanRuleRuleType(excludeSpanRuleCreate.ruleType()))
.build();
}

Expand Down Expand Up @@ -119,4 +122,19 @@ private UpdateApiNamingRule convertInput(ApiNamingRuleUpdate apiNamingRuleUpdate
DeleteApiNamingRuleRequest convert(ApiNamingDeleteRuleRequest request) {
return DeleteApiNamingRuleRequest.newBuilder().setId(request.id()).build();
}

RuleType convertExcludeSpanRuleRuleType(ExcludeSpanRuleRuleType ruleType) {
// TODO: remove this check after making this field non-nullable
if (ruleType == null) {
return RuleType.RULE_TYPE_USER;
}
switch (ruleType) {
case SYSTEM:
return RuleType.RULE_TYPE_SYSTEM;
case USER:
return RuleType.RULE_TYPE_USER;
default:
throw new NoSuchElementException("Unsupported exclude span rule rule type: " + ruleType);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
import org.hypertrace.graphql.spanprocessing.schema.rule.ApiNamingRuleConfig;
import org.hypertrace.graphql.spanprocessing.schema.rule.ApiNamingRuleConfigType;
import org.hypertrace.graphql.spanprocessing.schema.rule.ExcludeSpanRule;
import org.hypertrace.graphql.spanprocessing.schema.rule.ExcludeSpanRuleRuleType;
import org.hypertrace.graphql.spanprocessing.schema.rule.SegmentMatchingBasedRuleConfig;
import org.hypertrace.graphql.spanprocessing.schema.rule.filter.SpanProcessingRuleFilter;
import org.hypertrace.span.processing.config.service.v1.ApiNamingRuleDetails;
import org.hypertrace.span.processing.config.service.v1.RuleType;
import org.hypertrace.span.processing.config.service.v1.SegmentMatchingBasedConfig;

class ConfigServiceSpanProcessingRuleConverter {
Expand All @@ -36,6 +38,7 @@ public Single<ExcludeSpanRule> convert(
ruleDetails.getRule().getRuleInfo().getName(),
spanProcessingRuleFilter,
ruleDetails.getRule().getRuleInfo().getDisabled(),
convertExcludeSpanRuleRuleType(ruleDetails.getRule().getRuleInfo().getType()),
Instant.ofEpochSecond(
ruleDetails.getMetadata().getCreationTimestamp().getSeconds(),
ruleDetails.getMetadata().getCreationTimestamp().getNanos()),
Expand Down Expand Up @@ -79,13 +82,27 @@ private ApiNamingRuleConfig convertApiNamingRuleConfig(
}
}

private ExcludeSpanRuleRuleType convertExcludeSpanRuleRuleType(RuleType ruleType) {
switch (ruleType) {
case RULE_TYPE_UNSPECIFIED: // required to cater for the older user configs(as they didn't
// have a rule type field)
case RULE_TYPE_USER:
return ExcludeSpanRuleRuleType.USER;
case RULE_TYPE_SYSTEM:
return ExcludeSpanRuleRuleType.SYSTEM;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be user?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right😅, updated it now.

default:
throw new NoSuchElementException("Unsupported Exclude span rule rule type: " + ruleType);
}
}

@Value
@Accessors(fluent = true)
private static class ConvertedExcludeSpanRule implements ExcludeSpanRule {
String id;
String name;
SpanProcessingRuleFilter spanFilter;
boolean disabled;
ExcludeSpanRuleRuleType ruleType;
Instant creationTime;
Instant lastUpdatedTime;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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.ExcludeSpanRuleRuleType;
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;
Expand Down Expand Up @@ -45,5 +46,6 @@ private static class DefaultExcludeSpanRuleCreate implements ExcludeSpanRuleCrea
String name;
SpanProcessingRuleFilter spanFilter;
boolean disabled;
ExcludeSpanRuleRuleType ruleType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public interface ExcludeSpanRuleInfo {
String NAME_KEY = "name";
String SPAN_FILTER_KEY = "spanFilter";
String DISABLED_KEY = "disabled";
String RULE_TYPE_KEY = "ruleType";

@GraphQLField
@GraphQLName(NAME_KEY)
Expand All @@ -27,4 +28,9 @@ public interface ExcludeSpanRuleInfo {
@GraphQLName(DISABLED_KEY)
@GraphQLNonNull
boolean disabled();

@GraphQLField
@GraphQLName(RULE_TYPE_KEY)
// TODO: make this field non-nullable
ExcludeSpanRuleRuleType ruleType();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.hypertrace.graphql.spanprocessing.schema.rule;

import graphql.annotations.annotationTypes.GraphQLName;

@GraphQLName(ExcludeSpanRuleRuleType.TYPE_NAME)
public enum ExcludeSpanRuleRuleType {
SYSTEM,
USER,
;
static final String TYPE_NAME = "ExcludeSpanRuleRuleType";
}