-
Notifications
You must be signed in to change notification settings - Fork 169
[jmx-scraper] add support for Solr #1595
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
36eed4d
fix units for solr jmx metrics
SylvainJuge 336cc7d
add solr tests + yaml metrics
SylvainJuge 4583e6b
reformat
SylvainJuge 8ca9e61
post-review: consistent string quoting in yaml
SylvainJuge 3050852
remove quotes
SylvainJuge 93e87a0
Merge branch 'main' of github.com:open-telemetry/opentelemetry-java-c…
SylvainJuge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 150 additions & 0 deletions
150
...tionTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/SolrIntegrationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.contrib.jmxscraper.target_systems; | ||
|
|
||
| import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attribute; | ||
| import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attributeGroup; | ||
| import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attributeWithAnyValue; | ||
|
|
||
| import io.opentelemetry.contrib.jmxscraper.JmxScraperContainer; | ||
| import io.opentelemetry.contrib.jmxscraper.assertions.AttributeMatcher; | ||
| import io.opentelemetry.contrib.jmxscraper.assertions.AttributeMatcherGroup; | ||
| import java.nio.file.Path; | ||
| import java.time.Duration; | ||
| import org.testcontainers.containers.GenericContainer; | ||
| import org.testcontainers.containers.Network; | ||
| import org.testcontainers.containers.wait.strategy.Wait; | ||
|
|
||
| public class SolrIntegrationTest extends TargetSystemIntegrationTest { | ||
|
|
||
| @Override | ||
| protected GenericContainer<?> createTargetContainer(int jmxPort) { | ||
| return new GenericContainer<>("solr:8.8.2") | ||
| .withNetwork(Network.SHARED) | ||
| .withEnv("LOCAL_JMX", "no") | ||
| .withEnv("ENABLE_REMOTE_JMX_OPTS", "true") | ||
| .withEnv("RMI_PORT", Integer.toString(jmxPort)) | ||
| .withCommand("solr-precreate", "gettingstarted") | ||
| .withExposedPorts(jmxPort) | ||
| .withStartupTimeout(Duration.ofMinutes(2)) | ||
| .waitingFor(Wait.forListeningPort()); | ||
| } | ||
|
|
||
| @Override | ||
| protected JmxScraperContainer customizeScraperContainer( | ||
| JmxScraperContainer scraper, GenericContainer<?> target, Path tempDir) { | ||
| return scraper.withTargetSystem("solr"); | ||
| } | ||
|
|
||
| @Override | ||
| protected MetricsVerifier createMetricsVerifier() { | ||
|
|
||
| AttributeMatcher coreAttribute = attribute("core", "gettingstarted"); | ||
| AttributeMatcherGroup[] requestAttributes = requestAttributes(coreAttribute); | ||
| AttributeMatcherGroup cacheAttributes = | ||
| attributeGroup(coreAttribute, attribute("cache", "searcher")); | ||
|
|
||
| return MetricsVerifier.create() | ||
| .add( | ||
| "solr.document.count", | ||
| metric -> | ||
| metric | ||
| .hasDescription("The total number of indexed documents.") | ||
| .hasUnit("{document}") | ||
| .isUpDownCounter() | ||
| .hasDataPointsWithOneAttribute(coreAttribute)) | ||
| .add( | ||
| "solr.index.size", | ||
| metric -> | ||
| metric | ||
| .hasDescription("The total index size.") | ||
| .hasUnit("By") | ||
| .isUpDownCounter() | ||
| .hasDataPointsWithOneAttribute(coreAttribute)) | ||
| .add( | ||
| "solr.request.count", | ||
| metric -> | ||
| metric | ||
| .hasDescription("The number of queries made.") | ||
| .hasUnit("{query}") | ||
| .isCounter() | ||
| .hasDataPointsWithAttributes(requestAttributes)) | ||
| .add( | ||
| "solr.request.time.average", | ||
| metric -> | ||
| metric | ||
| .hasDescription( | ||
| "The average time of a query, based on Solr's histogram configuration.") | ||
| .hasUnit("ms") | ||
| .isGauge() | ||
| .hasDataPointsWithAttributes(requestAttributes)) | ||
| .add( | ||
| "solr.request.error.count", | ||
| metric -> | ||
| metric | ||
| .hasDescription("The number of queries resulting in an error.") | ||
| .hasUnit("{query}") | ||
| .isCounter() | ||
| .hasDataPointsWithAttributes(requestAttributes)) | ||
| .add( | ||
| "solr.request.timeout.count", | ||
| metric -> | ||
| metric | ||
| .hasDescription("The number of queries resulting in a timeout.") | ||
| .hasUnit("{query}") | ||
| .isCounter() | ||
| .hasDataPointsWithAttributes(requestAttributes)) | ||
| .add( | ||
| "solr.cache.eviction.count", | ||
| metric -> | ||
| metric | ||
| .hasDescription("The number of evictions from a cache.") | ||
| .hasUnit("{eviction}") | ||
| .isCounter() | ||
| .hasDataPointsWithAttributes(cacheAttributes)) | ||
| .add( | ||
| "solr.cache.hit.count", | ||
| metric -> | ||
| metric | ||
| .hasDescription("The number of hits for a cache.") | ||
| .hasUnit("{hit}") | ||
| .isCounter() | ||
| .hasDataPointsWithAttributes(cacheAttributes)) | ||
| .add( | ||
| "solr.cache.insert.count", | ||
| metric -> | ||
| metric | ||
| .hasDescription("The number of inserts to a cache.") | ||
| .hasUnit("{insert}") | ||
| .isCounter() | ||
| .hasDataPointsWithAttributes(cacheAttributes)) | ||
| .add( | ||
| "solr.cache.lookup.count", | ||
| metric -> | ||
| metric | ||
| .hasDescription("The number of lookups to a cache.") | ||
| .hasUnit("{lookup}") | ||
| .isCounter() | ||
| .hasDataPointsWithAttributes(cacheAttributes)) | ||
| .add( | ||
| "solr.cache.size", | ||
| metric -> | ||
| metric | ||
| .hasDescription("The size of the cache occupied in memory.") | ||
| .hasUnit("By") | ||
| .isUpDownCounter() | ||
| .hasDataPointsWithAttributes(cacheAttributes)); | ||
| } | ||
|
|
||
| private static AttributeMatcherGroup[] requestAttributes(AttributeMatcher coreAttribute) { | ||
| // ignore actual 'handler' values due to high cardinality (10+) and an exact matching makes test | ||
| // flaky | ||
| return new AttributeMatcherGroup[] { | ||
| attributeGroup(coreAttribute, attributeWithAnyValue("handler"), attribute("type", "QUERY")), | ||
| attributeGroup(coreAttribute, attributeWithAnyValue("handler"), attribute("type", "UPDATE")) | ||
| }; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| --- | ||
|
|
||
| rules: | ||
|
|
||
| - bean: solr:dom1=core,dom2=*,category=SEARCHER,scope=searcher,name=numDocs | ||
| mapping: | ||
| Value: | ||
| metric: solr.document.count | ||
| type: updowncounter | ||
| unit: '{document}' | ||
| desc: The total number of indexed documents. | ||
| metricAttribute: | ||
| core: param(dom2) | ||
|
|
||
| - bean: solr:dom1=core,dom2=*,category=INDEX,name=sizeInBytes | ||
| mapping: | ||
| Value: | ||
| metric: solr.index.size | ||
| type: updowncounter | ||
| unit: By | ||
| desc: The total index size. | ||
| metricAttribute: | ||
| core: param(dom2) | ||
|
|
||
| - beans: | ||
| - solr:dom1=core,dom2=*,category=QUERY,scope=*,name=requests | ||
| - solr:dom1=core,dom2=*,category=UPDATE,scope=*,name=requests | ||
| mapping: | ||
| Count: | ||
| metric: solr.request.count | ||
| type: counter | ||
| unit: '{query}' | ||
| desc: The number of queries made. | ||
| metricAttribute: | ||
| core: param(dom2) | ||
| type: param(category) | ||
| handler: param(scope) | ||
|
|
||
| - beans: | ||
| - solr:dom1=core,dom2=*,category=QUERY,scope=*,name=requestTimes | ||
| - solr:dom1=core,dom2=*,category=UPDATE,scope=*,name=requestTimes | ||
| mapping: | ||
| Mean: | ||
| metric: solr.request.time.average | ||
| type: gauge | ||
| unit: 'ms' | ||
| desc: "The average time of a query, based on Solr's histogram configuration." | ||
| metricAttribute: | ||
| core: param(dom2) | ||
| type: param(category) | ||
| handler: param(scope) | ||
|
|
||
| - beans: | ||
| - solr:dom1=core,dom2=*,category=QUERY,scope=*,name=errors | ||
| - solr:dom1=core,dom2=*,category=UPDATE,scope=*,name=errors | ||
| mapping: | ||
| Count: | ||
| metric: solr.request.error.count | ||
| type: counter | ||
| unit: '{query}' | ||
| desc: The number of queries resulting in an error. | ||
| metricAttribute: | ||
| core: param(dom2) | ||
| type: param(category) | ||
| handler: param(scope) | ||
|
|
||
| - beans: | ||
| - solr:dom1=core,dom2=*,category=QUERY,scope=*,name=timeouts | ||
| - solr:dom1=core,dom2=*,category=UPDATE,scope=*,name=timeouts | ||
| mapping: | ||
| Count: | ||
| metric: solr.request.timeout.count | ||
| type: counter | ||
| unit: '{query}' | ||
| desc: The number of queries resulting in a timeout. | ||
| metricAttribute: | ||
| core: param(dom2) | ||
| type: param(category) | ||
| handler: param(scope) | ||
|
|
||
| - bean: solr:dom1=core,dom2=*,category=CACHE,scope=*,name=queryResultCache | ||
| prefix: solr.cache. | ||
| type: counter | ||
| metricAttribute: | ||
| core: param(dom2) | ||
| cache: param(scope) | ||
| mapping: | ||
| cumulative_evictions: | ||
| metric: eviction.count | ||
| unit: '{eviction}' | ||
| desc: The number of evictions from a cache. | ||
| cumulative_hits: | ||
| metric: hit.count | ||
| unit: '{hit}' | ||
| desc: The number of hits for a cache. | ||
| cumulative_inserts: | ||
| metric: insert.count | ||
| unit: '{insert}' | ||
| desc: The number of inserts to a cache. | ||
| cumulative_lookups: | ||
| metric: lookup.count | ||
| unit: '{lookup}' | ||
| desc: The number of lookups to a cache. | ||
| ramBytesUsed: | ||
| type: updowncounter | ||
| metric: size | ||
| unit: 'By' | ||
| desc: The size of the cache occupied in memory. | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.