Skip to content

Commit b715d9b

Browse files
committed
chore: ignore otel config errors
1 parent 2c000e3 commit b715d9b

File tree

1 file changed

+7
-4
lines changed
  • backend/jvm/src/main/kotlin/dev/suresh/plugins

1 file changed

+7
-4
lines changed

backend/jvm/src/main/kotlin/dev/suresh/plugins/OTel.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package dev.suresh.plugins
22

3+
import dev.suresh.http.log
34
import io.ktor.http.HttpMethod
45
import io.ktor.server.application.*
56
import io.ktor.server.request.httpMethod
7+
import io.opentelemetry.api.*
68
import io.opentelemetry.api.trace.SpanKind
79
import io.opentelemetry.instrumentation.ktor.v3_0.*
810
import io.opentelemetry.sdk.extension.incubator.fileconfig.*
9-
import kotlin.io.path.Path
10-
import kotlin.io.path.inputStream
11+
import kotlin.io.path.*
1112
import kotlin.time.Clock
1213

1314
fun 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
}

0 commit comments

Comments
 (0)