From 55be98e5c7daaca82bf31bbc6cc7794077e0a461 Mon Sep 17 00:00:00 2001 From: Maksym Ochenashko Date: Sat, 16 Dec 2023 11:23:03 +0200 Subject: [PATCH] rename `makeScope` -> `childScope` --- .../otel4s/sdk/trace/SdkTraceScope.scala | 8 ++++---- .../otel4s/sdk/trace/SdkTraceScopeSuite.scala | 20 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/sdk/trace/src/main/scala/org/typelevel/otel4s/sdk/trace/SdkTraceScope.scala b/sdk/trace/src/main/scala/org/typelevel/otel4s/sdk/trace/SdkTraceScope.scala index c11a4458f..5405910a4 100644 --- a/sdk/trace/src/main/scala/org/typelevel/otel4s/sdk/trace/SdkTraceScope.scala +++ b/sdk/trace/src/main/scala/org/typelevel/otel4s/sdk/trace/SdkTraceScope.scala @@ -110,9 +110,9 @@ private[trace] trait SdkTraceScope[F[_]] { * @param spanContext * the span context to use */ - def makeScope(spanContext: SpanContext): F[F ~> F] + def childScope(spanContext: SpanContext): F[F ~> F] - /** Creates a root scope. The difference with the [[makeScope]] is that we + /** Creates a root scope. The difference with the [[childScope]] is that we * override the whole [[Context]], rather then only a [[SpanContext]] within * the context. * @@ -186,7 +186,7 @@ private[trace] trait SdkTraceScope[F[_]] { * We use [[SpanContext.invalid]] as a mark that the propagation logic is * no-op. * - * A shortcut for `makeScope(SpanContext.invalid)`. + * A shortcut for `childScope(SpanContext.invalid)`. * * ==The propagation logic== * @@ -280,7 +280,7 @@ private[trace] object SdkTraceScope { def current: F[Option[SpanContext]] = L.reader(_.get(SpanContextKey)) - def makeScope(span: SpanContext): F[F ~> F] = + def childScope(span: SpanContext): F[F ~> F] = L.applicative.map(current) { context => createScope(nextScope(context, span)) } diff --git a/sdk/trace/src/test/scala/org/typelevel/otel4s/sdk/trace/SdkTraceScopeSuite.scala b/sdk/trace/src/test/scala/org/typelevel/otel4s/sdk/trace/SdkTraceScopeSuite.scala index 3868b3bdf..7bf4747f7 100644 --- a/sdk/trace/src/test/scala/org/typelevel/otel4s/sdk/trace/SdkTraceScopeSuite.scala +++ b/sdk/trace/src/test/scala/org/typelevel/otel4s/sdk/trace/SdkTraceScopeSuite.scala @@ -134,7 +134,7 @@ class SdkTraceScopeSuite extends CatsEffectSuite with ScalaCheckEffectSuite { _ <- scope.withContext(ctxWithKey) { for { _ <- assertIO(scope.contextReader(_.get(key)), Some(value)) - scope1 <- scope.makeScope(ctx) + scope1 <- scope.childScope(ctx) _ <- scope1 { for { // the key must be present within the custom scope @@ -156,14 +156,14 @@ class SdkTraceScopeSuite extends CatsEffectSuite with ScalaCheckEffectSuite { } } - test("makeScope - use the given context when there is no SpanContext") { + test("childScope - use the given context when there is no SpanContext") { PropF.forAllF { (ctx: SpanContext) => for { scope <- createTraceScope _ <- assertIO(scope.current, None) - lift <- scope.makeScope(ctx) + lift <- scope.childScope(ctx) _ <- lift(assertIO(scope.current, Some(ctx))) // the context must be reset @@ -172,18 +172,18 @@ class SdkTraceScopeSuite extends CatsEffectSuite with ScalaCheckEffectSuite { } } - test("makeScope - use the given context when there is a valid SpanContext") { + test("childScope - use the given context when there is a valid SpanContext") { PropF.forAllF { (ctx1: SpanContext, ctx2: SpanContext) => for { scope <- createTraceScope _ <- assertIO(scope.current, None) - scope1 <- scope.makeScope(ctx1) + scope1 <- scope.childScope(ctx1) _ <- scope1 { for { _ <- assertIO(scope.current, Some(ctx1)) - scope2 <- scope.makeScope(ctx2) + scope2 <- scope.childScope(ctx2) _ <- scope2(assertIO(scope.current, Some(ctx2))) _ <- assertIO(scope.current, Some(ctx1)) } yield () @@ -195,7 +195,7 @@ class SdkTraceScopeSuite extends CatsEffectSuite with ScalaCheckEffectSuite { } } - test("makeScope - use invalid context when there is an valid SpanContext") { + test("childScope - use invalid context when there is an valid SpanContext") { val invalid = SpanContext.invalid PropF.forAllF { (valid: SpanContext) => @@ -204,11 +204,11 @@ class SdkTraceScopeSuite extends CatsEffectSuite with ScalaCheckEffectSuite { _ <- assertIO(scope.current, None) - scope1 <- scope.makeScope(invalid) + scope1 <- scope.childScope(invalid) _ <- scope1 { for { _ <- assertIO(scope.current, Some(invalid)) - scope2 <- scope.makeScope(valid) + scope2 <- scope.childScope(valid) _ <- scope2(assertIO(scope.current, Some(invalid))) _ <- assertIO(scope.current, Some(invalid)) } yield () @@ -232,7 +232,7 @@ class SdkTraceScopeSuite extends CatsEffectSuite with ScalaCheckEffectSuite { // the context is empty _ <- assertIO(scope.noopScope(scope.current), Some(invalid)) - scope1 <- scope.makeScope(ctx) + scope1 <- scope.childScope(ctx) // the context has a valid span _ <- scope1 {