@@ -10,7 +10,7 @@ import io.embrace.android.embracesdk.internal.otel.schema.EmbType
1010import io.embrace.android.embracesdk.internal.otel.schema.ErrorCodeAttribute
1111import io.embrace.android.embracesdk.internal.otel.schema.ErrorCodeAttribute.Failure.fromErrorCode
1212import io.embrace.android.embracesdk.internal.otel.schema.LinkType
13- import io.embrace.android.embracesdk.internal.otel.sdk.LimitsValidator
13+ import io.embrace.android.embracesdk.internal.otel.sdk.DataValidator
1414import io.embrace.android.embracesdk.internal.otel.sdk.fromMap
1515import io.embrace.android.embracesdk.internal.otel.sdk.hasEmbraceAttribute
1616import io.embrace.android.embracesdk.internal.otel.sdk.id.OtelIds
@@ -44,7 +44,7 @@ class EmbraceSpanFactoryImpl(
4444 private val tracer : Tracer ,
4545 private val openTelemetryClock : Clock ,
4646 private val spanRepository : SpanRepository ,
47- private val limitsValidator : LimitsValidator = LimitsValidator (),
47+ private val dataValidator : DataValidator = DataValidator (),
4848 private val stopCallback : ((spanId: String ) -> Unit )? = null ,
4949 private var redactionFunction : ((key: String , value: String ) -> String )? = null ,
5050) : EmbraceSpanFactory {
@@ -75,7 +75,7 @@ class EmbraceSpanFactoryImpl(
7575 otelSpanBuilderWrapper = otelSpanBuilderWrapper,
7676 openTelemetryClock = openTelemetryClock,
7777 spanRepository = spanRepository,
78- limitsValidator = limitsValidator ,
78+ dataValidator = dataValidator ,
7979 stopCallback = stopCallback,
8080 redactionFunction = redactionFunction,
8181 autoTerminationMode = autoTerminationMode
@@ -86,7 +86,7 @@ private class EmbraceSpanImpl(
8686 private val otelSpanBuilderWrapper : OtelSpanBuilderWrapper ,
8787 private val openTelemetryClock : Clock ,
8888 private val spanRepository : SpanRepository ,
89- private val limitsValidator : LimitsValidator ,
89+ private val dataValidator : DataValidator ,
9090 private val stopCallback : ((spanId: String ) -> Unit )? = null ,
9191 private val redactionFunction : ((key: String , value: String ) -> String )? = null ,
9292 override val autoTerminationMode : AutoTerminationMode = AutoTerminationMode .NONE ,
@@ -212,7 +212,7 @@ private class EmbraceSpanImpl(
212212 }
213213
214214 override fun addEvent (name : String , timestampMs : Long? , attributes : Map <String , String >? ): Boolean =
215- addObject(customEvents, customEventCount, limitsValidator .otelLimitsConfig.getMaxCustomEventCount()) {
215+ addObject(customEvents, customEventCount, dataValidator .otelLimitsConfig.getMaxCustomEventCount()) {
216216 EmbraceSpanEvent .create(
217217 name = name,
218218 timestampMs = timestampMs?.normalizeTimestampAsMillis() ? : openTelemetryClock.now().nanosToMillis(),
@@ -221,7 +221,7 @@ private class EmbraceSpanImpl(
221221 }
222222
223223 override fun recordException (exception : Throwable , attributes : Map <String , String >? ): Boolean =
224- addObject(customEvents, customEventCount, limitsValidator .otelLimitsConfig.getMaxCustomEventCount()) {
224+ addObject(customEvents, customEventCount, dataValidator .otelLimitsConfig.getMaxCustomEventCount()) {
225225 val eventAttributes = mutableMapOf<String , String >()
226226 if (attributes != null ) {
227227 eventAttributes.putAll(attributes)
@@ -238,14 +238,14 @@ private class EmbraceSpanImpl(
238238 eventAttributes[ExceptionAttributes .EXCEPTION_STACKTRACE .key] = exception.truncatedStacktraceText()
239239
240240 EmbraceSpanEvent .create(
241- name = limitsValidator .otelLimitsConfig.getExceptionEventName(),
241+ name = dataValidator .otelLimitsConfig.getExceptionEventName(),
242242 timestampMs = openTelemetryClock.now().nanosToMillis(),
243243 attributes = eventAttributes
244244 )
245245 }
246246
247247 override fun addSystemEvent (name : String , timestampMs : Long? , attributes : Map <String , String >? ): Boolean =
248- addObject(systemEvents, systemEventCount, limitsValidator .otelLimitsConfig.getMaxSystemEventCount()) {
248+ addObject(systemEvents, systemEventCount, dataValidator .otelLimitsConfig.getMaxSystemEventCount()) {
249249 EmbraceSpanEvent .create(
250250 name = name,
251251 timestampMs = timestampMs?.normalizeTimestampAsMillis() ? : openTelemetryClock.now().nanosToMillis(),
@@ -280,11 +280,11 @@ private class EmbraceSpanImpl(
280280 override fun getStartTimeMs (): Long? = spanStartTimeMs
281281
282282 override fun addAttribute (key : String , value : String ): Boolean {
283- if (customAttributes.size < limitsValidator .otelLimitsConfig.getMaxCustomAttributeCount() &&
284- limitsValidator .isAttributeValid(key, value, otelSpanBuilderWrapper.internal)
283+ if (customAttributes.size < dataValidator .otelLimitsConfig.getMaxCustomAttributeCount() &&
284+ dataValidator .isAttributeValid(key, value, otelSpanBuilderWrapper.internal)
285285 ) {
286286 synchronized(customAttributes) {
287- if (customAttributes.size < limitsValidator .otelLimitsConfig.getMaxCustomAttributeCount() && isRecording) {
287+ if (customAttributes.size < dataValidator .otelLimitsConfig.getMaxCustomAttributeCount() && isRecording) {
288288 customAttributes[key] = value
289289 spanRepository.notifySpanUpdate()
290290 return true
@@ -296,7 +296,7 @@ private class EmbraceSpanImpl(
296296 }
297297
298298 override fun updateName (newName : String ): Boolean {
299- if (limitsValidator .isNameValid(newName, otelSpanBuilderWrapper.internal)) {
299+ if (dataValidator .isNameValid(newName, otelSpanBuilderWrapper.internal)) {
300300 synchronized(startedSpan) {
301301 if (! spanStarted() || isRecording) {
302302 updatedName = newName
@@ -311,12 +311,12 @@ private class EmbraceSpanImpl(
311311 }
312312
313313 override fun addSystemLink (linkedSpanContext : SpanContext , type : LinkType , attributes : Map <String , String >): Boolean =
314- addObject(systemLinks, systemLinkCount, limitsValidator .otelLimitsConfig.getMaxSystemLinkCount()) {
314+ addObject(systemLinks, systemLinkCount, dataValidator .otelLimitsConfig.getMaxSystemLinkCount()) {
315315 EmbraceLinkData (linkedSpanContext, mutableMapOf (type.asPair()).apply { putAll(attributes) })
316316 }
317317
318318 override fun addLink (linkedSpanContext : SpanContext , attributes : Map <String , String >? ): Boolean =
319- addObject(customLinks, customLinkCount, limitsValidator .otelLimitsConfig.getMaxCustomLinkCount()) {
319+ addObject(customLinks, customLinkCount, dataValidator .otelLimitsConfig.getMaxCustomLinkCount()) {
320320 EmbraceLinkData (linkedSpanContext, attributes ? : emptyMap())
321321 }
322322
@@ -414,7 +414,7 @@ private class EmbraceSpanImpl(
414414
415415 (systemEvents + redactedCustomEvents).forEach { event ->
416416 val eventAttributes = if (event.attributes.isNotEmpty()) {
417- Attributes .builder().fromMap(event.attributes, otelSpanBuilderWrapper.internal, limitsValidator ).build()
417+ Attributes .builder().fromMap(event.attributes, otelSpanBuilderWrapper.internal, dataValidator ).build()
418418 } else {
419419 Attributes .empty()
420420 }
@@ -433,7 +433,7 @@ private class EmbraceSpanImpl(
433433
434434 (systemLinks + redactedCustomLinks).forEach {
435435 val linkAttributes = if (it.attributes.isNotEmpty()) {
436- Attributes .builder().fromMap(attributes = it.attributes, false , limitsValidator ).build()
436+ Attributes .builder().fromMap(attributes = it.attributes, false , dataValidator ).build()
437437 } else {
438438 Attributes .empty()
439439 }
0 commit comments