Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added waggledance metrics with tags for enabling filtering in datadog #282

Merged
merged 34 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c5b17ea
Added the metrics with tags
Aug 14, 2023
4244a44
Added the metrics with tags testcase
Aug 14, 2023
7ce9fad
Added the metrics with tags testcase
Aug 14, 2023
275d75d
[maven-release-plugin] prepare release waggle-dance-parent-3.11.3
eg-oss-ci Aug 15, 2023
0286050
[maven-release-plugin] prepare for next development iteration
eg-oss-ci Aug 15, 2023
91c6497
updated to snapshot version
Aug 15, 2023
9388405
Merge branch 'feature/waggledance_metrics' of https://github.com/Expe…
Aug 15, 2023
769ade8
updated to snapshot version
Aug 15, 2023
e870ada
updated to snapshot version
Aug 15, 2023
5be4dfe
updated to snapshot version
Aug 15, 2023
dfea44f
updated to snapshot version
Aug 15, 2023
3d2630a
updated to snapshot version
Aug 15, 2023
7d02d12
updated to snapshot version
Aug 15, 2023
3ff30e4
updated to snapshot version
Aug 15, 2023
a33c372
Added prometheus dependency to send metrics
Aug 16, 2023
5831a5f
Updated the changelog.md
Aug 16, 2023
d6c5564
Updated the changelog.md
Aug 16, 2023
bdab6c8
Updated the changelog.md
Aug 16, 2023
d815707
Tested the tags to verify the changes.
Aug 16, 2023
22ae5ca
Tested the tags to verify the changes.
Aug 16, 2023
6bb61e2
Tested the tags to verify the changes.
Aug 16, 2023
016fbcf
updated the integration tests
Aug 17, 2023
822a2be
updated the integration tests
Aug 17, 2023
6e8cdab
updated the integration tests
Aug 17, 2023
908bec3
refactored the code
Aug 17, 2023
878d978
refactored the code
Aug 17, 2023
7e68051
refactored the code
Aug 23, 2023
28dbfeb
refactored the code
Aug 23, 2023
f0f68ab
refactored the code
Aug 23, 2023
4d97e22
refactored the code
Aug 23, 2023
92d2455
refactored the code
Aug 23, 2023
0f508b2
refactored the code
Aug 23, 2023
222b01d
refactored the code
Aug 23, 2023
6d7604a
refactored the code
Aug 23, 2023
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
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
DhrubajyotiSadhu marked this conversation as resolved.
Show resolved Hide resolved
- 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).
DhrubajyotiSadhu marked this conversation as resolved.
Show resolved Hide resolved
- 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>
DhrubajyotiSadhu marked this conversation as resolved.
Show resolved Hide resolved
<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 @@ -63,10 +67,12 @@ public Object monitor(ProceedingJoinPoint pjp, Monitored monitored) throws Throw
throw t;
} finally {
stopwatch.stop();
increment(buildMetricPath(COUNTER, metricBasePath, getMonitorMetastore(), "calls"));
increment(buildMetricPath(COUNTER, metricBasePath, getMonitorMetastore(), result));
submit(buildMetricPath(TIMER, metricBasePath, getMonitorMetastore(), "duration"),
stopwatch.elapsed(TimeUnit.MILLISECONDS));
increment(buildMetricName(COUNTER, metricBasePath, getMonitorMetastore(), "calls"),methodName,
buildMetricName(COUNTER, className, "calls"));
increment(buildMetricName(COUNTER, metricBasePath, getMonitorMetastore(), result),methodName,
buildMetricName(COUNTER, className, result));
submit(buildMetricName(TIMER, metricBasePath, getMonitorMetastore(), "duration"),
stopwatch.elapsed(TimeUnit.MILLISECONDS),methodName, buildMetricName(TIMER, className, "duration"));
}
}

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

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

private void submit(String metricName, long value) {
private void submit(String metricName, long value, String methodName, String metricWithTag) {
if (meterRegistry != null) {
Iterable<Tag> tags = getMetricsTags(methodName);
meterRegistry.timer(metricName).record(Duration.ofMillis(value));
meterRegistry.timer(metricWithTag, tags).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 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 @@ -98,8 +122,7 @@ private String clean(String string) {
return result;
}

private String buildMetricPath(String... parts) {
private String buildMetricName(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,8 @@
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.when;

import java.util.Collection;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.junit.Before;
Expand All @@ -28,6 +30,7 @@
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.search.RequiredSearch;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
Expand Down Expand Up @@ -109,6 +112,39 @@ public void monitorSuccesses() throws Throwable {
assertThat(rs.timer().count(), is(1L));
DhrubajyotiSadhu marked this conversation as resolved.
Show resolved Hide resolved
}

@Test
public void monitorSuccessWithTags() throws Throwable {
DhrubajyotiSadhu marked this conversation as resolved.
Show resolved Hide resolved
aspect.monitor(pjp, monitored);

RequiredSearch rs = meterRegistry.get("counter.Type_Anonymous.success");
assertThat(rs.counter().count(), is(1.0));

rs = meterRegistry.get("counter.Type_Anonymous.calls");
assertThat(rs.counter().count(), is(1.0));

rs = meterRegistry.get("timer.Type_Anonymous.duration");
assertThat(rs.timer().count(), is(1L));

// Verify the tags for successMeters
Collection<Meter> successMeters = meterRegistry.get("counter.Type_Anonymous.success").meters();
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
Collection<Meter> callsMeters = meterRegistry.get("counter.Type_Anonymous.calls").meters();
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
Collection<Meter> durationMeters = meterRegistry.get("timer.Type_Anonymous.duration").meters();
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
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,18 @@ public void typicalWithGraphite() throws Exception {
"graphitePrefix.counter.com.hotels.bdp.waggledance.server.FederatedHMSHandler.get_table_req.remote.calls;metricattribute=count 1");
assertMetric(metrics,
"graphitePrefix.counter.com.hotels.bdp.waggledance.server.FederatedHMSHandler.get_table_req.remote.success;metricattribute=count 1");
assertMetric(metrics,
"graphitePrefix.counter.com.hotels.bdp.waggledance.server.FederatedHMSHandler.success{federation_namespace='get_all_databases',method_name='all'}=count 1");
assertMetric(metrics,
"graphitePrefix.counter.com.hotels.bdp.waggledance.server.FederatedHMSHandler.calls{federation_namespace='get_all_databases',method_name='all'}=count 1");
assertMetric(metrics,
"graphitePrefix.counter.com.hotels.bdp.waggledance.server.FederatedHMSHandler.failure{federation_namespace='get_all_databases',method_name='all'}=count 1");
assertMetric(metrics,
"graphitePrefix.counter.com.hotels.bdp.waggledance.server.FederatedHMSHandler.calls{federation_namespace='get_table_req',method_name='primary'}=count 1");
assertMetric(metrics,
"graphitePrefix.counter.com.hotels.bdp.waggledance.server.FederatedHMSHandler.success{federation_namespace='get_table_req',method_name='primary'}=count 1");
assertMetric(metrics,
"graphitePrefix.counter.com.hotels.bdp.waggledance.server.FederatedHMSHandler.failure{federation_namespace='get_table_req',method_name='primary'}=count 1");
}

private void assertMetric(Set<String> metrics, String partialMetric) {
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
Loading