Skip to content

Commit

Permalink
Merge pull request #316 from asserts/radha/sc-16579
Browse files Browse the repository at this point in the history
Default asserts_site to region in resource relation
  • Loading branch information
jradhakrishnan authored Sep 29, 2023
2 parents e39bc80 + b996ae6 commit b51d3bc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import java.util.SortedMap;
import java.util.TreeMap;

import static ai.asserts.aws.MetricNameUtil.SITE;

@Component
@Slf4j
public class ResourceRelationExporter extends Collector implements MetricProvider {
Expand Down Expand Up @@ -62,6 +64,8 @@ public void update() {
relations.forEach(relation -> {
String name = "aws_resource_relation";
SortedMap<String, String> labels = new TreeMap<>();
// Default site to from resource's region
labels.put(SITE, relation.getFrom().getRegion());
relation.getFrom().addLabels(labels, "from");
relation.getTo().addLabels(labels, "to");
labels.put("rel_name", relation.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void setup() {

@Test
public void update() {
expect(fromResource.getRegion()).andReturn("us-west-2").anyTimes();
expect(lbToECSRoutingBuilder.getRouting()).andReturn(ImmutableSet.of(ResourceRelation.builder()
.from(fromResource)
.to(toResource)
Expand Down Expand Up @@ -87,19 +88,29 @@ public void update() {
));

expect(sampleBuilder.buildSingleSample(
"aws_resource_relation", ImmutableSortedMap.of("rel_name", "name1"), 1.0D))
"aws_resource_relation", ImmutableSortedMap.of(
"asserts_site", "us-west-2",
"rel_name", "name1"), 1.0D))
.andReturn(Optional.of(sample));
expect(sampleBuilder.buildSingleSample(
"aws_resource_relation", ImmutableSortedMap.of("rel_name", "name2"), 1.0D))
"aws_resource_relation", ImmutableSortedMap.of(
"asserts_site", "us-west-2",
"rel_name", "name2"), 1.0D))
.andReturn(Optional.of(sample));
expect(sampleBuilder.buildSingleSample(
"aws_resource_relation", ImmutableSortedMap.of("rel_name", "name3"), 1.0D))
"aws_resource_relation", ImmutableSortedMap.of(
"asserts_site", "us-west-2",
"rel_name", "name3"), 1.0D))
.andReturn(Optional.of(sample));
expect(sampleBuilder.buildSingleSample(
"aws_resource_relation", ImmutableSortedMap.of("rel_name", "name4"), 1.0D))
"aws_resource_relation", ImmutableSortedMap.of(
"asserts_site", "us-west-2",
"rel_name", "name4"), 1.0D))
.andReturn(Optional.of(sample));
expect(sampleBuilder.buildSingleSample(
"aws_resource_relation", ImmutableSortedMap.of("rel_name", "name5"), 1.0D))
"aws_resource_relation", ImmutableSortedMap.of(
"asserts_site", "us-west-2",
"rel_name", "name5"), 1.0D))
.andReturn(Optional.of(sample));
expect(sampleBuilder.buildFamily(ImmutableList.of(sample, sample, sample, sample, sample)))
.andReturn(Optional.of(familySamples));
Expand Down

0 comments on commit b51d3bc

Please sign in to comment.