Skip to content

Add micrometer support - #1303

Merged
felixbarny merged 17 commits into
elastic:masterfrom
felixbarny:micrometer
Aug 10, 2020
Merged

felixbarny merged 17 commits into
elastic:masterfrom
felixbarny:micrometer

Conversation

@felixbarny

@felixbarny felixbarny commented Jul 22, 2020 •

Copy link
Copy Markdown
Member

What does this PR do?

Closes #893

Checklist

  • This is an enhancement of existing features, or a new feature in existing plugins
    • I have updated CHANGELOG.asciidoc
    • I have added tests that prove my fix is effective or that my feature works
    • Added an API method or config option? Document in which version this will be introduced
    • I have made corresponding changes to the documentation
  • This is a bugfix
  • This is a new plugin
    • I have updated CHANGELOG.asciidoc
    • My code follows the style guidelines of this project
    • I have made corresponding changes to the documentation
    • I have added tests that prove my fix is effective or that my feature works
    • New and existing unit tests pass locally with my changes
    • I have updated supported-technologies.asciidoc
    • Added an API method or config option? Document in which version this will be introduced
    • Added an instrumentation plugin? Describe how you made sure that old, non-supported versions are not instrumented by accident.
      We're not instrumenting a particular method in MeterRegistry, just all public methods. The plugin is compiled against 1.0.1 to make sure we don't call methods that have been introduced later. We're only calling public API methods that are guaranteed to be stable in 1.x. Testing against the most recent version doesn't seem necessary. I've tested with the currently most recent version 1.5 manually.
  • This is something else

@ghost

ghost commented Jul 22, 2020 •

Copy link
Copy Markdown

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #1303 updated]

  • Start Time: 2020-08-10T10:08:52.311+0000

  • Duration: 49 min 25 sec

Test stats 🧪

Test Results
Failed 0
Passed 1446
Skipped 11
Total 1457

@felixbarny felixbarny added instrumentation Instrumentation: framework support, custom plugins, ... component: metrics docs Documentation new-feature New feature labels Jul 31, 2020
@felixbarny

felixbarny commented Jul 31, 2020 •

Copy link
Copy Markdown
Member Author

I've also tested this manually with https://github.com/micrometer-metrics/micrometer-samples-spring-boot/

These are the metrics it creates:

