Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions micrometer-registry-signalfx/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.signalfx.public</groupId>
<artifactId>clients-parent</artifactId>
<version>1.0.14</version>
</parent>

<artifactId>micrometer-registry-signalfx</artifactId>
<name>Micrometer Registry for SignalFx</name>
<packaging>jar</packaging>
<description>
A temporary fork of the io.micrometer:micrometer-registry-signalfx project
</description>
<version>1.8.4-splunk1</version>

<url>https://www.signalfx.com</url>

<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<connection>scm:git:[email protected]:signalfx/signalfx-java.git</connection>
<developerConnection>scm:git:[email protected]:signalfx/signalfx-java.git</developerConnection>
<url>[email protected]:signalfx/signalfx-java.git</url>
</scm>

<developers>
<developer>
<id>signalfx</id>
<name>SignalFx</name>
<email>[email protected]</email>
<organization>SignalFx, Inc</organization>
<organizationUrl>http://www.signalfx.com</organizationUrl>
</developer>
</developers>

<dependencies>
<!-- compile -->
<dependency>
<groupId>com.signalfx.public</groupId>
<artifactId>signalfx-java</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
<version>1.8.4</version>
</dependency>

<!-- test -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-test</artifactId>
<version>1.8.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<!-- skip the shading for this artifact -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<id>build-shaded-jar</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<!-- use a newer version for junit5 support -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright Splunk Inc.
*
* 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.
*/

// Includes work from:
/*
* Copyright 2017 VMware, Inc.
*
* 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
*
* https://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 io.micrometer.signalfx;

import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;

import java.time.Duration;
import java.util.Arrays;

final class CumulativeHistogramConfigUtil {

static DistributionStatisticConfig updateConfig(
DistributionStatisticConfig distributionStatisticConfig) {
double[] sloBoundaries = distributionStatisticConfig.getServiceLevelObjectiveBoundaries();
if (sloBoundaries == null || sloBoundaries.length == 0) {
return distributionStatisticConfig;
}
double[] newSLA = sloBoundaries;
// Add the +Inf bucket since the "count" resets every export.
if (!isPositiveInf(sloBoundaries[sloBoundaries.length - 1])) {
newSLA = Arrays.copyOf(sloBoundaries, sloBoundaries.length + 1);
newSLA[newSLA.length - 1] = Double.MAX_VALUE;
}
return DistributionStatisticConfig.builder()
// Set the expiration duration for the histogram counts to be effectively a lifetime.
// Without this, the counts are reset every expiry duration.
.expiry(Duration.ofNanos(Long.MAX_VALUE)) // effectively a lifetime
.bufferLength(1)
.serviceLevelObjectives(newSLA)
.build()
.merge(distributionStatisticConfig);
}

private static boolean isPositiveInf(double bucket) {
return bucket == Double.POSITIVE_INFINITY || bucket == Double.MAX_VALUE || (long) bucket == Long.MAX_VALUE;
}

private CumulativeHistogramConfigUtil() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* Copyright Splunk Inc.
*
* 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.
*/

// Includes work from:
/*
* Copyright 2017 VMware, Inc.
*
* 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
*
* https://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 io.micrometer.signalfx;

import io.micrometer.core.instrument.config.validate.Validated;
import io.micrometer.core.instrument.step.StepRegistryConfig;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.Duration;

import static io.micrometer.core.instrument.config.MeterRegistryConfigValidator.checkAll;
import static io.micrometer.core.instrument.config.MeterRegistryConfigValidator.checkRequired;
import static io.micrometer.core.instrument.config.validate.PropertyValidator.getBoolean;
import static io.micrometer.core.instrument.config.validate.PropertyValidator.getDuration;
import static io.micrometer.core.instrument.config.validate.PropertyValidator.getSecret;
import static io.micrometer.core.instrument.config.validate.PropertyValidator.getString;
import static io.micrometer.core.instrument.config.validate.PropertyValidator.getUrlString;

/**
* Configuration for {@link SignalFxMeterRegistry}.
*
* @author Jon Schneider
*/
public interface SignalFxConfig extends StepRegistryConfig {

@Override
default String prefix() {
return "signalfx";
}

default String accessToken() {
return getSecret(this, "accessToken").required().get();
}

/**
* @return {@code true} if the SignalFx registry should emit cumulative histogram buckets.
*/
default boolean publishCumulativeHistogram() {
return getBoolean(this, "publishCumulativeHistogram").orElse(false);
}

/**
* @return The URI to ship metrics to. If you need to publish metrics to an internal proxy en route to
* SignalFx, you can define the location of the proxy with this.
*/
default String uri() {
// NOTE: at some point, the property 'apiHost' diverged from the name of the method 'uri', so we accept
// either here for backwards compatibility.
return getUrlString(this, "apiHost")
.flatMap((uri, valid) -> uri == null ? getUrlString(this, "uri") : valid)
.orElse("https://ingest.signalfx.com");
}

/**
* @return Unique identifier for the app instance that is publishing metrics to SignalFx. Defaults to the local host name.
*/
default String source() {
return getString(this, "source").orElseGet(() -> {
try {
return InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException uhe) {
return "unknown";
}
});
}

@Override
default Duration step() {
return getDuration(this, "step").orElse(Duration.ofSeconds(10));
}

@Override
default Validated<?> validate() {
return checkAll(this,
c -> StepRegistryConfig.validate(c),
checkRequired("accessToken", SignalFxConfig::accessToken),
checkRequired("uri", SignalFxConfig::uri),
checkRequired("source", SignalFxConfig::source)
);
}
}
Loading