Skip to content
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

gauges for current batch id & normalized batch id #2378

Merged
merged 2 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions flow/activities/flowable_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,16 @@ func syncCore[TPull connectors.CDCPullConnectorCore, TSync connectors.CDCSyncCon
activity.RecordHeartbeat(ctx, pushedRecordsWithCount)
a.Alerter.LogFlowInfo(ctx, flowName, pushedRecordsWithCount)

if a.OtelManager != nil {
currentBatchID, err := a.OtelManager.GetOrInitInt64Gauge(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ideally we'd have something like I have for typed temoral slots & then this could just be

otel_metrics.CurrentBatchId.Record(ctx, a.OtelManager, res.CurrentSyncBatchID)

otel_metrics.BuildMetricName(otel_metrics.CurrentBatchIdGaugeName))
if err != nil {
logger.Error("Failed to get current batch id gauge", slog.Any("error", err))
} else {
currentBatchID.Record(ctx, res.CurrentSyncBatchID)
}
}

if err := a.applySchemaDeltas(ctx, config, options, res.TableSchemaDeltas); err != nil {
return 0, err
}
Expand Down Expand Up @@ -666,6 +676,15 @@ func (a *FlowableActivity) normalizeLoop(
} else if req.Done != nil {
close(req.Done)
}
if a.OtelManager != nil {
lastNormalizedBatchID, err := a.OtelManager.GetOrInitInt64Gauge(
otel_metrics.BuildMetricName(otel_metrics.LastNormalizedBatchIdGaugeName))
if err != nil {
logger.Error("Failed to get normalized batch id gauge", slog.Any("error", err))
} else {
lastNormalizedBatchID.Record(ctx, req.BatchID)
}
}
break
}
case <-syncDone:
Expand Down
14 changes: 9 additions & 5 deletions flow/otel_metrics/otel_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ import (
)

const (
SlotLagGaugeName string = "cdc_slot_lag"
OpenConnectionsGaugeName string = "open_connections"
OpenReplicationConnectionsGaugeName string = "open_replication_connections"
IntervalSinceLastNormalizeGaugeName string = "interval_since_last_normalize"
FetchedBytesCounterName string = "fetched_bytes"
SlotLagGaugeName = "cdc_slot_lag"
CurrentBatchIdGaugeName = "current_batch_id"
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should call it sync_batch_id

Also wondering if we should emit this twice, one at start and one at end, can attach different labels for both the times.

LastNormalizedBatchIdGaugeName = "last_normalized_batch_id"
OpenConnectionsGaugeName = "open_connections"
OpenReplicationConnectionsGaugeName = "open_replication_connections"
IntervalSinceLastNormalizeGaugeName = "interval_since_last_normalize"
FetchedBytesCounterName = "fetched_bytes"
)

type SlotMetricGauges struct {
SlotLagGauge metric.Float64Gauge
CurrentBatchIdGauge metric.Int64Gauge
LastNormalizedBatchIdGauge metric.Int64Gauge
OpenConnectionsGauge metric.Int64Gauge
OpenReplicationConnectionsGauge metric.Int64Gauge
IntervalSinceLastNormalizeGauge metric.Float64Gauge
Expand Down
Loading