-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add observability metric skeleton (#7769)
* feat: add observability metric skeleton * checkstyle
- Loading branch information
Showing
3 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
ksqldb-engine/src/main/java/io/confluent/ksql/internal/UtilizationMetricsListener.java
This file contains 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,66 @@ | ||
/* | ||
* Copyright 2021 Confluent Inc. | ||
* | ||
* Licensed under the Confluent Community License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of the | ||
* License at | ||
* | ||
* http://www.confluent.io/confluent-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package io.confluent.ksql.internal; | ||
|
||
import io.confluent.ksql.engine.QueryEventListener; | ||
import io.confluent.ksql.metastore.MetaStore; | ||
import io.confluent.ksql.services.ServiceContext; | ||
import io.confluent.ksql.util.QueryMetadata; | ||
import java.util.ArrayList; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import org.apache.kafka.common.utils.Time; | ||
import org.apache.kafka.streams.KafkaStreams; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class UtilizationMetricsListener implements Runnable, QueryEventListener { | ||
|
||
private final List<KafkaStreams> kafkaStreams; | ||
private final Logger logger = LoggerFactory.getLogger(UtilizationMetricsListener.class); | ||
private final List<String> metrics; | ||
private final Time time; | ||
private long lastSampleTime; | ||
|
||
public UtilizationMetricsListener() { | ||
this.kafkaStreams = new ArrayList<>(); | ||
this.metrics = new LinkedList<>(); | ||
time = Time.SYSTEM; | ||
lastSampleTime = time.milliseconds(); | ||
} | ||
|
||
@Override | ||
public void onCreate( | ||
final ServiceContext serviceContext, | ||
final MetaStore metaStore, | ||
final QueryMetadata queryMetadata) { | ||
kafkaStreams.add(queryMetadata.getKafkaStreams()); | ||
} | ||
|
||
@Override | ||
public void onDeregister(final QueryMetadata query) { | ||
final KafkaStreams streams = query.getKafkaStreams(); | ||
kafkaStreams.remove(streams); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
logger.info("Reporting Observability Metrics"); | ||
final Long currentTime = time.milliseconds(); | ||
// here is where we would report metrics | ||
lastSampleTime = currentTime; | ||
} | ||
} |
This file contains 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 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