@@ -23,7 +23,7 @@ use base_rt::get_current_cpu_time_ns;
23
23
use base_rt:: BlockingScopeCPUUsage ;
24
24
use base_rt:: DenoRuntimeDropToken ;
25
25
use base_rt:: DropToken ;
26
- use base_rt:: RuntimeOtelAttribute ;
26
+ use base_rt:: RuntimeOtelExtraAttributes ;
27
27
use base_rt:: RuntimeState ;
28
28
use base_rt:: RuntimeWaker ;
29
29
use cooked_waker:: IntoWaker ;
@@ -55,6 +55,7 @@ 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 ;
58
59
use deno_core:: url:: Url ;
59
60
use deno_core:: v8;
60
61
use deno_core:: v8:: GCCallbackFlags ;
@@ -1105,6 +1106,7 @@ where
1105
1106
s3_fs,
1106
1107
beforeunload_cpu_threshold,
1107
1108
beforeunload_mem_threshold,
1109
+ context,
1108
1110
..
1109
1111
} = match bootstrap_ret {
1110
1112
Ok ( Ok ( v) ) => v,
@@ -1116,6 +1118,7 @@ where
1116
1118
}
1117
1119
} ;
1118
1120
1121
+ let context = context. unwrap_or_default ( ) ;
1119
1122
let span = Span :: current ( ) ;
1120
1123
let post_task_ret = unsafe {
1121
1124
spawn_blocking_non_send ( || {
@@ -1143,14 +1146,31 @@ where
1143
1146
op_state. put :: < HashMap < usize , CancellationToken > > ( HashMap :: new ( ) ) ;
1144
1147
}
1145
1148
1149
+ let mut otel_attributes = HashMap :: new ( ) ;
1150
+
1151
+ otel_attributes. insert (
1152
+ "edge_runtime.worker.kind" . into ( ) ,
1153
+ conf. to_worker_kind ( ) . to_string ( ) . into ( ) ,
1154
+ ) ;
1155
+
1146
1156
if conf. is_user_worker ( ) {
1147
1157
let conf = conf. as_user_worker ( ) . unwrap ( ) ;
1148
1158
let key = conf. key . map_or ( "" . to_string ( ) , |k| k. to_string ( ) ) ;
1149
1159
1150
1160
// set execution id for user workers
1151
1161
env_vars. insert ( "SB_EXECUTION_ID" . to_string ( ) , key. clone ( ) ) ;
1152
1162
1153
- op_state. put ( RuntimeOtelAttribute ( key. into ( ) ) ) ;
1163
+ if let Some ( Value :: Object ( attributes) ) = context. get ( "otel" ) {
1164
+ for ( k, v) in attributes {
1165
+ otel_attributes. insert (
1166
+ k. to_string ( ) . into ( ) ,
1167
+ match v {
1168
+ Value :: String ( str) => str. to_string ( ) . into ( ) ,
1169
+ others => others. to_string ( ) . into ( ) ,
1170
+ } ,
1171
+ ) ;
1172
+ }
1173
+ }
1154
1174
1155
1175
if let Some ( events_msg_tx) = conf. events_msg_tx . clone ( ) {
1156
1176
op_state. put :: < mpsc:: UnboundedSender < WorkerEventWithMetadata > > (
@@ -1161,14 +1181,11 @@ where
1161
1181
execution_id : conf. key ,
1162
1182
} ) ;
1163
1183
}
1164
- } else {
1165
- op_state. put ( RuntimeOtelAttribute (
1166
- conf. to_worker_kind ( ) . to_string ( ) . into ( ) ,
1167
- ) ) ;
1168
1184
}
1169
1185
1170
1186
op_state. put ( ext_env:: EnvVars ( env_vars) ) ;
1171
1187
op_state. put ( DenoRuntimeDropToken ( DropToken ( drop_token. clone ( ) ) ) ) ;
1188
+ op_state. put ( RuntimeOtelExtraAttributes ( otel_attributes) ) ;
1172
1189
}
1173
1190
1174
1191
if is_user_worker {
0 commit comments