@@ -55,7 +55,6 @@ use deno_cache::SqliteBackedCache;
55
55
use deno_core:: error:: AnyError ;
56
56
use deno_core:: error:: JsError ;
57
57
use deno_core:: serde_json;
58
- use deno_core:: serde_json:: Value ;
59
58
use deno_core:: url:: Url ;
60
59
use deno_core:: v8;
61
60
use deno_core:: v8:: GCCallbackFlags ;
@@ -80,7 +79,6 @@ use deno_facade::EmitterFactory;
80
79
use deno_facade:: EszipPayloadKind ;
81
80
use deno_facade:: Metadata ;
82
81
use either:: Either ;
83
- use ext_event_worker:: events:: EventMetadata ;
84
82
use ext_event_worker:: events:: WorkerEventWithMetadata ;
85
83
use ext_runtime:: cert:: ValueRootCertStoreProvider ;
86
84
use ext_runtime:: external_memory:: CustomAllocator ;
@@ -462,6 +460,7 @@ where
462
460
pub ( crate ) async fn new ( mut worker : Worker ) -> Result < Self , Error > {
463
461
let init_opts = worker. init_opts . take ( ) ;
464
462
let flags = worker. flags . clone ( ) ;
463
+ let event_metadata = worker. event_metadata . clone ( ) ;
465
464
466
465
debug_assert ! ( init_opts. is_some( ) , "init_opts must not be None" ) ;
467
466
@@ -1111,7 +1110,6 @@ where
1111
1110
s3_fs,
1112
1111
beforeunload_cpu_threshold,
1113
1112
beforeunload_mem_threshold,
1114
- context,
1115
1113
..
1116
1114
} = match bootstrap_ret {
1117
1115
Ok ( Ok ( v) ) => v,
@@ -1123,7 +1121,7 @@ where
1123
1121
}
1124
1122
} ;
1125
1123
1126
- let context = context . unwrap_or_default ( ) ;
1124
+ let otel_attributes = event_metadata . otel_attributes . clone ( ) ;
1127
1125
let span = Span :: current ( ) ;
1128
1126
let post_task_ret = unsafe {
1129
1127
spawn_blocking_non_send ( || {
@@ -1151,46 +1149,30 @@ where
1151
1149
op_state. put :: < HashMap < usize , CancellationToken > > ( HashMap :: new ( ) ) ;
1152
1150
}
1153
1151
1154
- let mut otel_attributes = HashMap :: new ( ) ;
1155
-
1156
- otel_attributes. insert (
1157
- "edge_runtime.worker.kind" . into ( ) ,
1158
- conf. to_worker_kind ( ) . to_string ( ) . into ( ) ,
1159
- ) ;
1160
-
1161
1152
if conf. is_user_worker ( ) {
1162
1153
let conf = conf. as_user_worker ( ) . unwrap ( ) ;
1163
1154
let key = conf. key . map_or ( "" . to_string ( ) , |k| k. to_string ( ) ) ;
1164
1155
1165
1156
// set execution id for user workers
1166
1157
env_vars. insert ( "SB_EXECUTION_ID" . to_string ( ) , key. clone ( ) ) ;
1167
1158
1168
- if let Some ( Value :: Object ( attributes) ) = context. get ( "otel" ) {
1169
- for ( k, v) in attributes {
1170
- otel_attributes. insert (
1171
- k. to_string ( ) . into ( ) ,
1172
- match v {
1173
- Value :: String ( str) => str. to_string ( ) . into ( ) ,
1174
- others => others. to_string ( ) . into ( ) ,
1175
- } ,
1176
- ) ;
1177
- }
1178
- }
1179
-
1180
1159
if let Some ( events_msg_tx) = conf. events_msg_tx . clone ( ) {
1181
1160
op_state. put :: < mpsc:: UnboundedSender < WorkerEventWithMetadata > > (
1182
1161
events_msg_tx,
1183
1162
) ;
1184
- op_state. put :: < EventMetadata > ( EventMetadata {
1185
- service_path : conf. service_path . clone ( ) ,
1186
- execution_id : conf. key ,
1187
- } ) ;
1163
+ op_state. put ( event_metadata) ;
1188
1164
}
1189
1165
}
1190
1166
1191
1167
op_state. put ( ext_env:: EnvVars ( env_vars) ) ;
1192
1168
op_state. put ( DenoRuntimeDropToken ( DropToken ( drop_token. clone ( ) ) ) ) ;
1193
- op_state. put ( RuntimeOtelExtraAttributes ( otel_attributes) ) ;
1169
+ op_state. put ( RuntimeOtelExtraAttributes (
1170
+ otel_attributes
1171
+ . unwrap_or_default ( )
1172
+ . into_iter ( )
1173
+ . map ( |( k, v) | ( k. into ( ) , v. into ( ) ) )
1174
+ . collect ( ) ,
1175
+ ) ) ;
1194
1176
}
1195
1177
1196
1178
if is_user_worker {
0 commit comments