File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
backend/jvm/src/main/kotlin/dev/suresh/plugins Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 11package dev.suresh.plugins
22
3+ import dev.suresh.http.log
34import io.ktor.http.HttpMethod
45import io.ktor.server.application.*
56import io.ktor.server.request.httpMethod
7+ import io.opentelemetry.api.*
68import io.opentelemetry.api.trace.SpanKind
79import io.opentelemetry.instrumentation.ktor.v3_0.*
810import io.opentelemetry.sdk.extension.incubator.fileconfig.*
9- import kotlin.io.path.Path
10- import kotlin.io.path.inputStream
11+ import kotlin.io.path.*
1112import kotlin.time.Clock
1213
1314fun Application.configureOTel () {
@@ -33,13 +34,15 @@ fun Application.configureOTel() {
3334}
3435
3536/* * See [Configure the SDK](https://opentelemetry.io/docs/languages/java/configuration/) */
36- val openTelemetrySdk by lazy {
37+ val openTelemetrySdk: OpenTelemetry by lazy {
3738 val sdkConfPath =
3839 System .getenv(" OTEL_EXPERIMENTAL_CONFIG_FILE" )?.takeIf { it.isNotBlank() }?.let { Path (it) }
3940 val ins =
4041 when (sdkConfPath) {
4142 null -> object {}::class .java.getResourceAsStream(" /otel/sdk-config.yaml" )
4243 else -> sdkConfPath.inputStream()
4344 }
44- DeclarativeConfiguration .parseAndCreate(ins)
45+ runCatching { DeclarativeConfiguration .parseAndCreate(ins) }
46+ .onFailure { log.error(it) {} }
47+ .getOrElse { GlobalOpenTelemetry .get() }
4548}
You can’t perform that action at this time.
0 commit comments