UNPKG

opentelemetry-instrumentation-neo4j

Version:

open telemetry instrumentation for the `neo4j` javascript driver

27 lines 1.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAttributesFromNeo4jSession = void 0; const semantic_conventions_1 = require("@opentelemetry/semantic-conventions"); function getAttributesFromNeo4jSession(session) { var _a, _b, _c, _d; const connectionHolder = (_b = (_a = (session._mode === 'WRITE' ? session._writeConnectionHolder : session._readConnectionHolder)) !== null && _a !== void 0 ? _a : session._connectionHolder) !== null && _b !== void 0 ? _b : {}; const connectionProvider = (_c = connectionHolder._connectionProvider) !== null && _c !== void 0 ? _c : {}; // seedRouter is used when connecting to a url that starts with "neo4j", usually aura const address = (_d = connectionProvider._address) !== null && _d !== void 0 ? _d : connectionProvider._seedRouter; const auth = connectionProvider._authToken; const attributes = { [semantic_conventions_1.SEMATTRS_NET_TRANSPORT]: 'IP.TCP', // "neo4j" is the default database name. When used, "session._database" is an empty string [semantic_conventions_1.SEMATTRS_DB_NAME]: session._database ? session._database : 'neo4j', }; if (address) { attributes[semantic_conventions_1.SEMATTRS_NET_PEER_NAME] = address._host; attributes[semantic_conventions_1.SEMATTRS_NET_PEER_PORT] = address._port; } if (auth === null || auth === void 0 ? void 0 : auth.principal) { attributes[semantic_conventions_1.SEMATTRS_DB_USER] = auth.principal; } return attributes; } exports.getAttributesFromNeo4jSession = getAttributesFromNeo4jSession; //# sourceMappingURL=utils.js.map