From ac080d5f4bd2eb9135ab7700bdc1714c260d1e66 Mon Sep 17 00:00:00 2001 From: kkumar-gcc Date: Sun, 8 Feb 2026 01:42:22 +0530 Subject: [PATCH 1/4] install telemetry facade --- app/facades/telemetry.go | 9 +++++ bootstrap/providers.go | 2 + config/logging.go | 4 ++ config/telemetry.go | 80 ++++++++++++++++++++++++++++++++++++++-- go.mod | 4 ++ go.sum | 6 ++- 6 files changed, 100 insertions(+), 5 deletions(-) create mode 100755 app/facades/telemetry.go diff --git a/app/facades/telemetry.go b/app/facades/telemetry.go new file mode 100755 index 0000000..78dba26 --- /dev/null +++ b/app/facades/telemetry.go @@ -0,0 +1,9 @@ +package facades + +import ( + "github.com/goravel/framework/contracts/telemetry" +) + +func Telemetry() telemetry.Telemetry { + return App().MakeTelemetry() +} diff --git a/bootstrap/providers.go b/bootstrap/providers.go index 2cc1078..13f2f3f 100644 --- a/bootstrap/providers.go +++ b/bootstrap/providers.go @@ -20,6 +20,7 @@ import ( "github.com/goravel/framework/route" "github.com/goravel/framework/schedule" "github.com/goravel/framework/session" + "github.com/goravel/framework/telemetry" "github.com/goravel/framework/testing" "github.com/goravel/framework/translation" "github.com/goravel/framework/validation" @@ -68,5 +69,6 @@ func Providers() []foundation.ServiceProvider { &redis.ServiceProvider{}, &gin.ServiceProvider{}, &fiber.ServiceProvider{}, + &telemetry.ServiceProvider{}, } } diff --git a/config/logging.go b/config/logging.go index d65e048..5d35f34 100644 --- a/config/logging.go +++ b/config/logging.go @@ -39,6 +39,10 @@ func init() { "print": true, "formatter": "text", }, + "otel": map[string]any{ + "driver": "otel", + "instrument_name": config.GetString("APP_NAME", "goravel/log"), + }, }, }) } diff --git a/config/telemetry.go b/config/telemetry.go index ab056a2..cccf5b7 100755 --- a/config/telemetry.go +++ b/config/telemetry.go @@ -49,7 +49,7 @@ func init() { // // The name of the exporter definition in the "exporters" section below. // Set to "" to disable tracing. - "exporter": config.Env("OTEL_TRACES_EXPORTER", "otlptrace"), + "exporter": config.Env("OTEL_TRACES_EXPORTER"), // Sampler Configuration // @@ -80,7 +80,7 @@ func init() { // // The name of the exporter definition in the "exporters" section below. // Set to "" to disable metrics. - "exporter": config.Env("OTEL_METRICS_EXPORTER", "otlpmetric"), + "exporter": config.Env("OTEL_METRICS_EXPORTER"), // Reader Configuration // @@ -106,7 +106,7 @@ func init() { // // The name of the exporter definition in the "exporters" section below. // Set to "" to disable OTel logging. - "exporter": config.Env("OTEL_LOGS_EXPORTER", "otlplog"), + "exporter": config.Env("OTEL_LOGS_EXPORTER"), // Processor Configuration // @@ -122,6 +122,56 @@ func init() { }, }, + // Instrumentation Configuration + // + // Configures the automatic instrumentation for specific components. + "instrumentation": map[string]any{ + // HTTP Server Instrumentation + // + // Configures the telemetry middleware for incoming HTTP requests. + "http_server": map[string]any{ + "enabled": config.Env("OTEL_HTTP_SERVER_ENABLED", true), + "excluded_paths": []string{}, // e.g., ["/health", "/metrics"] + "excluded_methods": []string{}, // e.g., ["OPTIONS", "HEAD"] + }, + + // HTTP Client Instrumentation + // + // Configures instrumentation for outgoing HTTP requests made through the + // application's HTTP client facade. This acts as a global kill switch for + // HTTP client telemetry across all clients. + // + // To disable telemetry for a specific client, set + // "http.clients.{client_name}.enable_telemetry" to false for the + // corresponding client configuration. + "http_client": map[string]any{ + "enabled": config.Env("OTEL_HTTP_CLIENT_ENABLED", true), + }, + + // gRPC Server Instrumentation + // + // Configures the instrumentation for incoming gRPC requests to your server. + "grpc_server": map[string]any{ + "enabled": config.Env("OTEL_GRPC_SERVER_ENABLED", true), + }, + + // gRPC Client Instrumentation + // + // Configures the instrumentation for outgoing gRPC calls made by your application. + "grpc_client": map[string]any{ + "enabled": config.Env("OTEL_GRPC_CLIENT_ENABLED", true), + }, + + // Log Instrumentation + // + // Configures the instrumentation for the application logger. + // Disabling this acts as a global kill switch for sending logs to the OTel exporter, + // which can be useful for reducing cost/noise without changing logging config. + "log": map[string]any{ + "enabled": config.Env("OTEL_LOG_ENABLED", true), + }, + }, + // Exporters Configuration // // Defines the details for connecting to external telemetry backends. @@ -150,7 +200,11 @@ func init() { "otlpmetric": map[string]any{ "driver": "otlp", "endpoint": config.Env("OTEL_EXPORTER_OTLP_METRICS_ENDPOINT", "http://localhost:4318"), + + // Protocol: "http/protobuf", "http/json" or "grpc". "protocol": config.Env("OTEL_EXPORTER_OTLP_METRICS_PROTOCOL", "http/protobuf"), + + // Set to false to require TLS/SSL. "insecure": config.Env("OTEL_EXPORTER_OTLP_METRICS_INSECURE", true), // Timeout: Max time to wait for the backend to acknowledge. @@ -167,7 +221,11 @@ func init() { "otlplog": map[string]any{ "driver": "otlp", "endpoint": config.Env("OTEL_EXPORTER_OTLP_LOGS_ENDPOINT", "http://localhost:4318"), + + // Protocol: "http/protobuf", "http/json" or "grpc". "protocol": config.Env("OTEL_EXPORTER_OTLP_LOGS_PROTOCOL", "http/protobuf"), + + // Set to false to require TLS/SSL. "insecure": config.Env("OTEL_EXPORTER_OTLP_LOGS_INSECURE", true), // Timeout: Max time to wait for the backend to acknowledge. @@ -185,6 +243,22 @@ func init() { // Prints telemetry data to stdout. "console": map[string]any{ "driver": "console", + + // Set to true to pretty print the output. + "pretty_print": false, + }, + + // Custom Exporter + // + // Use this to provide your own exporter implementation. + // The "via" key should contain an instance of your custom exporter. + "custom": map[string]any{ + "driver": "custom", + + // For traces, via should be an instance of go.opentelemetry.io/otel/sdk/trace.SpanExporter or func(context.Context) (sdktrace.SpanExporter, error) + // For metrics, via should be an instance of go.opentelemetry.io/otel/sdk/metric.Reader or func(context.Context) (sdkmetric.Reader, error) + // For log, via should be an instance of go.opentelemetry.io/otel/sdk/log.Exporter or func(context.Context) (sdklog.Exporter, error) + // "via": YourCustomExporterInstance, }, }, }) diff --git a/go.mod b/go.mod index e9e92c5..104c8fe 100644 --- a/go.mod +++ b/go.mod @@ -83,6 +83,7 @@ require ( github.com/dromara/carbon/v2 v2.6.11 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect github.com/gabriel-vasile/mimetype v1.4.13 // indirect github.com/gin-contrib/sse v1.1.0 // indirect @@ -190,6 +191,7 @@ require ( github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0 // indirect go.opentelemetry.io/contrib/propagators/b3 v1.39.0 // indirect go.opentelemetry.io/otel v1.39.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.15.0 // indirect @@ -234,3 +236,5 @@ require ( gorm.io/gorm v1.31.1 // indirect gorm.io/plugin/dbresolver v1.6.2 // indirect ) + +replace github.com/goravel/framework v1.17.0 => ../framework diff --git a/go.sum b/go.sum index 607fa39..a2646b0 100644 --- a/go.sum +++ b/go.sum @@ -179,6 +179,8 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4= github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM= +github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= +github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= @@ -279,8 +281,6 @@ github.com/goravel/fiber v1.17.0 h1:XMkuz29hJzaN5mW7dK70oc6FfMDUQeYPbrLyBQoiIA8= github.com/goravel/fiber v1.17.0/go.mod h1:hu2eLwQ6u8ZDFsVWHeV1q0bh7g7PRQg0VZxceVr29Uc= github.com/goravel/file-rotatelogs/v2 v2.4.2 h1:g68AzbePXcm0V2CpUMc9j4qVzcDn7+7aoWSjZ51C0m4= github.com/goravel/file-rotatelogs/v2 v2.4.2/go.mod h1:23VuSW8cBS4ax5cmbV+5AaiLpq25b8UJ96IhbAkdo8I= -github.com/goravel/framework v1.17.0 h1:a02vTMO7ETQE+fkpfndiNgSXucJKA58qB3nzm+moW6A= -github.com/goravel/framework v1.17.0/go.mod h1:ClgXBsig8R2w+xAJT2TVxpAkazGHFtvVmNBolYT94gQ= github.com/goravel/gin v1.17.0 h1:8H66v9GaYJR9UQ7C0VOef25/r8t/BAH9ZxlvxbHprlc= github.com/goravel/gin v1.17.0/go.mod h1:n0W6V/H+E0mqO+Gh+UMjeBANZe//lpWJ6X7kF3kwxR8= github.com/goravel/minio v1.17.0 h1:WGiPP/KZl/fuDpT9THRM83wjhLCqe1oIAyNVJvVjhS4= @@ -549,6 +549,8 @@ github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3i github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0 h1:ssfIgGNANqpVFCndZvcuyKbl0g+UAVcbBcqGkG28H0Y= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0/go.mod h1:GQ/474YrbE4Jx8gZ4q5I4hrhUzM6UPzyrqJYV2AqPoQ= go.opentelemetry.io/contrib/propagators/b3 v1.39.0 h1:PI7pt9pkSnimWcp5sQhUA9OzLbc3Ba4sL+VEUTNsxrk= go.opentelemetry.io/contrib/propagators/b3 v1.39.0/go.mod h1:5gV/EzPnfYIwjzj+6y8tbGW2PKWhcsz5e/7twptRVQY= go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48= From 2faabbd32369fb9c41645325bd32eb706a780b53 Mon Sep 17 00:00:00 2001 From: kkumar-gcc Date: Sun, 8 Feb 2026 02:00:44 +0530 Subject: [PATCH 2/4] add telemetry auto instrumentation --- bootstrap/app.go | 13 +++++++++++-- config/http.go | 1 + config/logging.go | 2 +- config/telemetry.go | 6 +++--- go.mod | 1 + go.sum | 2 ++ 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/bootstrap/app.go b/bootstrap/app.go index 6ea51ac..6509953 100644 --- a/bootstrap/app.go +++ b/bootstrap/app.go @@ -12,6 +12,8 @@ import ( "github.com/goravel/framework/http/limit" httpmiddleware "github.com/goravel/framework/http/middleware" "github.com/goravel/framework/session/middleware" + telemetrygrpc "github.com/goravel/framework/telemetry/instrumentation/grpc" + telemetryhttp "github.com/goravel/framework/telemetry/instrumentation/http" "google.golang.org/grpc" "google.golang.org/grpc/stats" @@ -50,6 +52,7 @@ func Boot() contractsfoundation.Application { handler.Append( httpmiddleware.Throttle("global"), middleware.StartSession(), + telemetryhttp.Telemetry(facades.Config(), facades.Telemetry()), ).Recover(func(ctx http.Context, err any) { facades.Log().Error(err) _ = ctx.Response().String(http.StatusInternalServerError, "recover").Abort() @@ -68,10 +71,16 @@ func Boot() contractsfoundation.Application { } }). WithGrpcServerStatsHandlers(func() []stats.Handler { - return []stats.Handler{} + return []stats.Handler{ + telemetrygrpc.NewServerStatsHandler(facades.Config(), facades.Telemetry()), + } }). WithGrpcClientStatsHandlers(func() map[string][]stats.Handler { - return map[string][]stats.Handler{} + return map[string][]stats.Handler{ + "default": { + telemetrygrpc.NewClientStatsHandler(facades.Config(), facades.Telemetry()), + }, + } }). WithPaths(func(paths configuration.Paths) { paths.App("app") diff --git a/config/http.go b/config/http.go index 9652b1e..a871ae1 100644 --- a/config/http.go +++ b/config/http.go @@ -81,6 +81,7 @@ func init() { "max_idle_conns_per_host": config.Env("HTTP_CLIENT_MAX_IDLE_CONNS_PER_HOST", 2), "max_conns_per_host": config.Env("HTTP_CLIENT_MAX_CONN_PER_HOST", 0), "idle_conn_timeout": config.Env("HTTP_CLIENT_IDLE_CONN_TIMEOUT", "90s"), + "enable_telemetry": true, }, }, }) diff --git a/config/logging.go b/config/logging.go index 5d35f34..d3ddc59 100644 --- a/config/logging.go +++ b/config/logging.go @@ -22,7 +22,7 @@ func init() { "channels": map[string]any{ "stack": map[string]any{ "driver": "stack", - "channels": []string{"single", "daily"}, + "channels": []string{"single", "daily", "otel"}, }, "single": map[string]any{ "driver": "single", diff --git a/config/telemetry.go b/config/telemetry.go index cccf5b7..3f12a1c 100755 --- a/config/telemetry.go +++ b/config/telemetry.go @@ -49,7 +49,7 @@ func init() { // // The name of the exporter definition in the "exporters" section below. // Set to "" to disable tracing. - "exporter": config.Env("OTEL_TRACES_EXPORTER"), + "exporter": config.Env("OTEL_TRACES_EXPORTER", "console"), // Sampler Configuration // @@ -80,7 +80,7 @@ func init() { // // The name of the exporter definition in the "exporters" section below. // Set to "" to disable metrics. - "exporter": config.Env("OTEL_METRICS_EXPORTER"), + "exporter": config.Env("OTEL_METRICS_EXPORTER", "console"), // Reader Configuration // @@ -106,7 +106,7 @@ func init() { // // The name of the exporter definition in the "exporters" section below. // Set to "" to disable OTel logging. - "exporter": config.Env("OTEL_LOGS_EXPORTER"), + "exporter": config.Env("OTEL_LOGS_EXPORTER", "console"), // Processor Configuration // diff --git a/go.mod b/go.mod index 104c8fe..af0f924 100644 --- a/go.mod +++ b/go.mod @@ -191,6 +191,7 @@ require ( github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.64.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0 // indirect go.opentelemetry.io/contrib/propagators/b3 v1.39.0 // indirect go.opentelemetry.io/otel v1.39.0 // indirect diff --git a/go.sum b/go.sum index a2646b0..45782bb 100644 --- a/go.sum +++ b/go.sum @@ -549,6 +549,8 @@ github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3i github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.64.0 h1:RN3ifU8y4prNWeEnQp2kRRHz8UwonAEYZl8tUzHEXAk= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.64.0/go.mod h1:habDz3tEWiFANTo6oUE99EmaFUrCNYAAg3wiVmusm70= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0 h1:ssfIgGNANqpVFCndZvcuyKbl0g+UAVcbBcqGkG28H0Y= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0/go.mod h1:GQ/474YrbE4Jx8gZ4q5I4hrhUzM6UPzyrqJYV2AqPoQ= go.opentelemetry.io/contrib/propagators/b3 v1.39.0 h1:PI7pt9pkSnimWcp5sQhUA9OzLbc3Ba4sL+VEUTNsxrk= From f811217284685dade610a14ddbc5333008fc679e Mon Sep 17 00:00:00 2001 From: kkumar-gcc Date: Sun, 8 Feb 2026 03:13:12 +0530 Subject: [PATCH 3/4] add docker config for setting up telemetry services --- .env | 4 ++-- config/telemetry.go | 6 ++--- docker-compose.yml | 54 ++++++++++++++++++++++++++++++++++++++++++++- go.mod | 4 +--- go.sum | 2 ++ loki.yaml | 32 +++++++++++++++++++++++++++ otel-config.yaml | 41 ++++++++++++++++++++++++++++++++++ prometheus.yaml | 7 ++++++ 8 files changed, 141 insertions(+), 9 deletions(-) create mode 100644 loki.yaml create mode 100644 otel-config.yaml create mode 100644 prometheus.yaml diff --git a/.env b/.env index a131cf5..25834de 100644 --- a/.env +++ b/.env @@ -4,10 +4,10 @@ APP_KEY=ABCDEFGHIJKLMNOPQRSTUVWXYZ123456 APP_DEBUG=true APP_URL=http://localhost APP_HOST=127.0.0.1 -APP_PORT=3000 +APP_PORT=8080 GRPC_HOST=127.0.0.1 -GRPC_PORT=3001 +GRPC_PORT=3002 GRPC_USER_HOST=127.0.0.1 GRPC_USER_PORT=3001 diff --git a/config/telemetry.go b/config/telemetry.go index 3f12a1c..635c8c4 100755 --- a/config/telemetry.go +++ b/config/telemetry.go @@ -49,7 +49,7 @@ func init() { // // The name of the exporter definition in the "exporters" section below. // Set to "" to disable tracing. - "exporter": config.Env("OTEL_TRACES_EXPORTER", "console"), + "exporter": config.Env("OTEL_TRACES_EXPORTER", "otlptrace"), // Sampler Configuration // @@ -80,7 +80,7 @@ func init() { // // The name of the exporter definition in the "exporters" section below. // Set to "" to disable metrics. - "exporter": config.Env("OTEL_METRICS_EXPORTER", "console"), + "exporter": config.Env("OTEL_METRICS_EXPORTER", "otlpmetric"), // Reader Configuration // @@ -106,7 +106,7 @@ func init() { // // The name of the exporter definition in the "exporters" section below. // Set to "" to disable OTel logging. - "exporter": config.Env("OTEL_LOGS_EXPORTER", "console"), + "exporter": config.Env("OTEL_LOGS_EXPORTER", "otlplog"), // Processor Configuration // diff --git a/docker-compose.yml b/docker-compose.yml index 81f36ea..afde911 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3' +version: '3.8' services: goravel: @@ -6,4 +6,56 @@ services: context: . ports: - "3000:3000" + environment: + - OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318 + - OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf + - OTEL_TRACES_EXPORTER=otlptrace + - OTEL_METRICS_EXPORTER=otlpmetric + - OTEL_LOGS_EXPORTER=otlplog + depends_on: + - otel-collector + + otel-collector: + image: otel/opentelemetry-collector-contrib:latest + restart: always + command: ["--config=/etc/otel-config.yaml"] + volumes: + - ./otel-config.yaml:/etc/otel-config.yaml + ports: + - "4317:4317" + - "4318:4318" + + jaeger: + image: jaegertracing/all-in-one:latest + restart: always + ports: + - "16686:16686" + + prometheus: + image: prom/prometheus:latest restart: always + volumes: + - ./prometheus.yaml:/etc/prometheus/prometheus.yml + command: + - --config.file=/etc/prometheus/prometheus.yml + - --web.enable-remote-write-receiver + ports: + - "9090:9090" + + loki: + image: grafana/loki:latest + restart: always + volumes: + - ./loki.yaml:/etc/loki/local-config.yaml + command: -config.file=/etc/loki/local-config.yaml + ports: + - "3100:3100" + + grafana: + image: grafana/grafana:latest + restart: always + ports: + - "3001:3000" + environment: + - GF_AUTH_ANONYMOUS_ENABLED=true + - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin \ No newline at end of file diff --git a/go.mod b/go.mod index af0f924..f3ef41a 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/goravel/cos v1.17.0 github.com/goravel/example-proto v0.0.1 github.com/goravel/fiber v1.17.0 - github.com/goravel/framework v1.17.0 + github.com/goravel/framework v1.17.1-0.20260207193711-16b6ec3ccb18 github.com/goravel/gin v1.17.0 github.com/goravel/minio v1.17.0 github.com/goravel/mysql v1.17.0 @@ -237,5 +237,3 @@ require ( gorm.io/gorm v1.31.1 // indirect gorm.io/plugin/dbresolver v1.6.2 // indirect ) - -replace github.com/goravel/framework v1.17.0 => ../framework diff --git a/go.sum b/go.sum index 45782bb..fb5180d 100644 --- a/go.sum +++ b/go.sum @@ -281,6 +281,8 @@ github.com/goravel/fiber v1.17.0 h1:XMkuz29hJzaN5mW7dK70oc6FfMDUQeYPbrLyBQoiIA8= github.com/goravel/fiber v1.17.0/go.mod h1:hu2eLwQ6u8ZDFsVWHeV1q0bh7g7PRQg0VZxceVr29Uc= github.com/goravel/file-rotatelogs/v2 v2.4.2 h1:g68AzbePXcm0V2CpUMc9j4qVzcDn7+7aoWSjZ51C0m4= github.com/goravel/file-rotatelogs/v2 v2.4.2/go.mod h1:23VuSW8cBS4ax5cmbV+5AaiLpq25b8UJ96IhbAkdo8I= +github.com/goravel/framework v1.17.1-0.20260207193711-16b6ec3ccb18 h1:PVJIuuLQIKVN7n1dFxXNVdKWW+MQ87CC5wNrUFF713w= +github.com/goravel/framework v1.17.1-0.20260207193711-16b6ec3ccb18/go.mod h1:XcENnHvnbUkm1oBbrn2vi9MAWv1jMbs2ilnEdX8i6io= github.com/goravel/gin v1.17.0 h1:8H66v9GaYJR9UQ7C0VOef25/r8t/BAH9ZxlvxbHprlc= github.com/goravel/gin v1.17.0/go.mod h1:n0W6V/H+E0mqO+Gh+UMjeBANZe//lpWJ6X7kF3kwxR8= github.com/goravel/minio v1.17.0 h1:WGiPP/KZl/fuDpT9THRM83wjhLCqe1oIAyNVJvVjhS4= diff --git a/loki.yaml b/loki.yaml new file mode 100644 index 0000000..e537f1f --- /dev/null +++ b/loki.yaml @@ -0,0 +1,32 @@ +auth_enabled: false + +server: + http_listen_port: 3100 + grpc_listen_port: 9096 + +common: + instance_addr: 127.0.0.1 + path_prefix: /tmp/loki + storage: + filesystem: + chunks_directory: /tmp/loki/chunks + rules_directory: /tmp/loki/rules + replication_factor: 1 + ring: + kvstore: + store: inmemory + +schema_config: + configs: + - from: 2020-10-24 + store: tsdb + object_store: filesystem + schema: v13 + index: + prefix: index_ + period: 24h + +limits_config: + allow_structured_metadata: true + reject_old_samples: true + reject_old_samples_max_age: 168h \ No newline at end of file diff --git a/otel-config.yaml b/otel-config.yaml new file mode 100644 index 0000000..aefb96c --- /dev/null +++ b/otel-config.yaml @@ -0,0 +1,41 @@ +receivers: + otlp: + protocols: + http: + endpoint: 0.0.0.0:4318 + grpc: + endpoint: 0.0.0.0:4317 + +processors: + batch: + +exporters: + otlp/jaeger: + endpoint: "jaeger:4317" + tls: + insecure: true + + prometheusremotewrite: + endpoint: "http://prometheus:9090/api/v1/write" + resource_to_telemetry_conversion: + enabled: true + + otlphttp/loki: + endpoint: "http://loki:3100/otlp" + tls: + insecure: true + +service: + pipelines: + traces: + receivers: [otlp] + processors: [batch] + exporters: [otlp/jaeger] + metrics: + receivers: [otlp] + processors: [batch] + exporters: [prometheusremotewrite] + logs: + receivers: [otlp] + processors: [batch] + exporters: [otlphttp/loki] \ No newline at end of file diff --git a/prometheus.yaml b/prometheus.yaml new file mode 100644 index 0000000..cae0a7b --- /dev/null +++ b/prometheus.yaml @@ -0,0 +1,7 @@ +global: + scrape_interval: 15s + +scrape_configs: + - job_name: 'prometheus' + static_configs: + - targets: ['localhost:9090'] \ No newline at end of file From dffcf69477c0446bdbd6b93aaa75ffd86ac525f1 Mon Sep 17 00:00:00 2001 From: kkumar-gcc Date: Sat, 14 Feb 2026 00:25:31 +0530 Subject: [PATCH 4/4] update framework --- bootstrap/app.go | 6 +++--- go.mod | 2 +- go.sum | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bootstrap/app.go b/bootstrap/app.go index 6509953..c60accf 100644 --- a/bootstrap/app.go +++ b/bootstrap/app.go @@ -52,7 +52,7 @@ func Boot() contractsfoundation.Application { handler.Append( httpmiddleware.Throttle("global"), middleware.StartSession(), - telemetryhttp.Telemetry(facades.Config(), facades.Telemetry()), + telemetryhttp.Telemetry(), ).Recover(func(ctx http.Context, err any) { facades.Log().Error(err) _ = ctx.Response().String(http.StatusInternalServerError, "recover").Abort() @@ -72,13 +72,13 @@ func Boot() contractsfoundation.Application { }). WithGrpcServerStatsHandlers(func() []stats.Handler { return []stats.Handler{ - telemetrygrpc.NewServerStatsHandler(facades.Config(), facades.Telemetry()), + telemetrygrpc.NewServerStatsHandler(), } }). WithGrpcClientStatsHandlers(func() map[string][]stats.Handler { return map[string][]stats.Handler{ "default": { - telemetrygrpc.NewClientStatsHandler(facades.Config(), facades.Telemetry()), + telemetrygrpc.NewClientStatsHandler(), }, } }). diff --git a/go.mod b/go.mod index f3ef41a..825579d 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/goravel/cos v1.17.0 github.com/goravel/example-proto v0.0.1 github.com/goravel/fiber v1.17.0 - github.com/goravel/framework v1.17.1-0.20260207193711-16b6ec3ccb18 + github.com/goravel/framework v1.17.1-0.20260213185034-b6d4be586a85 github.com/goravel/gin v1.17.0 github.com/goravel/minio v1.17.0 github.com/goravel/mysql v1.17.0 diff --git a/go.sum b/go.sum index fb5180d..e94f345 100644 --- a/go.sum +++ b/go.sum @@ -283,6 +283,8 @@ github.com/goravel/file-rotatelogs/v2 v2.4.2 h1:g68AzbePXcm0V2CpUMc9j4qVzcDn7+7a github.com/goravel/file-rotatelogs/v2 v2.4.2/go.mod h1:23VuSW8cBS4ax5cmbV+5AaiLpq25b8UJ96IhbAkdo8I= github.com/goravel/framework v1.17.1-0.20260207193711-16b6ec3ccb18 h1:PVJIuuLQIKVN7n1dFxXNVdKWW+MQ87CC5wNrUFF713w= github.com/goravel/framework v1.17.1-0.20260207193711-16b6ec3ccb18/go.mod h1:XcENnHvnbUkm1oBbrn2vi9MAWv1jMbs2ilnEdX8i6io= +github.com/goravel/framework v1.17.1-0.20260213185034-b6d4be586a85 h1:IwYqyg1boD+gm+SWfxlxBpEBwHIFTQjvAKqMbyz6Xlw= +github.com/goravel/framework v1.17.1-0.20260213185034-b6d4be586a85/go.mod h1:XcENnHvnbUkm1oBbrn2vi9MAWv1jMbs2ilnEdX8i6io= github.com/goravel/gin v1.17.0 h1:8H66v9GaYJR9UQ7C0VOef25/r8t/BAH9ZxlvxbHprlc= github.com/goravel/gin v1.17.0/go.mod h1:n0W6V/H+E0mqO+Gh+UMjeBANZe//lpWJ6X7kF3kwxR8= github.com/goravel/minio v1.17.0 h1:WGiPP/KZl/fuDpT9THRM83wjhLCqe1oIAyNVJvVjhS4=