-
Notifications
You must be signed in to change notification settings - Fork 539
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
69 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,10 @@ import * as assert from 'assert'; | |
import * as pg from 'pg'; | ||
import * as pgPool from 'pg-pool'; | ||
import { AttributeNames } from '../src/enums'; | ||
import { | ||
SemanticAttributes, | ||
DbSystemValues, | ||
} from '@opentelemetry/semantic-conventions'; | ||
|
||
const memoryExporter = new InMemorySpanExporter(); | ||
|
||
|
@@ -52,25 +56,23 @@ const CONFIG = { | |
}; | ||
|
||
const DEFAULT_PGPOOL_ATTRIBUTES = { | ||
[AttributeNames.COMPONENT]: PgInstrumentation.COMPONENT, | ||
[AttributeNames.DB_INSTANCE]: CONFIG.database, | ||
[AttributeNames.DB_TYPE]: PgInstrumentation.DB_TYPE, | ||
[AttributeNames.PEER_HOSTNAME]: CONFIG.host, | ||
[AttributeNames.PEER_ADDRESS]: `jdbc:postgresql://${CONFIG.host}:${CONFIG.port}/${CONFIG.database}`, | ||
[AttributeNames.PEER_PORT]: CONFIG.port, | ||
[AttributeNames.DB_USER]: CONFIG.user, | ||
[SemanticAttributes.DB_SYSTEM]: DbSystemValues.POSTGRESQL, | ||
[SemanticAttributes.DB_NAME]: CONFIG.database, | ||
[SemanticAttributes.NET_PEER_NAME]: CONFIG.host, | ||
[SemanticAttributes.DB_CONNECTION_STRING]: `jdbc:postgresql://${CONFIG.host}:${CONFIG.port}/${CONFIG.database}`, | ||
[SemanticAttributes.NET_PEER_PORT]: CONFIG.port, | ||
[SemanticAttributes.DB_USER]: CONFIG.user, | ||
[AttributeNames.MAX_CLIENT]: CONFIG.maxClient, | ||
[AttributeNames.IDLE_TIMEOUT_MILLIS]: CONFIG.idleTimeoutMillis, | ||
}; | ||
|
||
const DEFAULT_PG_ATTRIBUTES = { | ||
[AttributeNames.COMPONENT]: PgInstrumentation.COMPONENT, | ||
[AttributeNames.DB_INSTANCE]: CONFIG.database, | ||
[AttributeNames.DB_TYPE]: PgInstrumentation.DB_TYPE, | ||
[AttributeNames.PEER_HOSTNAME]: CONFIG.host, | ||
[AttributeNames.PEER_ADDRESS]: `jdbc:postgresql://${CONFIG.host}:${CONFIG.port}/${CONFIG.database}`, | ||
[AttributeNames.PEER_PORT]: CONFIG.port, | ||
[AttributeNames.DB_USER]: CONFIG.user, | ||
[SemanticAttributes.DB_SYSTEM]: DbSystemValues.POSTGRESQL, | ||
[SemanticAttributes.DB_NAME]: CONFIG.database, | ||
[SemanticAttributes.NET_PEER_NAME]: CONFIG.host, | ||
[SemanticAttributes.DB_CONNECTION_STRING]: `jdbc:postgresql://${CONFIG.host}:${CONFIG.port}/${CONFIG.database}`, | ||
[SemanticAttributes.NET_PEER_PORT]: CONFIG.port, | ||
[SemanticAttributes.DB_USER]: CONFIG.user, | ||
}; | ||
|
||
const unsetStatus: SpanStatus = { | ||
|
@@ -162,7 +164,7 @@ describe('[email protected]', () => { | |
}; | ||
const pgAttributes = { | ||
...DEFAULT_PG_ATTRIBUTES, | ||
[AttributeNames.DB_STATEMENT]: 'SELECT NOW()', | ||
[SemanticAttributes.DB_STATEMENT]: 'SELECT NOW()', | ||
}; | ||
const events: TimedEvent[] = []; | ||
const span = provider.getTracer('test-pg-pool').startSpan('test span'); | ||
|
@@ -186,7 +188,7 @@ describe('[email protected]', () => { | |
}; | ||
const pgAttributes = { | ||
...DEFAULT_PG_ATTRIBUTES, | ||
[AttributeNames.DB_STATEMENT]: 'SELECT NOW()', | ||
[SemanticAttributes.DB_STATEMENT]: 'SELECT NOW()', | ||
}; | ||
const events: TimedEvent[] = []; | ||
const parentSpan = provider | ||
|
@@ -242,7 +244,7 @@ describe('[email protected]', () => { | |
}; | ||
const pgAttributes = { | ||
...DEFAULT_PG_ATTRIBUTES, | ||
[AttributeNames.DB_STATEMENT]: 'SELECT NOW()', | ||
[SemanticAttributes.DB_STATEMENT]: 'SELECT NOW()', | ||
}; | ||
const events: TimedEvent[] = []; | ||
const span = provider.getTracer('test-pg-pool').startSpan('test span'); | ||
|
@@ -261,7 +263,7 @@ describe('[email protected]', () => { | |
}; | ||
const pgAttributes = { | ||
...DEFAULT_PG_ATTRIBUTES, | ||
[AttributeNames.DB_STATEMENT]: 'SELECT NOW()', | ||
[SemanticAttributes.DB_STATEMENT]: 'SELECT NOW()', | ||
}; | ||
const events: TimedEvent[] = []; | ||
const parentSpan = provider | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,10 @@ import * as assert from 'assert'; | |
import type * as pg from 'pg'; | ||
import { PgInstrumentation } from '../src'; | ||
import { AttributeNames } from '../src/enums'; | ||
import { | ||
SemanticAttributes, | ||
DbSystemValues, | ||
} from '@opentelemetry/semantic-conventions'; | ||
|
||
const memoryExporter = new InMemorySpanExporter(); | ||
|
||
|
@@ -50,13 +54,12 @@ const CONFIG = { | |
}; | ||
|
||
const DEFAULT_ATTRIBUTES = { | ||
[AttributeNames.COMPONENT]: PgInstrumentation.COMPONENT, | ||
[AttributeNames.DB_INSTANCE]: CONFIG.database, | ||
[AttributeNames.DB_TYPE]: PgInstrumentation.DB_TYPE, | ||
[AttributeNames.PEER_HOSTNAME]: CONFIG.host, | ||
[AttributeNames.PEER_ADDRESS]: `jdbc:postgresql://${CONFIG.host}:${CONFIG.port}/${CONFIG.database}`, | ||
[AttributeNames.PEER_PORT]: CONFIG.port, | ||
[AttributeNames.DB_USER]: CONFIG.user, | ||
[SemanticAttributes.DB_SYSTEM]: DbSystemValues.POSTGRESQL, | ||
[SemanticAttributes.DB_NAME]: CONFIG.database, | ||
[SemanticAttributes.NET_PEER_NAME]: CONFIG.host, | ||
[SemanticAttributes.DB_CONNECTION_STRING]: `jdbc:postgresql://${CONFIG.host}:${CONFIG.port}/${CONFIG.database}`, | ||
[SemanticAttributes.NET_PEER_PORT]: CONFIG.port, | ||
[SemanticAttributes.DB_USER]: CONFIG.user, | ||
}; | ||
|
||
const unsetStatus: SpanStatus = { | ||
|
@@ -200,7 +203,7 @@ describe('[email protected]', () => { | |
it('should intercept client.query(text, callback)', done => { | ||
const attributes = { | ||
...DEFAULT_ATTRIBUTES, | ||
[AttributeNames.DB_STATEMENT]: 'SELECT NOW()', | ||
[SemanticAttributes.DB_STATEMENT]: 'SELECT NOW()', | ||
}; | ||
const events: TimedEvent[] = []; | ||
const span = tracer.startSpan('test span'); | ||
|
@@ -220,7 +223,7 @@ describe('[email protected]', () => { | |
const values = ['0']; | ||
const attributes = { | ||
...DEFAULT_ATTRIBUTES, | ||
[AttributeNames.DB_STATEMENT]: query, | ||
[SemanticAttributes.DB_STATEMENT]: query, | ||
}; | ||
const events: TimedEvent[] = []; | ||
const span = tracer.startSpan('test span'); | ||
|
@@ -239,7 +242,7 @@ describe('[email protected]', () => { | |
const query = 'SELECT NOW()'; | ||
const attributes = { | ||
...DEFAULT_ATTRIBUTES, | ||
[AttributeNames.DB_STATEMENT]: query, | ||
[SemanticAttributes.DB_STATEMENT]: query, | ||
}; | ||
const events: TimedEvent[] = []; | ||
const span = tracer.startSpan('test span'); | ||
|
@@ -261,7 +264,7 @@ describe('[email protected]', () => { | |
const query = 'SELECT NOW()'; | ||
const attributes = { | ||
...DEFAULT_ATTRIBUTES, | ||
[AttributeNames.DB_STATEMENT]: query, | ||
[SemanticAttributes.DB_STATEMENT]: query, | ||
}; | ||
const events: TimedEvent[] = []; | ||
const span = tracer.startSpan('test span'); | ||
|
@@ -281,7 +284,7 @@ describe('[email protected]', () => { | |
const values = ['0']; | ||
const attributes = { | ||
...DEFAULT_ATTRIBUTES, | ||
[AttributeNames.DB_STATEMENT]: query, | ||
[SemanticAttributes.DB_STATEMENT]: query, | ||
}; | ||
const events: TimedEvent[] = []; | ||
const span = tracer.startSpan('test span'); | ||
|
@@ -301,7 +304,7 @@ describe('[email protected]', () => { | |
const values = ['0']; | ||
const attributes = { | ||
...DEFAULT_ATTRIBUTES, | ||
[AttributeNames.DB_STATEMENT]: query, | ||
[SemanticAttributes.DB_STATEMENT]: query, | ||
}; | ||
const events: TimedEvent[] = []; | ||
const span = tracer.startSpan('test span'); | ||
|
@@ -326,7 +329,7 @@ describe('[email protected]', () => { | |
const attributes = { | ||
...DEFAULT_ATTRIBUTES, | ||
[AttributeNames.PG_PLAN]: name, | ||
[AttributeNames.DB_STATEMENT]: query, | ||
[SemanticAttributes.DB_STATEMENT]: query, | ||
}; | ||
const events: TimedEvent[] = []; | ||
const span = tracer.startSpan('test span'); | ||
|
@@ -350,7 +353,7 @@ describe('[email protected]', () => { | |
const query = 'SELECT NOW()'; | ||
const attributes = { | ||
...DEFAULT_ATTRIBUTES, | ||
[AttributeNames.DB_STATEMENT]: query, | ||
[SemanticAttributes.DB_STATEMENT]: query, | ||
}; | ||
const events: TimedEvent[] = []; | ||
const span = tracer.startSpan('test span'); | ||
|