Skip to content

Service names of web apps on same tomcat are all same despite having different config #795

@digz6666

Description

@digz6666

Describe the bug
Service names of web apps on same tomcat are all same despite having different config.
Also the log file of only first web app is created, others are not.

I builth project with maven and placed elasticapm.properties file in my src/main/resources folder.
Then I attached apm-agent in servlet initializer:

import co.elastic.apm.attach.ElasticApmAttacher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

public class ServletInitializer extends SpringBootServletInitializer {

    private static final Logger LOGGER = LoggerFactory.getLogger(ServletInitializer.class);

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        LOGGER.info("Attaching elastic APM agent ...");
        ElasticApmAttacher.attach();

        LOGGER.info("Starting servlet app ...");
        return application.sources(BootApplication.class);
    }
}

Versions
Tomcat version: 9.0.22
JDK: Oracle JDK 1.8 64bit
Agent version: 1.8.0
APM server: 7.3.0
Spring boot: 2.1.7.RELEASE

To Reproduce
Steps to reproduce the behavior:

  1. Download and extract clean tomcat 9
  2. Remove docs, examples from webapps
  3. Copy at least 2 web apps with different elastic-apm config
  4. Go to kibana console and see all your web app data is grouped together under same service

Expected behavior
Each web app data should be under its own service, not grouped together.

Elastic webapp config

Web app 1:

log_level=WARN
log_file=../logs/apm-backoffice.log

classes_excluded_from_instrumentation=java.*,com.sun.*,sun.*
application_packages=mn.astvision.starter

service_name=starter-backend
server_urls=https://xxx
secret_token=xxx
server_timeout=15s
verify_server_cert=false

Web app 2:

log_level=WARN
log_file=../logs/apm-notification-api.log

classes_excluded_from_instrumentation=java.*,com.sun.*,sun.*
application_packages=mn.astvision.starter

service_name=starter-notification-api
server_urls=https://xxx
secret_token=xxx
server_timeout=15s
verify_server_cert=false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions