-
Notifications
You must be signed in to change notification settings - Fork 157
feat(observability): add Observation SPI #1682
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
Merged
Merged
Conversation
This file contains hidden or 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
ab24ad9
to
8f8a462
Compare
c50590e
to
a1e7b06
Compare
BREAKING CHANGE: the experimental driver `Metrics` and `ConnectionPoolMetrics` have been replaced with `ObservationProvider`. ## Observation SPI NOTE: This is a feature preview. The Observation SPI is used by the driver to instrument points of interest in its implementation. For instance, an observation is created around connection acquisition - it starts when acquisition begins and stops when acquisition ends. These observations may be used by SPI implementations to produce some useful output, like: metrics, traces, etc. Importantly, this resposibility is outside the instrumentation itself. Driver configuration example: ```java var config = Config.builder() .withObservationProvider(implementation) // null by default, meaning no-op implementation .build() ``` At present, the SPI is not expected to be implemented by users directly. Instead, 2 new implementation modules are introduced alongside the driver. Their versions will be managed by the driver BOM (`neo4j-java-driver-bom`). Both are described below. ### Neo4j Java Driver (Metrics) NOTE: This is a feature preview. Artifact ID: `neo4j-java-driver-observation-metrics` A basic in-memory implementation with dedicated API - `Metrics` and `ConnectionPoolMetrics`, the effectively relocated interfaces from the driver. Driver configuration example: ```java var provider = MetricsObservationProvider.newInstance(); var config = Config.builder() .withObservationProvider(provider) // enable by registering the provider .build(); var metrics = provider.metrics(); ``` ### Neo4j Java Driver (Micrometer Observation) NOTE: This is a feature preview. Artifact ID: `neo4j-java-driver-observation-micrometer` An implementation based Micrometer Observation API. Driver observations are represented as dedicated Micrometer types: - `Observation.Context` - For example, `SessionRunContext`. - `ObservationConvention` - For example, `SessionRunConvention`. - Default `ObservationConvention` - For example, `DefaultSessionRunConvention`. The dedicated types enable users to benefit from Micrometer features, including high level of customisation of handling, naming and tagging. While the naming used in this module was guided by the OpenTelemetry semantic conventions 1.36.0, it was also adapted to Micrometer naming convention. Driver configuration example: ```java var provider = MicrometerObservationProvider.builder(observationRegistry) // requires Micrometer ObservationRegistry instance .build(); // extra options are omitted for brevity var config = Config.builder() .withObservationProvider(provider) // enable by registering the provider .build(); ``` In addition, it includes `ConnectionPoolMetricsHandler` that implements Micrometer `ObservationHandler`. It manages several additional Micrometer metrics and may be optionally instantiated and registered by users.
a1e7b06
to
c278558
Compare
MaxAake
approved these changes
Aug 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
MaxAake
approved these changes
Aug 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
MaxAake
approved these changes
Aug 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
BREAKING CHANGE: the experimental driver
Metrics
andConnectionPoolMetrics
have been replaced withObservationProvider
.Observation SPI
NOTE: This is a feature preview.
The Observation SPI is used by the driver to instrument points of interest in its implementation. For instance, an observation is created around connection acquisition - it starts when acquisition begins and stops when acquisition ends. These observations may be used by SPI implementations to produce some useful output, like: metrics, traces, etc. Importantly, this resposibility is outside the instrumentation itself.
Driver configuration example:
At present, the SPI is not expected to be implemented by users directly. Instead, 2 new implementation modules are introduced alongside the driver. Their versions will be managed by the driver BOM (
neo4j-java-driver-bom
). Both are described below.Neo4j Java Driver (Metrics)
NOTE: This is a feature preview.
Artifact ID:
neo4j-java-driver-observation-metrics
A basic in-memory implementation with dedicated API -
Metrics
andConnectionPoolMetrics
, the effectively relocated interfaces from the driver.Driver configuration example:
Neo4j Java Driver (Micrometer Observation)
NOTE: This is a feature preview.
Artifact ID:
neo4j-java-driver-observation-micrometer
An implementation based Micrometer Observation API.
Driver observations are represented as dedicated Micrometer types:
Observation.Context
SessionRunContext
.ObservationConvention
SessionRunConvention
.ObservationConvention
DefaultSessionRunConvention
.The dedicated types enable users to benefit from Micrometer features, including high level of customisation of handling, naming and tagging.
While the naming used in this module was guided by the OpenTelemetry semantic conventions 1.36.0, it was also adapted to Micrometer naming convention.
Driver configuration example:
In addition, it includes
ConnectionPoolMetricsHandler
that implements MicrometerObservationHandler
. It manages several additional Micrometer metrics and may be optionally instantiated and registered by users.