Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public Span createSpan(String name) {
return Span.NOOP;
} else {
TraceContext traceContext = tracer.traceContextBuilder()
.sampled(true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider making sampling configurable instead of hardcoding

While forcing sampling on can help with debugging, it may impact performance in production. Consider making this configurable through CommonConfig similar to how isTracingDetail() is used.

Here's a suggested approach:

+ private final boolean forceSampling;
+
+ public ObservationHelperImpl(Optional<Tracer> tracer, CommonConfig commonConfig) {
+     this.commonConfig = commonConfig;
+     this.tracer = tracer.orElse(Tracer.NOOP);
+     this.forceSampling = commonConfig.isTracingDetail();
+ }

  TraceContext traceContext = tracer.traceContextBuilder()
-     .sampled(true)
+     .sampled(forceSampling)
      .traceId(contextMap.get(TRACE_ID))

Committable suggestion skipped: line range outside the PR's diff.

.traceId(contextMap.get(TRACE_ID))
.spanId(contextMap.get(SPAN_ID))
.build();
Expand Down