@@ -561,29 +561,26 @@ mod otel {
561561 use std:: borrow:: Cow ;
562562 use std:: time:: { Duration , SystemTime , UNIX_EPOCH } ;
563563 use wasi:: clocks0_2_0:: wall_clock;
564- use wasi:: otel:: metrics as wasi_metrics;
565- use wasi:: otel:: tracing as wasi_tracing;
566- use wasi:: otel:: types as wasi_types;
567564
568- impl From < wasi_metrics:: ResourceMetrics > for opentelemetry_sdk:: metrics:: data:: ResourceMetrics {
569- fn from ( value : wasi_metrics:: ResourceMetrics ) -> Self {
565+ impl From < wasi:: otel:: metrics:: ResourceMetrics >
566+ for opentelemetry_sdk:: metrics:: data:: ResourceMetrics
567+ {
568+ fn from ( value : wasi:: otel:: metrics:: ResourceMetrics ) -> Self {
570569 Self {
571570 resource : value. resource . into ( ) ,
572571 scope_metrics : value. scope_metrics . into_iter ( ) . map ( Into :: into) . collect ( ) ,
573572 }
574573 }
575574 }
576575
577- impl From < wasi_metrics :: Resource > for opentelemetry_sdk:: Resource {
578- fn from ( value : wasi_metrics :: Resource ) -> Self {
576+ impl From < wasi :: otel :: metrics :: Resource > for opentelemetry_sdk:: Resource {
577+ fn from ( value : wasi :: otel :: metrics :: Resource ) -> Self {
579578 let attributes: Vec < opentelemetry:: KeyValue > =
580579 value. attributes . into_iter ( ) . map ( Into :: into) . collect ( ) ;
581580 let schema_url: Option < String > = value. schema_url . into ( ) ;
582581
583582 match schema_url {
584583 Some ( url) => opentelemetry_sdk:: resource:: Resource :: builder ( )
585- // TODO: I'm unclear about what to do with the `with_schema_url()` method and the
586- // `with_attribute()` or `with_attributes()` methods. Is this good enough?
587584 . with_schema_url ( attributes, url)
588585 . build ( ) ,
589586 None => opentelemetry_sdk:: resource:: Resource :: builder ( )
@@ -593,17 +590,17 @@ mod otel {
593590 }
594591 }
595592
596- impl From < wasi_metrics :: ScopeMetrics > for opentelemetry_sdk:: metrics:: data:: ScopeMetrics {
597- fn from ( value : wasi_metrics :: ScopeMetrics ) -> Self {
593+ impl From < wasi :: otel :: metrics :: ScopeMetrics > for opentelemetry_sdk:: metrics:: data:: ScopeMetrics {
594+ fn from ( value : wasi :: otel :: metrics :: ScopeMetrics ) -> Self {
598595 Self {
599596 scope : value. scope . into ( ) ,
600597 metrics : value. metrics . into_iter ( ) . map ( Into :: into) . collect ( ) ,
601598 }
602599 }
603600 }
604601
605- impl From < wasi_metrics :: Metric > for opentelemetry_sdk:: metrics:: data:: Metric {
606- fn from ( value : wasi_metrics :: Metric ) -> Self {
602+ impl From < wasi :: otel :: metrics :: Metric > for opentelemetry_sdk:: metrics:: data:: Metric {
603+ fn from ( value : wasi :: otel :: metrics :: Metric ) -> Self {
607604 Self {
608605 name : Cow :: Owned ( value. name ) ,
609606 description : Cow :: Owned ( value. description ) ,
@@ -759,80 +756,84 @@ mod otel {
759756 } ;
760757 }
761758
762- impl From < wasi_metrics:: MetricData > for Box < dyn opentelemetry_sdk:: metrics:: data:: Aggregation > {
763- fn from ( value : wasi_metrics:: MetricData ) -> Self {
759+ impl From < wasi:: otel:: metrics:: MetricData >
760+ for Box < dyn opentelemetry_sdk:: metrics:: data:: Aggregation >
761+ {
762+ fn from ( value : wasi:: otel:: metrics:: MetricData ) -> Self {
764763 match value {
765- wasi_metrics :: MetricData :: F64Sum ( s) => wasi_sum_to_otel ! ( s, f64 ) ,
766- wasi_metrics :: MetricData :: S64Sum ( s) => wasi_sum_to_otel ! ( s, i64 ) ,
767- wasi_metrics :: MetricData :: U64Sum ( s) => wasi_sum_to_otel ! ( s, u64 ) ,
768- wasi_metrics :: MetricData :: F64Gauge ( g) => wasi_gauge_to_otel ! ( g, f64 ) ,
769- wasi_metrics :: MetricData :: S64Gauge ( g) => wasi_gauge_to_otel ! ( g, i64 ) ,
770- wasi_metrics :: MetricData :: U64Gauge ( g) => wasi_gauge_to_otel ! ( g, u64 ) ,
771- wasi_metrics :: MetricData :: F64Histogram ( h) => wasi_histogram_to_otel ! ( h, f64 ) ,
772- wasi_metrics :: MetricData :: S64Histogram ( h) => wasi_histogram_to_otel ! ( h, i64 ) ,
773- wasi_metrics :: MetricData :: U64Histogram ( h) => wasi_histogram_to_otel ! ( h, u64 ) ,
774- wasi_metrics :: MetricData :: F64ExponentialHistogram ( h) => {
764+ wasi :: otel :: metrics :: MetricData :: F64Sum ( s) => wasi_sum_to_otel ! ( s, f64 ) ,
765+ wasi :: otel :: metrics :: MetricData :: S64Sum ( s) => wasi_sum_to_otel ! ( s, i64 ) ,
766+ wasi :: otel :: metrics :: MetricData :: U64Sum ( s) => wasi_sum_to_otel ! ( s, u64 ) ,
767+ wasi :: otel :: metrics :: MetricData :: F64Gauge ( g) => wasi_gauge_to_otel ! ( g, f64 ) ,
768+ wasi :: otel :: metrics :: MetricData :: S64Gauge ( g) => wasi_gauge_to_otel ! ( g, i64 ) ,
769+ wasi :: otel :: metrics :: MetricData :: U64Gauge ( g) => wasi_gauge_to_otel ! ( g, u64 ) ,
770+ wasi :: otel :: metrics :: MetricData :: F64Histogram ( h) => wasi_histogram_to_otel ! ( h, f64 ) ,
771+ wasi :: otel :: metrics :: MetricData :: S64Histogram ( h) => wasi_histogram_to_otel ! ( h, i64 ) ,
772+ wasi :: otel :: metrics :: MetricData :: U64Histogram ( h) => wasi_histogram_to_otel ! ( h, u64 ) ,
773+ wasi :: otel :: metrics :: MetricData :: F64ExponentialHistogram ( h) => {
775774 wasi_exponential_histogram_to_otel ! ( h, f64 )
776775 }
777- wasi_metrics :: MetricData :: S64ExponentialHistogram ( h) => {
776+ wasi :: otel :: metrics :: MetricData :: S64ExponentialHistogram ( h) => {
778777 wasi_exponential_histogram_to_otel ! ( h, i64 )
779778 }
780- wasi_metrics :: MetricData :: U64ExponentialHistogram ( h) => {
779+ wasi :: otel :: metrics :: MetricData :: U64ExponentialHistogram ( h) => {
781780 wasi_exponential_histogram_to_otel ! ( h, u64 )
782781 }
783782 }
784783 }
785784 }
786785
787- impl From < wasi_metrics :: MetricNumber > for f64 {
788- fn from ( value : wasi_metrics :: MetricNumber ) -> Self {
786+ impl From < wasi :: otel :: metrics :: MetricNumber > for f64 {
787+ fn from ( value : wasi :: otel :: metrics :: MetricNumber ) -> Self {
789788 match value {
790- wasi_metrics :: MetricNumber :: F64 ( n) => n,
789+ wasi :: otel :: metrics :: MetricNumber :: F64 ( n) => n,
791790 _ => panic ! ( "error converting WASI MetricNumber to f64" ) ,
792791 }
793792 }
794793 }
795794
796- impl From < wasi_metrics :: MetricNumber > for u64 {
797- fn from ( value : wasi_metrics :: MetricNumber ) -> Self {
795+ impl From < wasi :: otel :: metrics :: MetricNumber > for u64 {
796+ fn from ( value : wasi :: otel :: metrics :: MetricNumber ) -> Self {
798797 match value {
799- wasi_metrics :: MetricNumber :: U64 ( n) => n,
798+ wasi :: otel :: metrics :: MetricNumber :: U64 ( n) => n,
800799 _ => panic ! ( "error converting WASI MetricNumber to u64" ) ,
801800 }
802801 }
803802 }
804803
805- impl From < wasi_metrics :: MetricNumber > for i64 {
806- fn from ( value : wasi_metrics :: MetricNumber ) -> Self {
804+ impl From < wasi :: otel :: metrics :: MetricNumber > for i64 {
805+ fn from ( value : wasi :: otel :: metrics :: MetricNumber ) -> Self {
807806 match value {
808- wasi_metrics :: MetricNumber :: S64 ( n) => n,
807+ wasi :: otel :: metrics :: MetricNumber :: S64 ( n) => n,
809808 _ => panic ! ( "error converting WASI MetricNumber to i64" ) ,
810809 }
811810 }
812811 }
813812
814- impl From < wasi_metrics:: ExponentialBucket > for opentelemetry_sdk:: metrics:: data:: ExponentialBucket {
815- fn from ( value : wasi_metrics:: ExponentialBucket ) -> Self {
813+ impl From < wasi:: otel:: metrics:: ExponentialBucket >
814+ for opentelemetry_sdk:: metrics:: data:: ExponentialBucket
815+ {
816+ fn from ( value : wasi:: otel:: metrics:: ExponentialBucket ) -> Self {
816817 Self {
817818 offset : value. offset ,
818819 counts : value. counts ,
819820 }
820821 }
821822 }
822823
823- impl From < wasi_metrics :: Temporality > for opentelemetry_sdk:: metrics:: Temporality {
824- fn from ( value : wasi_metrics :: Temporality ) -> Self {
824+ impl From < wasi :: otel :: metrics :: Temporality > for opentelemetry_sdk:: metrics:: Temporality {
825+ fn from ( value : wasi :: otel :: metrics :: Temporality ) -> Self {
825826 use opentelemetry_sdk:: metrics:: Temporality ;
826827 match value {
827- wasi_metrics :: Temporality :: Cumulative => Temporality :: Cumulative ,
828- wasi_metrics :: Temporality :: Delta => Temporality :: Delta ,
829- wasi_metrics :: Temporality :: LowMemory => Temporality :: LowMemory ,
828+ wasi :: otel :: metrics :: Temporality :: Cumulative => Temporality :: Cumulative ,
829+ wasi :: otel :: metrics :: Temporality :: Delta => Temporality :: Delta ,
830+ wasi :: otel :: metrics :: Temporality :: LowMemory => Temporality :: LowMemory ,
830831 }
831832 }
832833 }
833834
834- impl From < wasi_tracing :: SpanData > for opentelemetry_sdk:: trace:: SpanData {
835- fn from ( value : wasi_tracing :: SpanData ) -> Self {
835+ impl From < wasi :: otel :: tracing :: SpanData > for opentelemetry_sdk:: trace:: SpanData {
836+ fn from ( value : wasi :: otel :: tracing :: SpanData ) -> Self {
836837 let mut span_events = SpanEvents :: default ( ) ;
837838 span_events. events = value. events . into_iter ( ) . map ( Into :: into) . collect ( ) ;
838839 span_events. dropped_count = value. dropped_events ;
@@ -857,8 +858,8 @@ mod otel {
857858 }
858859 }
859860
860- impl From < wasi_tracing :: SpanContext > for opentelemetry:: trace:: SpanContext {
861- fn from ( sc : wasi_tracing :: SpanContext ) -> Self {
861+ impl From < wasi :: otel :: tracing :: SpanContext > for opentelemetry:: trace:: SpanContext {
862+ fn from ( sc : wasi :: otel :: tracing :: SpanContext ) -> Self {
862863 let trace_id = opentelemetry:: trace:: TraceId :: from_hex ( & sc. trace_id )
863864 . unwrap_or ( opentelemetry:: trace:: TraceId :: INVALID ) ;
864865 let span_id = opentelemetry:: trace:: SpanId :: from_hex ( & sc. span_id )
@@ -875,7 +876,7 @@ mod otel {
875876 }
876877 }
877878
878- impl From < opentelemetry:: trace:: SpanContext > for wasi_tracing :: SpanContext {
879+ impl From < opentelemetry:: trace:: SpanContext > for wasi :: otel :: tracing :: SpanContext {
879880 fn from ( sc : opentelemetry:: trace:: SpanContext ) -> Self {
880881 Self {
881882 trace_id : format ! ( "{:x}" , sc. trace_id( ) ) ,
@@ -898,68 +899,68 @@ mod otel {
898899 }
899900 }
900901
901- impl From < wasi_tracing :: TraceFlags > for opentelemetry:: trace:: TraceFlags {
902- fn from ( flags : wasi_tracing :: TraceFlags ) -> Self {
902+ impl From < wasi :: otel :: tracing :: TraceFlags > for opentelemetry:: trace:: TraceFlags {
903+ fn from ( flags : wasi :: otel :: tracing :: TraceFlags ) -> Self {
903904 Self :: new ( flags. as_array ( ) [ 0 ] as u8 )
904905 }
905906 }
906907
907- impl From < opentelemetry:: trace:: TraceFlags > for wasi_tracing :: TraceFlags {
908+ impl From < opentelemetry:: trace:: TraceFlags > for wasi :: otel :: tracing :: TraceFlags {
908909 fn from ( flags : opentelemetry:: trace:: TraceFlags ) -> Self {
909910 if flags. is_sampled ( ) {
910- wasi_tracing :: TraceFlags :: SAMPLED
911+ wasi :: otel :: tracing :: TraceFlags :: SAMPLED
911912 } else {
912- wasi_tracing :: TraceFlags :: empty ( )
913+ wasi :: otel :: tracing :: TraceFlags :: empty ( )
913914 }
914915 }
915916 }
916917
917- impl From < wasi_tracing :: SpanKind > for opentelemetry:: trace:: SpanKind {
918- fn from ( kind : wasi_tracing :: SpanKind ) -> Self {
918+ impl From < wasi :: otel :: tracing :: SpanKind > for opentelemetry:: trace:: SpanKind {
919+ fn from ( kind : wasi :: otel :: tracing :: SpanKind ) -> Self {
919920 match kind {
920- wasi_tracing :: SpanKind :: Client => opentelemetry:: trace:: SpanKind :: Client ,
921- wasi_tracing :: SpanKind :: Server => opentelemetry:: trace:: SpanKind :: Server ,
922- wasi_tracing :: SpanKind :: Producer => opentelemetry:: trace:: SpanKind :: Producer ,
923- wasi_tracing :: SpanKind :: Consumer => opentelemetry:: trace:: SpanKind :: Consumer ,
924- wasi_tracing :: SpanKind :: Internal => opentelemetry:: trace:: SpanKind :: Internal ,
921+ wasi :: otel :: tracing :: SpanKind :: Client => opentelemetry:: trace:: SpanKind :: Client ,
922+ wasi :: otel :: tracing :: SpanKind :: Server => opentelemetry:: trace:: SpanKind :: Server ,
923+ wasi :: otel :: tracing :: SpanKind :: Producer => opentelemetry:: trace:: SpanKind :: Producer ,
924+ wasi :: otel :: tracing :: SpanKind :: Consumer => opentelemetry:: trace:: SpanKind :: Consumer ,
925+ wasi :: otel :: tracing :: SpanKind :: Internal => opentelemetry:: trace:: SpanKind :: Internal ,
925926 }
926927 }
927928 }
928929
929- impl From < wasi_tracing :: KeyValue > for opentelemetry:: KeyValue {
930- fn from ( kv : wasi_tracing :: KeyValue ) -> Self {
930+ impl From < wasi :: otel :: tracing :: KeyValue > for opentelemetry:: KeyValue {
931+ fn from ( kv : wasi :: otel :: tracing :: KeyValue ) -> Self {
931932 opentelemetry:: KeyValue :: new ( kv. key , kv. value )
932933 }
933934 }
934935
935- impl From < & wasi_tracing :: KeyValue > for opentelemetry:: KeyValue {
936- fn from ( kv : & wasi_tracing :: KeyValue ) -> Self {
936+ impl From < & wasi :: otel :: tracing :: KeyValue > for opentelemetry:: KeyValue {
937+ fn from ( kv : & wasi :: otel :: tracing :: KeyValue ) -> Self {
937938 opentelemetry:: KeyValue :: new ( kv. key . to_owned ( ) , kv. value . to_owned ( ) )
938939 }
939940 }
940941
941- impl From < wasi_types :: Value > for opentelemetry:: Value {
942- fn from ( value : wasi_types :: Value ) -> Self {
942+ impl From < wasi :: otel :: types :: Value > for opentelemetry:: Value {
943+ fn from ( value : wasi :: otel :: types :: Value ) -> Self {
943944 match value {
944- wasi_types :: Value :: String ( v) => v. into ( ) ,
945- wasi_types :: Value :: Bool ( v) => v. into ( ) ,
946- wasi_types :: Value :: F64 ( v) => v. into ( ) ,
947- wasi_types :: Value :: S64 ( v) => v. into ( ) ,
948- wasi_types :: Value :: StringArray ( v) => opentelemetry:: Value :: Array (
945+ wasi :: otel :: types :: Value :: String ( v) => v. into ( ) ,
946+ wasi :: otel :: types :: Value :: Bool ( v) => v. into ( ) ,
947+ wasi :: otel :: types :: Value :: F64 ( v) => v. into ( ) ,
948+ wasi :: otel :: types :: Value :: S64 ( v) => v. into ( ) ,
949+ wasi :: otel :: types :: Value :: StringArray ( v) => opentelemetry:: Value :: Array (
949950 v. into_iter ( )
950951 . map ( StringValue :: from)
951952 . collect :: < Vec < _ > > ( )
952953 . into ( ) ,
953954 ) ,
954- wasi_types :: Value :: BoolArray ( v) => opentelemetry:: Value :: Array ( v. into ( ) ) ,
955- wasi_types :: Value :: F64Array ( v) => opentelemetry:: Value :: Array ( v. into ( ) ) ,
956- wasi_types :: Value :: S64Array ( v) => opentelemetry:: Value :: Array ( v. into ( ) ) ,
955+ wasi :: otel :: types :: Value :: BoolArray ( v) => opentelemetry:: Value :: Array ( v. into ( ) ) ,
956+ wasi :: otel :: types :: Value :: F64Array ( v) => opentelemetry:: Value :: Array ( v. into ( ) ) ,
957+ wasi :: otel :: types :: Value :: S64Array ( v) => opentelemetry:: Value :: Array ( v. into ( ) ) ,
957958 }
958959 }
959960 }
960961
961- impl From < wasi_tracing :: Event > for opentelemetry:: trace:: Event {
962- fn from ( event : wasi_tracing :: Event ) -> Self {
962+ impl From < wasi :: otel :: tracing :: Event > for opentelemetry:: trace:: Event {
963+ fn from ( event : wasi :: otel :: tracing :: Event ) -> Self {
963964 Self :: new (
964965 event. name ,
965966 event. time . into ( ) ,
@@ -969,8 +970,8 @@ mod otel {
969970 }
970971 }
971972
972- impl From < wasi_tracing :: Link > for opentelemetry:: trace:: Link {
973- fn from ( link : wasi_tracing :: Link ) -> Self {
973+ impl From < wasi :: otel :: tracing :: Link > for opentelemetry:: trace:: Link {
974+ fn from ( link : wasi :: otel :: tracing :: Link ) -> Self {
974975 Self :: new (
975976 link. span_context . into ( ) ,
976977 link. attributes . into_iter ( ) . map ( Into :: into) . collect ( ) ,
@@ -979,20 +980,20 @@ mod otel {
979980 }
980981 }
981982
982- impl From < wasi_tracing :: Status > for opentelemetry:: trace:: Status {
983- fn from ( status : wasi_tracing :: Status ) -> Self {
983+ impl From < wasi :: otel :: tracing :: Status > for opentelemetry:: trace:: Status {
984+ fn from ( status : wasi :: otel :: tracing :: Status ) -> Self {
984985 match status {
985- wasi_tracing :: Status :: Unset => Self :: Unset ,
986- wasi_tracing :: Status :: Ok => Self :: Ok ,
987- wasi_tracing :: Status :: Error ( s) => Self :: Error {
986+ wasi :: otel :: tracing :: Status :: Unset => Self :: Unset ,
987+ wasi :: otel :: tracing :: Status :: Ok => Self :: Ok ,
988+ wasi :: otel :: tracing :: Status :: Error ( s) => Self :: Error {
988989 description : s. into ( ) ,
989990 } ,
990991 }
991992 }
992993 }
993994
994- impl From < wasi_types :: InstrumentationScope > for opentelemetry:: InstrumentationScope {
995- fn from ( value : wasi_tracing :: InstrumentationScope ) -> Self {
995+ impl From < wasi :: otel :: types :: InstrumentationScope > for opentelemetry:: InstrumentationScope {
996+ fn from ( value : wasi :: otel :: tracing :: InstrumentationScope ) -> Self {
996997 let builder = Self :: builder ( value. name )
997998 . with_attributes ( value. attributes . into_iter ( ) . map ( Into :: into) ) ;
998999 match ( value. version , value. schema_url ) {
0 commit comments