diff --git a/.env b/.env index 30cff0a..9a56ba3 100644 --- a/.env +++ b/.env @@ -1,5 +1,4 @@ OTEL_SERVICE_NAME="apitoolkit-otel-go-demo" OTEL_SERVICE_VERSION="0.0.1" +OTEL_RESOURCE_ATTRIBUTES="at-project-key=wKUZLJBKayszzIdJhaZsGDYc9DieSdqetLy8071Z8D8H/d7H" OTEL_LOG_LEVEL="debug" -OTEL_RESOURCE_ATTRIBUTES=at-project-key=wKUZLJBKayszzIdJhaZsGDYc9DieSdqetLy8071Z8D8H/d7H -OTEL_EXPORTER_OTLP_ENDPOINT="localhost:4317" diff --git a/chi/README.md b/chi/README.md index 02d80b6..f88b3a1 100644 --- a/chi/README.md +++ b/chi/README.md @@ -50,18 +50,13 @@ import ( apitoolkit "github.com/apitoolkit/apitoolkit-go/chi" "github.com/go-chi/chi/v5" - "github.com/joho/godotenv" + _ "github.com/joho/godotenv/autoload" ) func main() { - err := godotenv.Load(".env") - if err != nil { - log.Printf("Error loading .env file: %v", err) - } - shutdown, err := apitoolkit.ConfigureOpenTelemetry() + shutdown, err := apitoolkit.ConfigureOpenTelemetry() if err != nil { log.Printf("error configuring openTelemetry: %v", err) - } defer shutdown() diff --git a/chi/chi.go b/chi/chi.go index f7d630b..5080134 100644 --- a/chi/chi.go +++ b/chi/chi.go @@ -96,6 +96,7 @@ func Middleware(config Config) func(http.Handler) http.Handler { } func ConfigureOpenTelemetry(opts ...otelconfig.Option) (func(), error) { + opts = append([]otelconfig.Option{otelconfig.WithExporterEndpoint("otelcol.apitoolkit.io:4317"), otelconfig.WithExporterInsecure(true)}, opts...) return otelconfig.ConfigureOpenTelemetry(opts...) } diff --git a/echo/README.md b/echo/README.md index a4af12f..23b115e 100644 --- a/echo/README.md +++ b/echo/README.md @@ -50,19 +50,14 @@ import ( apitoolkit "github.com/apitoolkit/apitoolkit-go/echo" "github.com/labstack/echo/v4" - "github.com/joho/godotenv" + _ "github.com/joho/godotenv/autoload" ) func main() { - err := godotenv.Load(".env") - if err != nil { - log.Printf("Error loading .env file: %v", err) - } - shutdown, err := apitoolkit.ConfigureOpenTelemetry() + shutdown, err := apitoolkit.ConfigureOpenTelemetry() if err != nil { log.Printf("error configuring openTelemetry: %v", err) - } defer shutdown() diff --git a/echo/echo.go b/echo/echo.go index 26b6a1f..21a8c47 100644 --- a/echo/echo.go +++ b/echo/echo.go @@ -137,6 +137,7 @@ func Middleware(config Config) echo.MiddlewareFunc { } func ConfigureOpenTelemetry(opts ...otelconfig.Option) (func(), error) { + opts = append([]otelconfig.Option{otelconfig.WithExporterEndpoint("otelcol.apitoolkit.io:4317"), otelconfig.WithExporterInsecure(true)}, opts...) return otelconfig.ConfigureOpenTelemetry(opts...) } diff --git a/fiber/README.md b/fiber/README.md index dddb8c3..15bf983 100644 --- a/fiber/README.md +++ b/fiber/README.md @@ -50,18 +50,13 @@ import ( apitoolkit "github.com/apitoolkit/apitoolkit-go/fiber" "github.com/gofiber/fiber/v2" - "github.com/joho/godotenv" + _ "github.com/joho/godotenv/autoload" ) func main() { - err := godotenv.Load(".env") - if err != nil { - log.Printf("Error loading .env file: %v", err) - } shutdown, err := apitoolkit.ConfigureOpenTelemetry() if err != nil { log.Printf("error configuring openTelemetry: %v", err) - } defer shutdown() diff --git a/fiber/fiber.go b/fiber/fiber.go index 046005c..2451c49 100644 --- a/fiber/fiber.go +++ b/fiber/fiber.go @@ -98,6 +98,7 @@ func ReportError(ctx context.Context, err error) { } func ConfigureOpenTelemetry(opts ...otelconfig.Option) (func(), error) { + opts = append([]otelconfig.Option{otelconfig.WithExporterEndpoint("otelcol.apitoolkit.io:4317"), otelconfig.WithExporterInsecure(true)}, opts...) return otelconfig.ConfigureOpenTelemetry(opts...) } diff --git a/gin/README.md b/gin/README.md index 20970b8..407067e 100644 --- a/gin/README.md +++ b/gin/README.md @@ -50,18 +50,13 @@ import ( apitoolkit "github.com/apitoolkit/apitoolkit-go/gin" "github.com/gin-gonic/gin" - "github.com/joho/godotenv" + _ "github.com/joho/godotenv/autoload" ) func main() { - err := godotenv.Load(".env") - if err != nil { - log.Printf("Error loading .env file: %v", err) - } shutdown, err := apitoolkit.ConfigureOpenTelemetry() if err != nil { log.Printf("error configuring openTelemetry: %v", err) - } defer shutdown() diff --git a/gin/gin.go b/gin/gin.go index 3f43eb7..d900a20 100644 --- a/gin/gin.go +++ b/gin/gin.go @@ -122,6 +122,7 @@ func getAptConfig(config Config) apt.Config { } func ConfigureOpenTelemetry(opts ...otelconfig.Option) (func(), error) { + opts = append([]otelconfig.Option{otelconfig.WithExporterEndpoint("otelcol.apitoolkit.io:4317"), otelconfig.WithExporterInsecure(true)}, opts...) return otelconfig.ConfigureOpenTelemetry(opts...) } diff --git a/gorilla/README.md b/gorilla/README.md index 295e184..b10929c 100644 --- a/gorilla/README.md +++ b/gorilla/README.md @@ -51,18 +51,13 @@ import ( apitoolkit "github.com/apitoolkit/apitoolkit-go/gorilla" "github.com/gorilla/mux" - "github.com/joho/godotenv" + _ "github.com/joho/godotenv/autoload" ) func main() { - err := godotenv.Load(".env") - if err != nil { - log.Printf("Error loading .env file: %v", err) - } shutdown, err := apitoolkit.ConfigureOpenTelemetry(apitoolkit.WithMetricsEnabled(false)) if err != nil { log.Printf("error configuring openTelemetry: %v", err) - } defer shutdown() diff --git a/gorilla/gorilla.go b/gorilla/gorilla.go index 114352a..93cc7f0 100644 --- a/gorilla/gorilla.go +++ b/gorilla/gorilla.go @@ -88,6 +88,7 @@ func Middleware(config Config) func(next http.Handler) http.Handler { } func ConfigureOpenTelemetry(opts ...otelconfig.Option) (func(), error) { + opts = append([]otelconfig.Option{otelconfig.WithExporterEndpoint("otelcol.apitoolkit.io:4317"), otelconfig.WithExporterInsecure(true)}, opts...) return otelconfig.ConfigureOpenTelemetry(opts...) } diff --git a/native/README.md b/native/README.md index 6091489..4ff60b4 100644 --- a/native/README.md +++ b/native/README.md @@ -49,15 +49,10 @@ import ( "log" apitoolkit "github.com/apitoolkit/apitoolkit-go/native" - "github.com/joho/godotenv" + _ "github.com/joho/godotenv/autoload" ) func main() { - - err := godotenv.Load(".env") - if err != nil { - log.Printf("Error loading .env file: %v", err) - } shutdown, err := apitoolkit.ConfigureOpenTelemetry() if err != nil { log.Printf("error configuring openTelemetry: %v", err) diff --git a/native/native.go b/native/native.go index b8e2765..d46dd6a 100644 --- a/native/native.go +++ b/native/native.go @@ -95,6 +95,7 @@ func Middleware(config Config) func(http.Handler) http.Handler { } func ConfigureOpenTelemetry(opts ...otelconfig.Option) (func(), error) { + opts = append([]otelconfig.Option{otelconfig.WithExporterEndpoint("otelcol.apitoolkit.io:4317"), otelconfig.WithExporterInsecure(true)}, opts...) return otelconfig.ConfigureOpenTelemetry(opts...) }