Skip to content
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 26 additions & 0 deletions apm-sniffer/apm-agent-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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;

Expand All @@ -45,6 +46,7 @@ public static List<KeyStringValuePair> parseProperties() {

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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@
</resourceIncludes>
<resourceExcludes>
**/.asf.yaml,
**/.github/**
**/.github/**,
**/skywalking-agent-version.properties
</resourceExcludes>
<excludes>
**/target/generated-test-sources/**,
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/case/expected/service-instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }}
Expand Down
5 changes: 5 additions & 0 deletions tools/releasing/create_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down