Skip to content

Commit

Permalink
ci: Adding pprof exporter
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed May 4, 2024
1 parent 346f8ef commit afdc49f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand All @@ -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)
Expand Down
11 changes: 9 additions & 2 deletions cmd/exas/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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, "")
Expand All @@ -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")

Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
1 change: 1 addition & 0 deletions infra/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit afdc49f

Please sign in to comment.