Skip to content

Add C++ Prometheus Exporter Example Program#310

Closed
erichsueh3 wants to merge 6 commits into
open-telemetry:masterfrom
erichsueh3:example
Closed

Add C++ Prometheus Exporter Example Program#310
erichsueh3 wants to merge 6 commits into
open-telemetry:masterfrom
erichsueh3:example

Conversation

@erichsueh3
Copy link
Copy Markdown
Contributor

This PR implements an example program for C++ Prometheus Exporter. All related files are in the examples/prometheus_exporter folder. In order to run this example program, users need to modify the Prometheus configuration yaml file and start a Prometheus instance. There is a README.md included to help users setup and run the example program. At the end, we can view the exported result in Prometheus.

Changes:

  • main.cc implements the Prometheus Exporter example program
  • BUILD is the program build file for Bazel
  • CMakeLists.txt is the build configuration for CMake
  • README.md has step by step instructions to run this example

Primary contribution for this example was done by @CunjunWang

@erichsueh3 erichsueh3 requested a review from a team August 31, 2020 21:20
@CunjunWang
Copy link
Copy Markdown
Contributor

Thank you, Eric. This PR depends on the Prometheus Exporter class, and it should be working after #263 is merged.

Comment thread examples/prometheus_exporter/main.cc Outdated
Comment thread examples/prometheus_exporter/main.cc Outdated
Comment thread examples/prometheus_exporter/main.cc Outdated
Comment thread examples/prometheus_exporter/main.cc
Comment thread examples/prometheus_exporter/README.md Outdated
```shell script
bazel build //examples/prometheus_exporter:prometheus_exporter_example
bazel-bin/examples/prometheus_exporter/prometheus_exporter_example
bazel-bin/examples/prometheus_exporter/prometheus_exporter_example agg
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

agg -> counter so people can copy-paste this example.

"agg" is like a usage statement, "counter" is an example, which is what this block is :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, changed "agg" to "histogram" instead of "counter" to be more consistent with the example

Comment thread examples/prometheus_exporter/README.md Outdated
```

Run with Bazel:
```shell script
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you only need ```shell

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

int main()
int main(int argc, char** argv)
{
std::string agg(argv[1]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please handle argc < 2 before doing this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Missed this earlier, but fixed now.

@reyang reyang closed this Oct 7, 2020
GerHobbelt pushed a commit to GerHobbelt/opentelemetry-cpp that referenced this pull request Jun 17, 2025
…chmark-1.x

Update dependency google_benchmark to v1.9.4
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.

4 participants