All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.taig.flog.stackdriver.grpc.MonitoredResources.scala Maven / Gradle / Ivy

There is a newer version: 0.13.1
Show newest version
package io.taig.flog.stackdriver.grpc

import java.util.{Map => JMap}

import cats.effect.Sync
import com.google.cloud.MonitoredResource

object MonitoredResources {
  private def unsafeGetEnv(name: String): String = Option(System.getenv(name)).getOrElse("unknown")

  val global: MonitoredResource = MonitoredResource.newBuilder("global").build()

  def cloudRun[F[_]](implicit F: Sync[F]): F[MonitoredResource] = F.delay {
    MonitoredResource
      .newBuilder("cloud_run_revision")
      .setLabels(
        // format: off
        JMap.of(
          "service_name", unsafeGetEnv("K_SERVICE"),
          "revision_name", unsafeGetEnv("K_REVISION"),
          "configuration_name", unsafeGetEnv("K_CONFIGURATION")
        )
        // format: on
      )
      .build()
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy