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

[#9177] add metrics server to go function #9318

Conversation

freeznet
Copy link
Contributor

@freeznet freeznet commented Jan 26, 2021

Fixes #9177

Motivation

go function added metrics collector by #6105, but havnt pass metricsPort to go function, also not init & start prometheus http server. As the result, function worker will keep trying to access to the metrics port to collect data, which will cause massive log errors in log history.

Modifications

  • expose metricsPort to go function
  • add prometheus http server to go function

Verifying this change

  • Make sure that the change passes the CI checks.

@@ -119,7 +119,8 @@
public static List<String> getGoInstanceCmd(InstanceConfig instanceConfig,
String originalCodeFileName,
String pulsarServiceUrl,
boolean k8sRuntime) throws IOException {
boolean k8sRuntime,
int metricsPort) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

Why not introduce the new configuration in the InstanceConfig?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I havnt add metricsPort to InstanceConfig is because metricsPort is generated with different mechanisms for different runtime, such as for process runtime, metricsPort is generated by FunctionCommon.findAvailablePort() but for k8s runtime, metricsPort comes from the config functions_worker.yml.

Also, for java and python function, metricsPort is also not included in InstanceConfig (ref:

).

I did seem a bit lazy with these changes here, but also want to avoid making changes to java and python runtime's code. So let me know if we want apply metricsPort into InstanceConfig.

@zymap zymap added this to the 2.8.0 milestone Jan 26, 2021
@freeznet freeznet force-pushed the freeznet/fix-golang-function-metrics-port-error branch from cd65b4c to 2676bd5 Compare January 26, 2021 08:22
@freeznet
Copy link
Contributor Author

/pulsarbot run-failure-checks

1 similar comment
@freeznet
Copy link
Contributor Author

/pulsarbot run-failure-checks

@freeznet freeznet force-pushed the freeznet/fix-golang-function-metrics-port-error branch from 2676bd5 to f1a7572 Compare January 27, 2021 07:04
@freeznet
Copy link
Contributor Author

/pulsarbot run-failure-checks

1 similar comment
@freeznet
Copy link
Contributor Author

/pulsarbot run-failure-checks

@wolfstudy
Copy link
Member

Hello @freeznet Thanks you work on this, I agree with @zymap's point of view, it seems that it is more reasonable for us to use metricsPort as a field of InstanceConfig. Of course, there is no problem with your current implementation.

@freeznet freeznet force-pushed the freeznet/fix-golang-function-metrics-port-error branch from f1a7572 to 33b7258 Compare January 28, 2021 13:57
@freeznet
Copy link
Contributor Author

@wolfstudy thanks for review. I will go for @zymap and your advice. But this will affect java and python's code, should I put metricsPort into InstanceConfig in an individual pull-request?

@zymap
Copy link
Member

zymap commented Jan 29, 2021

Yes, make sense to me. Let's get merge this PR.

@freeznet
Copy link
Contributor Author

/pulsarbot run-failure-checks

@freeznet
Copy link
Contributor Author

/pulsarbot run-failure-checks

@freeznet freeznet force-pushed the freeznet/fix-golang-function-metrics-port-error branch from 33b7258 to a7f52b5 Compare January 29, 2021 15:50
@freeznet
Copy link
Contributor Author

/pulsarbot run-failure-checks

@codelipenghui codelipenghui merged commit 211a125 into apache:master Jan 30, 2021
sijie pushed a commit that referenced this pull request Feb 2, 2021
### Motivation

#9318 add metrics server to go function, but didnt serve `"/"` endpoint in metrics server, which will cause some metrics calls failed.

### Modifications

add handler for `"/"` in `MetricsServicer`

### Verifying this change

- [x] Make sure that the change passes the CI checks.
Anonymitaet pushed a commit that referenced this pull request Feb 3, 2021
### Motivation

#9318 add metrics server to go function, but didnt serve `"/"` endpoint in metrics server, which will cause some metrics calls failed.

### Modifications

add handler for `"/"` in `MetricsServicer`

### Verifying this change

- [x] Make sure that the change passes the CI checks.
@codelipenghui codelipenghui added the cherry-picked/branch-2.7 Archived: 2.7 is end of life label Feb 4, 2021
codelipenghui pushed a commit that referenced this pull request Feb 4, 2021
Fixes #9177

go function added metrics collector by #6105, but havnt pass `metricsPort` to go function, also not init & start prometheus http server. As the result, function worker will keep trying to access to the metrics port to collect data, which will cause massive log errors in log history.

- expose `metricsPort` to go function
- add prometheus http server to go function

- [x] Make sure that the change passes the CI checks.

(cherry picked from commit 211a125)
codelipenghui pushed a commit that referenced this pull request Feb 4, 2021
### Motivation

#9318 add metrics server to go function, but didnt serve `"/"` endpoint in metrics server, which will cause some metrics calls failed.

### Modifications

add handler for `"/"` in `MetricsServicer`

### Verifying this change

- [x] Make sure that the change passes the CI checks.

(cherry picked from commit c99e1a0)
zymap pushed a commit that referenced this pull request Feb 22, 2021
Master Issue: #9177

### Motivation

As discussed in #9318, both @zymap and @wolfstudy suggested, to add `metricsPort` as a field of `InstanceConfig`.

### Modifications

- add metricsPort to InstanceConfig
- add hasValidMetricsPort to InstanceConfig to check if metrics port is valid
- applied changes to k8s runtime & process runtime
@devinbost
Copy link
Contributor

@freeznet Thank you for fixing this issue!

ivankelly pushed a commit to ivankelly/pulsar that referenced this pull request Aug 10, 2021
Master Issue: apache#9177

As discussed in apache#9318, both @zymap and @wolfstudy suggested, to add `metricsPort` as a field of `InstanceConfig`.

- add metricsPort to InstanceConfig
- add hasValidMetricsPort to InstanceConfig to check if metrics port is valid
- applied changes to k8s runtime & process runtime
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.

[Go Functions] - Failed to collect metrics
7 participants