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

feat: add more metrics #2454

Merged
merged 20 commits into from
Jan 21, 2025
Merged

feat: add more metrics #2454

merged 20 commits into from
Jan 21, 2025

Conversation

iamKunalGupta
Copy link
Member

@iamKunalGupta iamKunalGupta commented Jan 17, 2025

Adds a few new metrics:

  1. error_emitted - instantaneous gauge of whether an error is being
    emitted
  2. errors_emitted - counter of errors emitted over time
  3. records_synced - number of records synced for every sync batch.
  4. synced_tables - number of tables configured in each mirror
  5. instance_status - a constant 1 metric every 5 minutes (same frequency as slots) with attributes differentiating the current status
  6. maintenance_status - a constant 1 when maintenance is running, also has attributes differentiating the current status

TODO: maybe refactor code so that maybe all gauges/counters are initialized inside the otelManager?

ref #2341

@@ -767,6 +768,19 @@ func (a *FlowableActivity) RecordSlotSizes(ctx context.Context) error {
return
}
slotMetricGauges.IntervalSinceLastNormalizeGauge = intervalSinceLastNormalizeGauge

syncedTablesGauge, err := a.OtelManager.GetOrInitInt64Gauge(
otel_metrics.BuildMetricName(otel_metrics.SyncedTablesGaugeName),
Copy link
Contributor

Choose a reason for hiding this comment

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

either now or after we should make RecordGauge utility method on otelmanager

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I feel that all gauges/counters can probably be initialized in otel manager. There is no flow specific information when we initialize them

@iamKunalGupta iamKunalGupta force-pushed the feat/add-more-metrics branch 3 times, most recently from ae6a4d4 to 7c237a5 Compare January 20, 2025 22:41
@iamKunalGupta iamKunalGupta linked an issue Jan 20, 2025 that may be closed by this pull request
@iamKunalGupta iamKunalGupta marked this pull request as ready for review January 21, 2025 00:13
@iamKunalGupta iamKunalGupta requested review from serprex and a team January 21, 2025 00:31
a.OtelManager.Metrics.RecordsSyncedGauge.Record(ctx, syncResponse.NumRecordsSynced, metric.WithAttributeSet(attribute.NewSet(
attribute.String(otel_metrics.FlowNameKey, config.FlowJobName),
attribute.String(otel_metrics.BatchIdKey, strconv.FormatInt(syncResponse.CurrentSyncBatchID, 10)),
attribute.String(otel_metrics.SourcePeerType, fmt.Sprintf("%T", srcConn)),
Copy link
Contributor

Choose a reason for hiding this comment

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

in behind %T just uses reflect: https://cs.opensource.google/go/go/+/refs/tags/go1.23.5:src/fmt/print.go;l=699

so if you prefer you could make a function in shared that does the same thing & then have more flexibility such as dropping package prefix or something

Copy link
Member Author

@iamKunalGupta iamKunalGupta Jan 21, 2025

Choose a reason for hiding this comment

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

i'm still leaning towards a Type() method, opened #2471 for later

flow/alerting/alerting.go Outdated Show resolved Hide resolved
@iamKunalGupta iamKunalGupta requested a review from serprex January 21, 2025 20:53
@iamKunalGupta iamKunalGupta enabled auto-merge (squash) January 21, 2025 20:55
@iamKunalGupta iamKunalGupta merged commit f9685e2 into main Jan 21, 2025
9 checks passed
@iamKunalGupta iamKunalGupta deleted the feat/add-more-metrics branch January 21, 2025 21:44
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.

Emit more metrics for broader visibility
2 participants