File tree Expand file tree Collapse file tree 3 files changed +15
-11
lines changed
Expand file tree Collapse file tree 3 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ import (
1313const wasmInstrVersionMajor = 0
1414const wasmInstrVersionMinor = 0 // TODO: bump this to match compiler when ready
1515
16+ var errorNoCompatibilityVersion = errors .New ("No compatibility versions in module" )
17+
1618// make sure that our function was instrumented with a compatible
1719// version of wasm-instr
1820func checkVersion (m * wasm.Module ) error {
@@ -31,7 +33,7 @@ func checkVersion(m *wasm.Module) error {
3133 }
3234
3335 if minorGlobal == nil || majorGlobal == nil {
34- return errors . New ( "wasm_instr_version functions not found" )
36+ return errorNoCompatibilityVersion
3537 }
3638
3739 minor , _ , err := leb128 .DecodeUint32 (bytes .NewReader (m .GlobalSection [minorGlobal .Index ].Init .Data ))
@@ -60,7 +62,7 @@ func parseNames(data []byte) (map[uint32]string, error) {
6062 }
6163
6264 // Check for version globals
63- if err := checkVersion (m ); err != nil {
65+ if err := checkVersion (m ); err != nil && err != errorNoCompatibilityVersion {
6466 return nil , err
6567 }
6668
Original file line number Diff line number Diff line change @@ -18,8 +18,10 @@ impl Adapter for OtelStdoutAdapter {
1818 for span in trace_evt. events {
1919 self . event_to_spans ( & mut spans, span, vec ! [ ] , trace_id. clone ( ) ) ?;
2020 }
21- let otf = OtelFormatter :: new ( spans, "stdout" . into ( ) ) ;
22- println ! ( "{:?}" , & otf. traces_data) ;
21+ if !spans. is_empty ( ) {
22+ let otf = OtelFormatter :: new ( spans, "stdout" . into ( ) ) ;
23+ println ! ( "{:?}" , & otf. traces_data) ;
24+ }
2325 Ok ( ( ) )
2426 }
2527}
Original file line number Diff line number Diff line change 11use std:: collections:: HashMap ;
22
3- use anyhow:: { bail, Context , Result } ;
3+ use anyhow:: { bail, Result } ;
44
55// these control the versions of instrumented wasm supported
66// WASM_INSTR_VERSION_MAJOR must match the instrumented wasm
@@ -17,12 +17,12 @@ pub struct WasmInstrInfo {
1717
1818impl WasmInstrInfo {
1919 pub fn check_version ( & self ) -> Result < ( ) > {
20- let maj_num = self
21- . maj_version
22- . context ( "wasm-instr missing major version" ) ? ;
23- let min_num = self
24- . min_version
25- . context ( "wasm-instr missing minor version" ) ? ;
20+ if self . maj_version . is_none ( ) && self . min_version . is_none ( ) {
21+ // likely this is an uninstrumented module, or not instrumented with automation
22+ return Ok ( ( ) ) ;
23+ }
24+ let maj_num = self . maj_version . unwrap ( ) ;
25+ let min_num = self . min_version . unwrap ( ) ;
2626
2727 if maj_num != WASM_INSTR_VERSION_MAJOR {
2828 bail ! ( "wasm wasm-instr major version {maj_num} is not equal to {WASM_INSTR_VERSION_MAJOR}!" )
You can’t perform that action at this time.
0 commit comments