Skip to content
Open
Show file tree
Hide file tree
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
18 changes: 18 additions & 0 deletions .github/workflows/apm-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,24 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: ./.github/actions/plugins/test

postgres-js:
runs-on: ubuntu-latest
permissions:
id-token: write
services:
postgres:
image: postgres@sha256:75ebf479151a8fd77bf2fed46ef76ce8d518c23264734c48f2d1de42b4eb40ae # 9.5
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
env:
PLUGINS: postgres
SERVICES: postgres
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: ./.github/actions/plugins/test

prisma:
strategy:
fail-fast: false
Expand Down
2 changes: 2 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ tracer.use('openai', {
<h5 id="pg"></h5>
<h5 id="pino"></h5>
<h5 id="playwright"></h5>
<h5 id="postgres"></h5>
<h5 id="prisma"></h5>
<h5 id="protobufjs"></h5>
<h5 id="redis"></h5>
Expand Down Expand Up @@ -221,6 +222,7 @@ tracer.use('openai', {
* [pg](./interfaces/export_.plugins.pg.html)
* [pino](./interfaces/export_.plugins.pino.html)
* [playwright](./interfaces/export_.plugins.playwright.html)
* [postgres](./interfaces/export_.plugins.postgres.html)
* [prisma](./interfaces/export_.plugins.prisma.html)
* [protobufjs](./interfaces/export_.plugins.protobufjs.html)
* [redis](./interfaces/export_.plugins.redis.html)
Expand Down
4 changes: 4 additions & 0 deletions docs/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ tracer.use('pg', { appendComment: true });
tracer.use('pg', { truncate: true });
tracer.use('pg', { truncate: 5000 });
tracer.use('pino');
tracer.use('postgres');
tracer.use('postgres', { service: 'postgres-service' });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we are moving away from allowing configurable per integration service name, can this be removed along with the optional configuration

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I believe doing this only for some is not ideal. Otherwise it is likely confusing for customers. I believe it would also require special handling to prevent it (I believe it is a generic functionality)

tracer.use('postgres', { truncate: true });
tracer.use('postgres', { truncate: 5000 });
tracer.use('prisma');
tracer.use('protobufjs');
tracer.use('redis');
Expand Down
12 changes: 12 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ interface Plugins {
"playwright": tracer.plugins.playwright;
"pg": tracer.plugins.pg;
"pino": tracer.plugins.pino;
"postgres": tracer.plugins.postgres;
"prisma": tracer.plugins.prisma;
"protobufjs": tracer.plugins.protobufjs;
"redis": tracer.plugins.redis;
Expand Down Expand Up @@ -3126,6 +3127,17 @@ declare namespace tracer {
*/
interface pino extends Integration {}

/**
* This plugin automatically instruments the
* [Postgres.js](https://github.com/porsager/postgres) module.
*/
interface postgres extends DatabaseInstrumentation {
/**
* The service name to be used for this plugin.
*/
service?: string;
}

/**
* This plugin automatically instruments the
* [@prisma/client](https://www.prisma.io/docs/orm/prisma-client) module.
Expand Down
12 changes: 12 additions & 0 deletions index.d.v5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ interface Plugins {
"playwright": tracer.plugins.playwright;
"pg": tracer.plugins.pg;
"pino": tracer.plugins.pino;
"postgres": tracer.plugins.postgres;
"prisma": tracer.plugins.prisma;
"protobufjs": tracer.plugins.protobufjs;
"redis": tracer.plugins.redis;
Expand Down Expand Up @@ -3296,6 +3297,17 @@ declare namespace tracer {
*/
interface pino extends Integration {}

/**
* This plugin automatically instruments the
* [Postgres.js](https://github.com/porsager/postgres) module.
*/
interface postgres extends DatabaseInstrumentation {
/**
* The service name to be used for this plugin.
*/
service?: string;
}

/**
* This plugin automatically instruments the
* [@prisma/client](https://www.prisma.io/docs/orm/prisma-client) module.
Expand Down
1 change: 1 addition & 0 deletions packages/datadog-instrumentations/src/helpers/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ module.exports = {
'pino-pretty': () => require('../pino'),
playwright: () => require('../playwright'),
'playwright-core': () => require('../playwright'),
postgres: { esmFirst: true, fn: () => require('../postgres') },
'promise-js': () => require('../promise-js'),
promise: () => require('../promise'),
protobufjs: () => require('../protobufjs'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ function createMatcher (moduleType) {
configureMercuriusRequest,
waitForAsyncEnd,
} = require('./transforms')
const {
postgresQueryHandlers,
postgresQueryLifecycle,
} = require('./transforms/postgres')

const matcher = create(instrumentations, getDcPolyfillSpecifier(moduleType))

Expand All @@ -126,6 +130,8 @@ function createMatcher (moduleType) {
matcher.addTransform('configureGraphqlJitExecute', configureGraphqlJitExecute)
matcher.addTransform('configureGraphqlJitRuntime', configureGraphqlJitRuntime)
matcher.addTransform('configureMercuriusRequest', configureMercuriusRequest)
matcher.addTransform('postgresQueryHandlers', postgresQueryHandlers)
matcher.addTransform('postgresQueryLifecycle', postgresQueryLifecycle)

return matcher
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = [
...require('./modelcontextprotocol-sdk'),
...require('./openai-agents'),
...require('./playwright'),
...require('./postgres'),
...require('./webdriverio'),
...require('./aws-durable-execution-sdk-js'),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict'

const handlers = ['src/index.js', 'cjs/src/index.js'].map(filePath => ({
module: {
name: 'postgres',
versionRange: '>=3.0.0',
filePath,
},
astQuery: 'Program',
transform: 'postgresQueryHandlers',
channelName: 'query',
}))

const lifecycles = ['src/query.js', 'cjs/src/query.js'].map(filePath => ({
module: {
name: 'postgres',
versionRange: '>=3.0.0',
filePath,
},
astQuery: 'Program',
transform: 'postgresQueryLifecycle',
channelName: 'query',
}))

module.exports = [...handlers, ...lifecycles]
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
"playwright-core/lib/coreBundle.js": "playwright-core",
"playwright/lib/index.js": "playwright",
"playwright/lib/runner/index.js": "playwright",
"postgres/cjs/src/index.js": "postgres",
"postgres/cjs/src/query.js": "postgres",
"postgres/src/index.js": "postgres",
"postgres/src/query.js": "postgres",
"webdriver/build/index.js": "webdriver",
"webdriver/build/node.js": "webdriver",
"webdriverio/build/index.js": "webdriverio",
Expand Down
Loading
Loading