From 3cb3195fadbe2c5dc828d3cf282f9422f8ba78a1 Mon Sep 17 00:00:00 2001 From: Brian Holt Date: Wed, 18 Sep 2024 14:51:49 -0500 Subject: [PATCH] run scalafmtAll and githubWorkflowGenerate --- .github/workflows/ci.yml | 4 +-- .../contrib/aws/AwsXRayIdGenerator.scala | 15 ++++---- .../contrib/aws/AwsXRayIdGeneratorSuite.scala | 34 +++++++++---------- 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e99c93fec..04720aebc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,11 +92,11 @@ jobs: - name: Make target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') - run: mkdir -p semconv/stable/.jvm/target oteljava/metrics/target sdk-exporter/common/.js/target sdk/common/native/target sdk/common/js/target core/trace/.js/target semconv/metrics/stable/.jvm/target semconv/metrics/experimental/.jvm/target semconv/metrics/stable/.native/target sdk-exporter/all/.jvm/target semconv/experimental/.js/target sdk/trace/.js/target core/common/.jvm/target sdk-exporter/common/.native/target oteljava/common-testkit/target sdk/metrics/.native/target sdk-exporter/metrics/.jvm/target sdk-exporter/trace/.jvm/target unidocs/target sdk-exporter/metrics/.native/target sdk-contrib/aws/resource/.jvm/target oteljava/trace-testkit/target core/metrics/.native/target core/all/.native/target sdk/trace-testkit/.jvm/target sdk/trace-testkit/.native/target sdk/testkit/.native/target sdk-contrib/aws/resource/.js/target semconv/experimental/.native/target core/metrics/.jvm/target core/all/.js/target sdk-exporter/proto/.jvm/target sdk-exporter/proto/.js/target sdk-exporter/metrics/.js/target semconv/stable/.native/target sdk/all/.native/target sdk/metrics-testkit/.js/target sdk-contrib/aws/xray-propagator/.native/target core/metrics/.js/target sdk/testkit/.js/target core/all/.jvm/target sdk-exporter/trace/.native/target sdk/common/jvm/target core/trace/.native/target oteljava/metrics-testkit/target sdk/trace/.native/target semconv/experimental/.jvm/target sdk/metrics-testkit/.native/target sdk/metrics/.jvm/target oteljava/common/target scalafix/rules/target sdk-exporter/proto/.native/target core/trace/.jvm/target sdk-exporter/common/.jvm/target sdk/metrics-testkit/.jvm/target sdk-contrib/aws/resource/.native/target sdk/metrics/.js/target sdk-exporter/trace/.js/target core/common/.native/target sdk/trace-testkit/.js/target core/common/.js/target oteljava/trace/target semconv/metrics/experimental/.native/target oteljava/testkit/target sdk/testkit/.jvm/target sdk-exporter/all/.js/target sdk-contrib/aws/xray-propagator/.js/target semconv/metrics/experimental/.js/target semconv/metrics/stable/.js/target sdk/all/.js/target sdk/all/.jvm/target sdk-exporter/all/.native/target oteljava/all/target sdk/trace/.jvm/target sdk-contrib/aws/xray-propagator/.jvm/target semconv/stable/.js/target project/target + run: mkdir -p semconv/stable/.jvm/target oteljava/metrics/target sdk-exporter/common/.js/target sdk/common/native/target sdk/common/js/target core/trace/.js/target semconv/metrics/stable/.jvm/target semconv/metrics/experimental/.jvm/target semconv/metrics/stable/.native/target sdk-exporter/all/.jvm/target semconv/experimental/.js/target sdk/trace/.js/target core/common/.jvm/target sdk-exporter/common/.native/target oteljava/common-testkit/target sdk/metrics/.native/target sdk-exporter/metrics/.jvm/target sdk-exporter/trace/.jvm/target unidocs/target sdk-exporter/metrics/.native/target sdk-contrib/aws/resource/.jvm/target oteljava/trace-testkit/target core/metrics/.native/target core/all/.native/target sdk/trace-testkit/.jvm/target sdk/trace-testkit/.native/target sdk/testkit/.native/target sdk-contrib/aws/resource/.js/target semconv/experimental/.native/target core/metrics/.jvm/target core/all/.js/target sdk-exporter/proto/.jvm/target sdk-exporter/proto/.js/target sdk-exporter/metrics/.js/target semconv/stable/.native/target sdk/all/.native/target sdk/metrics-testkit/.js/target sdk-contrib/aws/xray-propagator/.native/target core/metrics/.js/target sdk/testkit/.js/target core/all/.jvm/target sdk-exporter/trace/.native/target sdk/common/jvm/target core/trace/.native/target oteljava/metrics-testkit/target sdk/trace/.native/target semconv/experimental/.jvm/target sdk/metrics-testkit/.native/target sdk/metrics/.jvm/target oteljava/common/target scalafix/rules/target sdk-exporter/proto/.native/target core/trace/.jvm/target sdk-exporter/common/.jvm/target sdk/metrics-testkit/.jvm/target sdk-contrib/aws/resource/.native/target sdk/metrics/.js/target sdk-exporter/trace/.js/target core/common/.native/target sdk/trace-testkit/.js/target core/common/.js/target oteljava/trace/target semconv/metrics/experimental/.native/target oteljava/testkit/target sdk/testkit/.jvm/target sdk-exporter/all/.js/target sdk-contrib/aws/xray/.native/target sdk-contrib/aws/xray/.js/target sdk-contrib/aws/xray-propagator/.js/target semconv/metrics/experimental/.js/target semconv/metrics/stable/.js/target sdk/all/.js/target sdk/all/.jvm/target sdk-exporter/all/.native/target oteljava/all/target sdk/trace/.jvm/target sdk-contrib/aws/xray-propagator/.jvm/target semconv/stable/.js/target sdk-contrib/aws/xray/.jvm/target project/target - name: Compress target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') - run: tar cf targets.tar semconv/stable/.jvm/target oteljava/metrics/target sdk-exporter/common/.js/target sdk/common/native/target sdk/common/js/target core/trace/.js/target semconv/metrics/stable/.jvm/target semconv/metrics/experimental/.jvm/target semconv/metrics/stable/.native/target sdk-exporter/all/.jvm/target semconv/experimental/.js/target sdk/trace/.js/target core/common/.jvm/target sdk-exporter/common/.native/target oteljava/common-testkit/target sdk/metrics/.native/target sdk-exporter/metrics/.jvm/target sdk-exporter/trace/.jvm/target unidocs/target sdk-exporter/metrics/.native/target sdk-contrib/aws/resource/.jvm/target oteljava/trace-testkit/target core/metrics/.native/target core/all/.native/target sdk/trace-testkit/.jvm/target sdk/trace-testkit/.native/target sdk/testkit/.native/target sdk-contrib/aws/resource/.js/target semconv/experimental/.native/target core/metrics/.jvm/target core/all/.js/target sdk-exporter/proto/.jvm/target sdk-exporter/proto/.js/target sdk-exporter/metrics/.js/target semconv/stable/.native/target sdk/all/.native/target sdk/metrics-testkit/.js/target sdk-contrib/aws/xray-propagator/.native/target core/metrics/.js/target sdk/testkit/.js/target core/all/.jvm/target sdk-exporter/trace/.native/target sdk/common/jvm/target core/trace/.native/target oteljava/metrics-testkit/target sdk/trace/.native/target semconv/experimental/.jvm/target sdk/metrics-testkit/.native/target sdk/metrics/.jvm/target oteljava/common/target scalafix/rules/target sdk-exporter/proto/.native/target core/trace/.jvm/target sdk-exporter/common/.jvm/target sdk/metrics-testkit/.jvm/target sdk-contrib/aws/resource/.native/target sdk/metrics/.js/target sdk-exporter/trace/.js/target core/common/.native/target sdk/trace-testkit/.js/target core/common/.js/target oteljava/trace/target semconv/metrics/experimental/.native/target oteljava/testkit/target sdk/testkit/.jvm/target sdk-exporter/all/.js/target sdk-contrib/aws/xray-propagator/.js/target semconv/metrics/experimental/.js/target semconv/metrics/stable/.js/target sdk/all/.js/target sdk/all/.jvm/target sdk-exporter/all/.native/target oteljava/all/target sdk/trace/.jvm/target sdk-contrib/aws/xray-propagator/.jvm/target semconv/stable/.js/target project/target + run: tar cf targets.tar semconv/stable/.jvm/target oteljava/metrics/target sdk-exporter/common/.js/target sdk/common/native/target sdk/common/js/target core/trace/.js/target semconv/metrics/stable/.jvm/target semconv/metrics/experimental/.jvm/target semconv/metrics/stable/.native/target sdk-exporter/all/.jvm/target semconv/experimental/.js/target sdk/trace/.js/target core/common/.jvm/target sdk-exporter/common/.native/target oteljava/common-testkit/target sdk/metrics/.native/target sdk-exporter/metrics/.jvm/target sdk-exporter/trace/.jvm/target unidocs/target sdk-exporter/metrics/.native/target sdk-contrib/aws/resource/.jvm/target oteljava/trace-testkit/target core/metrics/.native/target core/all/.native/target sdk/trace-testkit/.jvm/target sdk/trace-testkit/.native/target sdk/testkit/.native/target sdk-contrib/aws/resource/.js/target semconv/experimental/.native/target core/metrics/.jvm/target core/all/.js/target sdk-exporter/proto/.jvm/target sdk-exporter/proto/.js/target sdk-exporter/metrics/.js/target semconv/stable/.native/target sdk/all/.native/target sdk/metrics-testkit/.js/target sdk-contrib/aws/xray-propagator/.native/target core/metrics/.js/target sdk/testkit/.js/target core/all/.jvm/target sdk-exporter/trace/.native/target sdk/common/jvm/target core/trace/.native/target oteljava/metrics-testkit/target sdk/trace/.native/target semconv/experimental/.jvm/target sdk/metrics-testkit/.native/target sdk/metrics/.jvm/target oteljava/common/target scalafix/rules/target sdk-exporter/proto/.native/target core/trace/.jvm/target sdk-exporter/common/.jvm/target sdk/metrics-testkit/.jvm/target sdk-contrib/aws/resource/.native/target sdk/metrics/.js/target sdk-exporter/trace/.js/target core/common/.native/target sdk/trace-testkit/.js/target core/common/.js/target oteljava/trace/target semconv/metrics/experimental/.native/target oteljava/testkit/target sdk/testkit/.jvm/target sdk-exporter/all/.js/target sdk-contrib/aws/xray/.native/target sdk-contrib/aws/xray/.js/target sdk-contrib/aws/xray-propagator/.js/target semconv/metrics/experimental/.js/target semconv/metrics/stable/.js/target sdk/all/.js/target sdk/all/.jvm/target sdk-exporter/all/.native/target oteljava/all/target sdk/trace/.jvm/target sdk-contrib/aws/xray-propagator/.jvm/target semconv/stable/.js/target sdk-contrib/aws/xray/.jvm/target project/target - name: Upload target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') diff --git a/sdk-contrib/aws/xray/src/main/scala/org/typelevel/otel4s/sdk/trace/contrib/aws/AwsXRayIdGenerator.scala b/sdk-contrib/aws/xray/src/main/scala/org/typelevel/otel4s/sdk/trace/contrib/aws/AwsXRayIdGenerator.scala index dd33b7722..699941b3d 100644 --- a/sdk-contrib/aws/xray/src/main/scala/org/typelevel/otel4s/sdk/trace/contrib/aws/AwsXRayIdGenerator.scala +++ b/sdk-contrib/aws/xray/src/main/scala/org/typelevel/otel4s/sdk/trace/contrib/aws/AwsXRayIdGenerator.scala @@ -9,22 +9,19 @@ import org.typelevel.otel4s.trace.SpanContext.{SpanId, TraceId} import scodec.bits.ByteVector object AwsXRayIdGenerator { - def apply[F[_] : Monad : Clock : Random]: AwsXRayIdGenerator[F] = new AwsXRayIdGenerator + def apply[F[_]: Monad: Clock: Random]: AwsXRayIdGenerator[F] = new AwsXRayIdGenerator } -class AwsXRayIdGenerator[F[_] : Monad : Clock : Random] extends IdGenerator[F] { +class AwsXRayIdGenerator[F[_]: Monad: Clock: Random] extends IdGenerator[F] { override def generateSpanId: F[ByteVector] = - Random[F] - .nextLong + Random[F].nextLong .iterateUntil(_ != 0L) .map(SpanId.fromLong) override def generateTraceId: F[ByteVector] = - (Clock[F].realTime.map(_.toSeconds), - Random[F].nextInt.map(_ & 0xFFFFFFFFL), - Random[F].nextLong - ).mapN { case (timestampSecs, hiRandom, lowRandom) => - TraceId.fromLongs(timestampSecs << 32 | hiRandom, lowRandom) + (Clock[F].realTime.map(_.toSeconds), Random[F].nextInt.map(_ & 0xffffffffL), Random[F].nextLong).mapN { + case (timestampSecs, hiRandom, lowRandom) => + TraceId.fromLongs(timestampSecs << 32 | hiRandom, lowRandom) } override private[trace] val canSkipIdValidation: Boolean = true diff --git a/sdk-contrib/aws/xray/src/test/scala/org/typelevel/otel4s/sdk/trace/contrib/aws/AwsXRayIdGeneratorSuite.scala b/sdk-contrib/aws/xray/src/test/scala/org/typelevel/otel4s/sdk/trace/contrib/aws/AwsXRayIdGeneratorSuite.scala index fa102c0bb..070024ba6 100644 --- a/sdk-contrib/aws/xray/src/test/scala/org/typelevel/otel4s/sdk/trace/contrib/aws/AwsXRayIdGeneratorSuite.scala +++ b/sdk-contrib/aws/xray/src/test/scala/org/typelevel/otel4s/sdk/trace/contrib/aws/AwsXRayIdGeneratorSuite.scala @@ -13,21 +13,18 @@ import scodec.bits.ByteVector import scala.concurrent.duration.* -class AwsXRayIdGeneratorSuite - extends CatsEffectSuite - with ScalaCheckEffectSuite { +class AwsXRayIdGeneratorSuite extends CatsEffectSuite with ScalaCheckEffectSuite { - /** - * Generate an arbitrary list of delays representing the times between pairs of - * calls to {{{AwsXRayIdGenerator[IO].generateTraceId}}} - */ + /** Generate an arbitrary list of delays representing the times between pairs of calls to + * {{{AwsXRayIdGenerator[IO].generateTraceId}}} + */ private val genTimeline: Gen[List[FiniteDuration]] = - Gen.posNum[Int] + Gen + .posNum[Int] .flatMap(Gen.listOfN(_, Gen.choose(0.seconds, 1.second))) test("Trace IDs should be a combination of the current timestamp with random numbers") { - PropF.forAllNoShrinkF(Gen.long, genTimeline) { (seed: Long, - timeline: List[FiniteDuration]) => + PropF.forAllNoShrinkF(Gen.long, genTimeline) { (seed: Long, timeline: List[FiniteDuration]) => IntermittentlyZeroRandom[IO](seed).flatMap { controlRandom => IntermittentlyZeroRandom[IO](seed).flatMap { implicit testRandom => val expecteds: IO[List[ByteVector]] = @@ -35,7 +32,7 @@ class AwsXRayIdGeneratorSuite .scanLeft(0.millis)(_ + _) // convert delays to absolute timestamps .traverse { now => for { - hiRandom <- controlRandom.nextInt.map(_ & 0xFFFFFFFFL) + hiRandom <- controlRandom.nextInt.map(_ & 0xffffffffL) lowRandom <- controlRandom.nextLong } yield TraceId.fromLongs(now.toSeconds << 32 | hiRandom, lowRandom) } @@ -85,21 +82,22 @@ class AwsXRayIdGeneratorSuite } object IntermittentlyZeroRandom { - def apply[F[_] : Sync](seed: Long): F[Random[F]] = + def apply[F[_]: Sync](seed: Long): F[Random[F]] = Random.scalaUtilRandomSeedLong[F](seed).map(new IntermittentlyZeroRandom[F](_)) } -class IntermittentlyZeroRandom[F[_] : MonadThrow](actualRandom: Random[F]) extends UnimplementedRandom[F] { - override def nextDouble: F[Double] = actualRandom.nextBoolean.ifM(0D.pure[F], actualRandom.nextDouble) - override def nextFloat: F[Float] = actualRandom.nextBoolean.ifM(0F.pure[F], actualRandom.nextFloat) - override def nextGaussian: F[Double] = actualRandom.nextBoolean.ifM(0D.pure[F], actualRandom.nextGaussian) +class IntermittentlyZeroRandom[F[_]: MonadThrow](actualRandom: Random[F]) extends UnimplementedRandom[F] { + override def nextDouble: F[Double] = actualRandom.nextBoolean.ifM(0d.pure[F], actualRandom.nextDouble) + override def nextFloat: F[Float] = actualRandom.nextBoolean.ifM(0f.pure[F], actualRandom.nextFloat) + override def nextGaussian: F[Double] = actualRandom.nextBoolean.ifM(0d.pure[F], actualRandom.nextGaussian) override def nextInt: F[Int] = actualRandom.nextBoolean.ifM(0.pure[F], actualRandom.nextInt) override def nextIntBounded(n: Int): F[Int] = actualRandom.nextBoolean.ifM(0.pure[F], actualRandom.nextIntBounded(n)) override def nextLong: F[Long] = actualRandom.nextBoolean.ifM(0L.pure[F], actualRandom.nextLong) - override def nextLongBounded(n: Long): F[Long] = actualRandom.nextBoolean.ifM(0L.pure[F], actualRandom.nextLongBounded(n)) + override def nextLongBounded(n: Long): F[Long] = + actualRandom.nextBoolean.ifM(0L.pure[F], actualRandom.nextLongBounded(n)) } -class UnimplementedRandom[F[_] : MonadThrow] extends Random[F] { +class UnimplementedRandom[F[_]: MonadThrow] extends Random[F] { private def notImplemented[A]: F[A] = (new NotImplementedError).raiseError[F, A] override def betweenDouble(minInclusive: Double, maxExclusive: Double): F[Double] = notImplemented