Skip to content

Conversation

@jonatan-ivanov
Copy link
Member

@jonatan-ivanov jonatan-ivanov commented May 26, 2021

see: #2295

pirgeo and others added 22 commits April 20, 2021 15:46
* Move Dynatrace metrics exporter for API v1 to a separate package

* rename dynatrace exporter

* use an enum for Dynatrace API versions.

* make DynatraceNamingConvention public

* fix formatting

* rename classes to have version at the end, move enum to uppercase, remove thread factory from exporter

* move naming convention and delegate to the v1 implementation

* update config validation and tests

* rename variables in test files

* remove unused imports

* split out validation

* re-add the apiVersion check and test

* update misleading comment and remove duplicate apiVersion check
Unfortunately Java 8 does not support private methods in interfaces (9+ does) and I'm not sure we should have a public validateV1 method
- javadoc
- ctor/method reordering (to be consistent and ease diffing)
- get the logger based on Class not by String
- start the threadpool at the last step in the ctor
- license
- static imports
# Conflicts:
#	implementations/micrometer-registry-dynatrace/src/main/java/io/micrometer/dynatrace/DynatraceNamingConvention.java
#	implementations/micrometer-registry-dynatrace/src/test/java/io/micrometer/dynatrace/v1/DynatraceNamingConventionV1Test.java
…e-oss-contrib/micrometer into dynatrace-oss-contrib-add-dynatrace-registry-v2

# Conflicts:
#	implementations/micrometer-registry-dynatrace/src/main/java/io/micrometer/dynatrace/AbstractDynatraceExporter.java
#	implementations/micrometer-registry-dynatrace/src/main/java/io/micrometer/dynatrace/DynatraceApiVersion.java
#	implementations/micrometer-registry-dynatrace/src/main/java/io/micrometer/dynatrace/DynatraceConfig.java
#	implementations/micrometer-registry-dynatrace/src/main/java/io/micrometer/dynatrace/DynatraceMeterRegistry.java
#	implementations/micrometer-registry-dynatrace/src/main/java/io/micrometer/dynatrace/v1/DynatraceExporterV1.java
#	implementations/micrometer-registry-dynatrace/src/test/java/io/micrometer/dynatrace/DynatraceConfigTest.java
(Parenthesis is not a must in Groovy)
@jonatan-ivanov
Copy link
Member Author

@pirgeo I tried to improve this a little, I haven't checked the validation logic and the tests (including the Nan/Inf behavior) but I'm going to do it soon.

@shank9918
Copy link

shank9918 commented May 27, 2021

Hi @jonatan-ivanov, just wanted to check on the availability of these changes. We are using Dynatrace V1 APIs with micrometer-registry-dynatrace at the moment and looking forward to using the V2 APIs. So, when do you think these will changes will be released?

@jonatan-ivanov
Copy link
Member Author

@shank9918 After this PR get merged, you can use it as a snapshot release (should happen soon, see my previous comment about what needs to be done).
As for non-snapshot releases, we need sync-up with the Dynatrace OSS Team and figure out how/when to release this.

jonatan-ivanov and others added 3 commits May 27, 2021 15:50
(cherry picked from commit 46f2b77b747b017ba37a0ef585b98d0dc65c3c02)
… to be sent

(cherry picked from commit 2c43bddc5e260d44dbc0f8f0b479e08fd18c3771)
Co-authored-by: Georg Pirklbauer <[email protected]>
@jonatan-ivanov jonatan-ivanov marked this pull request as ready for review June 2, 2021 17:59
- Using MockClock instead of Thread.sleep
- Improve test setup
- Fix/improve tests for: Gauge, TimeGauge, Counter, FunctionCounter, Timer, FunctionTimer, LongTaskTimer, DistributionSummary
- Custom Meter
- Invalid cases (also dedupe)
@jonatan-ivanov
Copy link
Member Author

jonatan-ivanov commented Jun 3, 2021

@pirgeo I think this is close to be merged, I fixed a couple of things:

  • Added your proposal for the validation
  • Fixed tests by using MockClock instead of Thread.sleep
  • Registering 0th percentile (for min) overwrote the user-defined ones (if any) so I implemented a fix

I also have a few notes, just to double check if these are intended and you are fine with them:

  • Registering 0th percentile (for min) will also mean that the 0th percentile gauge will be reported to Dynatrace, this happens if I register a timer without any user-defined tags or percentiles
test-timer-v2,dt.metrics.source=micrometer gauge,min=125.82912,max=190.0,sum=954.0,count=6 1622746380008
test-timer-v2.percentile,phi=0,dt.metrics.source=micrometer gauge,125.82912 1622746380011
  • The Dynatrace java lib does not filter out empty tags, so this will be sent on the wire:
test-timer-v2,tag1=value1,dt.metrics.source=micrometer,tag2= gauge,min=142.606336,max=191.0,sum=866.0,count=5 1622745540019

Please notice tag2=. This does not seem to cause any issues, the tag is filtered out on the server-side.

Could you please check if these look ok for you?

Copy link
Contributor

@pirgeo pirgeo left a comment

Choose a reason for hiding this comment

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

@jonatan-ivanov Thanks, the changes are looking very good to me.

  • Regarding the 0th percentile export: We would rather not export the extra percentile line. Do you have any suggestions as to how we could drop just that line, preferably without having to look through the created lines and dropping it after creation?
  • Regarding the empty tags, this is something we would like to keep, for now. As you saw, empty tags are currently dropped upon ingestion, but might be used in the future. I have added suggestions to change the test method names.

@jonatan-ivanov
Copy link
Member Author

@pirgeo Great, I'm happy you liked them.

Empty tags: Makes sense, thanks for catching the test names, I've merged your changes in.

0th percentile export: I agree. I think we should not export the extra percentile line, I wasn't 100% sure if it was intentional or not. I think there are two ways to solve this:

  1. Hardcoding a 0 value if there is no good use-case for min (we are doing this for other meter registries)
  2. Using the same MeterFilter to deny the artificially created 0th percentile Meters. This is somewhat tricky/hacky since accept does not know about the DistributionConfig. Because of this, we need to record which meters can be the subject of removal in the config phase, see: 21da805.
    This fortunately happens once per registered meter and before the registry or the exporter would receive it. Also, the exporter does not need the Meter itself, it only needs the HistogramSnapshot, please see the tests.

What do you think?

@jonatan-ivanov jonatan-ivanov merged commit 258a2f8 into main Jun 8, 2021
@jonatan-ivanov jonatan-ivanov deleted the add-dynatrace-registry-v2 branch June 8, 2021 18:12
@jonatan-ivanov jonatan-ivanov linked an issue Jun 8, 2021 that may be closed by this pull request
@jonatan-ivanov
Copy link
Member Author

I merged it based on the email exchange we had about this.
@pirgeo Thank you very much for your epic contribution, we really appreciate your help!

@pirgeo
Copy link
Contributor

pirgeo commented Jun 9, 2021

@jonatan-ivanov Thanks a lot! Appreciate your commitment and your help :)

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.

Support for Dynatrace metrics API v2

4 participants