Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
05bdf4f
Use Implementation-Title as default service name if it is available
tobiasstadler Jul 16, 2021
b05df14
Added #1921 to the changelog
tobiasstadler Jul 16, 2021
7b2bef4
Merge branch 'into implementation-title
tobiasstadler Jul 22, 2021
d1d04c3
Merge branch 'master' into implementation-title
tobiasstadler Jul 23, 2021
24a8907
Merge branch 'master' into implementation-title
tobiasstadler Aug 4, 2021
3be5c44
Merge branch 'master' into implementation-title
tobiasstadler Aug 23, 2021
b762d2b
Merge branch 'master' into implementation-title
tobiasstadler Aug 25, 2021
3f347be
Merge remote-tracking branch 'upstream/master' into implementation-title
tobiasstadler Sep 20, 2021
61604f7
Merge remote-tracking branch 'upstream/master' into implementation-title
tobiasstadler Sep 21, 2021
596aeba
Merge branch 'master' into implementation-title
tobiasstadler Oct 1, 2021
8e80f26
Merge branch 'master' into implementation-title
tobiasstadler Oct 6, 2021
d07e79e
Merge branch 'master' into implementation-title
tobiasstadler Oct 13, 2021
ac3461e
Merge branch 'master' into implementation-title
tobiasstadler Oct 27, 2021
08791da
Merge branch 'master' into implementation-title
tobiasstadler Nov 2, 2021
c382aa0
Merge branch 'master' into implementation-title
tobiasstadler Nov 8, 2021
7d213b6
Merge branch 'master' into implementation-title
tobiasstadler Nov 9, 2021
58d31f3
Merge branch 'master' into implementation-title
tobiasstadler Nov 10, 2021
4349484
Merge branch 'master' into implementation-title
tobiasstadler Nov 11, 2021
d537a88
Merge branch 'master' into implementation-title
tobiasstadler Nov 12, 2021
ac372f2
Merge branch 'master' into implementation-title
tobiasstadler Nov 14, 2021
88157ca
Merge remote-tracking branch 'upstream/master' into implementation-title
tobiasstadler Nov 15, 2021
92db7e2
Merge branch 'master' into implementation-title
tobiasstadler Nov 17, 2021
0ef85e2
Merge branch 'master' into implementation-title
tobiasstadler Nov 24, 2021
8b5d38f
Merge remote-tracking branch 'upstream/master' into google-http-client
tobiasstadler Nov 30, 2021
8de2d83
Merge branch 'master' into implementation-title
tobiasstadler Dec 1, 2021
aeda50b
Merge branch 'master' into implementation-title
tobiasstadler Dec 2, 2021
4e0d07a
Updated configuration.asciidoc
tobiasstadler Dec 2, 2021
c165991
Merge remote-tracking branch 'upstream/master' into implementation-title
tobiasstadler Dec 7, 2021
3d3cc24
Merge branch 'master' into implementation-title
tobiasstadler Dec 9, 2021
76876e5
Merge remote-tracking branch 'upstream/master' into implementation-title
tobiasstadler Dec 10, 2021
9aee937
Merge remote-tracking branch 'upstream/master' into implementation-title
tobiasstadler Dec 16, 2021
9767013
Merge remote-tracking branch 'upstream/master' into implementation-title
tobiasstadler Dec 22, 2021
436bf12
Merge remote-tracking branch 'upstream/master' into implementation-title
tobiasstadler Dec 31, 2021
0455983
Merge branch 'master' into implementation-title
tobiasstadler Jan 14, 2022
10a0f73
Merge branch 'master' into implementation-title
tobiasstadler Jan 14, 2022
11b17e6
Merge branch 'master' into implementation-title
tobiasstadler Jan 17, 2022
d24f7de
Merge branch 'master' into implementation-title
tobiasstadler Jan 18, 2022
7cda330
Merge remote-tracking branch 'upstream/master' into implementation-title
tobiasstadler Jan 20, 2022
3098608
Document implementation-title fallback
felixbarny Jan 26, 2022
ec1688c
Update CHANGELOG.asciidoc
tobiasstadler Jan 26, 2022
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
2 changes: 2 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ endif::[]
* Replaced `authorization` in the default value of `sanitize_field_names` with `*auth*` - {pull}2326[#2326]
* Unsampled transactions are dropped and not sent to the APM-Server if the APM-Server version is 8.0+ - {pull}2329[#2329]
* Adding agent logging capabilities to our SDK, making it available for external plugins - {pull}2390[#2390]
* When the `MANIFEST.MF` of the main jar contains the `Implementation-Title` attribute, it is used as the default service name - {pull}1921[#1921]
Note: this may change your service names if you relied on the auto-discovery that uses the name of the jar file. If that jar file also contains an `Implementation-Title` attribute in the `MANIFEST.MF` file, the latter will take precedence.

[float]
===== Bug fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.jar.Attributes;
import java.util.jar.JarFile;

public class ServiceNameUtil {
private static final String JAR_VERSION_SUFFIX = "-(\\d+\\.)+(\\d+)(.*)?$";
Expand Down Expand Up @@ -91,7 +93,14 @@ private static String parseJarCommand(String command) {
String result = null;
for (String commandPart : commandParts) {
if (commandPart.endsWith(".jar")) {
result = removeVersionFromJar(removePath(removeJarExtension(commandPart)));
try (JarFile jarFile = new JarFile(commandPart)) {
result = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_TITLE);
} catch (Exception ignored) {
}

if (result == null || result.isEmpty()) {
result = removeVersionFromJar(removePath(removeJarExtension(commandPart)));
}
break;
}
}
Expand Down
1 change: 1 addition & 0 deletions apm-agent/src/test/resources/configuration.asciidoc.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ ELASTIC_APM_SERVER_URL=http://localhost:8200
For Spring-based application, uses the `spring.application.name` property, if set.
For Servlet-based applications, uses the `display-name` of the `web.xml`, if available.
Falls back to the servlet context path the application is mapped to (unless mapped to the root context).
Falls back to the `Implementation-Title` in the `MANIFEST.MF` file.
Falls back to the name of the main class or jar file.
If the service name is set explicitly, it overrides all of the above.
</#assign>
Expand Down
2 changes: 2 additions & 0 deletions docs/configuration.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ NOTE: Service name auto discovery mechanisms require APM Server 7.0+.
| For Spring-based application, uses the `spring.application.name` property, if set.
For Servlet-based applications, uses the `display-name` of the `web.xml`, if available.
Falls back to the servlet context path the application is mapped to (unless mapped to the root context).
Falls back to the `Implementation-Title` in the `MANIFEST.MF` file.
Falls back to the name of the main class or jar file.
If the service name is set explicitly, it overrides all of the above.
| String | false
Expand Down Expand Up @@ -2891,6 +2892,7 @@ The default unit for this option is `ms`.
# Default value: For Spring-based application, uses the `spring.application.name` property, if set.
# For Servlet-based applications, uses the `display-name` of the `web.xml`, if available.
# Falls back to the servlet context path the application is mapped to (unless mapped to the root context).
# Falls back to the `Implementation-Title` in the `MANIFEST.MF` file.
# Falls back to the name of the main class or jar file.
# If the service name is set explicitly, it overrides all of the above.
#
Expand Down