mirror of
https://github.com/floci-io/floci.git
synced 2026-12-04 02:28:08 -05:00
feat(xray): support TagResource, UntagResource and ListTagsForResource (#10067)
XrayRouteFilter now claims /TagResource, /UntagResource and /ListTagsForResource, so an xray-signed call there no longer reaches Marketplace Catalog's handler, and CreateSamplingRule keeps its Tags. A sampling rule's tags are changed and read by the rule's ARN, with AWS's key, value and 50-tag limits; a group's ARN, the Default rule's, or one from another Region or account answers ResourceNotFoundException with "Resource <arn> not found". IAM reads a rule's tags for aws:ResourceTag conditions.
This commit is contained in:
1 parent
b95c6b21e2
commit
fcd6a89300
12 files changed
+732
-4
No files matched your search
@@ -9,10 +9,12 @@ import software.amazon.awssdk.services.xray.model.BatchGetTracesResponse;
|
||||
import software.amazon.awssdk.services.xray.model.GetSamplingTargetsResponse;
|
||||
import software.amazon.awssdk.services.xray.model.GetServiceGraphResponse;
|
||||
import software.amazon.awssdk.services.xray.model.GetTraceSummariesResponse;
|
||||
import software.amazon.awssdk.services.xray.model.ResourceNotFoundException;
|
||||
import software.amazon.awssdk.services.xray.model.SamplingRuleRecord;
|
||||
import software.amazon.awssdk.services.xray.model.SamplingStatisticsDocument;
|
||||
import software.amazon.awssdk.services.xray.model.Service;
|
||||
import software.amazon.awssdk.services.xray.model.ServiceId;
|
||||
import software.amazon.awssdk.services.xray.model.Tag;
|
||||
import software.amazon.awssdk.services.xray.model.TraceSummary;
|
||||
|
||||
import java.time.Instant;
|
||||
@@ -20,8 +22,11 @@ import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.assertj.core.api.Assertions.tuple;
|
||||
import static org.assertj.core.api.Assertions.within;
|
||||
|
||||
class XrayTest {
|
||||
@@ -136,6 +141,34 @@ class XrayTest {
|
||||
assertThat(response.unprocessedStatistics()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("A sampling rule keeps its create-time tags, and the tag calls change and list them by its ARN")
|
||||
void samplingRuleTags() {
|
||||
String name = "sdk-tags-" + UUID.randomUUID().toString().substring(0, 8);
|
||||
String arn = xray.createSamplingRule(r -> r
|
||||
.samplingRule(rule -> rule.ruleName(name).priority(9000).fixedRate(0.1).reservoirSize(1)
|
||||
.serviceName("*").serviceType("*").host("*").httpMethod("*").urlPath("*")
|
||||
.resourceARN("*").version(1))
|
||||
.tags(Tag.builder().key("team").value("orders").build()))
|
||||
.samplingRuleRecord().samplingRule().ruleARN();
|
||||
try {
|
||||
assertThat(xray.listTagsForResource(r -> r.resourceARN(arn)).tags())
|
||||
.extracting(Tag::key, Tag::value)
|
||||
.containsExactly(tuple("team", "orders"));
|
||||
|
||||
xray.tagResource(r -> r.resourceARN(arn).tags(Tag.builder().key("env").value("local").build()));
|
||||
xray.untagResource(r -> r.resourceARN(arn).tagKeys("team"));
|
||||
|
||||
assertThat(xray.listTagsForResource(r -> r.resourceARN(arn)).tags())
|
||||
.extracting(Tag::key, Tag::value)
|
||||
.containsExactly(tuple("env", "local"));
|
||||
assertThatThrownBy(() -> xray.listTagsForResource(r -> r.resourceARN(arn + "-gone")))
|
||||
.isInstanceOf(ResourceNotFoundException.class);
|
||||
} finally {
|
||||
xray.deleteSamplingRule(r -> r.ruleName(name));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("GetServiceGraph answers one node per service and the call between them")
|
||||
void serviceGraph() {
|
||||
|
||||
Reference in new issue
Block a user