@@ -23,22 +23,23 @@ addHook({ name: 'durable-functions', versions: ['>=3'], patchDefault: false }, (
2323
2424function entityWrapper ( method ) {
2525 return function ( entityName , arg ) {
26+ if ( azureDurableFunctionsChannel . hasSubscribers ) return method . apply ( this , arguments )
27+
2628 // because this method is overloaded, the second argument can either be an object
2729 // with the handler or the handler itself, so first we figure which type it is
28-
2930 if ( typeof arg === 'function' ) {
3031 // if a function, this is the handler we want to wrap and trace
31- arguments [ 1 ] = shimmer . wrapFunction ( arg , handler => entityHandler ( handler , entityName , method . name ) )
32+ arguments [ 1 ] = shimmer . wrapFunction ( arg , handler => entityHandler ( handler , entityName ) )
3233 } else {
3334 // if an object, access the handler then trace it
34- shimmer . wrap ( arg , 'handler' , handler => entityHandler ( handler , entityName , method . name ) )
35+ shimmer . wrap ( arg , 'handler' , handler => entityHandler ( handler , entityName ) )
3536 }
3637
3738 return method . apply ( this , arguments )
3839 }
3940}
4041
41- function entityHandler ( handler , entityName , methodName ) {
42+ function entityHandler ( handler , entityName ) {
4243 return function ( ) {
4344 const entityContext = arguments [ 0 ]
4445 return azureDurableFunctionsChannel . traceSync (
@@ -50,6 +51,8 @@ function entityHandler (handler, entityName, methodName) {
5051
5152function activityHandler ( method ) {
5253 return function ( activityName , activityOptions ) {
54+ if ( azureDurableFunctionsChannel . hasSubscribers ) return method . apply ( this , arguments )
55+
5356 shimmer . wrap ( activityOptions , 'handler' , handler => {
5457 const isAsync =
5558 handler && handler . constructor && handler . constructor . name === 'AsyncFunction'
0 commit comments