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 14 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [3.11.4] - 2023-08-15
### Changed
- Metrics have been incorporated into Waggle Dance with the inclusion of tags, which will facilitate filtering within Datadog.

## [3.11.3] - TBD
### Fixed
- Exclude Junit5 dependencies as they clashed with Junit4 and caused maven to stop running the tests.
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 newMetricBasePath = buildMetricWithTagsBasePath(pjp);
DhrubajyotiSadhu marked this conversation as resolved.
Show resolved Hide resolved
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));
DhrubajyotiSadhu marked this conversation as resolved.
Show resolved Hide resolved
submit(buildMetricPath(TIMER, metricBasePath, getMonitorMetastore(), "duration"),
stopwatch.elapsed(TimeUnit.MILLISECONDS));

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

Expand All @@ -75,21 +85,56 @@ 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 String buildMetricBasePath(ProceedingJoinPoint pjp) {
String className = clean(pjp.getSignature().getDeclaringTypeName());
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) {
String methodName = clean(pjp.getSignature().getName());
return new StringBuilder(methodName).toString();
DhrubajyotiSadhu marked this conversation as resolved.
Show resolved Hide resolved
}

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

private String buildMetricWithTagsBasePath(ProceedingJoinPoint pjp) {
DhrubajyotiSadhu marked this conversation as resolved.
Show resolved Hide resolved
String className = getClassName(pjp);
return new StringBuilder(className).toString();
DhrubajyotiSadhu marked this conversation as resolved.
Show resolved Hide resolved
}

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

Expand All @@ -101,5 +146,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,23 @@ 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);

Collection<Meter> meters = meterRegistry.get("counter.Type_Anonymous.success").meters();
assertThat(meters.size(), is(1));
assertThat(((CumulativeCounter) ((ArrayList) meters).get(0)).count(), is(1.0));
DhrubajyotiSadhu marked this conversation as resolved.
Show resolved Hide resolved

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

meters = meterRegistry.get("timer.Type_Anonymous.duration").meters();
assertThat(meters.size(), is(1));
assertThat(((CumulativeTimer) ((ArrayList) meters).get(0)).count(), is(1L));
}

@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
Loading