Skip to content

SOLR-17806: Migrate DirectUpdateHandler2 metrics to OTEL #3417

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

Open
wants to merge 7 commits into
base: feature/SOLR-17458
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -146,7 +146,8 @@ public void registerMetricProducer(String scope, SolrMetricProducer producer) {
+ producer);
}

// NOCOMMIT SOLR-17458: These attributes may not work for standalone mode
// NOCOMMIT SOLR-17458: These attributes may not work for standalone mode and maybe make the
// scope attribute optional
// use deprecated method for back-compat, remove in 9.0
producer.initializeMetrics(
solrMetricsContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
/** Used by objects that expose metrics through {@link SolrMetricManager}. */
public interface SolrMetricProducer extends AutoCloseable {

public static final AttributeKey<String> TYPE_ATTR = AttributeKey.stringKey("type");
public final AttributeKey<String> TYPE_ATTR = AttributeKey.stringKey("type");
public final AttributeKey<String> OPERATION_ATTR = AttributeKey.stringKey("operation");

/**
* Unique metric tag identifies components with the same life-cycle, which should be registered /
Expand Down
15 changes: 15 additions & 0 deletions solr/core/src/java/org/apache/solr/metrics/SolrMetricsContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.opentelemetry.api.metrics.LongUpDownCounter;
import io.opentelemetry.api.metrics.ObservableDoubleGauge;
import io.opentelemetry.api.metrics.ObservableDoubleMeasurement;
import io.opentelemetry.api.metrics.ObservableLongCounter;
import io.opentelemetry.api.metrics.ObservableLongGauge;
import io.opentelemetry.api.metrics.ObservableLongMeasurement;
import java.util.Map;
Expand Down Expand Up @@ -233,6 +234,20 @@ public ObservableDoubleGauge observableDoubleGauge(
registryName, metricName, description, callback, unit);
}

public ObservableLongCounter observableLongCounter(
String metricName, String description, Consumer<ObservableLongMeasurement> callback) {
return observableLongCounter(metricName, description, callback, null);
}

public ObservableLongCounter observableLongCounter(
String metricName,
String description,
Consumer<ObservableLongMeasurement> callback,
String unit) {
return metricManager.observableLongCounter(
registryName, metricName, description, callback, unit);
}

/**
* Convenience method for {@link SolrMetricManager#meter(SolrMetricsContext, String, String,
* String...)}.
Expand Down
Loading