Xuanwo commented on code in PR #2001:
URL:
https://github.com/apache/incubator-opendal/pull/2001#discussion_r1167115122
##########
core/src/layers/oteltrace.rs:
##########
@@ -0,0 +1,53 @@
+use opentelemetry::global;
+use opentelemetry::trace::FutureExt;
+use opentelemetry::trace::Span;
+use opentelemetry::trace::TraceContextExt;
+use opentelemetry::trace::Tracer;
+use opentelemetry::Context;
+
+use crate::ops::*;
+use crate::raw::*;
+
+pub struct OtelTraceLayer;
+
+#[derive(Debug)]
+pub struct OtelTraceAccessor<A> {
+ inner: A,
+}
+
+#[async_trait]
+impl<A: Accessor> LayeredAccessor for OtelTraceAccessor<A> {
+ type Inner = A;
+ type Reader = OtelTraceWrapper<A::Reader>;
+ type BlockingReader = OtelTraceWrapper<A::BlockingReader>;
+ type Writer = OtelTraceWrapper<A::Writer>;
+ type BlockingWriter = OtelTraceWrapper<A::BlockingWriter>;
+ type Pager = OtelTraceWrapper<A::Pager>;
+ type BlockingPager = OtelTraceWrapper<A::BlockingPager>;
+
+ fn inner(&self) -> &Self::Inner {
+ &self.inner
+ }
+
+ fn metadata(&self) -> AccessorInfo {
+ let tracer = global::tracer("opendal");
+ tracer.in_span("metadata", self.inner.info())
+ }
+
+ async fn create(&self, path: &str, args: OpCreate) -> Result<RpCreate> {
+ let tracer = global::tracer("opendal");
+ let cx = Context::current_with_value(span);
+ self.inner.create(path, args).with_context(cx).await
+ }
Review Comment:
But I don't know about otel's API, there are few advice I can give. Need you
to exploreš¤£
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]