Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
037b6d8b
Commit
037b6d8b
authored
Feb 09, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Auto-configure Micrometer's New Relic and SignalFX support
Closes gh-11803
parent
1b156fc2
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
698 additions
and
0 deletions
+698
-0
pom.xml
...g-boot-project/spring-boot-actuator-autoconfigure/pom.xml
+10
-0
NewRelicMetricsExportAutoConfiguration.java
...port/newrelic/NewRelicMetricsExportAutoConfiguration.java
+69
-0
NewRelicProperties.java
...configure/metrics/export/newrelic/NewRelicProperties.java
+71
-0
NewRelicPropertiesConfigAdapter.java
...rics/export/newrelic/NewRelicPropertiesConfigAdapter.java
+52
-0
package-info.java
...e/autoconfigure/metrics/export/newrelic/package-info.java
+20
-0
SignalFxMetricsExportAutoConfiguration.java
...port/signalfx/SignalFxMetricsExportAutoConfiguration.java
+69
-0
SignalFxProperties.java
...configure/metrics/export/signalfx/SignalFxProperties.java
+58
-0
SignalFxPropertiesConfigAdapter.java
...rics/export/signalfx/SignalFxPropertiesConfigAdapter.java
+47
-0
package-info.java
...e/autoconfigure/metrics/export/signalfx/package-info.java
+20
-0
spring.factories
...utoconfigure/src/main/resources/META-INF/spring.factories
+2
-0
NewRelicMetricsExportAutoConfigurationTests.java
...newrelic/NewRelicMetricsExportAutoConfigurationTests.java
+143
-0
SignalFxMetricsExportAutoConfigurationTests.java
...signalfx/SignalFxMetricsExportAutoConfigurationTests.java
+132
-0
pom.xml
spring-boot-project/spring-boot-dependencies/pom.xml
+5
-0
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/pom.xml
View file @
037b6d8b
...
@@ -117,11 +117,21 @@
...
@@ -117,11 +117,21 @@
<artifactId>
micrometer-registry-jmx
</artifactId>
<artifactId>
micrometer-registry-jmx
</artifactId>
<optional>
true
</optional>
<optional>
true
</optional>
</dependency>
</dependency>
<dependency>
<groupId>
io.micrometer
</groupId>
<artifactId>
micrometer-registry-new-relic
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<dependency>
<groupId>
io.micrometer
</groupId>
<groupId>
io.micrometer
</groupId>
<artifactId>
micrometer-registry-prometheus
</artifactId>
<artifactId>
micrometer-registry-prometheus
</artifactId>
<optional>
true
</optional>
<optional>
true
</optional>
</dependency>
</dependency>
<dependency>
<groupId>
io.micrometer
</groupId>
<artifactId>
micrometer-registry-signalfx
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<dependency>
<groupId>
io.micrometer
</groupId>
<groupId>
io.micrometer
</groupId>
<artifactId>
micrometer-registry-statsd
</artifactId>
<artifactId>
micrometer-registry-statsd
</artifactId>
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/newrelic/NewRelicMetricsExportAutoConfiguration.java
0 → 100644
View file @
037b6d8b
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
metrics
.
export
.
newrelic
;
import
io.micrometer.core.instrument.Clock
;
import
io.micrometer.newrelic.NewRelicConfig
;
import
io.micrometer.newrelic.NewRelicMeterRegistry
;
import
org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration
;
import
org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.AutoConfigureBefore
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* {@link EnableAutoConfiguration Auto-configuration} for exporting metrics to New Relic.
*
* @author Jon Schneider
* @author Andy Wilkinson
* @since 2.0.0
*/
@Configuration
@AutoConfigureBefore
(
SimpleMetricsExportAutoConfiguration
.
class
)
@AutoConfigureAfter
(
MetricsAutoConfiguration
.
class
)
@ConditionalOnBean
(
Clock
.
class
)
@ConditionalOnClass
(
NewRelicMeterRegistry
.
class
)
@EnableConfigurationProperties
(
NewRelicProperties
.
class
)
public
class
NewRelicMetricsExportAutoConfiguration
{
@Bean
@ConditionalOnMissingBean
public
Clock
micrometerClock
()
{
return
Clock
.
SYSTEM
;
}
@Bean
@ConditionalOnMissingBean
public
NewRelicConfig
newRelicConfig
(
NewRelicProperties
props
)
{
return
new
NewRelicPropertiesConfigAdapter
(
props
);
}
@Bean
@ConditionalOnMissingBean
public
NewRelicMeterRegistry
newRelicMeterRegistry
(
NewRelicConfig
config
,
Clock
clock
)
{
return
new
NewRelicMeterRegistry
(
config
,
clock
);
}
}
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/newrelic/NewRelicProperties.java
0 → 100644
View file @
037b6d8b
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
metrics
.
export
.
newrelic
;
import
org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
/**
* {@link ConfigurationProperties} for configuring New Relic metrics export.
*
* @author Jon Schneider
* @author Andy Wilkinson
* @since 2.0.0
*/
@ConfigurationProperties
(
prefix
=
"management.metrics.export.newrelic"
)
public
class
NewRelicProperties
extends
StepRegistryProperties
{
/**
* New Relic API key.
*/
private
String
apiKey
;
/**
* New Relic account ID.
*/
private
String
accountId
;
/**
* Optional custom URI for the New Relic Insights API.
*/
private
String
uri
;
public
String
getApiKey
()
{
return
this
.
apiKey
;
}
public
void
setApiKey
(
String
apiKey
)
{
this
.
apiKey
=
apiKey
;
}
public
String
getAccountId
()
{
return
this
.
accountId
;
}
public
void
setAccountId
(
String
accountId
)
{
this
.
accountId
=
accountId
;
}
public
String
getUri
()
{
return
this
.
uri
;
}
public
void
setUri
(
String
uri
)
{
this
.
uri
=
uri
;
}
}
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/newrelic/NewRelicPropertiesConfigAdapter.java
0 → 100644
View file @
037b6d8b
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
metrics
.
export
.
newrelic
;
import
io.micrometer.newrelic.NewRelicConfig
;
import
org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapter
;
/**
* Adapter to convert {@link NewRelicProperties} to a {@link NewRelicConfig}.
*
* @author Jon Schneider
* @since 2.0.0
*/
public
class
NewRelicPropertiesConfigAdapter
extends
StepRegistryPropertiesConfigAdapter
<
NewRelicProperties
>
implements
NewRelicConfig
{
public
NewRelicPropertiesConfigAdapter
(
NewRelicProperties
properties
)
{
super
(
properties
);
}
@Override
public
String
apiKey
()
{
return
get
(
NewRelicProperties:
:
getApiKey
,
NewRelicConfig
.
super
::
apiKey
);
}
@Override
public
String
accountId
()
{
return
get
(
NewRelicProperties:
:
getAccountId
,
NewRelicConfig
.
super
::
accountId
);
}
@Override
public
String
uri
()
{
return
get
(
NewRelicProperties:
:
getUri
,
NewRelicConfig
.
super
::
uri
);
}
}
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/newrelic/package-info.java
0 → 100644
View file @
037b6d8b
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Support for exporting actuator metrics to New Relic.
*/
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
metrics
.
export
.
newrelic
;
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/signalfx/SignalFxMetricsExportAutoConfiguration.java
0 → 100644
View file @
037b6d8b
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
metrics
.
export
.
signalfx
;
import
io.micrometer.core.instrument.Clock
;
import
io.micrometer.signalfx.SignalFxConfig
;
import
io.micrometer.signalfx.SignalFxMeterRegistry
;
import
org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration
;
import
org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.AutoConfigureBefore
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* {@link EnableAutoConfiguration Auto-configuration} for exporting metrics to SignalFX.
*
* @author Jon Schneider
* @author Andy Wilkinson
* @since 2.0.0
*/
@Configuration
@AutoConfigureBefore
(
SimpleMetricsExportAutoConfiguration
.
class
)
@AutoConfigureAfter
(
MetricsAutoConfiguration
.
class
)
@ConditionalOnBean
(
Clock
.
class
)
@ConditionalOnClass
(
SignalFxMeterRegistry
.
class
)
@EnableConfigurationProperties
(
SignalFxProperties
.
class
)
public
class
SignalFxMetricsExportAutoConfiguration
{
@Bean
@ConditionalOnMissingBean
public
SignalFxConfig
signalfxConfig
(
SignalFxProperties
props
)
{
return
new
SignalFxPropertiesConfigAdapter
(
props
);
}
@Bean
@ConditionalOnMissingBean
public
SignalFxMeterRegistry
signalFxMeterRegistry
(
SignalFxConfig
config
,
Clock
clock
)
{
return
new
SignalFxMeterRegistry
(
config
,
clock
);
}
@Bean
@ConditionalOnMissingBean
public
Clock
micrometerClock
()
{
return
Clock
.
SYSTEM
;
}
}
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/signalfx/SignalFxProperties.java
0 → 100644
View file @
037b6d8b
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
metrics
.
export
.
signalfx
;
import
org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
/**
* {@link ConfigurationProperties} for configuring metrics export to SignalFX.
*
* @author Jon Schneider
* @author Andy Wilkinson
* @since 2.0.0
*/
@ConfigurationProperties
(
prefix
=
"management.metrics.export.signalfx"
)
public
class
SignalFxProperties
extends
StepRegistryProperties
{
/**
* SignalFX access token.
*/
private
String
accessToken
;
/**
* Optional custom URI for the SignalFX API.
*/
private
String
uri
;
public
String
getAccessToken
()
{
return
this
.
accessToken
;
}
public
void
setAccessToken
(
String
accessToken
)
{
this
.
accessToken
=
accessToken
;
}
public
String
getUri
()
{
return
this
.
uri
;
}
public
void
setUri
(
String
uri
)
{
this
.
uri
=
uri
;
}
}
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/signalfx/SignalFxPropertiesConfigAdapter.java
0 → 100644
View file @
037b6d8b
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
metrics
.
export
.
signalfx
;
import
io.micrometer.signalfx.SignalFxConfig
;
import
org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapter
;
/**
* Adapter to convert {@link SignalFxProperties} to a {@link SignalFxConfig}.
*
* @author Jon Schneider
* @since 2.0.0
*/
public
class
SignalFxPropertiesConfigAdapter
extends
StepRegistryPropertiesConfigAdapter
<
SignalFxProperties
>
implements
SignalFxConfig
{
public
SignalFxPropertiesConfigAdapter
(
SignalFxProperties
properties
)
{
super
(
properties
);
}
@Override
public
String
accessToken
()
{
return
get
(
SignalFxProperties:
:
getAccessToken
,
SignalFxConfig
.
super
::
accessToken
);
}
@Override
public
String
uri
()
{
return
get
(
SignalFxProperties:
:
getUri
,
SignalFxConfig
.
super
::
uri
);
}
}
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/signalfx/package-info.java
0 → 100644
View file @
037b6d8b
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Support for exporting actuator metrics to SignalFX.
*/
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
metrics
.
export
.
signalfx
;
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring.factories
View file @
037b6d8b
...
@@ -42,8 +42,10 @@ org.springframework.boot.actuate.autoconfigure.metrics.export.ganglia.GangliaMet
...
@@ -42,8 +42,10 @@ org.springframework.boot.actuate.autoconfigure.metrics.export.ganglia.GangliaMet
org.springframework.boot.actuate.autoconfigure.metrics.export.graphite.GraphiteMetricsExportAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.metrics.export.graphite.GraphiteMetricsExportAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.metrics.export.influx.InfluxMetricsExportAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.metrics.export.influx.InfluxMetricsExportAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.metrics.export.jmx.JmxMetricsExportAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.metrics.export.jmx.JmxMetricsExportAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.metrics.export.newrelic.NewRelicMetricsExportAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus.PrometheusMetricsExportAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus.PrometheusMetricsExportAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.metrics.export.signalfx.SignalFxMetricsExportAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.metrics.export.statsd.StatsdMetricsExportAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.metrics.export.statsd.StatsdMetricsExportAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourcePoolMetricsAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourcePoolMetricsAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.metrics.web.client.RestTemplateMetricsAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.metrics.web.client.RestTemplateMetricsAutoConfiguration,\
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/newrelic/NewRelicMetricsExportAutoConfigurationTests.java
0 → 100644
View file @
037b6d8b
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
metrics
.
export
.
newrelic
;
import
io.micrometer.core.instrument.Clock
;
import
io.micrometer.newrelic.NewRelicConfig
;
import
io.micrometer.newrelic.NewRelicMeterRegistry
;
import
org.junit.Test
;
import
org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration
;
import
org.springframework.boot.autoconfigure.AutoConfigurations
;
import
org.springframework.boot.test.context.runner.ApplicationContextRunner
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
*
* Tests for {@link NewRelicMetricsExportAutoConfiguration}.
*
* @author Andy Wilkinson
*/
public
class
NewRelicMetricsExportAutoConfigurationTests
{
private
final
ApplicationContextRunner
runner
=
new
ApplicationContextRunner
()
.
withConfiguration
(
AutoConfigurations
.
of
(
NewRelicMetricsExportAutoConfiguration
.
class
,
MetricsAutoConfiguration
.
class
));
@Test
public
void
failsWithoutAnApiKey
()
{
this
.
runner
.
withPropertyValues
(
"management.metrics.export.newrelic.account-id=12345"
)
.
run
((
context
)
->
assertThat
(
context
).
hasFailed
());
}
@Test
public
void
failsWithoutAnAccountId
()
{
this
.
runner
.
withConfiguration
(
AutoConfigurations
.
of
(
NewRelicMetricsExportAutoConfiguration
.
class
,
MetricsAutoConfiguration
.
class
))
.
withPropertyValues
(
"management.metrics.export.newrelic.api-key=abcde"
)
.
run
((
context
)
->
assertThat
(
context
).
hasFailed
());
}
@Test
public
void
autoConfiguresWithAccountIdAndApiKey
()
{
this
.
runner
.
withPropertyValues
(
"management.metrics.export.newrelic.api-key=abcde"
,
"management.metrics.export.newrelic.account-id=12345"
)
.
run
((
context
)
->
assertThat
(
context
)
.
hasSingleBean
(
NewRelicMeterRegistry
.
class
)
.
hasSingleBean
(
Clock
.
class
).
hasSingleBean
(
NewRelicConfig
.
class
));
}
@Test
public
void
allowsClockToBeCustomized
()
{
this
.
runner
.
withUserConfiguration
(
CustomClockConfiguration
.
class
)
.
withPropertyValues
(
"management.metrics.export.newrelic.api-key=abcde"
,
"management.metrics.export.newrelic.account-id=12345"
)
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
Clock
.
class
)
.
hasBean
(
"customClock"
));
}
@Test
public
void
allowsConfigToBeCustomized
()
{
this
.
runner
.
withUserConfiguration
(
CustomConfigConfiguration
.
class
)
.
withPropertyValues
(
"management.metrics.export.newrelic.api-key=abcde"
,
"management.metrics.export.newrelic.account-id=12345"
)
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
NewRelicConfig
.
class
)
.
hasBean
(
"customConfig"
));
}
@Test
public
void
allowsRegistryToBeCustomized
()
{
this
.
runner
.
withUserConfiguration
(
CustomRegistryConfiguration
.
class
)
.
withPropertyValues
(
"management.metrics.export.newrelic.api-key=abcde"
,
"management.metrics.export.newrelic.account-id=12345"
)
.
run
((
context
)
->
assertThat
(
context
)
.
hasSingleBean
(
NewRelicMeterRegistry
.
class
)
.
hasBean
(
"customRegistry"
));
}
@Configuration
static
class
CustomClockConfiguration
{
@Bean
public
Clock
customClock
()
{
return
Clock
.
SYSTEM
;
}
}
@Configuration
static
class
CustomConfigConfiguration
{
@Bean
public
NewRelicConfig
customConfig
()
{
return
new
NewRelicConfig
()
{
@Override
public
String
get
(
String
k
)
{
if
(
"newrelic.accountId"
.
equals
(
k
))
{
return
"abcde"
;
}
if
(
"newrelic.apiKey"
.
equals
(
k
))
{
return
"12345"
;
}
return
null
;
}
};
}
}
@Configuration
static
class
CustomRegistryConfiguration
{
@Bean
public
NewRelicMeterRegistry
customRegistry
(
NewRelicConfig
config
,
Clock
clock
)
{
return
new
NewRelicMeterRegistry
(
config
,
clock
);
}
}
}
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/signalfx/SignalFxMetricsExportAutoConfigurationTests.java
0 → 100644
View file @
037b6d8b
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
metrics
.
export
.
signalfx
;
import
io.micrometer.core.instrument.Clock
;
import
io.micrometer.signalfx.SignalFxConfig
;
import
io.micrometer.signalfx.SignalFxMeterRegistry
;
import
org.junit.Test
;
import
org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration
;
import
org.springframework.boot.autoconfigure.AutoConfigurations
;
import
org.springframework.boot.test.context.runner.ApplicationContextRunner
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Tests for {@link SignalFxMetricsExportAutoConfiguration}.
*
* @author Andy Wilkinson
*/
public
class
SignalFxMetricsExportAutoConfigurationTests
{
private
final
ApplicationContextRunner
runner
=
new
ApplicationContextRunner
()
.
withConfiguration
(
AutoConfigurations
.
of
(
SignalFxMetricsExportAutoConfiguration
.
class
,
MetricsAutoConfiguration
.
class
));
@Test
public
void
failsWithoutAnAccessToken
()
{
this
.
runner
.
run
((
context
)
->
assertThat
(
context
).
hasFailed
());
}
@Test
public
void
autoConfiguresWithAnAccessToken
()
{
this
.
runner
.
withPropertyValues
(
"management.metrics.export.signalfx.access-token=abcde"
)
.
run
((
context
)
->
assertThat
(
context
)
.
hasSingleBean
(
SignalFxMeterRegistry
.
class
)
.
hasSingleBean
(
Clock
.
class
).
hasSingleBean
(
SignalFxConfig
.
class
));
}
@Test
public
void
allowsClockToBeCustomized
()
{
this
.
runner
.
withPropertyValues
(
"management.metrics.export.signalfx.access-token=abcde"
)
.
withUserConfiguration
(
CustomClockConfiguration
.
class
)
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
Clock
.
class
)
.
hasBean
(
"customClock"
));
}
@Test
public
void
allowsConfigToBeCustomized
()
{
this
.
runner
.
withPropertyValues
(
"management.metrics.export.signalfx.access-token=abcde"
)
.
withUserConfiguration
(
CustomConfigConfiguration
.
class
)
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
Clock
.
class
)
.
hasSingleBean
(
SignalFxMeterRegistry
.
class
)
.
hasSingleBean
(
SignalFxConfig
.
class
).
hasBean
(
"customConfig"
));
}
@Test
public
void
allowsRegistryToBeCustomized
()
{
this
.
runner
.
withPropertyValues
(
"management.metrics.export.signalfx.access-token=abcde"
)
.
withUserConfiguration
(
CustomRegistryConfiguration
.
class
)
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
Clock
.
class
)
.
hasSingleBean
(
SignalFxConfig
.
class
)
.
hasSingleBean
(
SignalFxMeterRegistry
.
class
)
.
hasBean
(
"customRegistry"
));
}
@Configuration
static
class
CustomClockConfiguration
{
@Bean
public
Clock
customClock
()
{
return
Clock
.
SYSTEM
;
}
}
@Configuration
static
class
CustomConfigConfiguration
{
@Bean
public
SignalFxConfig
customConfig
()
{
return
new
SignalFxConfig
()
{
@Override
public
String
get
(
String
k
)
{
if
(
"signalfx.accessToken"
.
equals
(
k
))
{
return
"abcde"
;
}
return
null
;
}
};
}
}
@Configuration
static
class
CustomRegistryConfiguration
{
@Bean
public
SignalFxMeterRegistry
customRegistry
(
SignalFxConfig
config
,
Clock
clock
)
{
return
new
SignalFxMeterRegistry
(
config
,
clock
);
}
}
}
spring-boot-project/spring-boot-dependencies/pom.xml
View file @
037b6d8b
...
@@ -893,6 +893,11 @@
...
@@ -893,6 +893,11 @@
<artifactId>
micrometer-registry-prometheus
</artifactId>
<artifactId>
micrometer-registry-prometheus
</artifactId>
<version>
${micrometer.version}
</version>
<version>
${micrometer.version}
</version>
</dependency>
</dependency>
<dependency>
<groupId>
io.micrometer
</groupId>
<artifactId>
micrometer-registry-signalfx
</artifactId>
<version>
${micrometer.version}
</version>
</dependency>
<dependency>
<dependency>
<groupId>
io.micrometer
</groupId>
<groupId>
io.micrometer
</groupId>
<artifactId>
micrometer-registry-statsd
</artifactId>
<artifactId>
micrometer-registry-statsd
</artifactId>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment