@@ -7,7 +7,7 @@ import com.ovoenergy.natchez.extras.datadog.Datadog.entryPoint
7
7
import com .ovoenergy .natchez .extras .datadog .DatadogTags .SpanType .{Cache , Db , Web }
8
8
import com .ovoenergy .natchez .extras .datadog .DatadogTags .spanType
9
9
import munit .CatsEffectSuite
10
- import natchez .EntryPoint
10
+ import natchez .{ EntryPoint , TraceValue }
11
11
import org .http4s .Request
12
12
import org .http4s .circe .CirceEntityDecoder ._
13
13
import org .http4s .syntax .literals ._
@@ -21,8 +21,8 @@ import scala.concurrent.duration._
21
21
*/
22
22
class DatadogTest extends CatsEffectSuite {
23
23
24
- def run (f : EntryPoint [IO ] => IO [Unit ]): IO [List [Request [IO ]]] =
25
- TestClient [IO ].flatMap(c => entryPoint(c.client, " test" , " blah" ).use(f) >> c.requests)
24
+ def run (f : EntryPoint [IO ] => IO [Unit ], meta : Map [ String , TraceValue ] = Map .empty ): IO [List [Request [IO ]]] =
25
+ TestClient [IO ].flatMap(c => entryPoint(c.client, " test" , " blah" , meta = meta ).use(f) >> c.requests)
26
26
27
27
test(" Obtain the agent host from the parameter" ) {
28
28
assertIO(
@@ -126,6 +126,21 @@ class DatadogTest extends CatsEffectSuite {
126
126
}
127
127
}
128
128
129
+ test(" Allow you to provide default tags" ) {
130
+ for {
131
+ res <- run(
132
+ _.root(" bar" ).use(_.span(" subspan" ).use(_ => IO .unit)),
133
+ Map (" defaultTag1" -> " some-value" , " defaultTag2" -> " some-other-value" )
134
+ )
135
+ spans <- res.flatTraverse(_.as[List [List [SubmittableSpan ]]]).map(_.flatten)
136
+ } yield {
137
+ assertEquals(spans.head.meta.get(" defaultTag1" ), Some (" some-value" ))
138
+ assertEquals(spans.head.meta.get(" defaultTag2" ), Some (" some-other-value" ))
139
+ assertEquals(spans.tail.head.meta.get(" defaultTag1" ), Some (" some-value" ))
140
+ assertEquals(spans.tail.head.meta.get(" defaultTag2" ), Some (" some-other-value" ))
141
+ }
142
+ }
143
+
129
144
test(" Inherit metadata into subspans but only at the time of creation" ) {
130
145
run(
131
146
_.root(" bar:res" ).use { root =>
0 commit comments