Report the agent version to OAP (#397)
This commit is contained in:
parent
6b33d053ea
commit
51161ae6a5
|
|
@ -13,6 +13,7 @@ Release Notes.
|
|||
* Upgrade agent test tools
|
||||
* [Breaking Change] Compatible with 3.x and 4.x RabbitMQ Client, rename `rabbitmq-5.x-plugin` to `rabbitmq-plugin`
|
||||
* Polish JDBC plugins to make DBType accurate
|
||||
* Report the agent version to OAP as an instance attribute
|
||||
|
||||
#### Documentation
|
||||
|
||||
|
|
|
|||
|
|
@ -33,10 +33,12 @@
|
|||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<generateGitPropertiesFilename>${project.build.outputDirectory}/skywalking-agent-version.properties</generateGitPropertiesFilename>
|
||||
<guava.version>30.1.1-jre</guava.version>
|
||||
<wiremock.version>2.6.0</wiremock.version>
|
||||
<netty-tcnative-boringssl-static.version>2.0.7.Final</netty-tcnative-boringssl-static.version>
|
||||
<os-maven-plugin.version>1.4.1.Final</os-maven-plugin.version>
|
||||
<git-commit-id-plugin.version>4.9.10</git-commit-id-plugin.version>
|
||||
<shade.com.google.source>com.google</shade.com.google.source>
|
||||
<shade.com.google.target>${shade.package}.${shade.com.google.source}</shade.com.google.target>
|
||||
<shade.io.grpc.source>io.grpc</shade.io.grpc.source>
|
||||
|
|
@ -171,6 +173,30 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>pl.project13.maven</groupId>
|
||||
<artifactId>git-commit-id-plugin</artifactId>
|
||||
<version>${git-commit-id-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>get-the-git-infos</id>
|
||||
<goals>
|
||||
<goal>revision</goal>
|
||||
</goals>
|
||||
<phase>initialize</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<failOnNoGitDirectory>false</failOnNoGitDirectory>
|
||||
<generateGitPropertiesFile>true</generateGitPropertiesFile>
|
||||
<generateGitPropertiesFilename>${generateGitPropertiesFilename}</generateGitPropertiesFilename>
|
||||
<commitIdGenerationMode>full</commitIdGenerationMode>
|
||||
<includeOnlyProperties>
|
||||
<includeOnlyProperty>git.build.version</includeOnlyProperty>
|
||||
<includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
|
||||
</includeOnlyProperties>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<executions>
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.skywalking.apm.agent.core.conf.Config;
|
||||
import org.apache.skywalking.apm.agent.core.version.Version;
|
||||
import org.apache.skywalking.apm.network.common.v3.KeyStringValuePair;
|
||||
import org.apache.skywalking.apm.util.StringUtil;
|
||||
|
||||
|
|
@ -45,6 +46,7 @@ public class InstanceJsonPropertiesUtil {
|
|||
|
||||
properties.add(KeyStringValuePair.newBuilder().setKey("namespace").setValue(Config.Agent.NAMESPACE).build());
|
||||
properties.add(KeyStringValuePair.newBuilder().setKey("cluster").setValue(Config.Agent.CLUSTER).build());
|
||||
properties.add(KeyStringValuePair.newBuilder().setKey("version").setValue(Version.CURRENT.toString()).build());
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* 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.apm.agent.core.version;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.apache.skywalking.apm.agent.core.logging.api.ILog;
|
||||
import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
@Getter
|
||||
public enum Version {
|
||||
CURRENT;
|
||||
|
||||
private static final ILog LOGGER = LogManager.getLogger(Version.class);
|
||||
private static final String VERSION_FILE_NAME = "skywalking-agent-version.properties";
|
||||
private final String buildVersion;
|
||||
private final String commitIdAbbrev;
|
||||
|
||||
Version() {
|
||||
try {
|
||||
InputStream inputStream = Version.class.getClassLoader().getResourceAsStream(VERSION_FILE_NAME);
|
||||
if (inputStream == null) {
|
||||
throw new IOException("Can't find " + VERSION_FILE_NAME);
|
||||
}
|
||||
Properties properties = new Properties();
|
||||
properties.load(inputStream);
|
||||
buildVersion = properties.getProperty("git.build.version");
|
||||
commitIdAbbrev = properties.getProperty("git.commit.id.abbrev");
|
||||
} catch (Exception e) {
|
||||
throw new ExceptionInInitializerError(e);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
LOGGER.info("SkyWalking agent version: {}", CURRENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s-%s", buildVersion, commitIdAbbrev);
|
||||
}
|
||||
}
|
||||
3
pom.xml
3
pom.xml
|
|
@ -402,7 +402,8 @@
|
|||
</resourceIncludes>
|
||||
<resourceExcludes>
|
||||
**/.asf.yaml,
|
||||
**/.github/**
|
||||
**/.github/**,
|
||||
**/skywalking-agent-version.properties
|
||||
</resourceExcludes>
|
||||
<excludes>
|
||||
**/target/generated-test-sources/**,
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@
|
|||
value: '{{ notEmpty .value }}'
|
||||
- name: ipv4s
|
||||
value: {{ notEmpty .value }}
|
||||
- name: version
|
||||
value: {{ notEmpty .value }}
|
||||
{{- end }}
|
||||
language: JAVA
|
||||
instanceuuid: {{ b64enc "e2e-service-provider" }}.1_{{ b64enc "provider1" }}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,11 @@ git checkout ${TAG_NAME}
|
|||
git submodule init
|
||||
git submodule update
|
||||
|
||||
# Generate a static skywalking-agent-version.properties and override the template when releasing source tar
|
||||
# because after that there is no Git information anymore.
|
||||
./mvnw -q -pl apm-sniffer/apm-agent-core initialize \
|
||||
-DgenerateGitPropertiesFilename="$(pwd)/apm-sniffer/apm-agent-core/src/main/resources/skywalking-agent-version.properties"
|
||||
|
||||
cd ..
|
||||
# Build source code tar
|
||||
tar czf ${PRODUCT_NAME}-src.tgz \
|
||||
|
|
|
|||
Loading…
Reference in New Issue