Skip to content

Commit

Permalink
rename makeScope -> childScope
Browse files Browse the repository at this point in the history
  • Loading branch information
iRevive committed Dec 16, 2023
1 parent 11bd300 commit 55be98e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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==
*
Expand Down Expand Up @@ -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))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 ()
Expand All @@ -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) =>
Expand All @@ -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 ()
Expand All @@ -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 {
Expand Down

0 comments on commit 55be98e

Please sign in to comment.