Skip to content

Commit

Permalink
SPARK-27562 Add actuator info
Browse files Browse the repository at this point in the history
  • Loading branch information
karolostaszewski committed Oct 20, 2020
1 parent e283b2f commit 3ed8a01
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 1 deletion.
8 changes: 7 additions & 1 deletion LICENSE-THIRD-PARTY.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Lists of 144 third-party dependencies.
Lists of 150 third-party dependencies.
(Eclipse Public License - v 1.0) (GNU Lesser General Public License) Logback Classic Module (ch.qos.logback:logback-classic:1.2.3 - http://logback.qos.ch/logback-classic)
(Eclipse Public License - v 1.0) (GNU Lesser General Public License) Logback Core Module (ch.qos.logback:logback-core:1.2.3 - http://logback.qos.ch/logback-core)
(Apache License, Version 2.0) ClassMate (com.fasterxml:classmate:1.5.1 - https://github.com/FasterXML/java-classmate)
Expand All @@ -22,6 +22,7 @@ Lists of 144 third-party dependencies.
(Apache License, Version 2.0) Apache Commons Collections (commons-collections:commons-collections:3.2.2 - http://commons.apache.org/collections/)
(The Apache Software License, Version 2.0) Apache Commons Logging (commons-logging:commons-logging:1.2 - http://commons.apache.org/proper/commons-logging/)
(The MIT License (MIT)) ClassGraph (io.github.classgraph:classgraph:4.8.69 - https://github.com/classgraph/classgraph)
(The Apache Software License, Version 2.0) micrometer-core (io.micrometer:micrometer-core:1.5.5 - https://github.com/micrometer-metrics/micrometer)
(The Apache Software License, Version 2.0) Allure Attachments (io.qameta.allure:allure-attachments:2.13.6 - https://github.com/allure-framework/allure-java)
(The Apache Software License, Version 2.0) Allure Java Commons (io.qameta.allure:allure-java-commons:2.13.6 - https://github.com/allure-framework/allure-java)
(The Apache Software License, Version 2.0) Allure JUnit Platform Integration (io.qameta.allure:allure-junit-platform:2.13.6 - https://github.com/allure-framework/allure-java)
Expand Down Expand Up @@ -80,6 +81,7 @@ Lists of 144 third-party dependencies.
(BSD License 3) Hamcrest (org.hamcrest:hamcrest:2.2 - http://hamcrest.org/JavaHamcrest/)
(BSD License 3) Hamcrest Core (org.hamcrest:hamcrest-core:2.2 - http://hamcrest.org/JavaHamcrest/)
(BSD License 3) Hamcrest Library (org.hamcrest:hamcrest-library:2.2 - http://hamcrest.org/JavaHamcrest/)
(BSD-2-Clause) (Public Domain, per Creative Commons CC0) HdrHistogram (org.hdrhistogram:HdrHistogram:2.1.12 - http://hdrhistogram.github.io/HdrHistogram/)
(Apache License 2.0) Hibernate Validator Engine (org.hibernate.validator:hibernate-validator:6.1.5.Final - http://hibernate.org/validator/hibernate-validator)
(Apache License, version 2.0) JBoss Logging 3 (org.jboss.logging:jboss-logging:3.4.1.Final - http://www.jboss.org)
(The Apache Software License, Version 2.0) JetBrains Java Annotations (org.jetbrains:annotations:19.0.0 - https://github.com/JetBrains/java-annotations)
Expand All @@ -92,6 +94,7 @@ Lists of 144 third-party dependencies.
(Eclipse Public License v2.0) JUnit Platform Commons (org.junit.platform:junit-platform-commons:1.6.2 - https://junit.org/junit5/)
(Eclipse Public License v2.0) JUnit Platform Engine API (org.junit.platform:junit-platform-engine:1.6.2 - https://junit.org/junit5/)
(Eclipse Public License v2.0) JUnit Vintage Engine (org.junit.vintage:junit-vintage-engine:5.6.2 - https://junit.org/junit5/)
(Public Domain, per Creative Commons CC0) LatencyUtils (org.latencyutils:LatencyUtils:2.0.3 - http://latencyutils.github.io/LatencyUtils/)
(The MIT License) mockito-core (org.mockito:mockito-core:3.3.3 - https://github.com/mockito/mockito)
(The MIT License) mockito-junit-jupiter (org.mockito:mockito-junit-jupiter:3.3.3 - https://github.com/mockito/mockito)
(Apache 2) Objenesis (org.objenesis:objenesis:2.6 - http://objenesis.org)
Expand Down Expand Up @@ -123,9 +126,12 @@ Lists of 144 third-party dependencies.
(Apache License, Version 2.0) Spring Web (org.springframework:spring-web:5.2.9.RELEASE - https://github.com/spring-projects/spring-framework)
(Apache License, Version 2.0) Spring Web MVC (org.springframework:spring-webmvc:5.2.9.RELEASE - https://github.com/spring-projects/spring-framework)
(Apache License, Version 2.0) spring-boot (org.springframework.boot:spring-boot:2.3.4.RELEASE - https://spring.io/projects/spring-boot)
(Apache License, Version 2.0) spring-boot-actuator (org.springframework.boot:spring-boot-actuator:2.3.4.RELEASE - https://spring.io/projects/spring-boot)
(Apache License, Version 2.0) spring-boot-actuator-autoconfigure (org.springframework.boot:spring-boot-actuator-autoconfigure:2.3.4.RELEASE - https://spring.io/projects/spring-boot)
(Apache License, Version 2.0) spring-boot-autoconfigure (org.springframework.boot:spring-boot-autoconfigure:2.3.4.RELEASE - https://spring.io/projects/spring-boot)
(Apache License, Version 2.0) spring-boot-devtools (org.springframework.boot:spring-boot-devtools:2.3.4.RELEASE - https://spring.io/projects/spring-boot)
(Apache License, Version 2.0) spring-boot-starter (org.springframework.boot:spring-boot-starter:2.3.4.RELEASE - https://spring.io/projects/spring-boot)
(Apache License, Version 2.0) spring-boot-starter-actuator (org.springframework.boot:spring-boot-starter-actuator:2.3.4.RELEASE - https://spring.io/projects/spring-boot)
(Apache License, Version 2.0) spring-boot-starter-jdbc (org.springframework.boot:spring-boot-starter-jdbc:2.3.4.RELEASE - https://spring.io/projects/spring-boot)
(Apache License, Version 2.0) spring-boot-starter-jooq (org.springframework.boot:spring-boot-starter-jooq:2.3.4.RELEASE - https://spring.io/projects/spring-boot)
(Apache License, Version 2.0) spring-boot-starter-json (org.springframework.boot:spring-boot-starter-json:2.3.4.RELEASE - https://spring.io/projects/spring-boot)
Expand Down
14 changes: 14 additions & 0 deletions appstore-metadata-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
<start-class>com.lgi.appstore.metadata.Application</start-class>
<generated.source.package>com.lgi.appstore.metadata</generated.source.package>
<maven.jib.plugin.version>2.2.0</maven.jib.plugin.version>
<scmBranch>current</scmBranch>
<scmCommit>latest</scmCommit>
</properties>

<dependencies>
Expand All @@ -32,6 +34,11 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
Expand Down Expand Up @@ -162,6 +169,13 @@
<port>8080</port>
<port>8081</port>
</ports>
<environment>
<APP_NAME>${project.artifactId}</APP_NAME>
<APP_VERSION>${project.version}</APP_VERSION>
<APP_REVISION>${scmCommit}</APP_REVISION><!-- specified at build level -->
<APP_BRANCH>${scmBranch}</APP_BRANCH><!-- specified at build level -->
<APP_BUILD_TIME>${maven.build.timestamp}</APP_BUILD_TIME>
</environment>
<filesModificationTime>${maven.build.timestamp}</filesModificationTime>
<creationTime>USE_CURRENT_TIMESTAMP</creationTime>
</container>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 Liberty Global B.V.
*
* 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 com.lgi.appstore.metadata.info;

import org.springframework.boot.actuate.info.Info;
import org.springframework.boot.actuate.info.InfoContributor;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.TimeZone;

@Component
public class AppInfoContributor implements InfoContributor {

private static final String MISSING_DETAIL_VALUE = "not specified";
private static final Map<String, Object> DETAILS = new HashMap<>();

private final Environment environment;

public AppInfoContributor(Environment environment) {
this.environment = environment;
}

@PostConstruct
public void init() {
addAppPropertyDetailFromEnvironment(AppProperty.APP_BRANCH);
addAppPropertyDetailFromEnvironment(AppProperty.APP_BUILD_TIME);
addAppPropertyDetailFromEnvironment(AppProperty.APP_NAME);
addAppPropertyDetailFromEnvironment(AppProperty.APP_REVISION);
addAppPropertyDetail(AppProperty.APP_START_TIME, getCurrentTime());
addAppPropertyDetailFromEnvironment(AppProperty.APP_VERSION);
addAppPropertyDetailFromEnvironment(AppProperty.HOST_NAME);
addAppPropertyDetailFromEnvironment(AppProperty.STACK_NAME);
}

@Override
public void contribute(Info.Builder builder) {
builder.withDetails(DETAILS);
}

private void addAppPropertyDetailFromEnvironment(AppProperty appProperty) {
addAppPropertyDetail(appProperty, getAppPropertyValueFromEnvironment(appProperty));
}

private void addAppPropertyDetail(AppProperty appProperty, Object value) {
DETAILS.put(appProperty.toString(), value);
}

private Object getAppPropertyValueFromEnvironment(AppProperty appProperty) {
return Optional.ofNullable(environment.getProperty(appProperty.toString()))
.orElse(MISSING_DETAIL_VALUE);
}

public static String getCurrentTime() {
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
df.setTimeZone(TimeZone.getTimeZone("UTC"));
return df.format(new Date());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 Liberty Global B.V.
*
* 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 com.lgi.appstore.metadata.info;

public enum AppProperty {
APP_BRANCH,
APP_BUILD_TIME,
APP_NAME,
APP_REVISION,
APP_START_TIME,
APP_VERSION,
HOST_NAME,
STACK_NAME
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ server.error.include-stacktrace=never
server.error.whitelabel.enabled=false
springdoc.swagger-ui.path=/swagger
springdoc.swagger-ui.url=/appstore-metadata-service.yaml
management.endpoints.enabled-by-default=false
management.endpoints.jmx.exposure.exclude=info
management.endpoints.web.base-path=
management.endpoint.info.enabled=true
management.info.defaults.enabled=false
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
BSD-2-Clause|${line.separator}
CC0|${line.separator}
CC0 1.0 Universal License|${line.separator}
Public Domain, per Creative Commons CC0|${line.separator}
COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0|${line.separator}
CDDL/GPLv2+CE|${line.separator}
Eclipse Public License 1.0|${line.separator}
Expand Down

0 comments on commit 3ed8a01

Please sign in to comment.