dsmiley commented on code in PR #3682:
URL: https://github.com/apache/solr/pull/3682#discussion_r2377264326
##########
solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java:
##########
@@ -387,12 +239,192 @@ public Map<String, Object> getRunningMerges() {
@Override
protected void doAfterFlush() throws IOException {
- if (flushes != null) { // this is null when writer is used only for
snapshot cleanup
- flushes.inc(); // or if mergeTotals == false
+ if (flushesCounter != null) { // this is null when writer is used only for
snapshot cleanup
+ flushesCounter.inc(); // or if mergeTotals == false
}
super.doAfterFlush();
}
+ private void initMetrics(final SolrCore core) {
+ if (solrMetricsContext == null) {
+ solrMetricsContext = core.getSolrMetricsContext().getChildContext(this);
+ }
+ var coreName = core.getName();
+ var baseAttributesBuilder =
+ Attributes.builder()
+ .put(CATEGORY_ATTR, SolrInfoBean.Category.INDEX.toString())
+ .put(CORE_ATTR, coreName);
+ if (core.getCoreContainer().isZooKeeperAware()) {
+ String collectionName = core.getCoreDescriptor().getCollectionName();
+ baseAttributesBuilder
+ .put(COLLECTION_ATTR, collectionName)
+ .put(SHARD_ATTR,
core.getCoreDescriptor().getCloudDescriptor().getShardId())
+ .put(REPLICA_ATTR, Utils.parseMetricsReplicaName(collectionName,
coreName));
+ }
+ var baseAttributes = baseAttributesBuilder.build();
+
+ var mergeTimerBaseMetric =
+ solrMetricsContext.longHistogram(
+ "solr_indexwriter_merge_time", "Time spent merging segments",
OtelUnit.MILLISECONDS);
+
+ majorMergeTimer =
+ new AttributedLongTimer(
+ mergeTimerBaseMetric,
baseAttributes.toBuilder().put(MERGE_TYPE_ATTR, "major").build());
+ minorMergeTimer =
+ new AttributedLongTimer(
+ mergeTimerBaseMetric,
baseAttributes.toBuilder().put(MERGE_TYPE_ATTR, "minor").build());
+
+ mergeErrorsCounter =
+ new AttributedLongCounter(
+ solrMetricsContext.longCounter(
+ "solr_indexwriter_merge_errors", "Number of merge errors"),
+ baseAttributes);
+
+ flushesCounter =
+ new AttributedLongCounter(
+ solrMetricsContext.longCounter(
+ "solr_indexwriter_flushes", "Number of times documents have
been flushed to disk"),
+ baseAttributes);
+
+ var mergesCountBaseMetric =
+ solrMetricsContext.longCounter("solr_indexwriter_merges", "Number of
merge operations");
+ var docsMergedCountBaseMetric =
+ solrMetricsContext.longCounter(
+ "solr_indexwriter_docs_merged", "Number of documents involved in
merge");
+ var docsDeletedCountBasedMetric =
+ solrMetricsContext.longCounter(
+ "solr_indexwriter_docs_deleted", "Number of documents deleted in
merge");
Review Comment:
It's okay to push back on my scope creep :-) But at least lets
name/structure the metrics you want to add and stop there for now (if you don't
want to go further). We have a rare opportunity in the OTEL transition to
reorganize our metrics.
I don't want the metrics you are adding, which relate to segments, to be
confused with metrics we may or may not have on _update operations_, nor to be
confused with whatever metrics we can see from indexsearcher (like num docs).
These are mostly different things.
I think what I'm looking for in this PR is a metric named like
"solr_writer_segment_docs" (emphasis on "segment") and with an attribute to
differentiate the 3 I listed; only 2 are coming in this PR, relating to merge
behavior.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]