Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: log pretty print cache config on instantiation #577

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

malandis
Copy link
Contributor

@malandis malandis commented Jan 17, 2025

Logs a pretty printed version of the cache configuration in the cache
client factory function.

When printing the cache configuration before, we would see something like this:

 &{loggerFactory:0x1400000ee80 transportStrategy:0x1400000ca50 retryStrategy:{eligibilityStrategy:{} maxAttempts:3 log:0x1400000ca68} numGrpcChannels:1 readConcern:balanced}

This contains pointers to parts of the configuration that should be dereferenced and recursively represented. We override the String function on the appropriate structs to get this. Now we will see:

Configuration{loggerFactory=DefaultMomentoLoggerFactory{level=20}, transportStrategy=TransportStrategy{grpcConfig=GrpcConfiguration{deadline=5s, keepAlivePermitWithoutCalls=true, keepAliveTimeout=1s, keepAliveTime=5s, maxSendMessageLength=5243000, maxReceiveMessageLength=5243000}, maxIdle=0s}, retryStrategy=fixedCountRetryStrategy{eligibilityStrategy={}, maxAttempts=3, log=DefaultMomentoLogger{loggerName=fixed-count-retry-strategy, level=20}}, numGrpcChannels=1, readConcern=balanced}

We further log the properties from the cache client constructors to log all relevant settings. We provide a String function for CredentialProvider where we censor the auth token. Here is what the log statement looks like:

[2025-01-17T00:50:18Z] INFO (CacheClient): Creating cache client with settings: CacheClientProps{CacheName: , Configuration: Configuration{loggerFactory=DefaultMomentoLoggerFactory{level=20}, transportStrategy=TransportStrategy{grpcConfig=GrpcConfiguration{deadline=5s, keepAlivePermitWithoutCalls=true, keepAliveTimeout=1s, keepAliveTime=5s, maxSendMessageLength=5243000, maxReceiveMessageLength=5243000}, maxIdle=0s}, retryStrategy=fixedCountRetryStrategy{eligibilityStrategy={}, maxAttempts=3, log=DefaultMomentoLogger{loggerName=fixed-count-retry-strategy, level=20}}, numGrpcChannels=1, readConcern=balanced}, CredentialProvider: CredentialProvider{authToken=ey***uM, controlEndpoint=Endpoint{Endpoint=control.cell-4-us-west-2-1.prod.a.momentohq.com:443, InsecureConnection=false}, cacheEndpoint=Endpoint{Endpoint=cache.cell-4-us-west-2-1.prod.a.momentohq.com:443, InsecureConnection=false}, tokenEndpoint=Endpoint{Endpoint=token.cell-4-us-west-2-1.prod.a.momentohq.com:443, InsecureConnection=false}, storageEndpoint=Endpoint{Endpoint=storage.cell-4-us-west-2-1.prod.a.momentohq.com:443, InsecureConnection=false}}, DefaultTtl: 1m0s, EagerConnectTimeout: 30s}

I considered adding a String method to relevant configuration interface types. Since that would be a breaking change for existing users that have made their own implementation, I have foregone that.

Logs a pretty printed version of the cache configuration in the cache
client factory function.
momento/cache_client.go Dismissed Show resolved Hide resolved
Copy link

@danielamiao danielamiao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the fast turnaround!

@malandis malandis merged commit 851b9c2 into main Jan 17, 2025
6 checks passed
@malandis malandis deleted the chore/pretty-print-config branch January 17, 2025 17:53
malandis pushed a commit that referenced this pull request Jan 17, 2025
1.32.1 (2025-01-17)
Miscellaneous
log pretty print cache config on instantiation (#577) (851b9c2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants