Skip to content

[Metrics] Align Metric and Span duration for timing API #3289

@philipphofmann

Description

@philipphofmann

Description

The metric and span for a call to the metrics timing method might not have the same duration. Starting and finishing the span and measuring the duration in the aggregator for the callback use two distinct calls to get the current time. Therefore, it's highly likely that the duration of the span and the metric don't match in some cases.

final @Nullable ISpan span = aggregator.startSpanForMetric("metric.timing", key);
if (span != null && tags != null) {
for (final @NotNull Map.Entry<String, String> entry : tags.entrySet()) {
span.setTag(entry.getKey(), entry.getValue());
}
}
try {
aggregator
.getMetricsAggregator()
.timing(key, callback, durationUnit, enrichedTags, localMetricsAggregator);
} finally {
if (span != null) {
span.finish();

Metadata

Metadata

Assignees

Labels

BugIssue type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions