-
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.
docs: Add an example of manual configuretion
- Loading branch information
1 parent
be5b385
commit 044ab17
Showing
5 changed files
with
68 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
services: | ||
jeager: | ||
image: jaegertracing/all-in-one:latest | ||
ports: | ||
- "4317:4317" | ||
- "16686:16686" |
32 changes: 32 additions & 0 deletions
32
.../src/test/scala/dev/nomadblacky/scalatest_otel_reporter/examples/JaegerTestReporter.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,32 @@ | ||
package dev.nomadblacky.scalatest_otel_reporter.examples | ||
|
||
import dev.nomadblacky.scalatest_otel_reporter.BaseOpenTelemetryTestReporter | ||
import io.opentelemetry.api.OpenTelemetry | ||
import io.opentelemetry.api.common.Attributes | ||
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter | ||
import io.opentelemetry.sdk.OpenTelemetrySdk | ||
import io.opentelemetry.sdk.resources.Resource | ||
import io.opentelemetry.sdk.trace.SdkTracerProvider | ||
import io.opentelemetry.sdk.trace.`export`.BatchSpanProcessor | ||
import io.opentelemetry.semconv.ResourceAttributes | ||
|
||
import java.util.concurrent.TimeUnit | ||
|
||
class JaegerTestReporter extends BaseOpenTelemetryTestReporter { | ||
def otel: OpenTelemetry = { | ||
// Export traces to Jaeger over OTLP | ||
val jaegerOtlpExporter = | ||
OtlpGrpcSpanExporter.builder.setEndpoint("http://localhost:4317").setTimeout(30, TimeUnit.SECONDS).build | ||
|
||
val serviceNameResource = | ||
Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, "scalatest-otel-demo")) | ||
|
||
// Set to process the spans by the Jaeger Exporter | ||
val tracerProvider = SdkTracerProvider.builder | ||
.addSpanProcessor(BatchSpanProcessor.builder(jaegerOtlpExporter).build) | ||
.setResource(Resource.getDefault.merge(serviceNameResource)) | ||
.build | ||
|
||
OpenTelemetrySdk.builder.setTracerProvider(tracerProvider).build | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...t/scala/dev/nomadblacky/scalatest_otel_reporter/examples/ManualConfigurationExample.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,13 @@ | ||
package dev.nomadblacky.scalatest_otel_reporter.examples | ||
|
||
import org.scalatest.funspec.AnyFunSpecLike | ||
|
||
class ManualConfigurationExample extends AnyFunSpecLike { | ||
|
||
describe("Describe") { | ||
it("It") { | ||
Thread.sleep(1000) | ||
assert(1 == 1) | ||
} | ||
} | ||
} |