Skip to content

Commit

Permalink
Merge pull request #1 from MaksymDolgykh/v1.0.0
Browse files Browse the repository at this point in the history
Release v1.0.0
  • Loading branch information
MaksymDolgykh authored Sep 30, 2020
2 parents 88cbe5e + f4c7751 commit d8fa104
Show file tree
Hide file tree
Showing 7 changed files with 730 additions and 1 deletion.
135 changes: 135 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@

# Created by https://www.toptal.com/developers/gitignore/api/java,intellij
# Edit at https://www.toptal.com/developers/gitignore?templates=java,intellij

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
.idea/artifacts
.idea/compiler.xml
.idea/jarRepositories.xml
.idea/modules.xml
.idea/*.iml
.idea/modules
*.iml
*.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
.idea/
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
# https://plugins.jetbrains.com/plugin/7973-sonarlint
.idea/**/sonarlint/

# SonarQube Plugin
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
.idea/**/sonarIssues.xml

# Markdown Navigator plugin
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator-enh.xml
.idea/**/markdown-navigator/

# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
.idea/$CACHE_FILE$

# CodeStream plugin
# https://plugins.jetbrains.com/plugin/12206-codestream
.idea/codestream.xml

### Java ###
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# End of https://www.toptal.com/developers/gitignore/api/java,intellij

77 changes: 76 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,76 @@
# dropwizard-micrometer
# dropwizard-micrometer

[Dropwizard](https://www.dropwizard.io/en/latest/) bundle that enables your dropwizard
application for exposition of [micrometer-like](http://micrometer.io/) metrics (system, jvm and http requests) as a
prometheus endpoint.

## Usage

### Add dependency into your `pom.xml`
If you use `maven`, you can simply reference it in the `<dependenccies>` block as below.
The latest version can be found on in the maven
[repository](https://mvnrepository.com/artifact/io.github.maksymdolgykh.dropwizard)

```xml
<dependencies>
...
...
<dependency>
<groupId>io.github.maksymdolgykh.dropwizard</groupId>
<artifactId>dropwizard-micrometer</artifactId>
<version>1.0.0</version>
</dependency>
...
...
</dependencies>

```
### Import DropwizardMicrometer classes in your Application class
```java
import io.github.maksymdolgykh.dropwizard.micrometer.MicrometerBundle;
import io.github.maksymdolgykh.dropwizard.micrometer.MicrometerHttpFilter;
import javax.servlet.FilterRegistration;
import javax.servlet.DispatcherType;
import java.util.EnumSet;
```


### Add the bundle to your application

Add `MicrometerBundle` class to the bootstrapping phase of your Application class

```java
public class HelloWorldApplication extends Application<HelloWorldConfiguration> {
//...
//...

@Override
public void initialize(Bootstrap<HelloWorldConfiguration> bootstrap) {
//...
//...
bootstrap.addBundle(new MicrometerBundle());
//...
//...
}
//...
//...
}
```

### Assign servlet filter to the environment

To leverage latency metrics per http endpoint you need to assign servlet filter to the environment
in your Application class within `run` method
```java
public class HelloWorldApplication extends Application<HelloWorldConfiguration> {
//...
//...
@Override
public void run(HelloWorldConfiguration configuration, Environment environment) {
//...
//...
FilterRegistration.Dynamic micrometerFilter = environment.servlets().addFilter("MicrometerHttpFilter", new MicrometerHttpFilter());
micrometerFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
}
}
```
Loading

0 comments on commit d8fa104

Please # to comment.