How to use the diagnostic-channel.channel.addContextPreservation function in diagnostic-channel

To help you get started, we’ve selected a few diagnostic-channel 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 microsoft / node-diagnostic-channel / src / publisher-legacy-tests / mongo3.0.5 / mongo3.0.5.spec.ts View on Github external
it("should fire events when we communicate with a collection, and preserve context", function(done) {
        channel.addContextPreservation((cb) => Zone.current.wrap(cb, "context preservation"));

        const events: Array> = [];
        channel.subscribe("mongodb", function(event) {
            events.push(event);
        });

        const mongodb = require("mongodb");

        const z1 = Zone.current.fork({name: "1"});
        z1.run(() =>
        mongodb.MongoClient.connect("mongodb://localhost:27017", { useNewUrlParser: true }, function(err, client) {
            if (err) {
                done(err);
            }

            const collection = client.db("testdb").collection("documents");
github microsoft / node-diagnostic-channel / src / publisher-legacy-tests / pg6 / pg6.spec.ts View on Github external
before(() => {
        enablePostgres();
        enablePostgresPool();
        channel.addContextPreservation((cb) => Zone.current.wrap(cb, "context preservation"));
        pg = require("pg");
        pool = new pg.Pool({
            user: dbSettings.user,
            password: dbSettings.password,
            database: dbSettings.database,
            host: dbSettings.host,
            port: dbSettings.port,
            max: 2,
        });
    });

diagnostic-channel

Provides a context-saving pub/sub channel to connect diagnostic event publishers and subscribers

MIT
Latest version published 1 year ago

Package Health Score

74 / 100
Full package analysis

Similar packages