Skip to content
This repository was archived by the owner on Sep 18, 2025. It is now read-only.

Commit 375b142

Browse files
committed
Apply scalafmt formatting
1 parent b27aa7a commit 375b142

36 files changed

Lines changed: 217 additions & 172 deletions

File tree

build.sbt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ lazy val modules: List[ProjectReference] = List(
66
`stracer`,
77
`stracer-play-json`,
88
`stracer-circe`,
9-
`stracer-kafka`
9+
`stracer-kafka`,
1010
)
1111

1212
lazy val root = project
@@ -30,21 +30,26 @@ lazy val `stracer` = project
3030
CatsEffect.effect,
3131
configTools,
3232
Pureconfig.pureconfig,
33-
scalatest % Test))
33+
scalatest % Test,
34+
),
35+
)
3436

3537
lazy val `stracer-play-json` = project
3638
.dependsOn(`stracer`)
3739
.settings(commonSettings)
3840
.settings(
3941
libraryDependencies ++= Seq(
4042
PlayJsonTools.tools,
41-
scalatest % Test))
43+
scalatest % Test,
44+
),
45+
)
4246

4347
lazy val `stracer-circe` = project
4448
.dependsOn(`stracer`)
4549
.settings(commonSettings)
4650
.settings(
47-
libraryDependencies ++= Circe.all ++ Seq(scalatest % Test))
51+
libraryDependencies ++= Circe.all ++ Seq(scalatest % Test),
52+
)
4853

4954
lazy val `stracer-kafka` = project
5055
.dependsOn(`stracer`)
@@ -63,11 +68,11 @@ val commonSettings = Seq(
6368
releaseCrossBuild := true,
6469
licenses := Seq(("MIT", url("https://opensource.org/licenses/MIT"))),
6570
publishTo := Some(Resolver.evolutionReleases),
66-
scalacOptsFailOnWarn := Some(false))
71+
scalacOptsFailOnWarn := Some(false),
72+
)
6773

6874
val alias: Seq[sbt.Def.Setting[?]] =
6975
// addCommandAlias("check", "all versionPolicyCheck Compile/doc") ++
7076
addCommandAlias("check", "all Compile/doc scalafmtCheckAll scalafmtSbtCheck") ++
7177
addCommandAlias("build", "+all compile test") ++
7278
addCommandAlias("fmt", "+all scalafmtAll scalafmtSbt")
73-

project/Dependencies.scala

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ import sbt._
22

