未验证 提交 a5685cb1 编写于 作者: K kezhenxu94 提交者: GitHub

Add a GraphQL query to get OAP version, display OAP version in startup message...

Add a GraphQL query to get OAP version, display OAP version in startup message and error logs (#8004)
上级 3470f7fb
......@@ -18,3 +18,7 @@ OALLexer.tokens
.checkstyle
.externalToolBuilders
oap-server/oal-grammar/**/gen/
# This serves as a template but will ONLY be updated when building a source release tar,
# so we don't track future updates of this file.
oap-server/server-starter/src/main/resources/version.properties
......@@ -61,5 +61,6 @@ header:
- '**/src/main/proto/protoc-gen-swagger/**'
- '**/src/main/proto/validate/validate.proto'
- '**/src/main/proto/opencensus/**'
- 'oap-server/server-starter/src/main/resources/version.properties'
comment: on-failure
......@@ -52,6 +52,7 @@ Release Notes.
* Add `getProfileTaskLogs` to profile query protocol.
* Set `SW_KAFKA_FETCHER_ENABLE_NATIVE_PROTO_LOG`, `SW_KAFKA_FETCHER_ENABLE_NATIVE_JSON_LOG` default `true`.
* Fix unexpected deleting due to TTL mechanism bug for H2, MySQL, TiDB and PostgreSQL.
* Add a GraphQL query to get OAP version, display OAP version in startup message and error logs.
#### UI
......
Subproject commit e6742be211302cf7eb93db83bdf1da2a8e600d17
Subproject commit 21492e496b797567d0e127f4510509baf73e10fd
......@@ -20,7 +20,11 @@
<Configuration status="INFO">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout charset="UTF-8" pattern="%d %c %L [%t] %-5p %x - %m%n"/>
<PatternLayout>
<LevelPatternSelector defaultPattern="%d %c %L [%t] %-5p %x - %m%n">
<PatternMatch key="ERROR" pattern="%d %c %L [%t] %-5p %x - [%swversion] %m%n" />
</LevelPatternSelector>
</PatternLayout>
</Console>
</Appenders>
<Loggers>
......
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.skywalking.oap.server.core.version;
import java.io.IOException;
import java.util.Properties;
import lombok.Getter;
import org.apache.logging.log4j.util.Strings;
@Getter
public enum Version {
CURRENT;
private final String buildVersion;
private final String buildTime;
private final String commitId;
private final Properties properties = new Properties();
Version() {
try {
properties.load(Version.class.getClassLoader()
.getResourceAsStream("version.properties"));
buildVersion = properties.getProperty("git.build.version");
buildTime = properties.getProperty("git.build.time");
commitId = properties.getProperty("git.commit.id");
} catch (IOException e) {
throw new ExceptionInInitializerError(e);
}
}
@Override
public String toString() {
return String.format(
"%s-%s (%s)",
buildVersion,
Strings.left(commitId, 7),
buildTime
);
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.skywalking.oap.server.core.version;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.pattern.ConverterKeys;
import org.apache.logging.log4j.core.pattern.LogEventPatternConverter;
import org.apache.logging.log4j.core.pattern.PatternConverter;
@Plugin(name = "VersionLogConverter", category = PatternConverter.CATEGORY)
@ConverterKeys({"swversion"})
public class VersionLogConverter extends LogEventPatternConverter {
protected VersionLogConverter(String name) {
super(name, null);
}
public static VersionLogConverter newInstance(String[] options) {
return new VersionLogConverter("swversion");
}
@Override
public void format(LogEvent event, StringBuilder toAppendTo) {
toAppendTo.append(Version.CURRENT);
}
}
......@@ -19,10 +19,12 @@
package org.apache.skywalking.oap.query.graphql.resolver;
import com.coxautodev.graphql.tools.GraphQLQueryResolver;
import org.apache.skywalking.oap.server.core.version.Version;
/**
* Root Query Resolver.
*/
public class Query implements GraphQLQueryResolver {
private String version = "8.0";
@SuppressWarnings("unused") // Used in GraphQL query
private final String version = Version.CURRENT.toString();
}
......@@ -17,7 +17,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">
<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">
<parent>
<artifactId>oap-server</artifactId>
<groupId>org.apache.skywalking</groupId>
......@@ -27,6 +28,10 @@
<artifactId>server-starter</artifactId>
<properties>
<generateGitPropertiesFilename>${project.build.outputDirectory}/version.properties</generateGitPropertiesFilename>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.skywalking</groupId>
......@@ -260,6 +265,22 @@
<build>
<finalName>skywalking-oap</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>version.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>version.properties</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
......@@ -320,6 +341,33 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.9.10</version>
<executions>
<execution>
<id>get-the-git-information</id>
<goals>
<goal>revision</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
<configuration>
<verbose>false</verbose>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${generateGitPropertiesFilename}</generateGitPropertiesFilename>
<dateFormatTimeZone>UTC</dateFormatTimeZone>
<dateFormat>yyyyMMddHHmmss</dateFormat>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<includeOnlyProperties>
<includeOnlyProperty>^git.build.version$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.id$</includeOnlyProperty>
<includeOnlyProperty>^git.build.time$</includeOnlyProperty>
</includeOnlyProperties>
</configuration>
</plugin>
</plugins>
</build>
</project>
......@@ -20,6 +20,7 @@ package org.apache.skywalking.oap.server.starter;
import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.oap.server.core.RunningMode;
import org.apache.skywalking.oap.server.core.version.Version;
import org.apache.skywalking.oap.server.library.module.ApplicationConfiguration;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.starter.config.ApplicationConfigLoader;
......@@ -49,6 +50,8 @@ public class OAPServerBootstrap {
// Set uptime to second
.setValue(System.currentTimeMillis() / 1000d);
log.info("Version of OAP: {}", Version.CURRENT);
if (RunningMode.isInitMode()) {
log.info("OAP starts up in init mode successfully, exit now...");
System.exit(0);
......
......@@ -20,7 +20,11 @@
<Configuration status="DEBUG">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout charset="UTF-8" pattern="%d %c %L [%t] %-5p %x - %m%n"/>
<PatternLayout>
<LevelPatternSelector defaultPattern="%d %c %L [%t] %-5p %x - %m%n">
<PatternMatch key="ERROR" pattern="%d %c %L [%t] %-5p %x - [%swversion] %m%n" />
</LevelPatternSelector>
</PatternLayout>
</Console>
</Appenders>
<Loggers>
......
......@@ -58,6 +58,11 @@ git checkout ${TAG_NAME}
git submodule init
git submodule update
# Generate a static version.properties and override the template when releasing source tar
# because after that there is no Git information anymore.
./mvnw -q -pl oap-server/server-starter initialize \
-DgenerateGitPropertiesFilename="$(pwd)/oap-server/server-starter/src/main/resources/version.properties"
cd ..
tar czf ${PRODUCT_NAME}-src.tgz \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册