Custom Events

In APM is there a feature available for custom events similar how New Relic provide it?

Custom event collection is enabled by default in Java agent version 3.13.0 or higher. To send custom events, simply call the relevant API. For example:

Map<String, Object> eventAttributes = new HashMap<String, Object>(); NewRelic.getAgent().getInsights().recordCustomEvent("MyCustomEvent" eventAttributes);

What I mean is insert a code snippet where APM agent is listening and throw events directly to APM server. (not to a log file)

Can our public API be used for what you need?

Thanks for the API resource which was helpful.

When building a Rest Service to be deployed on Wildfly 14.01 and 10.x, using APM agent 1.1.0 and 1.0.1 as follows:

public ControllerResult<String> processEvent(String message)
            throws SQLException, IOException, ParseException {
        //Transaction transaction = ElasticApm.currentTransaction();
        Transaction transaction = ElasticApm.startTransaction();
        try {
            transaction.setResult("Hallo Manuel");
        } catch (Exception e) {
            throw e;
        } finally {
        return ControllerResult.of("Event processed successfully");

POM contains the following artifact:

<!-- -->

The subsequent error prompted by WildFly as follows:

10:51:36,575 ERROR [default task-1] [] [request] UT005023: Exception handling request to /eventprocessor/receive: org.jboss.resteasy.spi.UnhandledException: java.lang.NoClassDefFoundError: co/elastic/apm/api/ElasticApm

at [org.jboss.resteasy.resteasy-jaxrs@3.6.1.Final//org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(](mailto:org.jboss.resteasy.resteasy-jaxrs@3.6.1.Final//org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(

at [io.undertow.servlet@2.0.13.Final//io.undertow.servlet.handlers.ServletHandler.handleRequest(](mailto:io.undertow.servlet@2.0.13.Final//io.undertow.servlet.handlers.ServletHandler.handleRequest(

at [org.wildfly.extension.undertow@14.0.1.Final//](mailto:org.wildfly.extension.undertow@14.0.1.Final//

at [org.jboss.threads@2.3.2.Final//](mailto:org.jboss.threads@2.3.2.Final//

at deployment.eventprocessor.war//

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(

at [org.jboss.weld.core@3.0.5.Final//org.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(](mailto:org.jboss.weld.core@3.0.5.Final//org.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(

at deployment.eventprocessor.war//$Proxy$_$$_WeldSubclass.storeEvent(Unknown Source)

... 50 more

Caused by: java.lang.ClassNotFoundException: co.elastic.apm.api.ElasticApm
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(
at java.base/java.lang.ClassLoader.loadClass(
at org.jboss.modules.JDKSpecific.getSystemClass(
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(
at org.jboss.modules.ConcurrentClassLoader.loadClass(

... 88 more

Appreciate any help.

We currently have a bug which prevents the public API from working on WildFly. See

1 Like

Thanks Felix!
Can we expect a fast fix or has this bug low priority on your table?
We are very keen to get a fix soon, because we are evaluating the APM solution in order to replace the current environment.

This bug has high priority for us.

I'm on vacation next week but @Eyal_Koren will take over.


Release 1.2.0 is ready and should fix this issue.
We will be happy to get any additional feedback.

Good luck!

1 Like

Thanks Koren.
We have been tested APM Java Client v1.2:

Wildfly agent is configured in standalone.conf.bat like:

set "JAVA_OPTS=%JAVA_OPTS% -javaagent:C:/admin/development/wildfly-14.0.1.Final/bin/elastic-apm-agent-1.2.0.jar -Delastic.apm.server_urls= -Delastic.apm.service_name=apm-agent-1_2_0 -Delastic.apm.capture_body=all"

The results are as follows:

  • Using GET requests: a lot of useful data is now being displayed (solved)
  • Using POST requests: the context.request.body field is [REDACTED] which is useless (still a bug?)
Key Value
? context.request.body [REDACTED]
? context.request.headers.Accept /
? context.request.headers.Connection keep-alive
? context.request.headers.Content-Type text/plain
? context.request.headers.Host localhost:8080
? context.request.headers.Postman-Token [REDACTED]
? context.request.headers.User-Agent PostmanRuntime/7.4.0
? context.request.headers.accept-encoding gzip, deflate
? context.request.headers.cache-control no-cache
? context.request.headers.content-length 2
t context.request.http_version 1.1
t context.request.method POST
? context.request.socket.encrypted false
? context.request.socket.remote_address
t context.request.url.full http://localhost:8080/eventprocessor/event/receive
t context.request.url.hostname localhost
t context.request.url.pathname /eventprocessor/event/receive
t context.request.url.port 8080
t context.request.url.protocol http

Note that the capture_headers option currently only supports recording application/x-www-form-urlencoded data (form parameters). Recording JSON data, for example, is not currently supported.

1 Like

Thanks Felix!
Is there any intention to offer other headers in the near future? (e.g. text/plain).
x-www-form-urlencoded is not really flexible...

Wish you soon a Happy New Year!

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.