Skip to content

Commit

Permalink
Add version infomation in query
Browse files Browse the repository at this point in the history
  • Loading branch information
kezhenxu94 committed Oct 26, 2021
1 parent f13502f commit e6b2cdc
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions apm-dist/src/main/assembly/binary.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<include>ui-initialized-templates/*</include>
<include>lal/*</include>
<include>log-mal-rules/*</include>
<include>version.properties</include>
</includes>
<outputDirectory>config</outputDirectory>
</fileSet>
Expand Down
2 changes: 1 addition & 1 deletion apm-protocol/apm-network/src/main/proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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;

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
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
* 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();
}
51 changes: 50 additions & 1 deletion oap-server/server-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -27,6 +28,10 @@

<artifactId>server-starter</artifactId>

<properties>
<generateGitPropertiesFilename>${project.build.outputDirectory}/version.properties</generateGitPropertiesFilename>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.skywalking</groupId>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -299,6 +320,7 @@
<exclude>zabbix-rules/</exclude>
<exclude>lal/</exclude>
<exclude>log-mal-rules/</exclude>
<exclude>version.properties</exclude>
</excludes>
</configuration>
</plugin>
Expand All @@ -320,6 +342,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>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.oap.server.core.RunningMode;
import org.apache.skywalking.oap.server.core.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;
Expand Down Expand Up @@ -49,6 +50,8 @@ public static void start() {
// 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);
Expand Down
6 changes: 5 additions & 1 deletion tools/releasing/create_source_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ PRODUCT_NAME=${PRODUCT_NAME}-${RELEASE_VERSION}
rm -rf ${PRODUCT_NAME}
mkdir ${PRODUCT_NAME}

git clone https://github.com/apache/skywalking.git ./${PRODUCT_NAME}
# TODO
git clone https://github.com/kezhenxu94/skywalking.git ./${PRODUCT_NAME}
cd ${PRODUCT_NAME}

TAG_EXIST=`git tag -l ${TAG_NAME} | wc -l`
Expand All @@ -58,6 +59,9 @@ git checkout ${TAG_NAME}
git submodule init
git submodule update

./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 \
Expand Down

0 comments on commit e6b2cdc

Please sign in to comment.