Skip to content

Commit

Permalink
Merge d815707 into 46a5e1a
Browse files Browse the repository at this point in the history
  • Loading branch information
DhrubajyotiSadhu committed Aug 16, 2023
2 parents 46a5e1a + d815707 commit b2c3153
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 15 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
## [3.11.3] - TBD
## [3.11.4] - 2023-08-16
### Changed
- Metrics have been incorporated into Waggle Dance with the inclusion of tags, which will facilitate filtering within Datadog.
- Exclude jetty-all from core module, because it makes spring start fail and makes `WaggleDanceIntegrationTest` fail.
- Upgrade maven.surefire.plugin.version to 3.1.2 (was 3.0.0-m5).
- Exclude jdk.tools clashes with > java8 JDK.
### Fixed
- Exclude Junit5 dependencies as they clashed with Junit4 and caused maven to stop running the tests.
- Fixed metric(graphite) integration test (was broken since 3.10.12 (spring-boot upgrade).

## [3.11.3] - YANKED
### Fixed
- Exclude Junit5 dependencies as they clashed with Junit4 and caused maven to stop running the tests.
- Fixed metric(graphite) integration test (was broken since 3.10.12 (spring-boot upgrade).
Expand Down
5 changes: 2 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand All @@ -10,7 +9,7 @@

<groupId>com.hotels</groupId>
<artifactId>waggle-dance-parent</artifactId>
<version>3.11.3-SNAPSHOT</version>
<version>3.11.4-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Waggle Dance Parent</name>
<description>Hive Metastore federation service.</description>
Expand Down
2 changes: 1 addition & 1 deletion waggle-dance-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.hotels</groupId>
<artifactId>waggle-dance-parent</artifactId>
<version>3.11.3-SNAPSHOT</version>
<version>3.11.4-SNAPSHOT</version>
</parent>

<artifactId>waggle-dance-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion waggle-dance-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.hotels</groupId>
<artifactId>waggle-dance-parent</artifactId>
<version>3.11.3-SNAPSHOT</version>
<version>3.11.4-SNAPSHOT</version>
</parent>

<artifactId>waggle-dance-boot</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion waggle-dance-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.hotels</groupId>
<artifactId>waggle-dance-parent</artifactId>
<version>3.11.3-SNAPSHOT</version>
<version>3.11.4-SNAPSHOT</version>
</parent>

<artifactId>waggle-dance-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.springframework.beans.factory.annotation.Configurable;

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.Tags;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner;
Expand All @@ -51,6 +53,8 @@ public Object monitor(ProceedingJoinPoint pjp) throws Throwable {
public Object monitor(ProceedingJoinPoint pjp, Monitored monitored) throws Throwable {

String metricBasePath = buildMetricBasePath(pjp);
String className = getClassName(pjp);
String methodName = getMethodName(pjp);

String result = null;
Stopwatch stopwatch = Stopwatch.createStarted();
Expand All @@ -67,6 +71,12 @@ public Object monitor(ProceedingJoinPoint pjp, Monitored monitored) throws Throw
increment(buildMetricPath(COUNTER, metricBasePath, getMonitorMetastore(), result));
submit(buildMetricPath(TIMER, metricBasePath, getMonitorMetastore(), "duration"),
stopwatch.elapsed(TimeUnit.MILLISECONDS));

// Sends metrics with Tags: federation_namespace and method_name
incrementWithTags(buildMetricPath(COUNTER, className, "calls"), methodName);
incrementWithTags(buildMetricPath(COUNTER, className, result), methodName);
submitWithTags(buildMetricPath(TIMER, className, "duration"),
stopwatch.elapsed(TimeUnit.MILLISECONDS), methodName);
}
}

Expand All @@ -75,21 +85,54 @@ void setMeterRegistry(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
}

private void incrementWithTags(String metricName, String methodName) {
if (meterRegistry != null) {
Iterable<Tag> tags = getMetricsTags(methodName);
meterRegistry.counter(metricName, tags).increment();
}
}

private void increment(String metricName) {
if (meterRegistry != null) {
meterRegistry.counter(metricName).increment();
}
}

private void submitWithTags(String metricName, long value, String methodName) {
if (meterRegistry != null) {
Iterable<Tag> tags = getMetricsTags(methodName);
meterRegistry.timer(metricName, tags).record(Duration.ofMillis(value));
}
}

private void submit(String metricName, long value) {
if (meterRegistry != null) {
meterRegistry.timer(metricName).record(Duration.ofMillis(value));
}
}

private Tags getMetricsTags(String methodName) {
Tag federationTag = Tag.of("federation_namespace", getMonitorMetastore());
Tag methodTag = Tag.of("method_name", methodName);
return Tags.of(federationTag).and(methodTag);
}

private String getMethodName(ProceedingJoinPoint pjp) {
return clean(pjp.getSignature().getName());
}

private String getClassName(ProceedingJoinPoint pjp) {
return clean(pjp.getSignature().getDeclaringTypeName());
}

private String buildMetricWithTagsBasePath(ProceedingJoinPoint pjp) {
String className = getClassName(pjp);
return new StringBuilder(className).toString();
}

private String buildMetricBasePath(ProceedingJoinPoint pjp) {
String className = clean(pjp.getSignature().getDeclaringTypeName());
String methodName = clean(pjp.getSignature().getName());
String className = getClassName(pjp);
String methodName = getMethodName(pjp);
return new StringBuilder(className).append(".").append(methodName).toString();
}

Expand All @@ -101,5 +144,4 @@ private String clean(String string) {
private String buildMetricPath(String... parts) {
return DOT_JOINER.join(parts);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2016-2020 Expedia, Inc.
* Copyright (C) 2016-2023 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,6 +20,9 @@
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.when;

import java.util.ArrayList;
import java.util.Collection;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.junit.Before;
Expand All @@ -28,7 +31,10 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;

import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.cumulative.CumulativeCounter;
import io.micrometer.core.instrument.cumulative.CumulativeTimer;
import io.micrometer.core.instrument.search.RequiredSearch;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;

Expand Down Expand Up @@ -109,6 +115,39 @@ public void monitorSuccesses() throws Throwable {
assertThat(rs.timer().count(), is(1L));
}

@Test
public void monitorSuccessWithTags() throws Throwable {
aspect.monitor(pjp, monitored);

Collection<Meter> successMeters = meterRegistry.get("counter.Type_Anonymous.success").meters();
assertThat(successMeters.size(), is(1));
assertThat(((CumulativeCounter) ((ArrayList) successMeters).get(0)).count(), is(1.0));

Collection<Meter> callsMeters = meterRegistry.get("counter.Type_Anonymous.calls").meters();
assertThat(callsMeters.size(), is(1));
assertThat(((CumulativeCounter) ((ArrayList) callsMeters).get(0)).count(), is(1.0));

Collection<Meter> durationMeters = meterRegistry.get("timer.Type_Anonymous.duration").meters();
assertThat(durationMeters.size(), is(1));
assertThat(((CumulativeTimer) ((ArrayList) durationMeters).get(0)).count(), is(1L));

// Verify the tags for successMeters
Meter successMeter = successMeters.iterator().next();
assertThat(successMeter.getId().getTag("federation_namespace"), is("all"));
assertThat(successMeter.getId().getTag("method_name"), is("myMethod"));

// Verify the tags for callsMeters
Meter callsMeter = callsMeters.iterator().next();
assertThat(callsMeter.getId().getTag("federation_namespace"), is("all"));
assertThat(successMeter.getId().getTag("method_name"), is("myMethod"));

// Verify the tags for durationMeters
Meter durationMeter = durationMeters.iterator().next();
assertThat(durationMeter.getId().getTag("federation_namespace"), is("all"));
assertThat(successMeter.getId().getTag("method_name"), is("myMethod"));
}


@Test
public void monitorFailuresForSpecificMetastore() throws Throwable {
CurrentMonitoredMetaStoreHolder.monitorMetastore("metastoreName");
Expand Down
2 changes: 1 addition & 1 deletion waggle-dance-integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.hotels</groupId>
<artifactId>waggle-dance-parent</artifactId>
<version>3.11.3-SNAPSHOT</version>
<version>3.11.4-SNAPSHOT</version>
</parent>

<artifactId>waggle-dance-integration-tests</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion waggle-dance-rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.hotels</groupId>
<artifactId>waggle-dance-parent</artifactId>
<version>3.11.3-SNAPSHOT</version>
<version>3.11.4-SNAPSHOT</version>
</parent>

<artifactId>waggle-dance-rest</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion waggle-dance-rpm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.hotels</groupId>
<artifactId>waggle-dance-parent</artifactId>
<version>3.11.3-SNAPSHOT</version>
<version>3.11.4-SNAPSHOT</version>
</parent>

<artifactId>waggle-dance-rpm</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion waggle-dance/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.hotels</groupId>
<artifactId>waggle-dance-parent</artifactId>
<version>3.11.3-SNAPSHOT</version>
<version>3.11.4-SNAPSHOT</version>
</parent>

<artifactId>waggle-dance</artifactId>
Expand Down

0 comments on commit b2c3153

Please sign in to comment.