33
object Dependencies {
44

5-
val scalatest = "org.scalatest" %% "scalatest" % "3.2.15"
6-
val zipkin = "io.zipkin.zipkin2" % "zipkin" % "2.21.6"
7-
val `cats-helper` = "com.evolutiongaming" %% "cats-helper" % "3.5.0"
8-
val random = "com.evolutiongaming" %% "random" % "1.0.0"
9-
val configTools = "com.evolutiongaming" %% "config-tools" % "1.0.4"
10-
val skafka = "com.evolutiongaming" %% "skafka" % "17.1.2"
11-
5+
val scalatest = "org.scalatest" %% "scalatest" % "3.2.15"
6+
val zipkin = "io.zipkin.zipkin2" % "zipkin" % "2.21.6"
7+
val `cats-helper` = "com.evolutiongaming" %% "cats-helper" % "3.5.0"
8+
val random = "com.evolutiongaming" %% "random" % "1.0.0"
9+
val configTools = "com.evolutiongaming" %% "config-tools" % "1.0.4"
10+
val skafka = "com.evolutiongaming" %% "skafka" % "17.1.2"
1211

1312
object Cats {
1413
private val version = "2.8.0"
@@ -28,24 +27,24 @@ object Dependencies {
2827
object PlayJsonTools {
2928
private val version = "1.1.1"
3029

31-
val tools = "com.evolution" %% "play-json-tools" % version
30+
val tools = "com.evolution" %% "play-json-tools" % version
3231
}
3332

3433
object Circe {
35-
private val version = "0.14.9"
34+
private val version = "0.14.9"
3635
private val versionExtras = "0.14.1"
3736

38-
val core = "io.circe" %% "circe-core" % version
39-
val generic = "io.circe" %% "circe-generic" % version
40-
val parser = "io.circe" %% "circe-parser" % version
37+
val core = "io.circe" %% "circe-core" % version
38+
val generic = "io.circe" %% "circe-generic" % version
39+
val parser = "io.circe" %% "circe-parser" % version
4140
val `generic-extras` = "io.circe" %% "circe-generic-extras" % versionExtras
4241

4342
val all: Seq[ModuleID] = Seq(core, generic, parser, `generic-extras`)
4443
}
4544

4645
object Pureconfig {
4746
private val version = "0.17.3"
48-
val pureconfig = "com.github.pureconfig" %% "pureconfig" % version
49-
val cats = "com.github.pureconfig" %% "pureconfig-cats" % version
47+
val pureconfig = "com.github.pureconfig" %% "pureconfig" % version
48+
val cats = "com.github.pureconfig" %% "pureconfig-cats" % version
5049
}
5150
}

project/plugins.sbt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.2.1")
2-
32
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.1")
4-
53
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
6-
74
addSbtPlugin("com.evolution" % "sbt-scalac-opts-plugin" % "0.0.9")
8-
95
addSbtPlugin("com.evolution" % "sbt-artifactory-plugin" % "0.0.2")
10-
11-
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.5")
6+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.5")

stracer-circe/src/main/scala/com/evolutiongaming/stracer/TraceJson.scala

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
package com.evolutiongaming.stracer
22

3-
import io.circe.Decoder.Result
4-
import io.circe.{Codec, DecodingFailure, HCursor, Json}
5-
import io.circe.generic.semiauto._
63
import cats.syntax.either._
74
import com.evolutiongaming.stracer.hex.{FromHex, ToHex}
5+
import io.circe.Decoder.Result
6+
import io.circe.generic.semiauto._
7+
import io.circe.{Codec, DecodingFailure, HCursor, Json}
88

99
object TraceJson {
1010

1111
implicit val samplingCodec: Codec[Sampling] = new Codec[Sampling] {
1212
def name(a: Sampling): String = a.toString.toLowerCase
13-
val elements = Sampling.Values.map(a => (name(a), a)).toMap
13+
val elements = Sampling.Values.map(a => (name(a), a)).toMap
1414

1515
override def apply(a: Sampling): Json = Json.fromString(name(a))
1616

@@ -23,13 +23,17 @@ object TraceJson {
2323
} yield sampling
2424
}
2525

26-
def hexCodec[A](implicit toHex: ToHex[A], fromHex: FromHex[A]): Codec[A] = new Codec[A] {
27-
override def apply(a: A): Json = Json.fromString(toHex(a))
26+
def hexCodec[A](
27+
implicit
28+
toHex: ToHex[A],
29+
fromHex: FromHex[A],
30+
): Codec[A] = new Codec[A] {
31+
override def apply(a: A): Json = Json.fromString(toHex(a))
2832
override def apply(c: HCursor): Result[A] =
2933
for {
30-
hex <- c.as[String]
31-
value <- fromHex(hex).leftMap(
32-
error => DecodingFailure(s"Value $hex is not a proper hex. Got error $error while decoding.", List.empty)
34+
hex <- c.as[String]
35+
value <- fromHex(hex).leftMap(error =>
36+
DecodingFailure(s"Value $hex is not a proper hex. Got error $error while decoding.", List.empty),
3337
)
3438
} yield value
3539
}

stracer-circe/src/test/scala/com/evolutiongaming/stracer/TraceJsonSpec.scala

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
package com.evolutiongaming.stracer
22

33
import cats.syntax.all._
4-
import java.time.Instant
54
import com.evolutiongaming.stracer.TraceJson._
65
import io.circe.Decoder
76
import io.circe.parser._
8-
9-
import scala.io.Source
107
import io.circe.syntax._
118
import org.scalatest.funsuite.AnyFunSuite
129
import org.scalatest.matchers.should.Matchers
1310

11+
import java.time.Instant
12+
import scala.io.Source
13+
1414
class TraceJsonSpec extends AnyFunSuite with Matchers {
1515

1616
val trace: Trace = {
1717

18-
val timestamp = Instant.ofEpochMilli(1551824013554L)
19-
val traceId = TraceId(timestamp, randomInt = 12345, randomLong = 123456789L)
20-
val spanId = SpanId(1551818273913L)
18+
val timestamp = Instant.ofEpochMilli(1551824013554L)
19+
val traceId = TraceId(timestamp, randomInt = 12345, randomLong = 123456789L)
20+
val spanId = SpanId(1551818273913L)
2121

2222
Trace(
2323
traceId = traceId,
2424
spanId = spanId,
2525
parentId = none,
2626
timestamp = timestamp.some,
27-
sampling = Sampling.Accept.some
27+
sampling = Sampling.Accept.some,
2828
)
2929
}
3030

3131
test("toJson & fromJson") {
3232

3333
val resourceStream = getClass.getResourceAsStream("trace.json")
34-
val expectedJson = parse(Source.fromInputStream(resourceStream).mkString).getOrElse(sys.error("No file found."))
34+
val expectedJson =
35+
parse(Source.fromInputStream(resourceStream).mkString).getOrElse(sys.error("No file found."))
3536

3637
val json = trace.asJson
3738
json shouldEqual expectedJson

stracer-kafka/src/main/scala/com/evolutiongaming/stracer/ReportSpan.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ object ReportSpan {
2121
localEndpoint: Endpoint,
2222
tags: Tags,
2323
reportSpan: ReportSpanRecord[F],
24-
kind: Kind
24+
kind: Kind,
2525
): ReportSpan[F] = new ReportSpan[F] {
2626

2727
def apply(span: Span) = {
@@ -43,7 +43,7 @@ object ReportSpan {
4343
annotations = List.empty,
4444
tags = tags1,
4545
debug = None,
46-
shared = span.shared
46+
shared = span.shared,
4747
)
4848

4949
reportSpan(record)

stracer-kafka/src/main/scala/com/evolutiongaming/stracer/ReportSpanRecord.scala

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ object ReportSpanRecord {
3030
def of[F[_]: Async: LogOf: FromTry](
3131
config: Config,
3232
enabled: F[Boolean],
33-
producerOf: ProducerOf[F]
33+
producerOf: ProducerOf[F],
3434
): Resource[F, ReportSpanRecord[F]] = {
3535

3636
val reportSpan = for {
37-
_ <- config.getOpt[Boolean]("enabled").filter(identity)
37+
_ <- config.getOpt[Boolean]("enabled").filter(identity)
3838
producerConfig <- config.getOpt[Config]("kafka.producer").map(ProducerConfig(_))
3939
} yield {
40-
val topic = config.getOpt[String]("topic") getOrElse "jaeger"
40+
val topic = config.getOpt[String]("topic") getOrElse "jaeger"
4141
implicit val toBytes = ToBytesOf(SpanBytesEncoder.THRIFT)
4242
of[F](topic, producerConfig, enabled, producerOf)
4343
}
@@ -49,10 +49,9 @@ object ReportSpanRecord {
4949
topic: Topic,
5050
producerConfig: ProducerConfig,
5151
enabled: F[Boolean],
52-
producerOf: ProducerOf[F]
53-
)(
54-
implicit
55-
toBytes: ToBytes[F, Nel[SpanRecord]]
52+
producerOf: ProducerOf[F],
53+
)(implicit
54+
toBytes: ToBytes[F, Nel[SpanRecord]],
5655
): Resource[F, ReportSpanRecord[F]] = {
5756

5857
sealed trait State
@@ -94,7 +93,7 @@ object ReportSpanRecord {
9493

9594
case None if enabled =>
9695
val state = for {
97-
_ <- log.info("enable")
96+
_ <- log.info("enable")
9897
producer <- producer(log)
9998
} yield {
10099
State.running(producer.some)
@@ -120,8 +119,8 @@ object ReportSpanRecord {
120119
case _: State.Running =>
121120
for {
122121
enabled <- enabled
123-
_ <- Sync[F].uncancelable { _ => update(stateRef, enabled, log) }
124-
_ <- Temporal[F].sleep(10.seconds)
122+
_ <- Sync[F].uncancelable { _ => update(stateRef, enabled, log) }
123+
_ <- Temporal[F].sleep(10.seconds)
125124
} yield {
126125
().asLeft[Unit]
127126
}
@@ -130,12 +129,12 @@ object ReportSpanRecord {
130129
}
131130

132131
val resource = for {
133-
log <- LogOf[F].apply(getClass)
132+
log <- LogOf[F].apply(getClass)
134133
stateRef <- SerialRef[F].of(State.running(none))
135134
release = stateRef.update {
136135
case State.Running(Some((_, release))) => release.as(State.stopped)
137-
case State.Running(None) => State.stopped.pure[F]
138-
case State.Stopped => State.stopped.pure[F]
136+
case State.Running(None) => State.stopped.pure[F]
137+
case State.Stopped => State.stopped.pure[F]
139138
}
140139
fiber <- background(stateRef, log)
141140
.guarantee(release)
@@ -155,7 +154,7 @@ object ReportSpanRecord {
155154
} yield {
156155
state match {
157156
case State.Running(producer) => producer.map { case (producer, _) => producer }
158-
case State.Stopped => none[Producer[F]]
157+
case State.Stopped => none[Producer[F]]
159158
}
160159
}
161160

@@ -166,15 +165,19 @@ object ReportSpanRecord {
166165
Resource(resource)
167166
}
168167

169-
def apply[F[_]: Concurrent: FromTry](topic: Topic, producer: F[Option[Producer[F]]], log: Log[F])(
170-
implicit
171-
toBytes: ToBytes[F, Nel[SpanRecord]]
168+
def apply[F[_]: Concurrent: FromTry](
169+
topic: Topic,
170+
producer: F[Option[Producer[F]]],
171+
log: Log[F],
172+
)(implicit
173+
toBytes: ToBytes[F, Nel[SpanRecord]],
172174
): ReportSpanRecord[F] = new ReportSpanRecord[F] {
173175

174176
def apply(span: SpanRecord): F[Unit] = {
175177

176178
def send(producer: Producer[F]) = {
177-
val record = ProducerRecord[String, Nel[SpanRecord]](topic = topic, key = span.traceId.hex, value = Nel.of(span))
179+
val record =
180+
ProducerRecord[String, Nel[SpanRecord]](topic = topic, key = span.traceId.hex, value = Nel.of(span))
178181
producer
179182
.send(record)
180183
.void
@@ -187,7 +190,7 @@ object ReportSpanRecord {
187190

188191
for {
189192
producer <- producer
190-
result <- producer.foldMapM(send)
193+
result <- producer.foldMapM(send)
191194
} yield result
192195
}
193196
}

stracer-kafka/src/main/scala/com/evolutiongaming/stracer/ToBytesOf.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ package com.evolutiongaming.stracer
33
import cats.data.{NonEmptyList => Nel}
44
import cats.effect.Sync
55
import com.evolutiongaming.skafka.{ToBytes, Topic}
6-
import zipkin2.codec.SpanBytesEncoder
7-
86
import com.evolutiongaming.stracer.compat.CollectionConverters._
7+
import zipkin2.codec.SpanBytesEncoder
98

109
object ToBytesOf {
1110

12-
def apply[F[_]: Sync](encode: SpanBytesEncoder): ToBytes[F, Nel[SpanRecord]] = { (spans: Nel[SpanRecord], _: Topic) =>
13-
{
14-
val spansJ = spans.toList.map(_.toJava).asJava
15-
Sync[F].delay { encode.encodeList(spansJ) }
16-
}
11+
def apply[F[_]: Sync](encode: SpanBytesEncoder): ToBytes[F, Nel[SpanRecord]] = {
12+
(spans: Nel[SpanRecord], _: Topic) =>
13+
{
14+
val spansJ = spans.toList.map(_.toJava).asJava
15+
Sync[F].delay { encode.encodeList(spansJ) }
16+
}
1717
}
1818
}

stracer-kafka/src/test/scala/com/evolutiongaming/stracer/ReportSpanSpec.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.evolutiongaming.stracer
22

33
import cats.syntax.all._
4-
import java.time.Instant
54
import com.evolutiongaming.stracer.implicits._
6-
7-
import scala.concurrent.duration._
85
import org.scalatest.funsuite.AnyFunSuite
96
import org.scalatest.matchers.should.Matchers
107

8+
import java.time.Instant
9+
import scala.concurrent.duration._
10+
1111
class ReportSpanSpec extends AnyFunSuite with Matchers {
1212

1313
import ReportSpanSpec._
@@ -39,7 +39,7 @@ class ReportSpanSpec extends AnyFunSuite with Matchers {
3939
"name",
4040
timestamp,
4141
duration = duration.some,
42-
tags = ("name2" -> "value") & ("name3" -> "value3")
42+
tags = ("name2" -> "value") & ("name3" -> "value3"),
4343
)
4444

4545
val reportSpan = ReportSpan[StateT](localEndpoint, tags, reportSpanRecord, Kind.producer)
@@ -58,7 +58,7 @@ class ReportSpanSpec extends AnyFunSuite with Matchers {
5858
annotations = List.empty,
5959
tags = Map(("name1", "value1"), ("name2", "value"), ("name3", "value3")),
6060
debug = None,
61-
shared = None
61+
shared = None,
6262
)
6363
state shouldEqual State(List(record))
6464
}

0 commit comments

Comments
 (0)