Skip to content

codefresh-io/cf-telemetry-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cf-telemetry-go

Base utils for monitoring.

Usage

add

import cfotel "github.com/codefresh-io/cf-telemetry-go/pkg/otel"

...

func main() {
  ...
  tpShutdown, err := cfotel.InitGlobalTraceProvider(ctx)
  if err != nil {
    panic(err)
  }

  defer func() {
    traceErr, meterErr := tpShutdown(ctx)
    if traceErr != nil {
      log.Errorf("Error shutting down tracer %v", traceErr)
    }

    if meterErr != nil {
      log.Errorf("Error shutting down metrics %v", meterErr)
    }
  }()
  ...
}

to initialize tracing and metrics instrumentation. follow instructions to add metrics and create trace spans.

Environment variables

Variable Required Default value Example Description
OTEL_SDK_DISABLED optional "false" "true" If “true”, a no-op SDK implementation will be used for all telemetry signals.
OTEL_SERVICE_NAME optional "" application-event-reporter sets service name for traces and metrics
OTEL_RESOURCE_ATTRIBUTES optional "" version=1.2.3,runtime=runtime-name comma-seperated key=value pairs that will be included in the reported resource
OTEL_EXPORTER_OTLP_ENDPOINT optional https://localhost:4317 https://g.codefresh.io/api/otel target to which the exporter sends traces and metrics
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT optional https://localhost:4317 https://g.codefresh.io/api/otel target to which the exporter sends traces
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT optional https://localhost:4317 https://g.codefresh.io/api/otel target to which the exporter sends metrics
OTEL_EXPORTER_OTLP_PROTOCOL optional http/protobuf groc defines OTLP exporter's transport protocol
OTEL_TRACES_EXPORTER optional none otlp Trace exporter to be used
OTEL_METRICS_EXPORTER optional none otlp or prometheus Metrics exporter to be used
OTEL_METRIC_EXPORT_INTERVAL optional 60000 - The time interval (in milliseconds) between the start of two export attempts.
OTEL_METRIC_EXPORT_TIMEOUT optional 30000 - Maximum allowed time (in milliseconds) to export data.
OTEL_EXPORTER_PROMETHEUS_HOST optional localhost - define the host for the Prometheus exporter's HTTP server.
OTEL_EXPORTER_PROMETHEUS_PORT optional 9464 - define the port for the Prometheus exporter's HTTP server.

more fine-grained env-variables for the different exporters can be found here and here.

About

enable simple telemetry for our golang servers

Topics

Resources

Stars

Watchers

Forks

Contributors 2

  •  
  •