Only set service.framework if info available
While the json schema does not allow the framwork name and version
to be null, it allows framework to be null
@@ -6,14 +6,17 @@ import co.elastic.apm.util.VersionUtils;
public class ServiceFactory {
public Service createService(CoreConfiguration coreConfiguration, String frameworkName, String frameworkVersion) {
- return new Service()
+ Service service = new Service()
.withName(coreConfiguration.getServiceName())
.withVersion(coreConfiguration.getServiceVersion())
.withEnvironment(coreConfiguration.getEnvironment())
.withAgent(new Agent("elastic-apm-java", getAgentVersion()))
- .withRuntime(new Runtime("Java", java.lang.System.getProperty("java.version")))
- .withFramework(new Framework(frameworkName, frameworkVersion))
- .withLanguage(new Language("Java", java.lang.System.getProperty("java.version")));
+ .withRuntime(new Runtime("Java", System.getProperty("java.version")))
+ .withLanguage(new Language("Java", System.getProperty("java.version")));
+ if (frameworkName != null && frameworkVersion != null) {
+ service.withFramework(new Framework(frameworkName, frameworkVersion));
+ }
+ return service;
}
private String getAgentVersion() {
