-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce API Metrics/Telemetry (#1142)
Neo4j would like to be able to track more information about driver apis usage, so that smarter decisions can be made on improving drivers and their stack. The collection of metrics must be respectful of users. Thus, the collected metrics are: 1. impossible to be tied back the customer or user 1. transparent to the users that inspect 1. restrained to required metrics The metric collection is disabled by default in Neo4j. It can be enabled in the server by setting `server.bolt.telemetry.enabled` to `true`. However, the metric collection is enabled by default in the drivers. It can be disabled in the driver by configuring the driver with `telemetryDisabled` to `true`. Default: `false`. **Metrics are only collected when enabled both in server and driver instances.** Disabling metrics on driver: ```typescript const driver = neo4j.driver( 'neo4j://localhost:7687', neo4j.auth.basic('neo4j', 'password'), { telemetryDisabled: true }) ``` Co-authored-by: Robsdedude <[email protected]>
- Loading branch information
1 parent
b774cf3
commit 266671a
Showing
70 changed files
with
2,786 additions
and
177 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* Copyright (c) "Neo4j" | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* 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. | ||
*/ | ||
import BoltProtocolV5x3 from './bolt-protocol-v5x3' | ||
|
||
import transformersFactories from './bolt-protocol-v5x4.transformer' | ||
import RequestMessage from './request-message' | ||
import { TelemetryObserver } from './stream-observers' | ||
import Transformer from './transformer' | ||
|
||
import { internal } from 'neo4j-driver-core' | ||
|
||
const { | ||
constants: { BOLT_PROTOCOL_V5_4 } | ||
} = internal | ||
|
||
export default class BoltProtocol extends BoltProtocolV5x3 { | ||
get version () { | ||
return BOLT_PROTOCOL_V5_4 | ||
} | ||
|
||
get transformer () { | ||
if (this._transformer === undefined) { | ||
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log))) | ||
} | ||
return this._transformer | ||
} | ||
|
||
/** | ||
* Send a TELEMETRY through the underlying connection. | ||
* | ||
* @param {object} param0 Message params | ||
* @param {number} param0.api The API called | ||
* @param {object} param1 Configuration and callbacks callbacks | ||
* @param {function()} param1.onCompleted Called when completed | ||
* @param {function()} param1.onError Called when error | ||
* @return {StreamObserver} the stream observer that monitors the corresponding server response. | ||
*/ | ||
telemetry ({ api }, { onError, onCompleted } = {}) { | ||
const observer = new TelemetryObserver({ onCompleted, onError }) | ||
|
||
this.write(RequestMessage.telemetry({ api }), observer, false) | ||
|
||
return observer | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/bolt-connection/src/bolt/bolt-protocol-v5x4.transformer.js
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Copyright (c) "Neo4j" | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* 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. | ||
*/ | ||
|
||
import v5x3 from './bolt-protocol-v5x3.transformer' | ||
|
||
export default { | ||
...v5x3 | ||
} |
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
8 changes: 4 additions & 4 deletions
8
packages/bolt-connection/test/bolt/__snapshots__/bolt-protocol-v1.test.js.snap
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
8 changes: 4 additions & 4 deletions
8
packages/bolt-connection/test/bolt/__snapshots__/bolt-protocol-v2.test.js.snap
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
8 changes: 4 additions & 4 deletions
8
packages/bolt-connection/test/bolt/__snapshots__/bolt-protocol-v3.test.js.snap
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
8 changes: 4 additions & 4 deletions
8
packages/bolt-connection/test/bolt/__snapshots__/bolt-protocol-v4x0.test.js.snap
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
8 changes: 4 additions & 4 deletions
8
packages/bolt-connection/test/bolt/__snapshots__/bolt-protocol-v4x1.test.js.snap
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
Oops, something went wrong.