diff --git a/README.md b/README.md index 8d3ce2c..28a04eb 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ Usage of exas: --address string [server] Listen address ${EXAS_ADDRESS} --amqpExchange string [amqp] Exchange name ${EXAS_AMQP_EXCHANGE} (default "fibr") --amqpExclusive [amqp] Queue exclusive mode (for fanout exchange) ${EXAS_AMQP_EXCLUSIVE} (default false) + --amqpInactiveTimeout duration [amqp] When inactive during the given timeout, stop listening ${EXAS_AMQP_INACTIVE_TIMEOUT} (default 0s) --amqpMaxRetry uint [amqp] Max send retries ${EXAS_AMQP_MAX_RETRY} (default 3) --amqpPrefetch int [amqp] Prefetch count for QoS ${EXAS_AMQP_PREFETCH} (default 1) --amqpQueue string [amqp] Queue name ${EXAS_AMQP_QUEUE} (default "exas") @@ -49,8 +50,10 @@ Usage of exas: --loggerLevelKey string [logger] Key for level in JSON ${EXAS_LOGGER_LEVEL_KEY} (default "level") --loggerMessageKey string [logger] Key for message in JSON ${EXAS_LOGGER_MESSAGE_KEY} (default "msg") --loggerTimeKey string [logger] Key for timestamp in JSON ${EXAS_LOGGER_TIME_KEY} (default "time") + --name string [server] Name ${EXAS_NAME} (default "http") --okStatus int [http] Healthy HTTP Status code ${EXAS_OK_STATUS} (default 204) --port uint [server] Listen port (0 to disable) ${EXAS_PORT} (default 1080) + --pprofAgent string [pprof] URL of the Datadog Trace Agent (e.g. http://datadog.observability:8126) ${EXAS_PPROF_AGENT} --readTimeout duration [server] Read Timeout ${EXAS_READ_TIMEOUT} (default 2m0s) --routingKey string [exas] AMQP Routing Key to fibr ${EXAS_ROUTING_KEY} (default "exif_output") --shutdownTimeout duration [server] Shutdown Timeout ${EXAS_SHUTDOWN_TIMEOUT} (default 10s) @@ -65,6 +68,7 @@ Usage of exas: --storagePartSize uint [storage] PartSize configuration ${EXAS_STORAGE_PART_SIZE} (default 5242880) --telemetryRate string [telemetry] OpenTelemetry sample rate, 'always', 'never' or a float value ${EXAS_TELEMETRY_RATE} (default "always") --telemetryURL string [telemetry] OpenTelemetry gRPC endpoint (e.g. otel-exporter:4317) ${EXAS_TELEMETRY_URL} + --telemetryUint64 [telemetry] Change OpenTelemetry Trace ID format to an unsigned int 64 ${EXAS_TELEMETRY_UINT64} (default true) --url string [alcotest] URL to check ${EXAS_URL} --userAgent string [alcotest] User-Agent for check ${EXAS_USER_AGENT} (default "Alcotest") --writeTimeout duration [server] Write Timeout ${EXAS_WRITE_TIMEOUT} (default 2m0s) diff --git a/cmd/exas/api.go b/cmd/exas/api.go index ed20202..547e096 100644 --- a/cmd/exas/api.go +++ b/cmd/exas/api.go @@ -22,6 +22,7 @@ import ( "github.com/ViBiOh/httputils/v4/pkg/health" "github.com/ViBiOh/httputils/v4/pkg/httputils" "github.com/ViBiOh/httputils/v4/pkg/logger" + "github.com/ViBiOh/httputils/v4/pkg/pprof" "github.com/ViBiOh/httputils/v4/pkg/recoverer" "github.com/ViBiOh/httputils/v4/pkg/request" "github.com/ViBiOh/httputils/v4/pkg/server" @@ -38,7 +39,7 @@ func main() { alcotestConfig := alcotest.Flags(fs, "") loggerConfig := logger.Flags(fs, "logger") telemetryConfig := telemetry.Flags(fs, "telemetry") - + pprofConfig := pprof.Flags(fs, "pprof") exasConfig := exas.Flags(fs, "") abstoConfig := absto.Flags(fs, "storage", flags.NewOverride("FileSystemDirectory", "")) geocodeConfig := geocode.Flags(fs, "") @@ -54,6 +55,8 @@ func main() { ctx := context.Background() + healthService := health.New(ctx, healthConfig) + telemetryService, err := telemetry.New(ctx, telemetryConfig) logger.FatalfOnErr(ctx, err, "create telemetry") @@ -62,12 +65,16 @@ func main() { logger.AddOpenTelemetryToDefaultLogger(telemetryService) request.AddOpenTelemetryToDefaultClient(telemetryService.MeterProvider(), telemetryService.TracerProvider()) + service, version, envName := telemetryService.GetServiceVersionAndEnv() + pprofApp := pprof.New(pprofConfig, service, version, envName) + go func() { fmt.Println(http.ListenAndServe("localhost:9999", http.DefaultServeMux)) }() + go pprofApp.Start(healthService.DoneCtx()) + appServer := server.New(appServerConfig) - healthService := health.New(ctx, healthConfig) storageProvider, err := absto.New(abstoConfig, telemetryService.TracerProvider()) logger.FatalfOnErr(ctx, err, "create absto") diff --git a/go.mod b/go.mod index 4373789..a377620 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ toolchain go1.22.0 require ( github.com/ViBiOh/absto v1.7.9 github.com/ViBiOh/flags v1.5.0 - github.com/ViBiOh/httputils/v4 v4.75.1 + github.com/ViBiOh/httputils/v4 v4.75.2 github.com/rabbitmq/amqp091-go v1.9.0 go.opentelemetry.io/otel v1.26.0 go.opentelemetry.io/otel/metric v1.26.0 diff --git a/go.sum b/go.sum index 34dd2a5..4247cc4 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/ViBiOh/absto v1.7.9 h1:OkgZm+2fslowGOn2r7sap3DQPQpolL6imP2k1LtPlaM= github.com/ViBiOh/absto v1.7.9/go.mod h1:7SGXBLLqyhCx1i3EBCqPaB4T3Qju/cZkV5Wvh56rDpc= github.com/ViBiOh/flags v1.5.0 h1:nwuFS8tAwtV6rTPpv2pCB+r12WjZYLjluW7yT+SeVpQ= github.com/ViBiOh/flags v1.5.0/go.mod h1:39UMuTnKsIp6walgD8dK99KRCb4DJt9vPtbWehHh1T0= -github.com/ViBiOh/httputils/v4 v4.75.1 h1:HPQ9zzs9qaNaXz7sbmqFFp+PQthnwHXElfI3Ii1JCB0= -github.com/ViBiOh/httputils/v4 v4.75.1/go.mod h1:hjrxCv58B8RFGgGNjIOBXqnzoYL7De2IjC2AIMsRKWU= +github.com/ViBiOh/httputils/v4 v4.75.2 h1:U+768KbZA4TS1KDfic4gZaeLRhXP3h9/cYrqI3hzZjc= +github.com/ViBiOh/httputils/v4 v4.75.2/go.mod h1:hjrxCv58B8RFGgGNjIOBXqnzoYL7De2IjC2AIMsRKWU= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= diff --git a/infra/api.yaml b/infra/api.yaml index 44aa43d..7b26bbd 100644 --- a/infra/api.yaml +++ b/infra/api.yaml @@ -59,6 +59,7 @@ spec: config: EXAS_GEOCODE_URL: "https://nominatim.openstreetmap.org" EXAS_LOGGER_JSON: "true" + EXAS_PPROF_AGENT: http://datadog.observability:8126 EXAS_STORAGE_FILE_SYSTEM_DIRECTORY: "/data" EXAS_TELEMETRY_URL: datadog.observability:4317 OTEL_RESOURCE_ATTRIBUTES: env=production,git.repository_url=github.com/ViBiOh/exas