Skip to content

Commit

Permalink
Merge pull request #46 from Ryanair/explicit-env
Browse files Browse the repository at this point in the history
Explicit environment passing to logger configuration
  • Loading branch information
SodaDev authored Oct 21, 2024
2 parents f003a46 + 3bae038 commit af91db3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 35 deletions.
69 changes: 35 additions & 34 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,54 @@ module github.com/Ryanair/gofrlib
go 1.21

require (
github.com/aws/aws-lambda-go v1.46.0
github.com/aws/aws-sdk-go-v2 v1.25.3
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.13.9
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.30.4
github.com/aws/aws-sdk-go-v2/service/sqs v1.31.2
github.com/aws/aws-xray-sdk-go v1.8.3
github.com/aws/aws-lambda-go v1.47.0
github.com/aws/aws-sdk-go-v2 v1.30.1
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.14.7
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.34.1
github.com/aws/aws-sdk-go-v2/service/sqs v1.34.1
github.com/aws/aws-xray-sdk-go v1.8.4
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/contrib/detectors/aws/lambda v0.49.0
go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda v0.49.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0
go.opentelemetry.io/otel v1.24.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.24.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0
go.opentelemetry.io/otel/sdk v1.24.0
go.opentelemetry.io/otel/sdk/metric v1.24.0
go.opentelemetry.io/otel/trace v1.24.0
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/contrib/detectors/aws/lambda v0.53.0
go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda v0.53.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0
go.opentelemetry.io/otel v1.28.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0
go.opentelemetry.io/otel/sdk v1.28.0
go.opentelemetry.io/otel/sdk/metric v1.28.0
go.opentelemetry.io/otel/trace v1.28.0
go.uber.org/zap v1.27.0
)

require (
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/aws/aws-sdk-go v1.50.38 // indirect
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.20.2 // indirect
github.com/aws/smithy-go v1.20.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/aws/aws-sdk-go v1.54.16 // indirect
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.22.1 // indirect
github.com/aws/smithy-go v1.20.3 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.52.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/proto/otlp v1.1.0 // indirect
github.com/valyala/fasthttp v1.55.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7 // indirect
google.golang.org/grpc v1.62.1 // indirect
google.golang.org/protobuf v1.33.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240708141625-4ad9e859172b // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240708141625-4ad9e859172b // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
1 change: 1 addition & 0 deletions log/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
Logger = "Resource.logger"
Application = "Resource.application"
Project = "Resource.project"
Environment = "@env"
ProjectGroup = "Resource.projectGroup"
ResourceServiceName = "Resource.service.name"
ResourceServiceVersion = "Resource.service.version"
Expand Down
5 changes: 4 additions & 1 deletion log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ type Configuration struct {
logLevel string
application string
project string
environment string
projectGroup string
version string
customAttributesPrefix string
}

func NewConfiguration(logLevel, application, project, projectGroup, version, customAttributesPrefix string) Configuration {
func NewConfiguration(logLevel, application, project, projectGroup, version, customAttributesPrefix, env string) Configuration {
v := lambdacontext.FunctionVersion
if version != "" {
v = version
Expand All @@ -34,6 +35,7 @@ func NewConfiguration(logLevel, application, project, projectGroup, version, cus
logLevel: strings.ToUpper(logLevel),
application: strings.ToLower(application),
project: strings.ToLower(project),
environment: strings.ToUpper(env),
projectGroup: strings.ToLower(projectGroup),
version: v,
customAttributesPrefix: strings.ToLower(customAttributesPrefix),
Expand Down Expand Up @@ -85,6 +87,7 @@ func Init(config Configuration) {
WithOptions(zap.AddCallerSkip(1)).
With(zap.String(Application, config.application)).
With(zap.String(Project, config.project)).
With(zap.String(Environment, config.environment)).
With(zap.String(ProjectGroup, config.projectGroup)).
With(zap.String(ResourceServiceName, serviceName)).
With(zap.String(ResourceServiceVersion, config.version)).
Expand Down

0 comments on commit af91db3

Please sign in to comment.