use crate::error::OTelSdkResult;
use crate::Resource;
use opentelemetry::trace::{SpanContext, SpanId, SpanKind, Status};
use opentelemetry::{InstrumentationScope, KeyValue};
use std::borrow::Cow;
use std::fmt::Debug;
use std::time::{Duration, SystemTime};
pub trait SpanExporter: Send + Sync + Debug {
fn export(
&self,
batch: Vec<SpanData>,
) -> impl std::future::Future<Output = OTelSdkResult> + Send;
fn shutdown_with_timeout(&mut self, _timeout: Duration) -> OTelSdkResult {
Ok(())
}
fn shutdown(&mut self) -> OTelSdkResult {
self.shutdown_with_timeout(Duration::from_nanos(5))
}
fn force_flush(&mut self) -> OTelSdkResult {
Ok(())
}
fn set_resource(&mut self, _resource: &Resource) {}
}
#[derive(Clone, Debug, PartialEq)]
pub struct SpanData {
pub span_context: SpanContext,
pub parent_span_id: SpanId,
pub parent_span_is_remote: bool,
pub span_kind: SpanKind,
pub name: Cow<'static, str>,
pub start_time: SystemTime,
pub end_time: SystemTime,
pub attributes: Vec<KeyValue>,
pub dropped_attributes_count: u32,
pub events: crate::trace::SpanEvents,
pub links: crate::trace::SpanLinks,
pub status: Status,
pub instrumentation_scope: InstrumentationScope,
}