Skip to content

Commit

Permalink
Merge branch 'main' into opentelemetry-annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainJuge authored Nov 16, 2023
2 parents 2bc6c8d + 3e2ec51 commit a948efa
Show file tree
Hide file tree
Showing 22 changed files with 318 additions and 69 deletions.
13 changes: 12 additions & 1 deletion .ci/updatecli.d/update-gherkin-specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ sources:
transformers:
- findsubmatch:
pattern: "[0-9a-f]{40}"

pull_request:
kind: shell
dependson:
- sha
spec:
command: gh api /repos/elastic/apm/commits/{{ source "sha" }}/pulls --jq '.[].html_url'
environments:
- name: GITHUB_TOKEN
- name: PATH
api_key.feature:
kind: file
spec:
Expand Down Expand Up @@ -62,10 +70,13 @@ actions:
description: |-
### What
APM agent Gherkin specs automatic sync
### Why
*Changeset*
* {{ source "pull_request" }}
* https://github.com/elastic/apm/commit/{{ source "sha" }}
targets:
api_key.feature:
name: api_key.feature
Expand Down
12 changes: 11 additions & 1 deletion .ci/updatecli.d/update-json-specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ sources:
transformers:
- findsubmatch:
pattern: "[0-9a-f]{40}"

