-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add support for custom attributes function #3198
base: master
Are you sure you want to change the base?
Conversation
120cdd0
to
64bfb34
Compare
@ofekshenawa Please take a look at this one |
Can you please add some tests? |
Added tests for metrics and custom attributes |
0524dee
to
b04e7ba
Compare
@ofekshenawa Added tests but something weird is happening with the tests. It was passing tests yesterday and failing now. It should only fail on 1.19 afaik because the metric sdk version I am using requires 1.20 and above ( not able to find a working version before that) |
fda6b07
to
f7d3f48
Compare
@ofekshenawa Fixed the tests, but it is failing on 1.19 ( the test setup for metrics require 1.20+) , before those not able to find test functions for metric testing. How can we proceed? |
@ndyakov can you please take a look at this one? Thanks |
@urdarinda I do not have a lot of context on the |
@ndyakov added |
@urdarinda please resolve conflicts and request a review from @monkey92t since maybe he has more background with the |
@monkey92t please review |
1、In the example, the demonstration is for tracing, but the actual implementation only includes metrics. Would you like to add tracing? 2、Based on the example and the code, the custom attributes seem to be global and cannot be changed based on execution commands or any conditions. In the go-redis hook, the ctx does not contain much useful information, making it difficult to modify custom variables through ctx. 3、 attrs := make([]attribute.KeyValue, 0, len(mh.attrs)+2)
attrs = append(attrs, mh.attrsFunc(ctx)...)
attrs = append(attrs, mh.attrs...)
attrs = append(attrs, attribute.String("type", "command"))
attrs = append(attrs, statusAttr(err)) This is a Go-related issue. Obviously, a slice expansion will occur here, and we should avoid it. |
Added for tracing, updated test as well
This can be actually to augment the metrics/traces when used with other frameworks. I can add things like
How do you suggest we do it? I believe this is the only way to expand a slice into individual values for now |
For custom parameters, should we customize the parameters based on the form of a command or a key? |
Sometimes we want to add custom attributes to metrics in order to give better context with the application.
Example,
I want to identify which API is responsible for calling this redis command and group by the calling API