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

Prometheus example crashes #1903

Closed
bachittle opened this issue Jan 6, 2023 · 8 comments · Fixed by #1986
Closed

Prometheus example crashes #1903

bachittle opened this issue Jan 6, 2023 · 8 comments · Fixed by #1986
Assignees
Labels
bug Something isn't working

Comments

@bachittle
Copy link
Contributor

Describe your environment Describe any aspect of your environment relevant to the problem, including your platform, build system, version numbers of installed dependencies, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main branch.

  • windows 10 x64
  • ubuntu gcc x64

Steps to reproduce
Describe exactly how to reproduce the error. Include a code sample if applicable.

  • run prometheus in docker container
  • compile opentelemetry via cmake with the WITH_PROMETHEUS flag turned on
  • run the prometheus_example

What is the expected behavior?
What did you expect to see?

  • Connection to my prometheus docker service, with metrics pushed in

What is the actual behavior?
What did you see instead?

  • program crashes, outputting: null context when constructing CivetServer. Possible problem binding to port.
@bachittle bachittle added the bug Something isn't working label Jan 6, 2023
@marcalff
Copy link
Member

marcalff commented Jan 6, 2023

@bachittle

Thanks for the report.

Do you have a call stack by chance, this would help.

@bachittle
Copy link
Contributor Author

PrometheusExporter example program running ...
./prometheus_example(_Z7handlerv+0x32) [0x55b5a3a715f4]
/lib/x86_64-linux-gnu/libstdc++.so.6(+0xae24c) [0x7f4d0a49724c]
/lib/x86_64-linux-gnu/libstdc++.so.6(+0xae2b7) [0x7f4d0a4972b7]
/lib/x86_64-linux-gnu/libstdc++.so.6(+0xae518) [0x7f4d0a497518]
./prometheus_example(_ZN11CivetServerC1ERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS6_EEPK14CivetCallbacksPKv+0x346) [0x55b5a3b30320]
./prometheus_example(_ZN10prometheus6detail11make_uniqueI11CivetServerJSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EERPK14CivetCallbacksEEESt10unique_ptrIT_St14default_deleteISH_EEDpOT0_+0x5a) [0x55b5a3b2d2c8]
./prometheus_example(_ZN10prometheus7ExposerC1ESt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EEPK14CivetCallbacks+0x49) [0x55b5a3b2c765]
./prometheus_example(_ZN10prometheus7ExposerC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmPK14CivetCallbacks+0x141) [0x55b5a3b2c5fb]
./prometheus_example(_ZN13opentelemetry2v18exporter7metrics18PrometheusExporterC2ERKNS2_25PrometheusExporterOptionsE+0xa8) [0x55b5a3b14580]
./prometheus_example(+0x2d5737) [0x55b5a3a71737]
./prometheus_example(main+0x134) [0x55b5a3a725eb]
/lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f4d0a0e3d90]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7f4d0a0e3e40]
./prometheus_example(_start+0x25) [0x55b5a3a714f5]

The issue comes from the prometheus exporter. It uses civet server and, as the error states, generates a null context and throws at this part of the code:
image

@esigo esigo self-assigned this Jan 6, 2023
@esigo
Copy link
Member

esigo commented Jan 7, 2023

Hi @bachittle,
Thanks for reaching out to us.
Is your port 8080 already used by some other process when you run into this issue?

@bachittle
Copy link
Contributor Author

well that is what is being used by prometheus. Unless the address you specify in the url is what is used by another process (civet web server)? In that case how do you specify where the prometheus url is?

@esigo
Copy link
Member

esigo commented Jan 8, 2023

sorry I mentioned the wrong port. The default port for the example app is 9464. You could change the port with:
bazel run //examples/prometheus/... -- all localhost:<port>
or pass all localhost:<port> as arg to your executable. You then need to update the port in the yaml file.
Please make sure the port is not used by any other app.

@bachittle
Copy link
Contributor Author

ok, so the documentation seems to be a bit confusing then in this regard. It says it will export data via the metrics_exporter::PrometheusExporterOptions::url, but in the code this is set to localhost:8080, not localhost:9464. Also, I tried running prometheus on port 9464 and it did not connect and show metrics results. Maybe I am just confused as to how it works, perhaps this documentation can also be fixed?

@lalitb
Copy link
Member

lalitb commented Feb 8, 2023

Also, I tried running prometheus on port 9464 and it did not connect and show metrics results.

@bachittle - There are few changes in prometheus exporter recently in main branch (#1953), can you follow the example and see if you can fetch the metrics - https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/prometheus/main.cc

Meanwhile, will go through the docs and modify the steps documented there.

@bachittle
Copy link
Contributor Author

thank you, have been working on other things but glad this got fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants