@@ -22,6 +22,7 @@ import natchez._
22
22
23
23
import java .net .URI
24
24
import cats .effect .Ref
25
+ import org .typelevel .ci .CIString
25
26
26
27
/*
27
28
* A minimal Natchez tracing implementation that accumulates
@@ -47,9 +48,9 @@ object Tracing {
47
48
IO .unit // not implemented
48
49
49
50
def kernel : IO [Kernel ] =
50
- IO .pure(Kernel (Map (" span-id" -> id.toString)))
51
+ IO .pure(Kernel (Map (CIString ( " span-id" ) -> id.toString)))
51
52
52
- def span (name : String ): Resource [IO , Span [IO ]] =
53
+ override def span (name : String , options : Span . Options ): Resource [IO , Span [IO ]] =
53
54
Resource .make(
54
55
for {
55
56
spanId <- ref.modify(_.incrementNextSpanId)
@@ -63,12 +64,21 @@ object Tracing {
63
64
override def traceUri : IO [Option [URI ]] = IO .pure(None )
64
65
65
66
override def spanId : IO [Option [String ]] = IO .pure(Some (id.toString))
67
+
68
+ override def log (fields : (String , TraceValue )* ): IO [Unit ] =
69
+ IO .unit // not implemented
70
+
71
+ override def log (event : String ): IO [Unit ] =
72
+ IO .unit // not implemented
73
+
74
+ override def attachError (err : Throwable , fields : (String , TraceValue )* ): IO [Unit ] =
75
+ IO .unit // not implemented
66
76
}
67
77
68
78
def entrypoint (ref : Ref [IO , TracingData ]): EntryPoint [IO ] =
69
79
new EntryPoint [IO ] {
70
80
71
- def root (name : String ): Resource [IO , Span [IO ]] =
81
+ override def root (name : String , options : Span . Options ): Resource [IO , Span [IO ]] =
72
82
Resource .make(
73
83
for {
74
84
spanId <- ref.modify(_.incrementNextSpanId)
@@ -77,12 +87,16 @@ object Tracing {
77
87
} yield span
78
88
)(span => ref.update(_.append(s " End $span" )))
79
89
80
- def continue (name : String , kernel : Kernel ): Resource [IO , Span [IO ]] =
90
+ override def continue (
91
+ name : String ,
92
+ kernel : Kernel ,
93
+ options : Span .Options
94
+ ): Resource [IO , Span [IO ]] =
81
95
Resource .make(
82
96
for {
83
97
parentSpanId <- IO {
84
98
kernel.toHeaders
85
- .get(" span-id" )
99
+ .get(CIString ( " span-id" ) )
86
100
.map(_.toInt)
87
101
.getOrElse(throw new Exception (" Required trace header not found!" ))
88
102
}
@@ -92,7 +106,11 @@ object Tracing {
92
106
} yield span
93
107
)(span => ref.update(_.append(s " End $span" )))
94
108
95
- def continueOrElseRoot (name : String , kernel : Kernel ): Resource [IO , Span [IO ]] =
109
+ override def continueOrElseRoot (
110
+ name : String ,
111
+ kernel : Kernel ,
112
+ options : Span .Options
113
+ ): Resource [IO , Span [IO ]] =
96
114
continue(name, kernel).recoverWith { case _ : Exception =>
97
115
root(name)
98
116
}
0 commit comments