{"metricset":{"timestamp":1596121299144000,"samples":{"jvm.gc.memory.allocated":{"value":7987096.0},"tomcat.sessions.created":{"value":0.0},"tomcat.sessions.expired":{"value":0.0},"jvm.gc.max.data.size":{"value":-1.0},"system.cpu.count":{"value":8.0},"process.files.max":{"value":10240.0},"jvm.threads.daemon":{"value":36.0},"process.start.time":{"value":1596121130.193},"tomcat.sessions.active.max":{"value":0.0},"jvm.gc.live.data.size":{"value":0.0},"process.files.open":{"value":110.0},"process.cpu.usage":{"value":0.0014566713814238566},"process.uptime":{"value":169.021},"tomcat.cache.hit":{"value":0.0},"system.load.average.1m":{"value":3.44970703125},"tomcat.cache.access":{"value":0.0},"tomcat.sessions.active.current":{"value":0.0},"system.cpu.usage":{"value":0.1777638190954774},"jvm.threads.live":{"value":38.0},"jvm.classes.loaded":{"value":12398.0},"jvm.classes.unloaded":{"value":0.0},"jvm.threads.peak":{"value":44.0},"jvm.gc.memory.promoted":{"value":0.0},"tomcat.sessions.rejected":{"value":0.0},"tomcat.sessions.alive.max":{"value":0.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"area":"nonheap","id":"CodeHeap 'non-nmethods'"},"samples":{"jvm.memory.committed":{"value":3211264.0},"jvm.memory.max":{"value":7553024.0},"jvm.memory.used":{"value":3158144.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"action":"end of minor GC","cause":"G1 Evacuation Pause"},"samples":{"jvm.gc.pause.count":{"value":2},"jvm.gc.pause.sum.us":{"value":35000.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"area":"heap","id":"G1 Old Gen"},"samples":{"jvm.memory.used":{"value":81345392.0},"jvm.memory.committed":{"value":137363456.0},"jvm.memory.max":{"value":4294967296.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"area":"nonheap","id":"Metaspace"},"samples":{"jvm.memory.max":{"value":-1.0},"jvm.memory.committed":{"value":65265664.0},"jvm.memory.used":{"value":61225784.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"level":"trace"},"samples":{"logback.events":{"value":0.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"level":"info"},"samples":{"logback.events":{"value":43.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"exception":"None","method":"GET","phi":"0.95","status":"200","uri":"/api/people"},"samples":{"http.server.requests.percentile":{"value":0.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"area":"heap","id":"G1 Eden Space"},"samples":{"jvm.memory.committed":{"value":125829120.0},"jvm.memory.used":{"value":52428800.0},"jvm.memory.max":{"value":-1.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"level":"warn"},"samples":{"logback.events":{"value":0.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"id":"direct"},"samples":{"jvm.buffer.memory.used":{"value":1176295.0},"jvm.buffer.total.capacity":{"value":1176295.0},"jvm.buffer.count":{"value":3.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"level":"debug"},"samples":{"logback.events":{"value":0.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"name":"http-nio-8080"},"samples":{"tomcat.global.request.max":{"value":0.43},"tomcat.global.error":{"value":0.0},"tomcat.global.sent":{"value":15.0},"tomcat.threads.config.max":{"value":200.0},"tomcat.global.received":{"value":0.0},"tomcat.threads.busy":{"value":0.0},"tomcat.threads.current":{"value":10.0},"tomcat.global.request.count":{"value":1},"tomcat.global.request.sum.us":{"value":430000.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"exception":"None","method":"GET","phi":"0.999","status":"200","uri":"/api/people"},"samples":{"http.server.requests.percentile":{"value":0.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"area":"nonheap","id":"CodeHeap 'non-profiled nmethods'"},"samples":{"jvm.memory.max":{"value":244105216.0},"jvm.memory.committed":{"value":14155776.0},"jvm.memory.used":{"value":14121216.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"level":"error"},"samples":{"logback.events":{"value":0.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"exception":"None","method":"GET","status":"200","uri":"/api/people"},"samples":{"http.server.requests.count":{"value":1},"http.server.requests.sum.us":{"value":293042.45}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"id":"mapped"},"samples":{"jvm.buffer.count":{"value":0.0},"jvm.buffer.total.capacity":{"value":0.0},"jvm.buffer.memory.used":{"value":0.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"action":"end of minor GC","cause":"Metadata GC Threshold"},"samples":{"jvm.gc.pause.count":{"value":1},"jvm.gc.pause.sum.us":{"value":17000.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"area":"heap","id":"G1 Survivor Space"},"samples":{"jvm.memory.committed":{"value":5242880.0},"jvm.memory.max":{"value":-1.0},"jvm.memory.used":{"value":5242880.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"name":"default"},"samples":{"tomcat.servlet.request.count":{"value":0},"tomcat.servlet.request.sum.us":{"value":0.0},"tomcat.servlet.error":{"value":0.0},"tomcat.servlet.request.max":{"value":0.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"exception":"None","method":"GET","phi":"0.5","status":"200","uri":"/api/people"},"samples":{"http.server.requests.percentile":{"value":0.0}}}}
{"metricset":{"timestamp":1596121299144000,"tags":{"area":"nonheap","id":"Compressed Class Space"},"samples":{"jvm.memory.max":{"value":1073741824.0},"jvm.memory.used":{"value":8402928.0},"jvm.memory.committed":{"value":9175040.0}}}}

One issue is that the metrics starting with http are not indexed because APM Server applies common fields to all indices:
https://github.com/elastic/apm-server/blob/57830070b4bbc1bb487eefd96bb79fb9bc203901/_meta/fields.common.yml#L72-L74

This is intentional. Quoting @graphaelli:

so yes, the metric index getting the same mapping as the others is intentional, splitting indices by type is optional though the default

@felixbarny
felixbarny marked this pull request as ready for review July 31, 2020 09:14
@felixbarny

Copy link
Copy Markdown
Member Author

As docs go, we might want to add a section on how to visualize a timer and a gauge with Lens and/or TSVB. I suspect visualizing a timer may be problematic with Lens as we have to calculate a weighted average based on the .count and the .sum.us part of the timer.

@eyalkoren

Copy link
Copy Markdown
Contributor

Started looking into it, but there is a consistent failure in integration tests at its current state

@felixbarny

Copy link
Copy Markdown
Member Author

Thx for the notice. Should be fixed with the latest commit. Let's see...

@eyalkoren eyalkoren left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Beautiful!
A few minor comments.
Main one - why do we serialize this differently (to a buffer first and then to the actual connection)?

Comment thread docs/metrics.asciidoc Outdated
@felixbarny felixbarny added this to the 7.10 milestone Aug 10, 2020

@eyalkoren eyalkoren left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎉

@felixbarny
felixbarny merged commit 1e26d7d into elastic:master Aug 10, 2020
@felixbarny
felixbarny deleted the micrometer branch August 10, 2020 15:39
@felixbarny

Copy link
Copy Markdown
Member Author

Histogram support will be added later once elastic/apm-server#3195 is resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation instrumentation Instrumentation: framework support, custom plugins, ... new-feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Micrometer Integration

2 participants