Skip to content

[controller] integrate OpenTelemetry into Controller & add log compaction metrics #1665

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

Draft
wants to merge 33 commits into
base: main
Choose a base branch
from

Conversation

WhitneyDeng
Copy link
Contributor

Problem Statement

Solution

Code changes

  • Added new code behind a config. If so list the config names and their default values in the PR description.
  • Introduced new log lines.
    • Confirmed if logs need to be rate limited to avoid excessive logging.

Concurrency-Specific Checks

Both reviewer and PR author to verify

  • Code has no race conditions or thread safety issues.
  • Proper synchronization mechanisms (e.g., synchronized, RWLock) are used where needed.
  • No blocking calls inside critical sections that could lead to deadlocks or performance degradation.
  • Verified thread-safe collections are used (e.g., ConcurrentHashMap, CopyOnWriteArrayList).
  • Validated proper exception handling in multi-threaded code to avoid silent thread termination.

How was this PR tested?

  • New unit tests added.
  • New integration tests added.
  • Modified or extended existing tests.
  • Verified backward compatibility (if applicable).

Does this PR introduce any user-facing or breaking changes?

  • No. You can skip the rest of this section.
  • Yes. Clearly explain the behavior change and its impact.

@WhitneyDeng WhitneyDeng changed the title [controller] integrate OpenTelemetry into Controller [controller] integrate OpenTelemetry into Controller & add log compaction metrics May 8, 2025
Copy link
Contributor

@m-nagarajan m-nagarajan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Left some very initial review.

@@ -34,6 +34,7 @@ dependencies {

implementation project(':internal:venice-common')
implementation project(':clients:venice-thin-client')
implementation project(':internal:venice-client-common')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this not under venice-common rather than under venice-client-common. We can fix this if needed separately, no AI for you on this.

import java.util.HashMap;
import java.util.Map;


public class RepushJobRequest {
public static final String SCHEDULED_TRIGGER = "Scheduled";
public static final String MANUAL_TRIGGER = "Manual";
public static final RepushStoreTriggerSource SCHEDULED_TRIGGER = RepushStoreTriggerSource.SCHEDULED;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can directly use RepushStoreTriggerSource.SCHEDULED or MANUAL where ever its needed or use the new member variable triggerSource. No need to have another static variable for this.

package com.linkedin.venice.stats.dimensions;

public enum LogCompactionSelectionReason implements VeniceDimensionInterface {
TIME_SINCE_LAST_VERSION_CREATION_EXCEEDS_THRESHOLD;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there another reason which we are thinking to add in the future?

@@ -62,6 +67,11 @@ public class VeniceController {
private static final Logger LOGGER = LogManager.getLogger(VeniceController.class);
private static final String CONTROLLER_GRPC_SERVER_THREAD_NAME = "ControllerGrpcServer";
static final String CONTROLLER_SERVICE_NAME = "venice-controller";
public static final String CONTROLLER_SERVICE_METRIC_PREFIX = "controller";
public static final Collection<MetricEntity> CONTROLLER_SERVICE_METRIC_ENTITIES = Collections.unmodifiableList(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why duplicated?

@@ -375,11 +378,15 @@ public class VeniceParentHelixAdmin implements Admin {
private final Map<String, Map<String, ControllerClient>> newFabricControllerClientMap =
new VeniceConcurrentHashMap<>();

/** Metrics */
private final Map<String, LogCompactionStats> logCompactionStatsMap = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets use VeniceConcurrentHashMap

// initialise logCompactionStatsMap
for (String clusterName: multiClusterConfigs.getClusters()) {
if (multiClusterConfigs.getControllerConfig(clusterName).isLogCompactionEnabled()) {
logCompactionStatsMap.put(clusterName, new LogCompactionStats(metricsRepository, clusterName));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use putIfAbsent

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inside LogCompactionStats, I see we use MetricEntityStateGeneric, the MES that doesn't have a caching layer. In that case, can we just use the clusterName as a dimension when we record, instead of building per cluster stats?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally yes, but we are adding per cluster stats for tehuti metrics to keep it similar to other controller stats.

.recordRepushStoreCall(
repushJobRequest.getStoreName(),
repushJobRequest.getTriggerSource(),
response.isError() ? VeniceResponseStatusCategory.FAIL : VeniceResponseStatusCategory.SUCCESS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JOB_EXECUTION_STATUS was defined but never used. where is the plan to use this?

@@ -38,10 +42,20 @@ public class LogCompactionService extends AbstractVeniceService {
private final Admin admin;
private final VeniceControllerMultiClusterConfig multiClusterConfigs;
final ScheduledExecutorService executor;
private final Map<String, LogCompactionStats> statsMap;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find who uses this map?

// initialise logCompactionStatsMap
for (String clusterName: multiClusterConfigs.getClusters()) {
if (multiClusterConfigs.getControllerConfig(clusterName).isLogCompactionEnabled()) {
logCompactionStatsMap.put(clusterName, new LogCompactionStats(metricsRepository, clusterName));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inside LogCompactionStats, I see we use MetricEntityStateGeneric, the MES that doesn't have a caching layer. In that case, can we just use the clusterName as a dimension when we record, instead of building per cluster stats?

Whitney Deng added 26 commits May 23, 2025 14:55
- add RepushStoreTriggerSource enum for metric dimension
- import `venice-client-common` in `venice-controller` to allow `VeniceParentHelixAdmin` to access `VeniceResponseStatusCategory` to emit metric
- add clusterName to RepushJobRequest for metric dimension
- in RepushJobRequest, streamline triggerSource to `RepushStoreTriggerSource`
- VeniceParentHelixAdmin::getStoresForCompaction call VeniceHelixAdmin::getStoresForCompaction directly rather than throw exception
- VeniceController only creates LogCompactionService if is parent controller
…::initializeParentAdmin to pass in metricsRepository for testing metric emission in VeniceParentHelixAdmin
for metric to record which stores are nominated for compaction
@WhitneyDeng WhitneyDeng force-pushed the log_compaction/observability/integrate-otel-to-controller branch from 6797aeb to 2062312 Compare May 23, 2025 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants