feat: add environment parameter to SetupOTelSDK function

Updates the SetupOTelSDK function to include an environment 
parameter. This change ensures that the OpenTelemetry setup 
now captures and sets the service environment along with 
the service name and version. It enhances observability 
by providing more context about the application's 
deployment environment.
This commit is contained in:
2025-05-30 13:53:07 +02:00
parent cf7ddf9df1
commit dbec05bdf7
+2 -2
View File
@@ -20,9 +20,9 @@ import (
)
// SetupOTelSDK bootstraps the OpenTelemetry pipeline.
func SetupOTelSDK(ctx context.Context, enabled bool, serviceName string, buildVersion string) (func(context.Context) error, error) {
func SetupOTelSDK(ctx context.Context, enabled bool, serviceName, buildVersion, environment string) (func(context.Context) error, error) {
if os.Getenv("OTEL_RESOURCE_ATTRIBUTES") == "" {
if err := os.Setenv("OTEL_RESOURCE_ATTRIBUTES", fmt.Sprintf("service.name=%s,service.version=%s", serviceName, buildVersion)); err != nil {
if err := os.Setenv("OTEL_RESOURCE_ATTRIBUTES", fmt.Sprintf("service.name=%s,service.version=%s,service.environment=%s", serviceName, buildVersion, environment)); err != nil {
return func(context.Context) error {
return nil
}, err