-
Notifications
You must be signed in to change notification settings - Fork 83
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
Set default values for tracing utilty parameters #231
Comments
Would an environment variable help here? That way you wouldn't change your code, and yet override the default -- it's something we've been thinking for the Python Powertools, at least. For our own learning, could you share more on what services you're working with that this breaks? We know S3 is one of them |
Yes, env vars make sense for this! I'm working with Cloudhsm, using the JCE. Curious that you mention S3, since that has not given us any issues with capture response. |
Agreed, the environment variable will probably be best here following how other utilities behave as well. |
I looked a bit into the implementation aspect of this. Few immediate thoughts, Since Java annotation won't allow Practically, that would mean something like: @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface PowertoolsTracing { String namespace() default ""; @Deprecated boolean captureResponse() default true; @Deprecated boolean captureError() default true; CaptureMode mode() default CaptureMode.ENVIRONMENT_VAR; } public enum CaptureMode { RESPONSE, ERROR, RESPONSE_AND_ERROR, ENVIRONMENT_VAR } The default value of mode can be ENVIRONMENT_VAR and which can in turn default to true if no env variable is specified. Pros:
Cons:
Unless I am missing something completely obvious and this can be solved in simpler way, Will be interesting to hear thoughts from others too. Partial implementation to set things in perspective. |
you are right, for us this would be a breaking change. no doubt but in the end it leads to a cleaner code. // Current way of handling things
@Tracing (captureResponse=false)
public void someMethod(int param, ...)
@Tracing (captureResponse=false)
public void noErrorCapture(int param, ...)
@Tracing (captureError=false)
public void anotherMethod(int param, ...)
@Tracing
public void extraMethod(int param, ...)
// Proposed way
@Tracing
@CaptureMode(mode="ENVIRONMENT_VAR")
public void someMethod(int param, ...)
@CaptureMode(mode="ENVIRONMENT_VAR")
public void noErrorCapture(int param, ...)
@Tracing
@CaptureMode(mode="RESPONSE")
public void anotherMethod(int param, ...)
@Tracing
@CaptureMode(mode="RESPONSE_AND_ERROR") //this would be optional since default mode is capture both, right?
public void extraMethod(int param, ...) |
Yeah like this, except that the Also, the default value will be If users want to change the default behavior, they can just override the 2 new environment variable to whatever value they want. If users want to override behavior for some of the users only, then they can choose any one of the supported modes. Hope this makes sense? @RobertoC27 |
one final question, is there going to be 1 env var per behavior? |
Yeah, At least that's how I have thought about it so far here |
makes sense, since combining them would make more complex overriding them down the line. |
Hi @RobertoC27 , This is now available in v1.2.0. Do try out and let us know in case of any feedback/issues. |
Hey @pankajagrawal16 |
Hey @RobertoC27, Great to hear! |
Is your feature request related to a problem? Please describe.
Changing the default captureResult param for the tracing utility to "false" would make my life easier, given that most of my methods require having it turned off because it causes errors while interacting with other services.
Describe the solution you'd like
It would be nice to be able to set the captureResult property for the tracing annotation to false and let all methods called inherit that default instead of having to put capture=false on every single annotation
Describe alternatives you've considered
right now I override the params on every annotation
Additional context
I'm working with a library that fails when tracing's capture response is true
The text was updated successfully, but these errors were encountered: