Conversation
| /** | ||
| * Logger | ||
| */ | ||
| private Logger logger = Logger.getLogger(ObservabilityTraceEventListenerProvider.class.getName()); |
| protected static final MBeanServer server = ManagementFactory.getPlatformMBeanServer();; | ||
|
|
||
|
|
||
| static { |
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
same remark as for the use of ObjectName above
| assertEquals("OK", resultSet.getString(1)); | ||
| } | ||
| } | ||
| recording.stop(); |
There was a problem hiding this comment.
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.
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.
Typo: 'the the' should be corrected to 'to the'.
| @@ -0,0 +1,90 @@ | |||
| package oracle.jdbc.provider.observability; | |||
| */ | ||
| 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.
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.
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.
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.
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.
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"; |
| 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.
same here Boolean.parseBoolean() instead of Boolean.valueOf()
| @@ -0,0 +1,86 @@ | |||
| ################################################################################ | |||
| # Copyright (c) 2024 Oracle and/or its affiliates. | |||
There was a problem hiding this comment.
we should update the copyright to 2025
…dbc-extensions into observability-provider
…D, and PDB && update the driver version to 23.26.0.0.0
This provider is intended to replace the Open Telemetry provider and integrates with both Open Telemetry and Java Flight Recorder.