Hi,

Can someone help me, please?

*My code is in attachment*.

I created the Metric class to has the static construtor (here I create a 
MetricServer instance and start it). My Metric class has also all metrics 
that i need (for now it has just a Counter).

In CounterTest() method my objective is to publish something like:

example_of_a_name{sys="my-app-name",env="dev",comp="SenderX",ep="n/a",met="n/a",status_code="n/a"}
 
4 

example_of_a_name{sys="my-app-name",env="dev",comp="SenderY",ep="n/a",met="n/a",status_code="n/a"}
 
1  

With this code, i don't have any error/exception but the metrics are not 
published on the server. 


-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/ae748c46-ab22-4131-95ae-5aa37ae0bacan%40googlegroups.com.
public static class Metric {

         private static readonly string[] labelNames = new[] {
            "sys", // should have as value the name of the system 
            "env", // the environment, "prd", “tst”, “dev”
            "comp", // the name of the component that is sending the metric
            "ep", // the endpoint path of the api we are monitoring
            "met", // the method used for the api, “get”, “delete”, “push”, 
“put”, etc
            "status_code" //if it's >= 200 and <=399 then SUCCESS, otherwise 
(>=400 and <=599) ERROR
        };
                
         public static readonly Counter Rate = 
Metrics.CreateCounter("example_of_a_name", "Number of requests received. Just a 
sample.",
                                                                                
                                                        new CounterConfiguration
                                                                                
                                                        {
                                                                                
                                                                // Here you 
specify only the names of the labels.
                                                                                
                                                                LabelNames = 
labelNames
                                                                                
                                                        });

        static Metric {
                var pusher = new MetricPusher(new MetricPusherOptions
                {
                        Endpoint = "https://here_is_my_url/metrics";,
                        Job = "some_job"
                });

                pusher.Start();
        }

} //close static class Metric 

public class CounterTest() {
        
                [Fact]
        public void RateTest()
        {
            //Arrange
            string sys = "my-app-name";
            string env = "dev"
            string na = "n/a"
            
            //Act --> Here i retrieve metric Rate from my Metric class and 
after i set values to all labels                         
            Metric.Rate.WithLabels(sys, env, "SenderX", na, na, na).Inc();
            Metric.Rate.WithLabels(sys, env, "SenderY", na, na, na).Inc();
            Metric.Rate.WithLabels(sys, env, "SenderX", na, na, na).Inc();
            Metric.Rate.WithLabels(sys, env, "SenderX", na, na, na).Inc();
            Metric.Rate.WithLabels(sys, env, "SenderX", na, na, na).Inc();

            //Assert
            Assert.Equal(1, 1);

        }

} //close class CounterTest

Reply via email to