Skip to content

Commit 9cf4d66

Browse files
committed
update address and port
1 parent d7da44c commit 9cf4d66

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

plugins/node/opentelemetry-instrumentation-pg/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ To select which semconv version(s) is emitted from this instrumentation, use the
7575
| (not included) | `db.namespace` | The name of the database, fully qualified within the server address and port. |
7676
| `db.statement` | `db.query.text` | The database query being executed. |
7777
| `db.system` | `db.system.name` | The database management system (DBMS) product as identified by the client instrumentation. |
78-
| `net.peer.port` | `network.peer.port` | Peer port number of the network connection. |
79-
| `net.peer.name` | `network.peer.address` | Peer address of the database node where the operation was performed. |
78+
| `net.peer.port` | `server.port` | Remote port number. |
79+
| `net.peer.name` | `server.address` | Remote hostname or similar. |
8080

8181
Metrics Exported:
8282

plugins/node/opentelemetry-instrumentation-pg/src/utils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import {
3030
ATTR_ERROR_TYPE,
3131
ATTR_DB_SYSTEM_NAME,
3232
ATTR_DB_NAMESPACE,
33-
ATTR_NETWORK_PEER_ADDRESS,
34-
ATTR_NETWORK_PEER_PORT,
33+
ATTR_SERVER_ADDRESS,
34+
ATTR_SERVER_PORT,
3535
ATTR_DB_QUERY_TEXT,
3636
} from '@opentelemetry/semantic-conventions';
3737
import {
@@ -175,8 +175,8 @@ export function getSemanticAttributesFromConnection(
175175
...attributes,
176176
[ATTR_DB_SYSTEM_NAME]: DB_SYSTEM_VALUE_POSTGRESQL,
177177
[ATTR_DB_NAMESPACE]: params.namespace,
178-
[ATTR_NETWORK_PEER_ADDRESS]: params.host,
179-
[ATTR_NETWORK_PEER_PORT]: getPort(params.port),
178+
[ATTR_SERVER_ADDRESS]: params.host,
179+
[ATTR_SERVER_PORT]: getPort(params.port),
180180
};
181181
}
182182

@@ -216,8 +216,8 @@ export function getSemanticAttributesFromPool(
216216
...attributes,
217217
[ATTR_DB_SYSTEM_NAME]: DB_SYSTEM_VALUE_POSTGRESQL,
218218
[ATTR_DB_NAMESPACE]: params.namespace,
219-
[ATTR_NETWORK_PEER_ADDRESS]: url?.hostname ?? params.host,
220-
[ATTR_NETWORK_PEER_PORT]: Number(url?.port) || getPort(params.port),
219+
[ATTR_SERVER_ADDRESS]: url?.hostname ?? params.host,
220+
[ATTR_SERVER_PORT]: Number(url?.port) || getPort(params.port),
221221
};
222222
}
223223

plugins/node/opentelemetry-instrumentation-pg/test/utils.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { PgInstrumentationConfig } from '../src';
3131
import { AttributeNames } from '../src/enums/AttributeNames';
3232
import { PgClientExtended, PgPoolOptionsParams } from '../src/internal-types';
3333
import * as utils from '../src/utils';
34-
import { ATTR_NETWORK_PEER_PORT } from '@opentelemetry/semantic-conventions';
34+
import { ATTR_SERVER_PORT } from '@opentelemetry/semantic-conventions';
3535

3636
const memoryExporter = new InMemorySpanExporter();
3737

@@ -206,7 +206,7 @@ describe('utils.ts', () => {
206206
port: Infinity,
207207
},
208208
SemconvStability.STABLE
209-
)[ATTR_NETWORK_PEER_PORT],
209+
)[ATTR_SERVER_PORT],
210210
undefined
211211
);
212212
assert.strictEqual(
@@ -215,7 +215,7 @@ describe('utils.ts', () => {
215215
port: -Infinity,
216216
},
217217
SemconvStability.STABLE
218-
)[ATTR_NETWORK_PEER_PORT],
218+
)[ATTR_SERVER_PORT],
219219
undefined
220220
);
221221
assert.strictEqual(
@@ -224,7 +224,7 @@ describe('utils.ts', () => {
224224
port: NaN,
225225
},
226226
SemconvStability.STABLE
227-
)[ATTR_NETWORK_PEER_PORT],
227+
)[ATTR_SERVER_PORT],
228228
undefined
229229
);
230230
assert.strictEqual(
@@ -233,7 +233,7 @@ describe('utils.ts', () => {
233233
port: 1.234,
234234
},
235235
SemconvStability.STABLE
236-
)[ATTR_NETWORK_PEER_PORT],
236+
)[ATTR_SERVER_PORT],
237237
undefined
238238
);
239239
});
@@ -245,7 +245,7 @@ describe('utils.ts', () => {
245245
port: 1234,
246246
},
247247
SemconvStability.STABLE
248-
)[ATTR_NETWORK_PEER_PORT],
248+
)[ATTR_SERVER_PORT],
249249
1234
250250
);
251251
assert.strictEqual(
@@ -254,7 +254,7 @@ describe('utils.ts', () => {
254254
port: Number.MAX_VALUE,
255255
},
256256
SemconvStability.STABLE
257-
)[ATTR_NETWORK_PEER_PORT],
257+
)[ATTR_SERVER_PORT],
258258
Number.MAX_VALUE
259259
);
260260
});

0 commit comments

Comments
 (0)