-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: main
Are you sure you want to change the base?
Conversation
/** | ||
* Logger | ||
*/ | ||
private Logger logger = Logger.getLogger(ObservabilityTraceEventListenerProvider.class.getName()); |
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.
not static ?
protected static final MBeanServer server = ManagementFactory.getPlatformMBeanServer();; | ||
|
||
|
||
static { |
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.
What is the need of this static block ?
try { | ||
objectName = new ObjectName(MBEAN_OBJECT_NAME); | ||
} catch (MalformedObjectNameException e) { | ||
objectName = null; |
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.
Our ObjectName name is fixed. This exception case will never happen.
And what will be the later consequences of objectName being null ?
|
||
@Override | ||
public TraceEventListener getTraceEventListener(Map<Parameter, CharSequence> map) { | ||
try { |
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.
It seems quite costly here, especially as we are registering a singleton. Why not moving this elsewhere ?
|
||
private String initAndGetTraceState(Span span) { | ||
final TraceState traceState = span.getSpanContext().getTraceState(); | ||
final StringBuilder stringBuilder = new StringBuilder(); |
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.
Why not
final StringBuilder stringBuilder = new StringBuilder("tracestate: ");
traceState.forEach((k, v) -> stringBuilder.append(k).append("=").append(v));
return stringBuilder.append("\r\n").toString();
Are we not missing a comma or something else between key/values ?
final String parentId = spanContext.getSpanId(); | ||
final String traceFlags = spanContext.getTraceFlags().toString(); | ||
|
||
return String.format("traceparent: %s-%s-%s-%s\r\n", |
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.
What is the "contract" regarding the format return ?
It looks like kind of toString() but this is used in the API which usually imply stronger specification.
(same apply to return of initAndGetTraceState())
/** | ||
* Logger | ||
*/ | ||
private Logger logger = Logger.getLogger(OpenTelemetryTraceEventListenerProvider.class.getName()); |
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.
Should be static.
General note about loggers : unless there is a justification to have a specific logger for a class, We usually see loggers being instantiated in a higher level context
i.e logger = Logger.getLogger(OpenTelemetryTraceEventListenerProvider.class..getPackage().getName());
*/ | ||
private Logger logger = Logger.getLogger(OpenTelemetryTraceEventListenerProvider.class.getName()); | ||
|
||
private static ObjectName objectName; |
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.
same remark as for the use of ObjectName above
assertEquals("OK", resultSet.getString(1)); | ||
} | ||
} | ||
recording.stop(); |
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.
General remark about test classes: please few comments about what they do when appropriate
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 sucess |
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.
Typo: 'sucess' should be corrected to 'success'.
* AC begin and sucess | ||
* VIP down event | ||
|
||
The following attributes are added the the traces for each event: |
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.
Typo: 'the the' should be corrected to 'to the'.
@@ -0,0 +1,90 @@ | |||
package oracle.jdbc.provider.observability; |
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.
missing copyright
*/ | ||
private static final String SENSITIVE_DATA_ENABLED = "oracle.jdbc.provider.observability.sensitiveDataEnabled"; | ||
|
||
private static final ReentrantLock observabilityConfiguraitonLock = new ReentrantLock(); |
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.
Typo in variable name: 'observabilityConfiguraitonLock' should be 'observabilityConfigurationLock'.
String enabledTracers = System.getProperty(ENABLED_TRACERS, "OTEL,JFR"); | ||
String sensitiveDataEnabled = System.getProperty(SENSITIVE_DATA_ENABLED, "false"); | ||
setEnabledTracers(enabledTracers); | ||
setSensitiveDataEnabled(Boolean.valueOf(sensitiveDataEnabled)); |
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.
Consider using Boolean.parseBoolean() instead of Boolean.valueOf() as it directly returns a primitive boolean rather than creating a Boolean object that needs to be unboxed.
*/ | ||
JFR(new JFRTracer()); | ||
|
||
private ObservabilityTracer tracer; |
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 can mark tracer
as final
* @return a user context object that is passed to the next call on this | ||
* Connection. May be null. | ||
*/ | ||
Object traceRoundtrip(Sequence sequence, TraceContext traceContext, Object userContext); |
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.
maybe we need to rename this method to traceRoundTrip
for consistency
/** | ||
* Name of the property used to enable or disable this listener. | ||
*/ | ||
public static final String OPEN_TELEMENTRY_TRACE_EVENT_LISTENER_ENABLED = "oracle.jdbc.provider.opentelemetry.enabled"; |
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.
There's a typo in the constant name OPEN_TELEMENTRY
. It should be OPEN_TELEMETRY
* Name of the property used to enable or disable sensitive data for this | ||
* listener. | ||
*/ | ||
public static final String OPEN_TELEMENTRY_TRACE_EVENT_LISTENER_SENSITIVE_ENABLED = "oracle.jdbc.provider.opentelemetry.sensitive-enabled"; |
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.
same here
public TraceEventListener getTraceEventListener(Map<Parameter, CharSequence> map) { | ||
try { | ||
if (!server.isRegistered(objectName)) { | ||
boolean enabled = Boolean.valueOf(System.getProperty(OPEN_TELEMENTRY_TRACE_EVENT_LISTENER_ENABLED, "true")); |
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.
same here Boolean.parseBoolean()
instead of Boolean.valueOf()
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.
looks good.
@@ -0,0 +1,86 @@ | |||
################################################################################ | |||
# Copyright (c) 2024 Oracle and/or its affiliates. |
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
…dbc-extensions into observability-provider
This provider is intended to replace the Open Telemetry provider and integrates with both Open Telemetry and Java Flight Recorder.