diff --git a/samza-core/src/main/scala/org/apache/samza/container/SamzaContainer.scala b/samza-core/src/main/scala/org/apache/samza/container/SamzaContainer.scala index d15c1090f2..5b182abc0f 100644 --- a/samza-core/src/main/scala/org/apache/samza/container/SamzaContainer.scala +++ b/samza-core/src/main/scala/org/apache/samza/container/SamzaContainer.scala @@ -764,6 +764,7 @@ class SamzaContainer( containerListener.afterStart() } metrics.containerStartupTime.set((System.nanoTime() - startTime)/1000000) + metrics.containerStarted.set(1) if (taskInstances.size > 0) runLoop.run else diff --git a/samza-core/src/main/scala/org/apache/samza/container/SamzaContainerMetrics.scala b/samza-core/src/main/scala/org/apache/samza/container/SamzaContainerMetrics.scala index 1beb3dd752..6ca1161398 100644 --- a/samza-core/src/main/scala/org/apache/samza/container/SamzaContainerMetrics.scala +++ b/samza-core/src/main/scala/org/apache/samza/container/SamzaContainerMetrics.scala @@ -46,6 +46,7 @@ class SamzaContainerMetrics( val diskQuotaBytes = newGauge("disk-quota-bytes", Long.MaxValue) val executorWorkFactor = newGauge("executor-work-factor", 1.0) val physicalMemoryMb = newGauge[Double]("physical-memory-mb", 0.0F) + val containerStarted = newGauge[Long]("container-started", 0L) val taskStoreRestorationMetrics: util.Map[TaskName, Gauge[Long]] = new util.HashMap[TaskName, Gauge[Long]]() diff --git a/samza-core/src/test/scala/org/apache/samza/container/TestSamzaContainer.scala b/samza-core/src/test/scala/org/apache/samza/container/TestSamzaContainer.scala index 78136bf03c..4d5007db0b 100644 --- a/samza-core/src/test/scala/org/apache/samza/container/TestSamzaContainer.scala +++ b/samza-core/src/test/scala/org/apache/samza/container/TestSamzaContainer.scala @@ -77,6 +77,7 @@ class TestSamzaContainer extends AssertionsForJUnit with MockitoSugar { MockitoAnnotations.initMocks(this) setupSamzaContainer(Some(this.applicationContainerContext)) when(this.metrics.containerStartupTime).thenReturn(mock[Gauge[Long]]) + when(this.metrics.containerStarted).thenReturn(mock[Gauge[Long]]) } @Test