5 commented on code in PR #204:
URL: https://github.com/apache/cassandra-sidecar/pull/204#discussion_r1999598993
##########
server/src/main/java/org/apache/cassandra/sidecar/datahub/SchemaReporter.java:
##########
@@ -96,44 +110,72 @@ public SchemaReporter(@NotNull IdentifiersProvider
identifiersProvider,
* @param keyspaceConverters a {@link List} of {@link
KeyspaceToAspectConverter} instances to use
* @param tableConverters a {@link List} of {@link TableToAspectConverter}
instances to use
* @param emitterFactory an instance of {@link EmitterFactory} to use
+ * @param reportingMetrics an instance of {@link SchemaReportingMetrics}
to use
*/
protected SchemaReporter(@NotNull IdentifiersProvider identifiersProvider,
@NotNull List<ClusterToAspectConverter<? extends
RecordTemplate>> clusterConverters,
@NotNull List<KeyspaceToAspectConverter<? extends
RecordTemplate>> keyspaceConverters,
@NotNull List<TableToAspectConverter<? extends
RecordTemplate>> tableConverters,
- @NotNull EmitterFactory emitterFactory)
+ @NotNull EmitterFactory emitterFactory,
+ @NotNull SchemaReportingMetrics reportingMetrics)
{
this.identifiersProvider = identifiersProvider;
this.clusterConverters = clusterConverters;
this.keyspaceConverters = keyspaceConverters;
this.tableConverters = tableConverters;
this.emitterFactory = emitterFactory;
+ this.reportingMetrics = reportingMetrics;
}
/**
- * Public method for converting and reporting the Cassandra schema
+ * Public method for converting and reporting the Cassandra schema when
triggered by a scheduled periodic task
*
* @param cluster the {@link Cluster} to extract Cassandra schema from
*/
- public void process(@NotNull Cluster cluster)
+ public void processScheduled(@NotNull Cluster cluster)
+ {
+ process(cluster.getMetadata(),
reportingMetrics.startedSchedule.metric);
+ }
+
+ /**
+ * Public method for converting and reporting the Cassandra schema when
triggered by a received API request
+ *
+ * @param metadata the {@link Metadata} to extract Cassandra schema from
+ */
+ public void processRequested(@NotNull Metadata metadata)
{
- process(cluster.getMetadata());
+ process(metadata, reportingMetrics.startedRequest.metric);
}
/**
- * Public method for converting and reporting the Cassandra schema
+ * Private method for converting and reporting the Cassandra schema
*
* @param metadata the {@link Metadata} to extract Cassandra schema from
+ * @param started the {@link DeltaGauge} for the metric counting
invocations
*/
- public void process(@NotNull Metadata metadata)
+ private void process(@NotNull Metadata metadata,
+ @NotNull DeltaGauge started)
{
+ LOGGER.info("Starting to report schema for cluster, identifiers={}",
identifiersProvider);
+ started.increment();
+
try (Emitter emitter = emitterFactory.emitter())
{
- stream(metadata).forEach(ThrowableUtils.consumer(emitter::emit));
+ Stopwatch stopwatch = Stopwatch.createStarted();
Review Comment:
Good point, switched to using `NamedMetric<Timer>` instead, thanks.
--
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]