Skip to content

Commit

Permalink
Remove import for SpanContextSupplier
Browse files Browse the repository at this point in the history
Signed-off-by: Fabian Stäber <[email protected]>
  • Loading branch information
fstab committed Apr 4, 2024
1 parent 4b6e78f commit 966360b
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.prometheus.metrics.core.exemplars;

import io.prometheus.metrics.tracer.common.SpanContext;
import io.prometheus.metrics.tracer.initializer.SpanContextSupplier;
import io.prometheus.metrics.model.snapshots.Exemplar;
import io.prometheus.metrics.model.snapshots.Exemplars;
import io.prometheus.metrics.model.snapshots.Labels;
Expand Down Expand Up @@ -46,8 +45,11 @@ public ExemplarSampler(ExemplarSamplerConfig config) {
/**
* Constructor with an additional {code spanContext} argument.
* This is useful for testing, but may also be useful in some production scenarios.
* If {@code spanContext != null} that spanContext is used and {@link SpanContextSupplier} is not used.
* If {@code spanContext == null} the {@link SpanContextSupplier#getSpanContext()} is called to find a span context.
* If {@code spanContext != null} that spanContext is used and
* {@link io.prometheus.metrics.tracer.initializer.SpanContextSupplier SpanContextSupplier} is not used.
* If {@code spanContext == null}
* {@link io.prometheus.metrics.tracer.initializer.SpanContextSupplier#getSpanContext() SpanContextSupplier.getSpanContext()}
* is called to find a span context.
*/
public ExemplarSampler(ExemplarSamplerConfig config, SpanContext spanContext) {
this.config = config;
Expand Down Expand Up @@ -319,7 +321,10 @@ private long updateExemplar(int index, double value, long now) {
}

private Labels doSampleExemplar() {
SpanContext spanContext = this.spanContext != null ? this.spanContext : SpanContextSupplier.getSpanContext();
// Using the qualified name so that Micrometer can exclude the dependency on prometheus-metrics-tracer-initializer
// as they provide their own implementation of SpanContextSupplier.
// If we had an import statement for SpanContextSupplier the dependency would be needed in any case.
SpanContext spanContext = this.spanContext != null ? this.spanContext : io.prometheus.metrics.tracer.initializer.SpanContextSupplier.getSpanContext();
try {
if (spanContext != null) {
if (spanContext.isCurrentSpanSampled()) {
Expand Down

0 comments on commit 966360b

Please sign in to comment.