-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Configure OpenTelemetryTestReporter by ScalaTest's ConfigMap
- Loading branch information
1 parent
37c740a
commit 961aa1d
Showing
7 changed files
with
66 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...l-reporter/src/test/scala/dev/nomadblacky/scalatest_otel_reporter/ConfigurationSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package dev.nomadblacky.scalatest_otel_reporter | ||
|
||
import org.scalatest.{ConfigMap, ParallelTestExecution} | ||
import org.scalatest.events.{Ordinal, RunCompleted, RunStarting} | ||
|
||
class ConfigurationSpec extends UnitTestSuite with OTelMockServer with ParallelTestExecution { | ||
import OpenTelemetryTestReporter._ | ||
|
||
test("Configure the root span name") { | ||
val spans = instrumentWithMockServer { mockServer => | ||
val reporter = new WireMockOTelTestReporter(host, mockServer.port()) | ||
reporter.apply(RunStarting(new Ordinal(0), 0, new ConfigMap(Map(ConfigKeyRootSpanName -> "my-awesome-tests")))) | ||
reporter.apply(RunCompleted(ordinal = new Ordinal(1))) | ||
} | ||
|
||
logger.info(s"Received spans: $spans") | ||
|
||
assert(spans.size == 1) | ||
val span = spans.head | ||
span.getName shouldBe "my-awesome-tests" | ||
} | ||
|
||
test("Fallback to the default root span name") { | ||
val spans = instrumentWithMockServer { mockServer => | ||
val reporter = new WireMockOTelTestReporter(host, mockServer.port()) | ||
reporter.apply(RunStarting(new Ordinal(0), 0, new ConfigMap(Map.empty))) | ||
reporter.apply(RunCompleted(ordinal = new Ordinal(1))) | ||
} | ||
|
||
logger.info(s"Received spans: $spans") | ||
|
||
assert(spans.size == 1) | ||
val span = spans.head | ||
span.getName shouldBe DefaultRootSpanName | ||
} | ||
} |
3 changes: 0 additions & 3 deletions
3
...tel-reporter/src/test/scala/dev/nomadblacky/scalatest_otel_reporter/FailedTestsSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters