How to use the shimmer.unwrap function in shimmer

To help you get started, we’ve selected a few shimmer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-http2 / src / http2.ts View on Github external
protected applyUnpatch(): void {
    // Only Client and Server constructors will be unwrapped. Any existing
    // Client or Server instances will still trace
    shimmer.unwrap(this.moduleExports, 'createServer');
    shimmer.unwrap(this.moduleExports, 'createSecureServer');
    shimmer.unwrap(this.moduleExports, 'connect');
  }
github googleapis / cloud-trace-nodejs / test / test-trace-writer.ts View on Github external
_cacheClientFromJSON: typeof writer.authClient.fromJSON;
        },
        '_cacheClientFromJSON',
        cacheClientFromJSON => {
          return function(
            this: GoogleAuth,
            json: JWTInput,
            options?: RefreshOptions
          ) {
            capturedJson = json;
            return cacheClientFromJSON.call(this, json, options);
          };
        }
      );
      await writer.authClient.getClient();
      shimmer.unwrap(
        writer.authClient as typeof writer.authClient & {
          _cacheClientFromJSON: typeof writer.authClient.fromJSON;
        },
        '_cacheClientFromJSON'
      );
      return capturedJson;
    };
github tjmehta / primus-graphql / test / relay-network-layer.unit.js View on Github external
afterEach(function () {
        shimmer.unwrap(Observable.prototype, 'backoff')
        shimmer.unwrap(Function.prototype, 'bind')
      })
github DataDog / datadog-lambda-layer-js / src / trace / patch-http.ts View on Github external
function unpatchMethod(mod: typeof http | typeof https, method: "get" | "request") {
  if (mod[method].__wrapped !== undefined) {
    shimmer.unwrap(mod, method);
  }
}
github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-http2 / src / http2.ts View on Github external
return function patchedCreateServer(
        this: Http2Plugin
      ): http2.Http2Server {
        const server = original.apply(this, arguments);
        shimmer.wrap(
          server.constructor.prototype,
          'emit',
          plugin.getPatchEmitFunction()
        );

        shimmer.unwrap(plugin.moduleExports, 'createServer');
        shimmer.unwrap(plugin.moduleExports, 'createSecureServer');

        return server;
      };
    };
github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-http / src / http.ts View on Github external
protected applyUnpatch(): void {
    shimmer.unwrap(this.moduleExports, 'request');
    if (semver.satisfies(this.version, '>=8.0.0')) {
      shimmer.unwrap(this.moduleExports, 'get');
    }
    if (
      this.moduleExports &&
      this.moduleExports.Server &&
      this.moduleExports.Server.prototype
    ) {
      shimmer.unwrap(this.moduleExports.Server.prototype, 'emit');
    }
  }
github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-redis / src / redis.ts View on Github external
applyUnpatch(): void {
    if (semver.lt(this.version, '2.6.0')) return;

    shimmer.unwrap(
      this.moduleExports.RedisClient.prototype,
      'internal_send_command'
    );
    shimmer.unwrap(this.moduleExports, 'createClient');
    shimmer.unwrap(this.moduleExports.RedisClient.prototype, 'create_stream');
  }
github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-https / src / https.ts View on Github external
protected applyUnpatch(): void {
    if (
      this.moduleExports &&
      this.moduleExports.Server &&
      this.moduleExports.Server.prototype
    ) {
      shimmer.unwrap(
        this.moduleExports &&
          this.moduleExports.Server &&
          this.moduleExports.Server.prototype,
        'emit'
      );
    }
    shimmer.unwrap(this.moduleExports, 'request');
    if (semver.satisfies(this.version, '>=8.0.0')) {
      shimmer.unwrap(this.moduleExports, 'get');
    }
  }
}
github keymetrics / pm2-io-apm / src / census / plugins / mongodb.ts View on Github external
applyUnpatch (): void {
    shimmer.unwrap(this.moduleExports.Server.prototype, 'insert')
    shimmer.unwrap(this.moduleExports.Server.prototype, 'remove')
    shimmer.unwrap(this.moduleExports.Server.prototype, 'command')
    shimmer.unwrap(this.moduleExports.Server.prototype, 'update')
    shimmer.unwrap(this.moduleExports.Cursor.prototype, 'next')
    if (this.internalFilesExports.ConnectionPool) {
      shimmer.unwrap(this.internalFilesExports.ConnectionPool.prototype, 'once')
    }
  }
github googleapis / cloud-trace-nodejs / src / plugins / plugin-mongodb-core.ts View on Github external
unpatch: function(mongo) {
      shimmer.unwrap(mongo.Server.prototype, 'command');
      shimmer.unwrap(mongo.Server.prototype, 'insert');
      shimmer.unwrap(mongo.Server.prototype, 'update');
      shimmer.unwrap(mongo.Server.prototype, 'remove');
      shimmer.unwrap(mongo.Cursor.prototype, 'next');
    }
  }

shimmer

Safe(r) monkeypatching for JavaScript.

BSD-2-Clause
Latest version published 6 years ago

Package Health Score

67 / 100
Full package analysis