def handle(self, event: BaseEvent, **kwargs: Any) -> None:
        """Handle events by pushing them to the correct span's bucket for later attachment to OpenTelemetry."""
        if self.debug:
            cprint(
                f"Registering a {event.class_name()} event at time: {datetime.now()}",
                color="green",
                attrs=["bold"],
            )

        # Get the current span id from the contextvars context
        current_span_id = active_span_id.get()
        if current_span_id is None:
            # The event is happening outside of any span - nothing to do
            return

        try:
            event_data = event.model_dump()
        except TypeError:
            # Some events can be unserializable,
            # so we just convert to a string as a fallback
            event_data = {"event_data": str(event)}

        otel_event = OTelEventAttributes(
            name=event.class_name(), attributes=filter_model_fields(event_data)
        )

        self.span_handler._events_by_span.setdefault(current_span_id, []).append(
            otel_event
        )
Handle events by pushing them to the correct span's bucket for later attachment to OpenTelemetry.
llama-index-integrations/observability/llama-index-observability-otel/llama_index/observability/otel/base.py