Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose library version in logs and as metric #631

Merged
merged 3 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Dependencies.*
import sbt.Package.ManifestAttributes

lazy val commonSettings = Seq(
organization := "com.evolutiongaming",
Expand All @@ -24,6 +25,13 @@ lazy val commonSettings = Seq(
autoAPIMappings := true,
versionScheme := Some("early-semver"),
versionPolicyIntention := Compatibility.BinaryCompatible,
packageOptions := {
Seq(
ManifestAttributes(
("Implementation-Version", (ThisProject / version).value),
),
)
},
)

val alias: Seq[sbt.Def.Setting[?]] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final case class Version(value: String) {

object Version {

val current: Version = Version("3.2.4")
val current: Version = Version(Option(Version.getClass.getPackage.getImplementationVersion).getOrElse("unknown"))

implicit val eqVersion: Eq[Version] = Eq.fromUniversalEquals

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ object EventualCassandra {
schema <- SetupSchema[F](schemaConfig, origin, consistencyConfig)
segmentNrsOf = SegmentNrsOf[F](first = Segments.default, second = Segments.old)
statements <- Statements.of(schema, segmentNrsOf, Segments.default, consistencyConfig.read)
_ <- log.info(s"kafka-journal version: ${Version.current.value}")
} yield {
val journal = apply1[F](statements, dataIntegrity).withLog(log)
metrics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ object ReplicatedCassandra {
statements <- Statements.of[F](schema, config.consistencyConfig)
log <- LogOf[F].apply(ReplicatedCassandra.getClass)
expiryService <- ExpiryService.of[F]
_ <- log.info(s"kafka-journal version: ${Version.current.value}")
} yield {
val segmentOf = SegmentNrsOf[F](first = Segments.default, second = Segments.old)
val journal = apply[F](config.segmentSize, segmentOf, statements, expiryService)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import cats.*
import cats.arrow.FunctionK
import cats.effect.Resource
import cats.syntax.all.*
import cats.effect.syntax.all.*
import com.evolutiongaming.catshelper.{Log, MeasureDuration, MonadThrowable}
import com.evolutiongaming.kafka.journal.*
import com.evolutiongaming.kafka.journal.util.StreamHelper.*
Expand Down Expand Up @@ -136,6 +137,12 @@ object EventualJournal {
prefix: String = "eventual_journal",
): Resource[F, Metrics[F]] = {

val versionGauge = registry.gauge(
name = s"${prefix}_info",
help = "Journal version information",
labels = LabelNames("version"),
)

val latencySummary = registry.summary(
name = s"${prefix}_topic_latency",
help = "Journal call latency in seconds",
Expand All @@ -151,6 +158,8 @@ object EventualJournal {
)

for {
versionGauge <- versionGauge
_ <- versionGauge.labels(Version.current.value).set(1).toResource
latencySummary <- latencySummary
eventsSummary <- eventsSummary
} yield {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ object ReplicatedJournal {
prefix: String = "replicated_journal",
): Resource[F, Metrics[F]] = {

val versionGauge = registry.gauge(
name = s"${prefix}_info",
help = "Journal version information",
labels = LabelNames("version"),
)

val latencySummary = registry.summary(
name = s"${prefix}_latency",
help = "Journal call latency in seconds",
Expand All @@ -203,6 +209,8 @@ object ReplicatedJournal {
)

for {
versionGauge <- versionGauge
_ <- versionGauge.labels(Version.current.value).set(1).toResource
latencySummary <- latencySummary
topicLatencySummary <- topicLatencySummary
eventsSummary <- eventsSummary
Expand Down
Loading