| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 800f7b8 commit 252e905
14 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,3 +11,5 @@ | |||
| 11 | 11 | target/ | |
| 12 | 12 | simpleclient_pushgateway/mockserver.log | |
| 13 | 13 | simpleclient_pushgateway/mockserver_request.log | |
| 14 | + nb-configuration.xml | ||
| 15 | + | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,10 +24,6 @@ | |||
| 24 | 24 | </license> | |
| 25 | 25 | </licenses> | |
| 26 | 26 | ||
| 27 | - <properties> | ||
| 28 | - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| 29 | - </properties> | ||
| 30 | - | ||
| 31 | 27 | <dependencies> | |
| 32 | 28 | <dependency> | |
| 33 | 29 | <groupId>org.openjdk.jmh</groupId> | |
@@ -43,12 +39,12 @@ | |||
| 43 | 39 | <dependency> | |
| 44 | 40 | <groupId>io.prometheus</groupId> | |
| 45 | 41 | <artifactId>client</artifactId> | |
| 46 | - <version>0.0.9-SNAPSHOT</version> | ||
| 42 | + <version>${project.version}</version> | ||
| 47 | 43 | </dependency> | |
| 48 | 44 | <dependency> | |
| 49 | 45 | <groupId>io.prometheus</groupId> | |
| 50 | 46 | <artifactId>simpleclient</artifactId> | |
| 51 | - <version>0.0.9-SNAPSHOT</version> | ||
| 47 | + <version>${project.version}</version> | ||
| 52 | 48 | </dependency> | |
| 53 | 49 | <dependency> | |
| 54 | 50 | <groupId>com.codahale.metrics</groupId> | |
@@ -59,14 +55,6 @@ | |||
| 59 | 55 | <build> | |
| 60 | 56 | <plugins> | |
| 61 | 57 | <plugin> | |
| 62 | - <artifactId>maven-compiler-plugin</artifactId> | ||
| 63 | - <version>3.1</version> | ||
| 64 | - <configuration> | ||
| 65 | - <source>1.6</source> | ||
| 66 | - <target>1.6</target> | ||
| 67 | - </configuration> | ||
| 68 | - </plugin> | ||
| 69 | - <plugin> | ||
| 70 | 58 | <groupId>org.apache.maven.plugins</groupId> | |
| 71 | 59 | <artifactId>maven-shade-plugin</artifactId> | |
| 72 | 60 | <version>2.2</version> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,9 +50,21 @@ | |||
| 50 | 50 | <module>simpleclient_common</module> | |
| 51 | 51 | <module>simpleclient_hotspot</module> | |
| 52 | 52 | <module>simpleclient_servlet</module> | |
| 53 | + <module>simpleclient_log4j</module> | ||
| 54 | + <module>simpleclient_logback</module> | ||
| 53 | 55 | <module>simpleclient_pushgateway</module> | |
| 54 | 56 | <module>benchmark</module> | |
| 55 | 57 | </modules> | |
| 58 | + | ||
| 59 | + <properties> | ||
| 60 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| 61 | + | ||
| 62 | + <maven.compiler.source>1.6</maven.compiler.source> | ||
| 63 | + <maven.compiler.target>1.6</maven.compiler.target> | ||
| 64 | + | ||
| 65 | + <junit.version>4.11</junit.version> | ||
| 66 | + <mockito.version>1.9.5</mockito.version> | ||
| 67 | + </properties> | ||
| 56 | 68 | ||
| 57 | 69 | <build> | |
| 58 | 70 | <plugins> | |
@@ -72,6 +84,11 @@ | |||
| 72 | 84 | <version>2.4.0</version> | |
| 73 | 85 | <extensions>true</extensions> | |
| 74 | 86 | </plugin> | |
| 87 | + <plugin> | ||
| 88 | + <groupId>org.apache.maven.plugins</groupId> | ||
| 89 | + <artifactId>maven-surefire-plugin</artifactId> | ||
| 90 | + <version>2.15</version> | ||
| 91 | + </plugin> | ||
| 75 | 92 | </plugins> | |
| 76 | 93 | </build> | |
| 77 | 94 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,9 +33,6 @@ | |||
| 33 | 33 | </developer> | |
| 34 | 34 | </developers> | |
| 35 | 35 | ||
| 36 | - <properties> | ||
| 37 | - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| 38 | - </properties> | ||
| 39 | 36 | ||
| 40 | 37 | <dependencies> | |
| 41 | 38 | <!-- The simpleclient has no dependencies by design, so that | |
@@ -45,20 +42,8 @@ | |||
| 45 | 42 | <dependency> | |
| 46 | 43 | <groupId>junit</groupId> | |
| 47 | 44 | <artifactId>junit</artifactId> | |
| 48 | - <version>4.11</version> | ||
| 45 | + <version>${junit.version}</version> | ||
| 49 | 46 | <scope>test</scope> | |
| 50 | 47 | </dependency> | |
| 51 | 48 | </dependencies> | |
| 52 | - <build> | ||
| 53 | - <plugins> | ||
| 54 | - <plugin> | ||
| 55 | - <artifactId>maven-compiler-plugin</artifactId> | ||
| 56 | - <version>3.1</version> | ||
| 57 | - <configuration> | ||
| 58 | - <source>1.6</source> | ||
| 59 | - <target>1.6</target> | ||
| 60 | - </configuration> | ||
| 61 | - </plugin> | ||
| 62 | - </plugins> | ||
| 63 | - </build> | ||
| 64 | 49 | </project> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,34 +33,18 @@ | |||
| 33 | 33 | </developer> | |
| 34 | 34 | </developers> | |
| 35 | 35 | ||
| 36 | - <properties> | ||
| 37 | - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| 38 | - </properties> | ||
| 39 | - | ||
| 40 | 36 | <dependencies> | |
| 41 | 37 | <dependency> | |
| 42 | 38 | <groupId>io.prometheus</groupId> | |
| 43 | 39 | <artifactId>simpleclient</artifactId> | |
| 44 | - <version>0.0.9-SNAPSHOT</version> | ||
| 40 | + <version>${project.version}</version> | ||
| 45 | 41 | </dependency> | |
| 46 | 42 | <!-- Test Dependencies Follow --> | |
| 47 | 43 | <dependency> | |
| 48 | 44 | <groupId>junit</groupId> | |
| 49 | 45 | <artifactId>junit</artifactId> | |
| 50 | - <version>4.11</version> | ||
| 46 | + <version>${junit.version}</version> | ||
| 51 | 47 | <scope>test</scope> | |
| 52 | 48 | </dependency> | |
| 53 | 49 | </dependencies> | |
| 54 | - <build> | ||
| 55 | - <plugins> | ||
| 56 | - <plugin> | ||
| 57 | - <artifactId>maven-compiler-plugin</artifactId> | ||
| 58 | - <version>3.1</version> | ||
| 59 | - <configuration> | ||
| 60 | - <source>1.6</source> | ||
| 61 | - <target>1.6</target> | ||
| 62 | - </configuration> | ||
| 63 | - </plugin> | ||
| 64 | - </plugins> | ||
| 65 | - </build> | ||
| 66 | 50 | </project> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,51 +33,37 @@ | |||
| 33 | 33 | </developer> | |
| 34 | 34 | </developers> | |
| 35 | 35 | ||
| 36 | - <properties> | ||
| 37 | - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| 38 | - </properties> | ||
| 39 | - | ||
| 40 | 36 | <dependencies> | |
| 41 | 37 | <dependency> | |
| 42 | 38 | <groupId>io.prometheus</groupId> | |
| 43 | 39 | <artifactId>simpleclient</artifactId> | |
| 44 | - <version>0.0.9-SNAPSHOT</version> | ||
| 40 | + <version>${project.version}</version> | ||
| 41 | + </dependency> | ||
| 42 | + <dependency> | ||
| 43 | + <groupId>io.prometheus</groupId> | ||
| 44 | + <artifactId>simpleclient_servlet</artifactId> | ||
| 45 | + <version>${project.version}</version> | ||
| 45 | 46 | </dependency> | |
| 47 | + | ||
| 46 | 48 | <!-- Test Dependencies Follow --> | |
| 47 | 49 | <dependency> | |
| 48 | 50 | <groupId>junit</groupId> | |
| 49 | 51 | <artifactId>junit</artifactId> | |
| 50 | - <version>4.11</version> | ||
| 52 | + <version>${junit.version}</version> | ||
| 51 | 53 | <scope>test</scope> | |
| 52 | 54 | </dependency> | |
| 53 | 55 | <dependency> | |
| 54 | 56 | <groupId>org.mockito</groupId> | |
| 55 | - <artifactId>mockito-all</artifactId> | ||
| 56 | - <version>1.8.4</version> | ||
| 57 | + <artifactId>mockito-core</artifactId> | ||
| 58 | + <version>${mockito.version}</version> | ||
| 57 | 59 | <scope>test</scope> | |
| 58 | 60 | </dependency> | |
| 59 | - <dependency> | ||
| 60 | - <groupId>io.prometheus</groupId> | ||
| 61 | - <artifactId>simpleclient_servlet</artifactId> | ||
| 62 | - <version>0.0.9-SNAPSHOT</version> | ||
| 63 | - </dependency> | ||
| 61 | + | ||
| 64 | 62 | <dependency> | |
| 65 | 63 | <groupId>org.eclipse.jetty</groupId> | |
| 66 | 64 | <artifactId>jetty-servlet</artifactId> | |
| 67 | 65 | <version>8.1.7.v20120910</version> | |
| 68 | 66 | <scope>test</scope> | |
| 69 | 67 | </dependency> | |
| 70 | 68 | </dependencies> | |
| 71 | - <build> | ||
| 72 | - <plugins> | ||
| 73 | - <plugin> | ||
| 74 | - <artifactId>maven-compiler-plugin</artifactId> | ||
| 75 | - <version>3.1</version> | ||
| 76 | - <configuration> | ||
| 77 | - <source>1.6</source> | ||
| 78 | - <target>1.6</target> | ||
| 79 | - </configuration> | ||
| 80 | - </plugin> | ||
| 81 | - </plugins> | ||
| 82 | - </build> | ||
| 83 | 69 | </project> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,67 @@ | |||
| 1 | + <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | + <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"> | ||
| 3 | + <modelVersion>4.0.0</modelVersion> | ||
| 4 | + | ||
| 5 | + <parent> | ||
| 6 | + <groupId>io.prometheus</groupId> | ||
| 7 | + <artifactId>parent</artifactId> | ||
| 8 | + <version>0.0.9-SNAPSHOT</version> | ||
| 9 | + </parent> | ||
| 10 | + | ||
| 11 | + <groupId>io.prometheus</groupId> | ||
| 12 | + <artifactId>simpleclient_log4j</artifactId> | ||
| 13 | + <packaging>bundle</packaging> | ||
| 14 | + | ||
| 15 | + <name>Prometheus Java Simpleclient log4j</name> | ||
| 16 | + <description> | ||
| 17 | + Metrics collector for log4j appender logging | ||
| 18 | + </description> | ||
| 19 | + | ||
| 20 | + <licenses> | ||
| 21 | + <license> | ||
| 22 | + <name>The Apache Software License, Version 2.0</name> | ||
| 23 | + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> | ||
| 24 | + <distribution>repo</distribution> | ||
| 25 | + </license> | ||
| 26 | + </licenses> | ||
| 27 | + | ||
| 28 | + <developers> | ||
| 29 | + <developer> | ||
| 30 | + <id>willfleury</id> | ||
| 31 | + <name>Will Fleury</name> | ||
| 32 | + <email>will.fleury@boxever.com</email> | ||
| 33 | + </developer> | ||
| 34 | + </developers> | ||
| 35 | + | ||
| 36 | + <properties> | ||
| 37 | + <log4j.version>1.2.17</log4j.version> | ||
| 38 | + </properties> | ||
| 39 | + | ||
| 40 | + <dependencies> | ||
| 41 | + <dependency> | ||
| 42 | + <groupId>io.prometheus</groupId> | ||
| 43 | + <artifactId>simpleclient</artifactId> | ||
| 44 | + <version>${project.version}</version> | ||
| 45 | + </dependency> | ||
| 46 | + <dependency> | ||
| 47 | + <groupId>log4j</groupId> | ||
| 48 | + <artifactId>log4j</artifactId> | ||
| 49 | + <version>${log4j.version}</version> | ||
| 50 | + </dependency> | ||
| 51 | + | ||
| 52 | + | ||
| 53 | + <dependency> | ||
| 54 | + <groupId>junit</groupId> | ||
| 55 | + <artifactId>junit</artifactId> | ||
| 56 | + <version>${junit.version}</version> | ||
| 57 | + <scope>test</scope> | ||
| 58 | + </dependency> | ||
| 59 | + | ||
| 60 | + <dependency> | ||
| 61 | + <groupId>org.mockito</groupId> | ||
| 62 | + <artifactId>mockito-core</artifactId> | ||
| 63 | + <version>${mockito.version}</version> | ||
| 64 | + <scope>test</scope> | ||
| 65 | + </dependency> | ||
| 66 | + </dependencies> | ||
| 67 | + </project> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,80 @@ | |||
| 1 | + package io.prometheus.client.log4j; | ||
| 2 | + | ||
| 3 | + import io.prometheus.client.Counter; | ||
| 4 | + import org.apache.log4j.AppenderSkeleton; | ||
| 5 | + import org.apache.log4j.Level; | ||
| 6 | + import org.apache.log4j.spi.LoggingEvent; | ||
| 7 | + | ||
| 8 | + public class InstrumentedAppender extends AppenderSkeleton { | ||
| 9 | + | ||
| 10 | + public static final String COUNTER_NAME = "log4j_appender_total"; | ||
| 11 | + | ||
| 12 | + private static final Counter COUNTER; | ||
| 13 | + private static final Counter.Child TRACE_LABEL; | ||
| 14 | + private static final Counter.Child DEBUG_LABEL; | ||
| 15 | + private static final Counter.Child INFO_LABEL; | ||
| 16 | + private static final Counter.Child WARN_LABEL; | ||
| 17 | + private static final Counter.Child ERROR_LABEL; | ||
| 18 | + private static final Counter.Child FATAL_LABEL; | ||
| 19 | + | ||
| 20 | + static { | ||
| 21 | + COUNTER = Counter.build().name(COUNTER_NAME) | ||
| 22 | + .help("Log4j log statements at various log levels") | ||
| 23 | + .labelNames("level") | ||
| 24 | + .register(); | ||
| 25 | + | ||
| 26 | + TRACE_LABEL = COUNTER.labels("trace"); | ||
| 27 | + DEBUG_LABEL = COUNTER.labels("debug"); | ||
| 28 | + INFO_LABEL = COUNTER.labels("info"); | ||
| 29 | + WARN_LABEL = COUNTER.labels("warn"); | ||
| 30 | + ERROR_LABEL = COUNTER.labels("error"); | ||
| 31 | + FATAL_LABEL = COUNTER.labels("fatal"); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * Create a new instrumented appender using the default registry. | ||
| 36 | + */ | ||
| 37 | + public InstrumentedAppender() { | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + | ||
| 41 | + @Override | ||
| 42 | + public void activateOptions() { | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + @Override | ||
| 46 | + protected void append(LoggingEvent event) { | ||
| 47 | + switch (event.getLevel().toInt()) { | ||
| 48 | + case Level.TRACE_INT: | ||
| 49 | + TRACE_LABEL.inc(); | ||
| 50 | + break; | ||
| 51 | + case Level.DEBUG_INT: | ||
| 52 | + DEBUG_LABEL.inc(); | ||
| 53 | + break; | ||
| 54 | + case Level.INFO_INT: | ||
| 55 | + INFO_LABEL.inc(); | ||
| 56 | + break; | ||
| 57 | + case Level.WARN_INT: | ||
| 58 | + WARN_LABEL.inc(); | ||
| 59 | + break; | ||
| 60 | + case Level.ERROR_INT: | ||
| 61 | + ERROR_LABEL.inc(); | ||
| 62 | + break; | ||
| 63 | + case Level.FATAL_INT: | ||
| 64 | + FATAL_LABEL.inc(); | ||
| 65 | + break; | ||
| 66 | + default: | ||
| 67 | + break; | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + @Override | ||
| 72 | + public void close() { | ||
| 73 | + // nothing doing | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + @Override | ||
| 77 | + public boolean requiresLayout() { | ||
| 78 | + return false; | ||
| 79 | + } | ||
| 80 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments