From a478d3b5678b6d001e92efcf948a344b3be61ca5 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Tue, 17 Sep 2024 07:41:15 +0100 Subject: [PATCH] make kamon-pekko tolerant of null dispatcherPrerequisites (#1361) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OK let's just get this in for now and I'll work on the instrumentation again today and hope I make better progress 😅 --- .../instrumentations/DispatcherInstrumentation.scala | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/instrumentation/kamon-pekko/src/main/scala/kamon/instrumentation/pekko/instrumentations/DispatcherInstrumentation.scala b/instrumentation/kamon-pekko/src/main/scala/kamon/instrumentation/pekko/instrumentations/DispatcherInstrumentation.scala index 31eee18c5..b2c3a7454 100644 --- a/instrumentation/kamon-pekko/src/main/scala/kamon/instrumentation/pekko/instrumentations/DispatcherInstrumentation.scala +++ b/instrumentation/kamon-pekko/src/main/scala/kamon/instrumentation/pekko/instrumentations/DispatcherInstrumentation.scala @@ -127,13 +127,18 @@ object InstrumentNewExecutorServiceOnPekko { @SuperCall callable: Callable[ExecutorService] ): ExecutorService = { val executor = callable.call() - val actorSystemName = factory.dispatcherPrerequisites.settings.name + val actorSystemName = if (factory.dispatcherPrerequisites != null) { + factory.dispatcherPrerequisites.settings.name + } else { + "unknown" + } val dispatcherName = factory.dispatcherName val scheduledActionName = actorSystemName + "/" + dispatcherName val systemTags = TagSet.of("pekko.system", actorSystemName) if (Kamon.filter(PekkoInstrumentation.TrackDispatcherFilterName).accept(dispatcherName)) { - val defaultEcOption = factory.dispatcherPrerequisites.defaultExecutionContext + val defaultEcOption = Option(factory.dispatcherPrerequisites) + .flatMap(_.defaultExecutionContext) if (dispatcherName == Dispatchers.DefaultDispatcherId && defaultEcOption.isDefined) { ExecutorInstrumentation.instrumentExecutionContext(