@@ -2,20 +2,18 @@ package com.colisweb.tracing.context
22
33import cats .data .OptionT
44import cats .effect ._
5- import cats .effect .concurrent .Ref
5+ import cats .effect .kernel .Ref
66import cats .syntax .all ._
77import com .colisweb .tracing .core ._
88import com .typesafe .scalalogging .StrictLogging
99import org .slf4j .Logger
1010
11- import scala .concurrent .duration .MILLISECONDS
12-
1311/** A tracing context that will log the beginning and the end of all traces along with
1412 * their tags.
1513 * The traces will be emitted with a TRACE level, so make sure to configure your logging backend
1614 * to ennable the TRACE level for com.colisweb.tracing
1715 */
18- class LoggingTracingContext [F [_]: Sync : Timer ](
16+ class LoggingTracingContext [F [_]: Sync ](
1917 traceIdP : String ,
2018 spanIdP : String ,
2119 tagsRef : Ref [F , Tags ],
@@ -41,7 +39,7 @@ object LoggingTracingContext extends StrictLogging {
4139 /** Returns a Resource[F, TracingContext[F]]. The first log will be emitted
4240 * as the resource is acquired, the second log when it is released.
4341 */
44- def apply [F [_]: Sync : Timer ](
42+ def apply [F [_]: Sync ](
4543 parentContext : Option [LoggingTracingContext [F ]] = None ,
4644 idGenerator : Option [F [String ]] = None ,
4745 slf4jLogger : org.slf4j.Logger = logger.underlying,
@@ -52,7 +50,7 @@ object LoggingTracingContext extends StrictLogging {
5250 ): TracingContextResource [F ] =
5351 resource(parentContext, idGenerator, slf4jLogger, operationName, correlationId).evalMap(ctx => ctx.addTags(tags).map(_ => ctx))
5452
55- private def resource [F [_]: Sync : Timer ](
53+ private def resource [F [_]: Sync ](
5654 parentContext : Option [LoggingTracingContext [F ]],
5755 idGenerator : Option [F [String ]],
5856 slf4jLogger : org.slf4j.Logger ,
@@ -68,7 +66,7 @@ object LoggingTracingContext extends StrictLogging {
6866 tagsRef <- Ref [F ].of[Tags ](Map .empty)
6967 spanId <- idGeneratorValue
7068 traceId <- traceIdF
71- start <- Clock [F ].monotonic( MILLISECONDS )
69+ start <- Clock [F ].monotonic.map(_.toMillis )
7270 ctx = new LoggingTracingContext [F ](traceId, spanId, tagsRef, correlationId)
7371 details = SpanDetails (start, traceId, spanId, ctx, tagsRef)
7472 _ <- logger.trace(" Trace {} Starting Span {} ({})" , traceId, spanId, operationName)
@@ -78,7 +76,7 @@ object LoggingTracingContext extends StrictLogging {
7876 case SpanDetails (start, traceId, spanId, _, tagsRef) =>
7977 for {
8078 tags <- tagsRef.get
81- end <- Clock [F ].monotonic( MILLISECONDS )
79+ end <- Clock [F ].monotonic.map(_.toMillis )
8280 duration = end - start
8381 _ <- logger.trace(
8482 " Trace {} Finished Span {} ({}) in {}ms. Tags: {}" ,
@@ -109,7 +107,7 @@ object LoggingTracingContext extends StrictLogging {
109107 * This is provided for convenience and consistency with regards to the other
110108 * tracing contexts types.
111109 */
112- def builder [F [_]: Sync : Timer ]: F [TracingContextBuilder [F ]] =
110+ def builder [F [_]: Sync ]: F [TracingContextBuilder [F ]] =
113111 Sync [F ].delay((operationName : String , tags : Tags , correlationId : String ) =>
114112 LoggingTracingContext .apply(correlationId = correlationId)(operationName, tags)
115113 )
0 commit comments