rocketmq-client-rust 1.0.0

Rust implementation of Apache rocketmq client
Documentation
// Copyright 2023 The RocketMQ Rust Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use rocketmq_model::common::message::message_ext::MessageExt;
use rocketmq_model::common::message::message_queue::MessageQueue;
use rocketmq_model::common::message::MessageTrait;

pub(crate) use rocketmq_observability::trace::client::record_process_event;

pub(crate) fn consumer_process_span<'a>(
    telemetry: &rocketmq_observability::TelemetryHandle,
    messages: impl IntoIterator<Item = &'a MessageExt>,
    message_count: usize,
    consumer_group: &str,
    message_queue: &MessageQueue,
    consume_mode: &'static str,
) -> tracing::Span {
    let messages = messages.into_iter().map(|message| {
        rocketmq_observability::trace::client::MessageSpanContext::new(
            message.get_properties(),
            message.get_body().map(|body| body.len()),
        )
    });
    rocketmq_observability::trace::client::consumer_process_span(
        telemetry,
        messages,
        message_count,
        consumer_group,
        message_queue,
        consume_mode,
    )
}