Skip to content

Engine worker metrics support#1470

Merged
jfallows merged 20 commits intoaklivity:developfrom
akrambek:feature/1465
May 23, 2025
Merged

Engine worker metrics support#1470
jfallows merged 20 commits intoaklivity:developfrom
akrambek:feature/1465

Conversation

@akrambek
Copy link
Contributor

@akrambek akrambek commented May 5, 2025

Fixes #1465

@akrambek akrambek changed the title Tcp capacity usage report Engine worker metrics support May 15, 2025
@akrambek akrambek marked this pull request as ready for review May 15, 2025 10:26

import org.agrona.collections.MutableInteger;

public final class CapacityTracker
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public final class CapacityTracker
public final class TcpCapacityTracker

{
MutableInteger capacity = new MutableInteger(ENGINE_WORKER_CAPACITY.getAsInt(config));
LongConsumer capacityUsage = context.supplyUtilizationMetric();
CapacityTracker capacity = new CapacityTracker(ENGINE_WORKER_CAPACITY.getAsInt(config), capacityUsage);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest passing config and context to TcpCapacityTracker and handling the metric lookup and the capacity lookup in the constructor.

Comment on lines +174 to +175
for (SocketChannel channel = router.accept(server); channel != null;
channel = router.accept(server))
Copy link
Contributor

Choose a reason for hiding this comment

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

We can revert this change.

{
// implicit int -> long conversion, it's OK
return labelResolver.apply(namespaceId);
return namespaceId != -1 ? labelResolver.apply(namespaceId) : null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return namespaceId != -1 ? labelResolver.apply(namespaceId) : null;
return namespaceId != NamespacedId.NO_NAMESPACE_ID ? labelResolver.apply(namespaceId) : null;

public String binding()
{
return labelResolver.apply(bindingId);
return bindingId != -1 ? labelResolver.apply(bindingId) : null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return bindingId != -1 ? labelResolver.apply(bindingId) : null;
return bindingId != NamespacedId.NO_LOCAL_ID ? labelResolver.apply(bindingId) : null;

Comment on lines +1 to +7
[
{
"op": "add",
"path": "/$defs/telemetry/metrics/items/enum/-",
"value": "engine.worker.utilization"
}
]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we shouldn't need this to be configured, it should be always on, even for empty config, agree?

'}'
'}]'
'}]'
'}]'
Copy link
Contributor

Choose a reason for hiding this comment

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

Please restore the original formatting for readability.

'}'
'}]'
'}]'
'}]'
Copy link
Contributor

Choose a reason for hiding this comment

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

Please restore the original formatting for readability.

NANOSECONDS,
COUNT
COUNT,
PERCENT
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to add a custom type here?

public String binding()
{
return bindingId != -1 ? labelResolver.apply(bindingId) : null;
return bindingId != NamespacedId.NO_NAMESPACE_ID ? labelResolver.apply(bindingId) : null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return bindingId != NamespacedId.NO_NAMESPACE_ID ? labelResolver.apply(bindingId) : null;
return bindingId != NamespacedId.NO_LOCAL_ID ? labelResolver.apply(bindingId) : null;

jfallows
jfallows previously approved these changes May 23, 2025
@jfallows jfallows merged commit df41e8b into aklivity:develop May 23, 2025
41 checks passed
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.

Collect exportable engine metric representing worker capacity usage for auto scaling

2 participants