Yeah,
I have hook in React Native application:
useEffect(() => {
const span = getSpan(spanId);
if (!span || !reasonAttributes) {
return;
}
const namespacedAttributes = Object.fromEntries(Object.entries(reasonAttributes).map(([key, value]) => [`${CONST.TELEMETRY.ATTRIBUTE_SKELETON_PREFIX}${key}`, value]));
span.setAttributes(namespacedAttributes);
span.addEvent(CONST.TELEMETRY.EVENT_SKELETON_ATTRIBUTES_UPDATE, namespacedAttributes);
}, [reasonAttributes, spanId]);
On every props change this should find a related span and add Event to it. getSpan returns span created with this such function:
function startSpan(spanId: string, options: StartSpanOptions, extraOptions: StartSpanExtraOptions = {}) {
cancelSpan(spanId);
const span = Sentry.startInactiveSpan(options);
if (extraOptions.minDuration) {
span.setAttribute(CONST.TELEMETRY.ATTRIBUTE_MIN_DURATION, extraOptions.minDuration);
}
activeSpans.set(spanId, span);
return span;
}
SpanID is arbitrary name to be stored in applications memory. Unrelated to Sentry's ID convention.
Events added via span.addEvent are not visible in Sentry