diff --git a/cosec-dependencies/build.gradle.kts b/cosec-dependencies/build.gradle.kts index 4053ab75..1e9bbe8b 100644 --- a/cosec-dependencies/build.gradle.kts +++ b/cosec-dependencies/build.gradle.kts @@ -23,7 +23,6 @@ dependencies { api(libs.javaJwt) api(libs.ip2region) api(libs.guava) - api(libs.opentelemetrySemconv) api(libs.swagger) api(libs.jmhCore) api(libs.jmhGeneratorAnnprocess) diff --git a/cosec-opentelemetry/build.gradle.kts b/cosec-opentelemetry/build.gradle.kts index 547587d0..3da725a1 100644 --- a/cosec-opentelemetry/build.gradle.kts +++ b/cosec-opentelemetry/build.gradle.kts @@ -14,7 +14,6 @@ dependencies { implementation(project(":cosec-core")) implementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api") - implementation("io.opentelemetry:opentelemetry-semconv") testImplementation("io.projectreactor:reactor-test") testImplementation("io.opentelemetry:opentelemetry-sdk") } diff --git a/cosec-opentelemetry/src/main/kotlin/me/ahoo/cosec/opentelemetry/CoSecInstrumenter.kt b/cosec-opentelemetry/src/main/kotlin/me/ahoo/cosec/opentelemetry/CoSecInstrumenter.kt index 9b02cd14..2d445911 100644 --- a/cosec-opentelemetry/src/main/kotlin/me/ahoo/cosec/opentelemetry/CoSecInstrumenter.kt +++ b/cosec-opentelemetry/src/main/kotlin/me/ahoo/cosec/opentelemetry/CoSecInstrumenter.kt @@ -15,12 +15,12 @@ package me.ahoo.cosec.opentelemetry import io.opentelemetry.api.GlobalOpenTelemetry import io.opentelemetry.api.common.AttributeKey +import io.opentelemetry.api.common.AttributeKey.stringKey import io.opentelemetry.api.common.AttributesBuilder import io.opentelemetry.context.Context import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes import me.ahoo.cosec.api.CoSec import me.ahoo.cosec.api.authorization.AuthorizeResult import me.ahoo.cosec.api.context.SecurityContext @@ -50,16 +50,18 @@ object CoSecSpanNameExtractor : SpanNameExtractor { } object CoSecAttributesExtractor : AttributesExtractor { + private val END_USER_ID_ATTRIBUTE_KEY = stringKey("enduser.id") + private val END_USER_ROLE_ATTRIBUTE_KEY = stringKey("enduser.role") private const val COSEC_TENANT_ID_KEY = CoSec.COSEC_PREFIX + "tenant_id" - private val COSEC_TENANT_ID_ATTRIBUTE_KEY = AttributeKey.stringKey(COSEC_TENANT_ID_KEY) + private val COSEC_TENANT_ID_ATTRIBUTE_KEY = stringKey(COSEC_TENANT_ID_KEY) private const val COSEC_POLICY_KEY = CoSec.COSEC_PREFIX + PolicyCapable.POLICY_KEY - private val COSEC_POLICY_ATTRIBUTE_KEY = AttributeKey.stringKey(COSEC_POLICY_KEY) + private val COSEC_POLICY_ATTRIBUTE_KEY = stringKey(COSEC_POLICY_KEY) private const val COSEC_AUTHORIZE_PREFIX = CoSec.COSEC_PREFIX + "authorize." private const val COSEC_AUTHORIZATION_POLICY_ID_KEY = COSEC_AUTHORIZE_PREFIX + "policy.id" - private val COSEC_AUTHORIZATION_POLICY_ID_ATTRIBUTE_KEY = AttributeKey.stringKey(COSEC_AUTHORIZATION_POLICY_ID_KEY) + private val COSEC_AUTHORIZATION_POLICY_ID_ATTRIBUTE_KEY = stringKey(COSEC_AUTHORIZATION_POLICY_ID_KEY) private const val COSEC_AUTHORIZATION_STATEMENT_PREFIX = COSEC_AUTHORIZE_PREFIX + "statement." private const val COSEC_AUTHORIZATION_STATEMENT_IDX_KEY = COSEC_AUTHORIZATION_STATEMENT_PREFIX + "index" @@ -68,17 +70,17 @@ object CoSecAttributesExtractor : AttributesExtractor