UNPKG

@splunk/otel

Version:

The Splunk distribution of OpenTelemetry Node Instrumentation provides a Node agent that automatically instruments your Node application to capture and report distributed traces to Splunk APM.

53 lines 2.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAttributesFromNeo4jSession = getAttributesFromNeo4jSession; /* * Copyright Splunk Inc., Aspecto * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ const semconv_1 = require("./semconv"); // eslint-disable-next-line @typescript-eslint/no-explicit-any function getAuth(connectionProvider) { var _a; if (connectionProvider._authenticationProvider) { return (_a = connectionProvider._authenticationProvider._authTokenManager) === null || _a === void 0 ? void 0 : _a._authToken; } return connectionProvider._authToken; } // eslint-disable-next-line @typescript-eslint/no-explicit-any 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 = getAuth(connectionProvider); // eslint-disable-next-line @typescript-eslint/no-explicit-any const attributes = { [semconv_1.ATTR_NET_TRANSPORT]: 'IP.TCP', // "neo4j" is the default database name. When used, "session._database" is an empty string [semconv_1.ATTR_DB_NAME]: session._database ? session._database : 'neo4j', }; if (address) { attributes[semconv_1.ATTR_NET_PEER_NAME] = address._host; attributes[semconv_1.ATTR_NET_PEER_PORT] = address._port; } if (auth === null || auth === void 0 ? void 0 : auth.principal) { attributes[semconv_1.ATTR_DB_USER] = auth.principal; } return attributes; } //# sourceMappingURL=utils.js.map