-
Notifications
You must be signed in to change notification settings - Fork 624
feat: add sequelize instrumentation #2396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
3dabf33
9c9ff4c
7700a12
1e17f8a
22173ed
2ec23e7
aacfe46
9023e2f
2b8b855
26fa4d0
bbca381
8bfac99
f9efe6d
558ffea
c92fcd8
6bdf646
2766f3c
f1d6ea4
203d2c5
d3335dd
ca3a6b1
5fe7cf8
2200f33
60bc681
81881ad
a8b0a14
f6b8517
df1bb5f
dbfc29c
91f0eb2
0d670c9
f87543e
86d4eab
b67ed74
8366442
b74af7d
e10c56e
286825f
9018be5
b3618f4
6a44776
cd305fc
1a4e296
9d6e5c6
fb1cc5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,19 +24,19 @@ import { | |
| } from '@opentelemetry/api'; | ||
| import { suppressTracing } from '@opentelemetry/core'; | ||
| import { | ||
| NETTRANSPORTVALUES_IP_TCP, | ||
| SEMATTRS_DB_NAME, | ||
| SEMATTRS_DB_OPERATION, | ||
| SEMATTRS_DB_SQL_TABLE, | ||
| SEMATTRS_DB_STATEMENT, | ||
| SEMATTRS_DB_SYSTEM, | ||
| SEMATTRS_DB_USER, | ||
| SEMATTRS_NET_PEER_NAME, | ||
| SEMATTRS_NET_PEER_PORT, | ||
| SEMATTRS_NET_TRANSPORT, | ||
| ATTR_DB_COLLECTION_NAME, | ||
| ATTR_DB_OPERATION_NAME, | ||
| ATTR_DB_NAMESPACE, | ||
| ATTR_DB_QUERY_TEXT, | ||
| ATTR_DB_SYSTEM_NAME, | ||
| ATTR_SERVER_ADDRESS, | ||
| ATTR_SERVER_PORT, | ||
| ATTR_NETWORK_TRANSPORT, | ||
| NETWORK_TRANSPORT_VALUE_TCP, | ||
| } from '@opentelemetry/semantic-conventions'; | ||
| import type * as sequelize from 'sequelize'; | ||
| import { SequelizeInstrumentationConfig } from './types'; | ||
| /** @knipignore */ | ||
| import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; | ||
| import { extractTableFromQuery } from './utils'; | ||
| import { | ||
|
|
@@ -164,17 +164,14 @@ export class SequelizeInstrumentation extends InstrumentationBase<SequelizeInstr | |
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| const attributes: Record<string, any> = { | ||
| [SEMATTRS_DB_SYSTEM]: sequelizeInstance.getDialect(), | ||
| [SEMATTRS_DB_USER]: config?.username, | ||
| [SEMATTRS_NET_PEER_NAME]: config?.host, | ||
| [SEMATTRS_NET_PEER_PORT]: config?.port | ||
| ? Number(config?.port) | ||
| : undefined, | ||
| [SEMATTRS_NET_TRANSPORT]: self._getNetTransport(config?.protocol), | ||
| [SEMATTRS_DB_NAME]: config?.database, | ||
| [SEMATTRS_DB_OPERATION]: operation, | ||
| [SEMATTRS_DB_STATEMENT]: statement, | ||
| [SEMATTRS_DB_SQL_TABLE]: tableName, | ||
| [ATTR_DB_SYSTEM_NAME]: sequelizeInstance.getDialect(), | ||
| [ATTR_DB_NAMESPACE]: config?.database, | ||
| [ATTR_DB_OPERATION_NAME]: operation, | ||
| [ATTR_DB_QUERY_TEXT]: statement, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not familiar with the package so I'm not sure if this may raise PII issues. I see the statement is extracted from the params but I'm not sure if it has placeholders for the values or may contain the actual values
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Played around with it a bit, when using where clauses, sequelize seems to generate the where part without placeholders 🤦 I guess the query summary could be used here, with the where clause hidden |
||
| [ATTR_DB_COLLECTION_NAME]: tableName, | ||
| [ATTR_SERVER_ADDRESS]: config?.host, | ||
| [ATTR_SERVER_PORT]: config?.port ? Number(config?.port) : undefined, | ||
| [ATTR_NETWORK_TRANSPORT]: self._getNetTransport(config?.protocol), | ||
| }; | ||
|
|
||
| Object.entries(attributes).forEach(([key, value]) => { | ||
|
|
@@ -244,7 +241,7 @@ export class SequelizeInstrumentation extends InstrumentationBase<SequelizeInstr | |
| private _getNetTransport(protocol: string) { | ||
| switch (protocol) { | ||
| case 'tcp': | ||
| return NETTRANSPORTVALUES_IP_TCP; | ||
| return NETWORK_TRANSPORT_VALUE_TCP; | ||
| default: | ||
| return undefined; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.