https://signoz.io logo
#general
Title
# general
d

Deep Desai

08/17/2023, 4:46 AM
Hi, I am trying to send custom metrics using otel. But I am unable to see them on the signoz dashboard. Do we have to do any configuration for custom metrics
v

Vishal Sharma

08/17/2023, 5:22 AM
@Srikanth Chekuri Can you please help here?
d

Deep Desai

08/17/2023, 6:13 AM
Copy code
meter:=otel.Meter("queue")
counter,err:=meter.Int64Counter("adduser")
if err!=nil{
   return
}
counter.Add(c.Request.Context(),1)
sample code
s

Srikanth Chekuri

08/17/2023, 8:57 AM
If you are not able to see they it’s most probably not received. Can you use
stdout
exporter and confirm if the instrumentation is working?
d

Deep Desai

08/17/2023, 8:58 AM
instrumentation specific to metrics?? As the trace and all other things are working
s

Srikanth Chekuri

08/17/2023, 8:59 AM
and all other things
What are these all other things? Please use stdout exporter for metrics and see if the custom metrics is written to console.
d

Deep Desai

08/17/2023, 9:00 AM
sure will check that, other things means traces and host metrics
will confirm after checking stdout exporter for metrics
@Srikanth Chekuri: I cant see it after enabling stdout
below is the init tracer function used
Copy code
func initTracer() func(context.Context) error {

   secureOption := otlptracegrpc.WithTLSCredentials(credentials.NewClientTLSFromCert(nil, ""))
   if len(insecure) > 0 {
      secureOption = otlptracegrpc.WithInsecure()
   }

   exporter, err := stdouttrace.New(stdouttrace.WithPrettyPrint())
   if err != nil {
      log.Fatalf("failed to initialize stdout export pipeline: %v", err)
   }

   tracer, err := otlptrace.New(
      context.Background(),
      otlptracegrpc.NewClient(
         secureOption,
         otlptracegrpc.WithEndpoint(collectorURL),
      ),
   )

   if err != nil {
      log.Fatal(err)
   }
   resources, err := resource.New(
      context.Background(),
      resource.WithAttributes(
         attribute.String("service.name", serviceName),
         attribute.String("library.language", "go"),
      ),
   )
   if err != nil {
      log.Println("Could not set resources: ", err)
   }

   otel.SetTracerProvider(
      sdktrace.NewTracerProvider(
         sdktrace.WithSampler(sdktrace.AlwaysSample()),
         sdktrace.WithBatcher(tracer),
         sdktrace.WithBatcher(exporter),
         sdktrace.WithResource(resources),
      ),
   )

   return tracer.Shutdown
}
@Srikanth Chekuri: gentle reminder on this
s

Srikanth Chekuri

08/18/2023, 6:51 AM
You haven’t set up the metric exporter pipeline for otlp/stdout (the above one is a trace pipeline). Please do, and the metrics will show up.
d

Deep Desai

08/21/2023, 5:03 AM
Thanks was able to get the metrics
3 Views