Skip to content

Commit

Permalink
Address review comment
Browse files Browse the repository at this point in the history
Signed-off-by: Gagan Juneja <[email protected]>
  • Loading branch information
Gagan Juneja committed Oct 17, 2023
1 parent c277a2b commit c359f90
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ private Telemetry telemetry(TelemetrySettings telemetrySettings) {

@Override
public void close() {
refCountedOpenTelemetry.close();
if (refCountedOpenTelemetry != null) {
refCountedOpenTelemetry.close();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class OTelMetricsTelemetry<T extends MeterProvider & Closeable> implement
*/
public OTelMetricsTelemetry(RefCountedReleasable<OpenTelemetrySdk> openTelemetry, T meterProvider) {
this.refCountedOpenTelemetry = openTelemetry;
this.refCountedOpenTelemetry.incRef();
this.meterProvider = meterProvider;
this.otelMeter = meterProvider.get(OTelTelemetryPlugin.INSTRUMENTATION_SCOPE_NAME);
}
Expand Down Expand Up @@ -67,6 +68,7 @@ public Counter createUpDownCounter(String name, String description, String unit)

@Override
public void close() throws IOException {
meterProvider.close();
refCountedOpenTelemetry.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ public OTelTelemetry(RefCountedReleasable<OpenTelemetrySdk> refCountedOpenTeleme

@Override
public TracingTelemetry getTracingTelemetry() {
refCountedOpenTelemetry.incRef();
return new OTelTracingTelemetry<>(refCountedOpenTelemetry, refCountedOpenTelemetry.get().getSdkTracerProvider());
}

@Override
public MetricsTelemetry getMetricsTelemetry() {
refCountedOpenTelemetry.incRef();
return new OTelMetricsTelemetry<>(refCountedOpenTelemetry, refCountedOpenTelemetry.get().getSdkMeterProvider());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ public class OTelTracingTelemetry<T extends TracerProvider & Closeable> implemen
*/
public OTelTracingTelemetry(RefCountedReleasable<OpenTelemetrySdk> refCountedOpenTelemetry, T tracerProvider) {
this.refCountedOpenTelemetry = refCountedOpenTelemetry;
this.refCountedOpenTelemetry.incRef();
this.tracerProvider = tracerProvider;
this.otelTracer = tracerProvider.get(OTelTelemetryPlugin.INSTRUMENTATION_SCOPE_NAME);
}

@Override
public void close() throws IOException {
tracerProvider.close();
refCountedOpenTelemetry.close();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private TraceableHttpChannel(HttpChannel delegate, Span span, Tracer tracer) {
* @return http channel
*/
public static HttpChannel create(HttpChannel delegate, Span span, Tracer tracer) {
if (tracer.isRecording()) {
if (tracer.isRecording() == true) {
return new TraceableHttpChannel(delegate, span, tracer);
} else {
return delegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private TraceableRestChannel(RestChannel delegate, Span span, Tracer tracer) {
* @return rest channel
*/
public static RestChannel create(RestChannel delegate, Span span, Tracer tracer) {
if (tracer.isRecording()) {
if (tracer.isRecording() == true) {
return new TraceableRestChannel(delegate, span, tracer);
} else {
return delegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public TraceableTcpTransportChannel(TcpTransportChannel delegate, Span span, Tra
* @return transport channel
*/
public static TransportChannel create(TcpTransportChannel delegate, final Span span, final Tracer tracer) {
if (tracer.isRecording()) {
if (tracer.isRecording() == true) {
delegate.getChannel().addCloseListener(new ActionListener<Void>() {
@Override
public void onResponse(Void unused) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static <S extends TransportResponse> TransportResponseHandler<S> create(
Span span,
Tracer tracer
) {
if (tracer.isRecording()) {
if (tracer.isRecording() == true) {
return new TraceableTransportResponseHandler<S>(delegate, span, tracer);
} else {
return delegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private TraceableActionListener(ActionListener<Response> delegate, Span span, Tr
* @return action listener
*/
public static <Response> ActionListener<Response> create(ActionListener<Response> delegate, Span span, Tracer tracer) {
if (tracer.isRecording()) {
if (tracer.isRecording() == true) {
return new TraceableActionListener<Response>(delegate, span, tracer);
} else {
return delegate;
Expand Down

0 comments on commit c359f90

Please sign in to comment.