Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions internal/generator/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ import (
{{ if .HasS3 }}"context"{{ end }}

"github.com/klass-lk/ginboot"
{{ if .HasTelemetry }}_ "github.com/klass-lk/ginboot/telemetry" // registers telemetry; enable it in ginboot.yml{{ end }}
"github.com/klass-lk/ginboot/db/mongo"
{{ if .HasLambda }}"github.com/klass-lk/ginboot/runtime/lambda"{{ end }}
{{ if .HasS3 }}"github.com/klass-lk/ginboot/storage/s3"{{ end }}
Expand All @@ -216,7 +217,8 @@ func main() {
userService := service.NewUserService(userRepo)
userController := controller.NewUserController(userService)

// Initialize Ginboot app (automatically loads .env, ginboot.yml, and configures telemetry)
// Initialize Ginboot app (loads .env and ginboot.yml, and applies the
// telemetry block of ginboot.yml if an instrumentation package is imported)
app := ginboot.New()

{{ if .HasS3 }}
Expand Down Expand Up @@ -344,6 +346,7 @@ import (
{{ if .HasS3 }}"context"{{ end }}

"github.com/klass-lk/ginboot"
{{ if .HasTelemetry }}_ "github.com/klass-lk/ginboot/telemetry" // registers telemetry; enable it in ginboot.yml{{ end }}
"github.com/klass-lk/ginboot/db/sql"
{{ if .HasLambda }}"github.com/klass-lk/ginboot/runtime/lambda"{{ end }}
{{ if .HasS3 }}"github.com/klass-lk/ginboot/storage/s3"{{ end }}
Expand All @@ -370,7 +373,8 @@ func main() {
userService := service.NewUserService(userRepo)
userController := controller.NewUserController(userService)

// Initialize Ginboot app (automatically loads .env, ginboot.yml, and configures telemetry)
// Initialize Ginboot app (loads .env and ginboot.yml, and applies the
// telemetry block of ginboot.yml if an instrumentation package is imported)
app := ginboot.New()

{{ if .HasS3 }}
Expand Down Expand Up @@ -415,6 +419,7 @@ import (
{{ if .HasS3 }}"context"{{ end }}

"github.com/klass-lk/ginboot"
{{ if .HasTelemetry }}_ "github.com/klass-lk/ginboot/telemetry" // registers telemetry; enable it in ginboot.yml{{ end }}
"github.com/klass-lk/ginboot/db/sql"
{{ if .HasLambda }}"github.com/klass-lk/ginboot/runtime/lambda"{{ end }}
{{ if .HasS3 }}"github.com/klass-lk/ginboot/storage/s3"{{ end }}
Expand All @@ -441,7 +446,8 @@ func main() {
userService := service.NewUserService(userRepo)
userController := controller.NewUserController(userService)

// Initialize Ginboot app (automatically loads .env, ginboot.yml, and configures telemetry)
// Initialize Ginboot app (loads .env and ginboot.yml, and applies the
// telemetry block of ginboot.yml if an instrumentation package is imported)
app := ginboot.New()

{{ if .HasS3 }}
Expand Down Expand Up @@ -621,6 +627,7 @@ import (
{{ if .HasS3 }}"context"{{ end }}

"github.com/klass-lk/ginboot"
{{ if .HasTelemetry }}_ "github.com/klass-lk/ginboot/telemetry" // registers telemetry; enable it in ginboot.yml{{ end }}
"github.com/klass-lk/ginboot/db/dynamodb"
{{ if .HasLambda }}"github.com/klass-lk/ginboot/runtime/lambda"{{ end }}
{{ if .HasS3 }}"github.com/klass-lk/ginboot/storage/s3"{{ end }}
Expand All @@ -646,7 +653,8 @@ func main() {
userService := service.NewUserService(userRepo)
userController := controller.NewUserController(userService)

// Initialize Ginboot app (automatically loads .env, ginboot.yml, and configures telemetry)
// Initialize Ginboot app (loads .env and ginboot.yml, and applies the
// telemetry block of ginboot.yml if an instrumentation package is imported)
app := ginboot.New()

{{ if .HasS3 }}
Expand Down Expand Up @@ -778,12 +786,14 @@ import (

"{{.ModuleName}}/internal/di"
"github.com/klass-lk/ginboot"
{{ if .HasTelemetry }}_ "github.com/klass-lk/ginboot/telemetry" // registers telemetry; enable it in ginboot.yml{{ end }}
{{ if .HasLambda }}"github.com/klass-lk/ginboot/runtime/lambda"{{ end }}
{{ if .HasS3 }}"github.com/klass-lk/ginboot/storage/s3"{{ end }}
)

func main() {
// Initialize Ginboot app (automatically loads .env, ginboot.yml, and configures telemetry)
// Initialize Ginboot app (loads .env and ginboot.yml, and applies the
// telemetry block of ginboot.yml if an instrumentation package is imported)
app := ginboot.New()

{{ if .HasS3 }}
Expand Down Expand Up @@ -971,10 +981,17 @@ const ginbootYmlTemplate = `ginboot:
url: ${DATABASE_URL:mongodb://localhost:27017}

telemetry:
# Requires the blank import of github.com/klass-lk/ginboot/telemetry that
# main.go carries; without it this block has nothing to switch on.
enabled: {{.HasTelemetry}}
service-name: {{.ProjectName}}
exporter: otlp
endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT:localhost:4317}
# Deliberately empty by default. With no endpoint the SDK installs providers
# that export nowhere, which costs nothing and is what you want on a laptop.
# Naming a collector here that is not running does not fail quietly — every
# batch is attempted and every attempt is logged. A deployment supplies the
# real endpoint through OTEL_EXPORTER_OTLP_ENDPOINT, which wins over this.
endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT:}
`

const envTemplate = `PORT=8080
Expand Down
Loading