generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 7
Observability provider #154
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
Open
fmeheust
wants to merge
28
commits into
main
Choose a base branch
from
observability-provider
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
6db2af2
First commit
fmeheust cf6b82a
Added static Events and tests
fmeheust 5f5fdb8
Replaced set by list
fmeheust 2546b01
Changes to tests
fmeheust 50211a2
Added test name
fmeheust 535737c
Check connectionID
fmeheust 65753e8
Static JFR events
fmeheust fe09409
Merge remote-tracking branch 'origin/main' into observability-provider
fmeheust ce3601d
Merged from main
fmeheust bc11b39
Documentation and tests
fmeheust b469a80
Added execution events to JFR
fmeheust a6cd874
Documentation changes
fmeheust 8142aa0
Fixed tests
fmeheust 01cfd12
Observability configuration test
fmeheust ad7df96
Added debug info
fmeheust ac08356
Run tests one by one
fmeheust 8478b83
Test Order
fmeheust 6b03e6f
Added comment for test run configuration.
fmeheust c8a8cdf
Backward compatibility
fmeheust dee07b4
Locks and event labels
fmeheust c649e57
Refactoring and added possibility to have different configuration and…
fmeheust 65c7765
Changed action version for deprecated action
fmeheust f6e972f
Set version in pom files correctly
fmeheust 8f7b15d
Fixed tests when running in the same JVM
fmeheust 1157aa3
Unique identifier and refactoring.
fmeheust ed0c89e
Merge branch 'main' into observability-provider
fmeheust dd9de05
Corrected copyright
fmeheust 59f3262
Merge branch 'observability-provider' of https://github.com/oracle/oj…
fmeheust File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
# Oracle JDBC Observability Provider | ||
|
||
This module contains a provider that adds tracing capabilities to the Oracle | ||
JDBC driver. Two tracers are available: | ||
* OTEL: adds Open Telemetry tracing capabilities. | ||
* JFR: exports events to Java Flight Recorder. | ||
|
||
This provider implements the TraceEventListener interface provided by the JDBC | ||
driver which will be notified whenever events are generated in the driver and | ||
will publish these events into Open Telemetry. These events include: | ||
* roundtrips to the database server | ||
* AC begin and success | ||
* VIP down event | ||
|
||
The following attributes are added the traces for each event: | ||
* **Roundtrips** | ||
* Connection ID | ||
* Database Operation | ||
* Database User | ||
* Database Tenant | ||
* SQL ID | ||
* Original SQL Text *(only present if sensitive data is enabled)* | ||
* Actual SQL Text *(only present if sensitive data is enabled)* | ||
* **AC begin and success** | ||
* Error Message | ||
* Error code | ||
* SQL state | ||
* Current replay retry count | ||
* **VIP down event** | ||
* Error message | ||
* VIP address | ||
* Protocol *(only present if sensitive data is enabled)* | ||
* Host *(only present if sensitive data is enabled)* | ||
* Port *(only present if sensitive data is enabled)* | ||
* Service name *(only present if sensitive data is enabled)* | ||
* SID *(only present if sensitive data is enabled)* | ||
* Connection data *(only present if sensitive data is enabled)* | ||
|
||
## Installation | ||
|
||
This provider is distributed as single jar on the Maven Central Repository. The | ||
jar is compiled for JDK 11, and is forward compatible with later JDK versions. | ||
The coordinates for the latest release are: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.oracle.database.jdbc</groupId> | ||
<artifactId>ojdbc-provider-observability</artifactId> | ||
<version>1.0.3</version> | ||
</dependency> | ||
``` | ||
|
||
## Usage | ||
|
||
To use the Oracle JDBC observability provider just add the artifact to the | ||
application's classpath and set the following connection property: | ||
|
||
```java | ||
oracle.jdbc.provider.traceEventListener=observability-trace-event-listener-provider | ||
``` | ||
|
||
A unique identifier connection property allows to identify the trace event | ||
listener. Connections setting the same unique identifier use the same trace | ||
event listener and share the same configuration. | ||
|
||
```java | ||
oracle.jdbc.provider.traceEventListener.unique_identifier=<unique identifier> | ||
``` | ||
|
||
If no unique identifier is provided, the unique idetifier "default" is used. | ||
|
||
## Configuration | ||
|
||
The provider can be configured by: | ||
* using system properties, | ||
```java | ||
System.setProperty("oracle.jdbc.provider.observability.enabledTracers", "OTEL,JFR"); | ||
System.setProperty("oracle.jdbc.provider.observability.sensitiveDataEnabled", "true"); | ||
``` | ||
* or using the MBean. | ||
```java | ||
ObservabilityTraceEventListener listener = ObservabilityTraceEventListener.getTraceEventListener("<unique identifier>"); | ||
ObjectName objectName = new ObjectName(listener.getMBeanObjectName()); | ||
MBeanServer server = ManagementFactory.getPlatformMBeanServer(); | ||
server.setAttribute(objectName, new Attribute("EnabledTracers", "OTEL,JFR")); | ||
server.setAttribute(objectName, new Attribute("SensitiveDataEnabled", "true")); | ||
``` | ||
* it is also possible to use the ObservabilityConfiguration object directly by | ||
calling the | ||
```java | ||
ObservabilityConfiguration configuration = ObservabilityTraceEventListener.getObservabilityConfiguration("<name>"); | ||
configuration.setEnabledTracers("OTEL,JFR"); | ||
configuration.setSensitiveDataEnabled(true); | ||
``` | ||
|
||
## Backward compatibility | ||
|
||
### Usage | ||
|
||
The provider can also be used by setting the following connection property: | ||
|
||
```java | ||
oracle.jdbc.provider.traceEventListener=open-telemetry-trace-event-listener-provider | ||
``` | ||
|
||
When this property is used only the OTEL tracer can be used. | ||
|
||
### Configuration | ||
|
||
To ensure backward compatibility Oracle JDBC provider for Open Telemetry configuration | ||
properties and MBean have been kept. When these properties and MBean are used only | ||
the Open Telemetry tracer will be enabled. | ||
|
||
The Oracle JDBC provider for Open Telemetry can be configured using system properties | ||
or a MBean. Two parameters can be configured: | ||
* **Enabled**: when enabled (*true*) traces will be exported to Open | ||
Telemetry. This property is **enabled by default**. | ||
* **Sensitive data enabled**: when enabled (*true*) attributes containing | ||
sensitive information like SQL statements and connection URL will be included | ||
in the traces. This property is **disabled by default**. | ||
|
||
The system properties are "oracle.jdbc.provider.opentelemetry.enabled" and | ||
"oracle.jdbc.provider.opentelemetry.sensitive-enabled" respectively and the MBean | ||
exposes two attributes "Enabled" and "SensitiveDataEnabled". | ||
|
||
The sample code below shows how to retrieve the value of an attribute: | ||
```java | ||
ObservabilityTraceEventListener listener = ObservabilityTraceEventListener.getTraceEventListener("<name>"); | ||
ObjectName objectName = new ObjectName(listener.getMBeanObjectName()); | ||
MBeanServer server = ManagementFactory.getPlatformMBeanServer(); | ||
boolean isEnabled = Boolean.valueOf(server.getAttribute(objectName, "Enabled").toString()) | ||
.booleanValue(); | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
################################################################################ | ||
# Copyright (c) 2024 Oracle and/or its affiliates. | ||
# | ||
# The Universal Permissive License (UPL), Version 1.0 | ||
# | ||
# Subject to the condition set forth below, permission is hereby granted to any | ||
# person obtaining a copy of this software, associated documentation and/or data | ||
# (collectively the "Software"), free of charge and under any and all copyright | ||
# rights in the Software, and any and all patent rights owned or freely | ||
# licensable by each licensor hereunder covering either (i) the unmodified | ||
# Software as contributed to or provided by such licensor, or (ii) the Larger | ||
# Works (as defined below), to deal in both | ||
# | ||
# (a) the Software, and | ||
# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if | ||
# one is included with the Software (each a "Larger Work" to which the Software | ||
# is contributed by such licensors), | ||
# | ||
# without restriction, including without limitation the rights to copy, create | ||
# derivative works of, display, perform, and distribute the Software and make, | ||
# use, sell, offer for sale, import, export, have made, and have sold the | ||
# Software and the Larger Work(s), and to sublicense the foregoing rights on | ||
# either these or other terms. | ||
# | ||
# This license is subject to the following condition: | ||
# The above copyright notice and either this complete permission notice or at | ||
# a minimum a reference to the UPL must be included in all copies or | ||
# substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
################################################################################ | ||
|
||
# This file provides examples of properties that configure tests in this | ||
# module. | ||
# | ||
# QUICK GUIDE TO RUNNING TESTS: | ||
# 1. Create a copy of this file named "test.properties": | ||
# cp example-test.properties test.properties | ||
# 2. In test.properties, replace example values with real values (the file is | ||
# .gitignore'd, so sensitive info won't be checked in to the repo) | ||
# 3. Comment out any lines for which a value can not be provided (tests are | ||
# skipped if no value is configured). | ||
# 4. mvn clean verify | ||
# | ||
# CONFIGURING TEST PROPERTIES | ||
# Test properties are read from a properties file by the TestProperties class. | ||
# The TestProperties class can be found in: | ||
# ojdbc-provider-common/src/testFixtures/java/oracle/jdbc/provider/TestProperties.java | ||
# The default behavior of TestProperties is to read a file named | ||
# "test.properties" in the current directory. A non-default location may be | ||
# specified as a JVM system property: | ||
# mvn clean verify -Doracle.jdbc.provider.TestProperties=/path/to/my-test.properties | ||
# | ||
# MAINTAINING THIS FILE | ||
# Project maintainers should add an example to this file anytime they write a | ||
# test which requires a new property. Not doing so will inflict pain and | ||
# suffering upon our fellow programmers, and will also lead to increased | ||
# maintenance costs. | ||
# | ||
# IGNORING UNCONFIGURED PROPERTIES | ||
# No test should cause a build failure due to an unconfigured property. | ||
# Using JUnit terminology: A test should "abort" rather than "fail" when a | ||
# property is not configured. This means that the test does not pass, but it | ||
# does not cause the build to fail either. | ||
# Methods of the TestProperties class will automatically abort a test if a | ||
# property is not configured. The org.junit.jupiter.api.Assumptions class may | ||
# also be used directly to abort a test. | ||
# There is NO environment in which ALL tests can be run. Some tests may | ||
# require authentication as a managed identity in an Azure VM, while other | ||
# tests require authentication as an instance principal in an OCI compute | ||
# instance; These environments are mutually exclusive. This is one reason why | ||
# tests can not fail the build if a required property is not set. | ||
# A more practical reason is that developers may not need to run all tests if | ||
# their changes are isolated to single module. For instance, a developer | ||
# working on an OCI provider should not need to set up an Azure tenancy to test | ||
# their changes. | ||
|
||
OBSERVABILITY_URL=<url> | ||
OBSERVABILITY_USERNAME=<username> | ||
OBSERVABILITY_PASSWORD=<password> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.oracle.database.jdbc</groupId> | ||
<artifactId>ojdbc-extensions</artifactId> | ||
<version>1.0.3</version> | ||
</parent> | ||
|
||
<name>Oracle JDBC Observability Provider</name> | ||
<groupId>com.oracle.database.jdbc</groupId> | ||
<artifactId>ojdbc-provider-observability</artifactId> | ||
|
||
<properties> | ||
<opentelemetry.version>1.44.1</opentelemetry.version> | ||
<maven.compiler.source>11</maven.compiler.source> | ||
<maven.compiler.target>11</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.oracle.database.jdbc</groupId> | ||
<artifactId>ojdbc11</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-api</artifactId> | ||
<version>${opentelemetry.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-params</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<artifactId>ojdbc-provider-common</artifactId> | ||
<groupId>com.oracle.database.jdbc</groupId> | ||
<classifier>tests</classifier> | ||
<type>test-jar</type> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<!-- | ||
ObservabilityConfigurationTest must run first and alone since it depends on | ||
ObservabilityConfiguration being started with system properties set on the | ||
test. | ||
Running tests alphabetical and single threaded ensures that. | ||
--> | ||
<parallel>none</parallel> | ||
<runOrder>alphabetical</runOrder> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Oops, something went wrong.
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.
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.
we should update the copyright to 2025