Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions modules/howtos/examples/request-tracer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"use strict";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering are we using this example anywhere? Or is this prep for referencing later?

Also this will need a new test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm yes, looks like this needs some more work, ta

const { ThresholdLoggingTracer } = require("couchbase");
const couchbase = require("couchbase");

async function go() {
const tracer = new ThresholdLoggingTracer({
emitInterval: 1,
kvThreshold: 0.1
})

const cluster = await couchbase.connect("couchbase://localhost", {
username: "Administrator",
password: "password",
logFunc: (j) => { if (j.subsys == "tracer") { console.log(j) } },
tracer
})

const collection = cluster.bucket("travel-sample").scope("inventory").collection("airline")

await collection.upsert(
"airline_11", {
callsign: "MILE-AIR",
iata: "Q5",
icao: "MLA",
id: 11,
name: "40-Mile Air",
type: "airline"
}
)
await sleep(10)
}

function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}

go()
.then((res) => console.log("DONE:", res))
.catch((err) => {
console.log("ERR:", err)
process.exit(1)
})
.then(process.exit)