Skip to content

Commit

Permalink
Update OtelBase.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
rli committed Nov 5, 2024
1 parent 06181dd commit 8da36b5
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ abstract class AbstractBaseSpan<SpanType : AbstractBaseSpan<SpanType>>(internal
return this as SpanType
}

override fun recordException(exception: Throwable): SpanType {
delegate.recordException(exception)
return this as SpanType
}

override fun end() {
validateRequiredAttributes()
delegate.end()
Expand All @@ -221,6 +226,22 @@ abstract class AbstractBaseSpan<SpanType : AbstractBaseSpan<SpanType>>(internal
delegate.end()
}

fun passive(passive: Boolean): SpanType {
this._passive = passive
return this as SpanType
}

fun unit(unit: MetricUnit): SpanType {
this._unit = unit
return this as SpanType

}

fun value(value: Number): SpanType {
this._value = value.toDouble()
return this as SpanType
}

private fun validateRequiredAttributes() {
val missingFields = requiredFields.filter { delegate.getAttribute(AttributeKey.stringKey(it)) == null }
val message = { "${delegate.name} is missing required fields: ${missingFields.joinToString(", ")}" }
Expand Down

0 comments on commit 8da36b5

Please sign in to comment.