forked from elastic/apm-agent-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
elastic#3030: Remove dependency to core module and use SDK dependency…
… instead.
- Loading branch information
Showing
175 changed files
with
3,187 additions
and
357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
apm-agent-core/src/main/java/co/elastic/apm/agent/configuration/JaxRsConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* 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.configuration; | ||
|
||
import org.stagemonitor.configuration.ConfigurationOption; | ||
import org.stagemonitor.configuration.ConfigurationOptionProvider; | ||
|
||
/** | ||
* Configuration provider for the apm jax-rs plugin | ||
*/ | ||
public class JaxRsConfiguration extends ConfigurationOptionProvider { | ||
private static final String JAXRS_CATEGORY = "JAX-RS"; | ||
|
||
private final ConfigurationOption<Boolean> enableJaxrsAnnotationInheritance = ConfigurationOption.booleanOption() | ||
.key("enable_jaxrs_annotation_inheritance") | ||
.tags("added[1.5.0]") | ||
.configurationCategory(JAXRS_CATEGORY) | ||
.tags("performance") | ||
.description( | ||
"By default, the agent will scan for @Path annotations on the whole class hierarchy, recognizing a class as a JAX-RS resource if the class or any of its superclasses/interfaces has a class level @Path annotation.\n" + | ||
"If your application does not use @Path annotation inheritance, set this property to 'false' to only scan for direct @Path annotations. This can improve the startup time of the agent.\n") | ||
.dynamic(false) | ||
.buildWithDefault(true); | ||
|
||
private final ConfigurationOption<Boolean> useAnnotationValueForTransactionName = ConfigurationOption.booleanOption() | ||
.key("use_jaxrs_path_as_transaction_name") | ||
.tags("added[1.8.0]") | ||
.configurationCategory(JAXRS_CATEGORY) | ||
.description("By default, the agent will use `ClassName#methodName` for the transaction name of JAX-RS requests.\n" + | ||
"If you want to use the URI template from the `@Path` annotation, set the value to `true`.") | ||
.dynamic(false) | ||
.buildWithDefault(false); | ||
|
||
/** | ||
* @return if true, the jax-rs plugin must scan for @Path annotations in the class hierarchy of classes. | ||
* if false, only @Path annotations on implementation classes are considered. | ||
*/ | ||
public boolean isEnableJaxrsAnnotationInheritance() { | ||
return enableJaxrsAnnotationInheritance.get(); | ||
} | ||
|
||
public boolean isUseJaxRsPathForTransactionName() { | ||
return useAnnotationValueForTransactionName.get(); | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
apm-agent-core/src/main/java/co/elastic/apm/agent/configuration/MongoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* 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.configuration; | ||
|
||
import co.elastic.apm.agent.configuration.converter.WildcardMatcher; | ||
import co.elastic.apm.agent.matcher.WildcardMatcherValueConverter; | ||
import org.stagemonitor.configuration.ConfigurationOption; | ||
import org.stagemonitor.configuration.ConfigurationOptionProvider; | ||
import org.stagemonitor.configuration.converter.ListValueConverter; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class MongoConfiguration extends ConfigurationOptionProvider { | ||
|
||
private final ConfigurationOption<List<WildcardMatcher>> captureStatementCommands = ConfigurationOption | ||
.builder(new ListValueConverter<>(new WildcardMatcherValueConverter()), List.class) | ||
.key("mongodb_capture_statement_commands") | ||
.configurationCategory("MongoDB") | ||
.description("MongoDB command names for which the command document will be captured, limited to common read-only operations by default.\n" + | ||
"Set to ` \"\"` (empty) to disable capture, and `\"*\"` to capture all (which is discouraged as it may lead to sensitive information capture).\n" + | ||
"\n" + | ||
WildcardMatcher.DOCUMENTATION | ||
) | ||
.dynamic(true) | ||
.buildWithDefault(Arrays.asList( | ||
WildcardMatcher.valueOf("find"), | ||
WildcardMatcher.valueOf("aggregate"), | ||
WildcardMatcher.valueOf("count"), | ||
WildcardMatcher.valueOf("distinct"), | ||
WildcardMatcher.valueOf("mapReduce") | ||
)); | ||
|
||
public List<WildcardMatcher> getCaptureStatementCommands() { | ||
return captureStatementCommands.get(); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...in-sdk/src/main/java/co/elastic/apm/agent/sdk/PluginClassLoaderRootPackageCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* 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.sdk; | ||
|
||
import java.util.Collection; | ||
import java.util.Map; | ||
|
||
public interface PluginClassLoaderRootPackageCustomizer { | ||
|
||
boolean isIncludePluginPackage(); | ||
|
||
Collection<String> pluginClassLoaderRootPackages(); | ||
|
||
Map<String, ? extends Collection<String>> requiredModuleOpens(); | ||
} |
117 changes: 117 additions & 0 deletions
117
apm-agent-plugin-sdk/src/main/java/co/elastic/apm/agent/sdk/Version.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* 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.sdk; | ||
|
||
import java.util.Arrays; | ||
import java.util.Objects; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
public class Version implements Comparable<Version> { | ||
|
||
private static final Version INVALID = new Version(new int[0], ""); | ||
|
||
private static final Pattern VERSION_REGEX = Pattern.compile("^" + | ||
"(?<prefix>.*?)" + | ||
"(?<version>(\\d+)(\\.\\d+)*)" + | ||
"(?<suffix>.*?)" + | ||
"$"); | ||
|
||
private final int[] numbers; | ||
private final String suffix; | ||
|
||
public static Version of(String version) { | ||
Matcher matcher = VERSION_REGEX.matcher(version); | ||
if (!matcher.find()) { | ||
return INVALID; | ||
} | ||
final String[] parts = matcher.group("version").split("\\."); | ||
int[] numbers = new int[parts.length]; | ||
for (int i = 0; i < parts.length; i++) { | ||
numbers[i] = Integer.parseInt(parts[i]); | ||
} | ||
|
||
String suffixTmp = matcher.group("suffix"); | ||
if (suffixTmp == null) { | ||
suffixTmp = ""; | ||
} | ||
String suffix = suffixTmp; | ||
return new Version(numbers, suffix); | ||
} | ||
|
||
private Version(int[] numbers, String suffix) { | ||
this.numbers = numbers; | ||
this.suffix = suffix; | ||
} | ||
|
||
public boolean hasSuffix() { | ||
return suffix.length() > 0; | ||
} | ||
|
||
public Version withoutSuffix() { | ||
return new Version(numbers, ""); | ||
} | ||
|
||
@Override | ||
public int compareTo(Version another) { | ||
final int maxLength = Math.max(numbers.length, another.numbers.length); | ||
for (int i = 0; i < maxLength; i++) { | ||
final int left = i < numbers.length ? numbers[i] : 0; | ||
final int right = i < another.numbers.length ? another.numbers[i] : 0; | ||
if (left != right) { | ||
return left < right ? -1 : 1; | ||
} | ||
} | ||
if (suffix.isEmpty() || another.suffix.isEmpty()) { | ||
// no suffix is greater than any suffix (1.0.0 > 1.0.0-SNAPSHOT) | ||
return another.suffix.compareTo(suffix); | ||
} else { | ||
// if both have a suffix, sort in natural order (1.0.0-RC2 > 1.0.0-RC1) | ||
return suffix.compareTo(another.suffix); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
for (int i = 0; i < numbers.length; i++) { | ||
sb.append(numbers[i]); | ||
if (i < numbers.length - 1) { | ||
sb.append('.'); | ||
} | ||
} | ||
sb.append(suffix); | ||
return sb.toString(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
Version version = (Version) o; | ||
return Arrays.equals(numbers, version.numbers) && suffix.equals(version.suffix); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = Objects.hash(suffix); | ||
result = 31 * result + Arrays.hashCode(numbers); | ||
return result; | ||
} | ||
} |
Oops, something went wrong.