Skip to content

feat: PostgreSQL Tracing Support - #3064

Merged
HazAT merged 4 commits into
masterfrom
node-pg
Dec 4, 2020
Merged

feat: PostgreSQL Tracing Support#3064
HazAT merged 4 commits into
masterfrom
node-pg

Conversation

@kamilogorek

@kamilogorekkamilogorek commented Nov 19, 2020

Copy link
Copy Markdown
Contributor

PostgreSQL and CockroachDB tracing support.

Usage:

constSentry=require("@sentry/node");constTracing=require("@sentry/tracing");constpg=require("pg");Sentry.init({dsn: "__PUBLIC_DSN__",integrations: [newTracing.Integrations.Postgres(),],tracesSampleRate: 1.0,});constclient=newpg.Client({user: "postgres",password: "docker",});client.connect();// the rest of the code, for raw-node code we need manual instrumentation, eg.consttransaction=Sentry.startTransaction({op: "transaction",name: "My Transaction",});Sentry.configureScope((scope)=>{scope.setSpan(transaction);});client.query("SELECT $1::text as message",["Hello world!"],(err,res)=>{console.log(err ? err.stack : res.rows[0].message);// Hello World!if(transaction)transaction.finish();client.end();});

Works nicely with Express too:

constSentry=require("@sentry/node");constTracing=require("@sentry/tracing");constpg=require("pg");constexpress=require("express");Sentry.init({dsn: "__PUBLIC_DSN__",integrations: [newSentry.Integrations.Http({tracing: true}),newTracing.Integrations.Express({app: express.Router,methods: ["get"],}),newTracing.Integrations.Postgres(),],});constapp=express();constclient=newpg.Client({user: "postgres",password: "docker",});client.connect();app.use(Sentry.Handlers.requestHandler());app.use(Sentry.Handlers.tracingHandler());app.use(express.json());app.get("/hi",functionsayHi(req,res){client.query("SELECT $1::text as name",["picklerick"],(err,rows)=>{res.send(rows[0]);});});app.use(Sentry.Handlers.errorHandler());app.listen(3000);

@kamilogorek
kamilogorek requested a review from a teamNovember 19, 2020 15:17
@github-actions

github-actionsBot commented Nov 19, 2020

Copy link
Copy Markdown
Contributor

size-limit report

PathSize
@sentry/browser - CDN Bundle (gzipped)19.73 KB (+0.01% 🔺)
@sentry/browser - Webpack20.6 KB (0%)
@sentry/react - Webpack20.6 KB (0%)
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped)26.88 KB (+0.01% 🔺)

Comment threadpackages/node/src/handlers.ts
Comment threadpackages/tracing/src/integrations/postgres.ts Outdated
Comment threadpackages/tracing/src/integrations/postgres.ts Outdated
Comment threadpackages/tracing/src/integrations/postgres.ts Outdated
Comment threadpackages/tracing/src/integrations/postgres.ts
@kamilogorek

Copy link
Copy Markdown
ContributorAuthor

Thanks @lobsterkatie, will make appropriate changes once I finish Mongo work.

@kamilogorekkamilogorek changed the title node-postgres tracing integrationfeat: PostgreSQL Tracing SupportNov 24, 2020
@ghost

Copy link
Copy Markdown

Is there a timeline for when this will be merged and released? The Express fix in here would be really nice to have given it is causing a lot of duplicates in our issues page.

@kamilogorek

Copy link
Copy Markdown
ContributorAuthor

@dlaudate-embark I'll extract it from the PR today so we can ship it tomorrow/monday

@kamilogorek

Copy link
Copy Markdown
ContributorAuthor

@dlaudate-embark ref: #3078

@kamilogorek
kamilogorekforce-pushed the node-pg branch 4 times, most recently from ee56d98 to baf089fCompareDecember 1, 2020 14:01

@lobsterkatielobsterkatie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good! Maybe some tests, though?

@HazAT
HazAT merged commit 1ab3b04 into masterDec 4, 2020
@HazAT
HazAT deleted the node-pg branch December 4, 2020 11:43
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@kamilogorek@lobsterkatie@HazAT