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

cleaning up and improving function metrics #2994

Merged
merged 9 commits into from
Nov 17, 2018

Conversation

jerrypeng
Copy link
Contributor

@jerrypeng jerrypeng commented Nov 15, 2018

Motivation

Cleaning up and improving metrics collection and presentation for functions

Modifications

  1. Add endpoints to get stats of function or function instances
  2. add function cli for stats
  3. redesigned MetricsData protobuf
  4. add overall aggregates stats for functions

for example:

./bin/pulsar-admin functions stats --name py-test
{
  "receivedTotal": 1000,
  "processedSuccessfullyTotal": 1000,
  "systemExceptionsTotal": 0,
  "userExceptionsTotal": 0,
  "avgProcessLatency": 0.06142544746398926,
  "lastInvocation": 1542318672866,
  "instances": [
    {
      "instanceId": 1,
      "metrics": {
        "receivedTotal": 500,
        "processedSuccessfullyTotal": 500,
        "systemExceptionsTotal": 0,
        "userExceptionsTotal": 0,
        "avgProcessLatency": 0.06087827682495117,
        "lastInvocation": 1542318672866,
        "userMetrics": {
          "user_metric_metrics_1_sum": 1500.0,
          "user_metric_metrics_1_count": 500.0,
          "user_metric_metrics_2_sum": 7500.0,
          "user_metric_metrics_2_count": 1000.0
        }
      }
    },
    {
      "instanceId": 0,
      "metrics": {
        "receivedTotal": 500,
        "processedSuccessfullyTotal": 500,
        "systemExceptionsTotal": 0,
        "userExceptionsTotal": 0,
        "avgProcessLatency": 0.061972618103027344,
        "lastInvocation": 1542318672766,
        "userMetrics": {
          "user_metric_metrics_1_sum": 1500.0,
          "user_metric_metrics_1_count": 500.0,
          "user_metric_metrics_2_sum": 7500.0,
          "user_metric_metrics_2_count": 1000.0
        }
      }
    }
  ]
}

and for instances:

./bin/pulsar-admin functions stats --name test --instance-id 0
{
  "receivedTotal": 500,
  "processedSuccessfullyTotal": 500,
  "systemExceptionsTotal": 0,
  "userExceptionsTotal": 0,
  "avgProcessLatency": 0.06325435638427734,
  "lastInvocation": 1542320665090,
  "userMetrics": {
    "user_metric_metrics_1_sum": 1500.0,
    "user_metric_metrics_1_count": 500.0,
    "user_metric_metrics_2_sum": 7500.0,
    "user_metric_metrics_2_count": 1000.0
  }
}

Getting all function stats on worker:

curl localhost:8080/admin/v2/worker-stats/functionsmetrics
[
  {
    "name": "public/default/test:0",
    "metrics": {
      "receivedTotal": 0,
      "processedSuccessfullyTotal": 0,
      "systemExceptionsTotal": 0,
      "userExceptionsTotal": 0,
      "avgProcessLatency": 0.0,
      "lastInvocation": 0,
      "userMetrics": {}
    }
  },
  {
    "name": "public/default/py-test:1",
    "metrics": {
      "receivedTotal": 500,
      "processedSuccessfullyTotal": 500,
      "systemExceptionsTotal": 0,
      "userExceptionsTotal": 0,
      "avgProcessLatency": 0.059513092041015625,
      "lastInvocation": 1542320665189,
      "userMetrics": {
        "user_metric_metrics_1_sum": 1500.0,
        "user_metric_metrics_1_count": 500.0,
        "user_metric_metrics_2_sum": 7500.0,
        "user_metric_metrics_2_count": 1000.0
      }
    }
  }
]

Next step in improving metrics, will be to add some system stats that are time windowed

FYI this PR overlaps with #2982

@jerrypeng jerrypeng changed the title Cleaning up function metrics cleaning up and improving function metrics Nov 15, 2018
@jerrypeng jerrypeng self-assigned this Nov 15, 2018
@jerrypeng jerrypeng added this to the 2.3.0 milestone Nov 15, 2018
Copy link
Contributor

@merlimat merlimat left a comment

Choose a reason for hiding this comment

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

👍

@jerrypeng
Copy link
Contributor Author

rerun integration tests

@@ -537,6 +454,223 @@ private void stopFunction(String fullyQualifiedInstanceId, boolean restart) thro
}
}

/**
Copy link
Contributor

Choose a reason for hiding this comment

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

For all new functionality, could we collapse getInstanceStats and getFunctionStats into one implementation? I see a lot of duplicate code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't really combine those two function since getFunctionInstanceStats returns the stats for instance with getFunctionStats returns stats overall and for all instances. Different objects are returned. What can be refactored / combined is the logic between the get stats functions and get status functions. I didn't want to refactor the logic there since there are already many changes in this PR as it is.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good

@jerrypeng jerrypeng force-pushed the cleaning_up_function_metrics branch from a1b3b30 to 756d595 Compare November 17, 2018 01:56
@jerrypeng jerrypeng merged commit 23c5505 into apache:master Nov 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants