You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use opentelemetry prometheus exporter WITHOUT the CivetWeb Webserver that is baked into prometheus-cpp.
The current target provided by this package is prometheus_exporter which links against prometheus-cpp::pull & prometheus-cpp::core
The pull dependency brings in the civetweb server in as well. Since our application already has a webserver (boost::beast) we'd like to avoid this.
Describe the solution you'd like
If this library provided a separate target for the prometheus/exporter_utils.cc file - which would only link against prometheus-cpp::core, I'd be able to use it.
Describe alternatives you've considered
Currently, I'm using a local copy of the source and I've added this separate target for 1 cc file and it all works locally.
Additional context
Here's the code that I have for my PrometheusExporter - it differs from the one present in lib as it has no PrometheusCollector & no Exposer:
#pragma once
#include<memory>
#include<mutex>
#include<sstream>
#include<string>
#include<vector>
#include<opentelemetry/exporters/prometheus/exporter_utils.h>
#include<opentelemetry/sdk/metrics/metric_reader.h>
#include<prometheus/collectable.h>
#include<prometheus/text_serializer.h>classPrometheusExporter : publicopentelemetry::sdk::metrics::MetricReader
{
public:
opentelemetry::sdk::metrics::AggregationTemporality GetAggregationTemporality(
opentelemetry::sdk::metrics::InstrumentType /*instrument_type*/) constnoexceptoverride
{
return opentelemetry::sdk::metrics::AggregationTemporality::kCumulative;
};
std::vector<prometheus::MetricFamily> CollectPrometheus()
{
if (IsShutdown())
{
return {};
}
collection_lock_.lock();
std::vector<prometheus::MetricFamily> result;
auto status = Collect([&result](opentelemetry::sdk::metrics::ResourceMetrics& metric_data) {
auto prometheus_metric_data
= opentelemetry::exporter::metrics::PrometheusExporterUtils::TranslateToPrometheus(
metric_data, true, true);
for (auto& data : prometheus_metric_data)
result.emplace_back(data);
returntrue;
});
collection_lock_.unlock();
return result;
}
std::string serialize()
{
// TODO: Do we need to allocate this stream here?// What if we took the boost stream itself as an arg & wrote to it?
std::ostringstream output;
prometheus::TextSerializer().Serialize(output, CollectPrometheus());
return output.str();
};
private:mutable std::mutex collection_lock_;
boolOnForceFlush(std::chrono::microseconds /*timeout*/) noexceptoverride { returntrue; };
boolOnShutDown(std::chrono::microseconds /*timeout*/) noexceptoverride { returntrue; };
};
The text was updated successfully, but these errors were encountered:
marcalff
added
triage/accepted
Indicates an issue or PR is ready to be actively worked on.
and removed
needs-triage
Indicates an issue or PR lacks a `triage/foo` label and requires one.
labels
Mar 6, 2024
dufferzafar
added a commit
to dufferzafar/opentelemetry-cpp
that referenced
this issue
Apr 23, 2024
Is your feature request related to a problem?
I'm trying to use opentelemetry prometheus exporter WITHOUT the CivetWeb Webserver that is baked into prometheus-cpp.
The current target provided by this package is
prometheus_exporter
which links againstprometheus-cpp::pull
&prometheus-cpp::core
The
pull
dependency brings in the civetweb server in as well. Since our application already has a webserver (boost::beast) we'd like to avoid this.Describe the solution you'd like
If this library provided a separate target for the
prometheus/exporter_utils.cc
file - which would only link againstprometheus-cpp::core
, I'd be able to use it.Describe alternatives you've considered
Currently, I'm using a local copy of the source and I've added this separate target for 1 cc file and it all works locally.
Additional context
Here's the code that I have for my PrometheusExporter - it differs from the one present in lib as it has no PrometheusCollector & no Exposer:
The text was updated successfully, but these errors were encountered: