Skip to content

Commit de1d02d

Browse files
authored
Merge pull request #1028 from iRevive/oteljava/testkit-reset-spans
oteljava: add `TracesTestkit#resetSpans`
2 parents b7514d3 + fd34d06 commit de1d02d

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import com.typesafe.tools.mima.core._
22

3-
ThisBuild / tlBaseVersion := "0.13"
3+
ThisBuild / tlBaseVersion := "0.14"
44

55
ThisBuild / organization := "org.typelevel"
66
ThisBuild / organizationName := "Typelevel"

oteljava/testkit/src/main/scala/org/typelevel/otel4s/oteljava/testkit/OtelJavaTestkit.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ object OtelJavaTestkit {
8686
def tracerProvider: TracerProvider[F] = traces.tracerProvider
8787
def propagators: ContextPropagators[Context] = traces.propagators
8888
def finishedSpans[A: FromSpanData]: F[List[A]] = traces.finishedSpans
89+
def resetSpans: F[Unit] = traces.resetSpans
8990
def collectMetrics[A: FromMetricData]: F[List[A]] = metrics.collectMetrics
9091
}
9192

oteljava/trace-testkit/src/main/scala/org/typelevel/otel4s/oteljava/testkit/trace/TracesTestkit.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,15 @@ trait TracesTestkit[F[_]] {
5555
* TracesTestkit[F].finishedSpans[SpanData] // OpenTelemetry Java models
5656
* }}}
5757
*
58-
* @note
59-
* each invocation cleans up the internal buffer.
58+
* @see
59+
* [[resetSpans]] to reset the internal buffer
6060
*/
6161
def finishedSpans[A: FromSpanData]: F[List[A]]
6262

63+
/** Resets the internal buffer.
64+
*/
65+
def resetSpans: F[Unit]
66+
6367
/** The propagators used by the [[org.typelevel.otel4s.trace.TracerProvider TracerProvider]].
6468
*/
6569
def propagators: ContextPropagators[Context]
@@ -137,6 +141,8 @@ object TracesTestkit {
137141
result <- Async[F].delay(exporter.getFinishedSpanItems)
138142
} yield result.asScala.toList.map(FromSpanData[A].from)
139143

144+
def resetSpans: F[Unit] =
145+
Async[F].delay(exporter.reset())
140146
}
141147

142148
}

0 commit comments

Comments
 (0)