feat!: telemetry utils (#206)#238
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a telemetry module to the Kotlin SDK, enabling the creation of OpenTelemetry-compliant evaluation events based on the OpenFeature specification. It includes a new EvaluationEvent data class and a Telemetry utility that maps evaluation details to standard OTel semantic conventions. The review feedback identifies a potential issue with case-sensitive string comparisons when detecting error states and suggests converting Instant values to strings to ensure compatibility with downstream OTel exporters.
Signed-off-by: Marcin Stepien <marcin.stepien@fluxon.com>
5ea87a9 to
c63876a
Compare
Signed-off-by: Marcin Stepien <marcin.stepien@fluxon.com>
c63876a to
081a04e
Compare
|
This PR removes Pre-1.0 SDK so this is fine, but worth noting in the PR description so it shows up in release notes. Something like:
|
Signed-off-by: Marcin Stepien marcin.stepien@fluxon.com
Add Telemetry Utils #206
Adds Appendix D (Observability/Telemetry) mapping utilities to the Kotlin SDK.
dev.openfeature.kotlin.sdk.telemetry.EvaluationEventdata construct mapped to OpenTelemetrydev.openfeature.kotlin.sdk.telemetry.Telemetrystatic mapping object exposing thecreateEvaluationEvent()bridging utility.HookContextandFlagEvaluationDetailspayloads, accounting for Error state mutations, Context evaluations, and natively unwrapping SDKValueobjects iteratively down to pure primitives/Maps.Related Issues
Fixes #206
Breaking changes
EvaluationEventandcreateEvaluationEvent()moved fromdev.openfeature.kotlin.sdktodev.openfeature.kotlin.sdk.telemetry.Telemetry. The old top-level function is replaced byTelemetry.createEvaluationEvent().Notes
Valuedefinitions natively wrap structures (Value.Structure,Value.List, etc). Because downstream standard OTEL loggers require primitives,createEvaluationEventemploys a robust recursive unwrapping mechanic natively translating customdev.openfeature.kotlin.sdk.Valueelements gracefully down to decoupled KotlinMap<String, Any?>interfaces to prevent logging friction.How to test
./gradlew :kotlin-sdk:testDebugUnitTest --tests "dev.openfeature.kotlin.sdk.telemetry.*"