pull_request:
kind: shell
dependson:
- sha
spec:
command: gh api /repos/elastic/apm/commits/{{ source "sha" }}/pulls --jq '.[].html_url'
environments:
- name: GITHUB_TOKEN
- name: PATH
container_metadata_discovery.json:
kind: file
spec:
Expand Down Expand Up @@ -65,8 +73,10 @@ actions:
description: |-
### What
APM agent specs automatic sync
### Why
*Changeset*
* {{ source "pull_request" }}
* https://github.com/elastic/apm/commit/{{ source "sha" }}
targets:
Expand Down
11 changes: 11 additions & 0 deletions .ci/updatecli.d/update-specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ sources:
transformers:
- findsubmatch:
pattern: "[0-9a-f]{40}"
pull_request:
kind: shell
dependson:
- sha
spec:
command: gh api /repos/elastic/apm-data/commits/{{ source "sha" }}/pulls --jq '.[].html_url'
environments:
- name: GITHUB_TOKEN
- name: PATH
error.json:
kind: file
spec:
Expand Down Expand Up @@ -58,8 +67,10 @@ actions:
description: |-
### What
APM agent json schema automatic sync
### Why
*Changeset*
* {{ source "pull_request" }}
* https://github.com/elastic/apm-data/commit/{{ source "sha" }}
targets:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,10 @@ jobs:
distribution: 'temurin'
- version: 17
distribution: 'temurin'
- version: 22-ea
distribution: 'temurin'
- version: 21
distribution: 'temurin'
- version: 22-ea
distribution: 'temurin'
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/maven-goal
Expand All @@ -311,7 +311,7 @@ jobs:
test-java-distribution: ${{ matrix.distribution }}
command: ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true
- name: Run tests for ${{ matrix.version }}:${{ matrix.distribution }}
run: ./mvnw test -Dtest_java_binary=${{ env.TEST_JAVA_BINARY }}
run: ./mvnw test -Delastic.jdkCompatibilityTest=true -Dtest_java_binary=${{ env.TEST_JAVA_BINARY }}
- name: Store test results
if: success() || failure()
uses: actions/upload-artifact@v3
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Use subheadings with the "=====" level for adding notes for unreleased changes:
* Added support for AWS SDK 2.21 - {pull}3373[#3373]
* Capture bucket and object key to Lambda transaction as OTel attributes - `aws.s3.bueckt`, `aws.s3.key` - {pull}3364[#3364]
* Added `context_propagation_only` configuration option - {pull}3358[#3358]
* Added attribute[*] for JMX pattern metrics (all metrics can now be generated with `object_name[*:type=*,name=*] attribute[*]`) - {pull}3376[#3376]
* Added support for OpenTelemetry annotations - `WithSpan` and `CaptureAttribute` - {pull}3406[#3406]
[float]
Expand Down
2 changes: 1 addition & 1 deletion apm-agent-builds/apm-agent-java8/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<!-- Upgrade log4j2 to non vulnerable version -->
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
<version>2.21.0</version>
<version>2.21.1</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. 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 co.elastic.apm.agent.util;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
import org.junit.jupiter.params.provider.Arguments;

import java.time.LocalDate;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

public class JdkVersionTest {

private static List<Arguments> releaseSchedule() {
// from https://www.oracle.com/java/technologies/java-se-support-roadmap.html
return List.of(
Arguments.of(22, LocalDate.parse("2024-04-01")),
Arguments.of(23, LocalDate.parse("2024-10-01")),
Arguments.of(24, LocalDate.parse("2025-04-01")),
Arguments.of(25, LocalDate.parse("2025-10-01"))
);
}

@Test
@EnabledIfSystemProperty(named = "elastic.jdkCompatibilityTest", matches = "true")
void jdkReleaseScheduleReminder() {
// not using @MethodSource and directly the arguments stream to ensure at least one is in the future
jdkReleaseScheduleReminder(releaseSchedule(), LocalDate.now());
}

void jdkReleaseScheduleReminder(List<Arguments> args, LocalDate now) {

assertThat(args).isNotEmpty();

args.forEach(a -> jdkReleaseScheduleReminder((int) a.get()[0], (LocalDate) a.get()[1], now));
}

void jdkReleaseScheduleReminder(int version, LocalDate gaDate, LocalDate now) {
if (now.isBefore(gaDate)) {
return;
}

assertThat(false)
.describedAs(
"This test fails to remind you that JDK %d is about or already released,\n\n" +
"please update the following:\n" +
"\n" +
"- .github/workflows/main.yml in 'jdk-compatibility-tests' : replace early-access with released GA version and add the new early-access version\n" +
"- in this test: remove released version in the release schedule\n" +
"- in this test: update release schedule if needed\n"
, version)
.isTrue();

}

@Test
void selfTest() {
// verify that the test will fail in the future when we need to get reminded to update

LocalDate now = LocalDate.now();

assertThatThrownBy(() -> jdkReleaseScheduleReminder(List.of(), now))
.isInstanceOf(AssertionError.class);

assertThatThrownBy(() ->
jdkReleaseScheduleReminder(List.of(Arguments.of(42, now)), now))
.isInstanceOf(AssertionError.class);

// should not trigger until the release day
jdkReleaseScheduleReminder(List.of(Arguments.of(42, now.plusDays(1))), now);

}
}
2 changes: 1 addition & 1 deletion apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<properties>
<apm-agent-parent.base.dir>${project.basedir}/../../..</apm-agent-parent.base.dir>
<version.aws.sdk>2.21.1</version.aws.sdk>
<version.aws.sdk>2.21.13</version.aws.sdk>
<version.aws.jms>2.0.0</version.aws.jms>
<!-- AWS SDK v2 is compiled for Java 8 -->
<maven.compiler.target>8</maven.compiler.target>
Expand Down
2 changes: 1 addition & 1 deletion apm-agent-plugins/apm-ecs-logging-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.21.0</version>
<version>2.21.1</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ public class JmxConfiguration extends ConfigurationOptionProvider {
"\n" +
"The agent creates `labels` for each link:https://docs.oracle.com/javase/7/docs/api/javax/management/ObjectName.html#getKeyPropertyList()[JMX key property] such as `type` and `name`.\n" +
"\n" +
"The link:https://docs.oracle.com/javase/7/docs/api/javax/management/ObjectName.html[JMX object name pattern] supports wildcards.\n" +
"In this example, the agent will create a metricset for each memory pool `name` (such as `G1 Old Generation` and `G1 Young Generation`)\n" +
"The link:https://docs.oracle.com/javase/7/docs/api/javax/management/ObjectName.html[JMX object name pattern] supports wildcards. The attribute definition does NOT support wildcards, but a special definition `attribute[*]` is accepted (from 1.44.0) to mean match all possible (numeric) attributes for the associated object name pattern\n" +
"The definition `object_name[*:type=*,name=*] attribute[*]` would match all possible JMX metrics\n" +
"In the following example, the agent will create a metricset for each memory pool `name` (such as `G1 Old Generation` and `G1 Young Generation`)\n" +
"\n" +
"----\n" +
"object_name[java.lang:type=GarbageCollector,name=*] attribute[CollectionCount:metric_name=collection_count] attribute[CollectionTime]\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,12 @@ public String getJmxAttributeName() {
return jmxAttributeName;
}

public String getMetricName() {
return JMX_PREFIX + (metricName != null ? metricName : jmxAttributeName);
public String getMetricName(String foundAttributeName) {
if (!foundAttributeName.isEmpty() && "*".equals(jmxAttributeName)) {
return JMX_PREFIX + (metricName != null ? metricName : foundAttributeName);
} else {
return JMX_PREFIX + (metricName != null ? metricName : jmxAttributeName);
}
}

@Override
Expand All @@ -211,8 +215,8 @@ public Labels getLabels(ObjectName objectName) {
return Labels.Mutable.of(objectName.getKeyPropertyList());
}

public String getCompositeMetricName(String key) {
return getMetricName() + "." + key;
public String getCompositeMetricName(String key, String foundAttributeName) {
return getMetricName(foundAttributeName) + "." + key;
}
}

Expand Down
Loading

0 comments on commit a948efa

Please sign in to comment.