Reputation: 29
What is an analogue of the publishing-to-pushgateway mechanism class in opentelemetry or another mechanism for sending metrics from a Windows application to the Web application (which collects all metrics by application names and sends them to Prometheus)? Both applications are hosted in docker containers.
https://github.com/prometheus-net/prometheus-net?tab=readme-ov-file#publishing-to-pushgateway
It’s interesting to use this pattern in the example code for sending and receiving metrics. I don’t fully understand the work of an open-telemetry-collector, but I think it performs other functions.
public class Program
{
private static readonly ActivitySource MyActivitySource = new("OpenTelemetry.Demo.Exemplar");
public static void Main()
{
var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource("OpenTelemetry.Demo.Exemplar")
.AddOtlpExporter()
.Build();
var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddMeter("OpenTelemetry.Demo.Exemplar")
.AddOtlpExporter((exporterOptions, metricReaderOptions) =>
{
exporterOptions.Endpoint = new Uri("http://localhost:9090/api/v1/otlp/v1/metrics");
exporterOptions.Protocol = OtlpExportProtocol.HttpProtobuf;
})
.Build();
Upvotes: 0
Views: 88
Reputation: 479
OpenTelemetry metrics are typically push based, similar to what you've seen with the Prometheus push gateway. The OpenTelemetry Collector accepts metrics pushed to it via gRPC or protobuf over HTTP. Some SDKs do implement exporters with pull based endpoints, but pushing is much more common.
After having metrics pushed to it, the OpenTelemetry Collector can expose an endpoint for Prometheus to scrape received metrics from, or push to Prometheus via remote write.
The same concept applies to metrics, traces, logs, and profiles - all four are typically push from applications to a collector instance or directly to an appropriate database.
Upvotes: 0