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

Add support for dw-metrics 4.x #1228

Conversation

kingster
Copy link
Contributor

@kingster kingster commented Dec 11, 2024

Adding support for com.codahale.metrics.MetricRegistry(Dropwizard Metrics 4.x)

Completes #867

@kingster kingster force-pushed the prometheus-metrics-instrumentation-dropwizard-4x branch 4 times, most recently from 2e0b416 to fa85d06 Compare December 11, 2024 19:21
@kingster kingster marked this pull request as ready for review December 11, 2024 19:30
@kingster
Copy link
Contributor Author

Hi @fstab Please do review this PR, this solves for Dropwizard 4.x metrics support.

Copy link
Member

@zeitlinger zeitlinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution 😄

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test dependencies are added in the parent already:

client_java/pom.xml

Lines 103 to 143 in 9a0848d

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.14.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.26.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.16</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit-pioneer</groupId>
<artifactId>junit-pioneer</artifactId>
<version>2.3.0</version>
<scope>test</scope>
</dependency>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, removed these.

</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>prometheus-metrics-exposition-formats</artifactId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should only depend on prometheus-metrics-exposition-textformats

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, changed this.


import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.data.Offset.offset;
import static org.junit.Assert.assertThrows;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use assertj for all assertions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out. Fixed this


// The result should look like this
//
// # TYPE hist summary
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did the assertion not work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works, just that its not a string comparison, hence this comment is to explain why its not asserted like in other cases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you test it like here:

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think doing it that way will lead to a flaky test-suite, because the problem is in the dw metrics4 histogram. This is something that had happened earlier and that is specially why this approach was taken.

fca49ff

I took reference of this method from the dw5 implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the pr to use

assertThat(textFormat)
        .satisfiesAnyOf(
            text -> assertThat(text).isEqualTo(expected1),
            text -> assertThat(text).isEqualTo(expected2));

So that it matches the exact output, and is a much simpler test.

@kingster kingster force-pushed the prometheus-metrics-instrumentation-dropwizard-4x branch 2 times, most recently from a07277c to 13c320c Compare December 12, 2024 13:43
Signed-off-by: Kinshuk Bairagi <[email protected]>
@kingster kingster force-pushed the prometheus-metrics-instrumentation-dropwizard-4x branch from 13c320c to 529676e Compare December 12, 2024 13:45
@kingster
Copy link
Contributor Author

@zeitlinger Have made the changes as requested, could you please have a look again?

kingster and others added 2 commits December 13, 2024 09:59
Signed-off-by: Kinshuk Bairagi <[email protected]>
Signed-off-by: Gregor Zeitlinger <[email protected]>
@zeitlinger zeitlinger merged commit 5359ba3 into prometheus:main Dec 13, 2024
4 checks passed
@kingster kingster deleted the prometheus-metrics-instrumentation-dropwizard-4x branch December 13, 2024 11:55
@kingster
Copy link
Contributor Author

kingster commented Dec 13, 2024

Thank you @zeitlinger

Are snapshot versions published at any repository? If not when is the next planned version release?

@zeitlinger
Copy link
Member

Thank you @zeitlinger

Are snapshot versions published at any repository? If not when is the next planned version release?

1.3.5 has just been released 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants