newrelic/newrelic-jfr-core

JFR as Daemon will add Java Agent app-name to common attributes

Closed this issue · 2 comments

When the running JFR as a daemon process, it currently obtains the entity.guid from the java agent via a JMX MBean.

It would be nice if the Java Agent app_name could also be passed to JFR Daemon. Then, the daemon would set its Service_name and App_name common attributes with the Java Agent app_name.

Just pushed up changes to JFR core, this commit seems to properly set the app name obtained from the agent via JMX on JFR metrics/events: 55e5953

I configured the Java agent with the app name app_name: Daemon Test and the JFR daemon with NEW_RELIC_APP_NAME=jfr-daemon. The daemon was able to get the app name from the agent via JMX and set the app.name and service.name attributes to match the agent.

Events:

        {
          "app.name": "Daemon Test",
          "collector.name": "JFR-Uploader",
          "entity.guid": "MjIxMjg2NHxBUE18QVBQTElDQVRJT058MTUzNDE3OTQ3MQ",
          "host.hostname": "C02XQ1RKJG5J/192.168.1.12",
          "instrumentation.name": "JFR",
          "instrumentation.provider": "JFR-Uploader",
          "nr.customEventSource": "customEventInserter",
          "service.name": "Daemon Test",
          "stackTrace": "{\"type\":\"stacktrace\",\"language\":\"java\",\"version\":1,\"truncated\":false,\"payload\":[{\"desc\":\"sun.nio.ch.ServerSocketChannelImpl.accept0(Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;[Ljava/net/InetSocketAddress;)I\",\"line\":\"0\",\"bytecodeIndex\":\"0\"},{\"desc\":\"sun.nio.ch.ServerSocketChannelImpl.accept(Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;[Ljava/net/InetSocketAddress;)I\",\"line\":\"0\",\"bytecodeIndex\":\"4\"},{\"desc\":\"sun.nio.ch.ServerSocketChannelImpl.accept()Ljava/nio/channels/SocketChannel;\",\"line\":\"0\",\"bytecodeIndex\":\"41\"},{\"desc\":\"org.apache.tomcat.util.net.NioEndpoint.serverSocketAccept()Ljava/nio/channels/SocketChannel;\",\"line\":\"0\",\"bytecodeIndex\":\"4\"},{\"desc\":\"org.apache.tomcat.util.net.NioEndpoint.serverSocketAccept()Ljava/lang/Object;\",\"line\":\"0\",\"bytecodeIndex\":\"1\"},{\"desc\":\"org.apache.tomcat.util.net.Acceptor.run()V\",\"line\":\"0\",\"bytecodeIndex\":\"98\"},{\"desc\":\"java.lang.Thread.run()V\",\"line\":\"0\",\"bytecodeIndex\":\"11\"}]}",
          "thread.name": "http-nio-8080-Acceptor",
          "thread.state": "STATE_RUNNABLE",
          "timestamp": 1617833702972
        }

Metrics:

        {
          "app.name": "Daemon Test",
          "collector.name": "JFR-Uploader",
          "entity.guid": "MjIxMjg2NHxBUE18QVBQTElDQVRJT058MTUzNDE3OTQ3MQ",
          "host.hostname": "C02XQ1RKJG5J/192.168.1.12",
          "instrumentation.name": "JFR",
          "instrumentation.provider": "JFR-Uploader",
          "jfr.CPULoad.jvmSystem": {
            "type": "gauge",
            "count": 1,
            "sum": 0.000631267495919019,
            "min": 0.000631267495919019,
            "max": 0.000631267495919019,
            "latest": 0.000631267495919019
          },
          "metricName": "jfr.CPULoad.jvmSystem",
          "newrelic.source": "metricAPI",
          "nr.entity.guid": "MjIxMjg2NHxBUE18QVBQTElDQVRJT058MTUzNDE3OTQ3MQ",
          "service.name": "Daemon Test",
          "timestamp": 1617833702521
        }

Tests in this commit: 847e06c