-
Notifications
You must be signed in to change notification settings - Fork 518
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 client.ip for iOS agent #4975
Conversation
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪 |
Introduce a new "ClientMetadata" gRPC interceptor, which records information about the gRPC client. The logic was extracted from the logging interceptor, which now relies on the client metadata interceptor being installed before it. Also, move the gRPC auth interceptor after logging and metrics so auth failures are logged and included in metrics.
|
||
// ContextWithClientMetadata returns a copy of ctx with values. | ||
func ContextWithClientMetadata(ctx context.Context, values ClientMetadataValues) context.Context { | ||
return context.WithValue(ctx, clientMetadataKey{}, values) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for my own education: using clientMetadataKey{}
provides us with an identifier to extract the values, but it also doesn't allocate because it's an empty struct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using an unexported struct type as the key is recommended by the Go docs (https://golang.org/pkg/context/):
// A key identifies a specific value in a Context. Functions that wish
// to store values in Context typically allocate a key in a global
// variable then use that key as the argument to context.WithValue and
// Context.Value. A key can be any type that supports equality;
// packages should define keys as an unexported type to avoid
// collisions.
// ClientMetadataFromContext returns client metadata extracted by the ClientMetadata interceptor. | ||
func ClientMetadataFromContext(ctx context.Context) (ClientMetadataValues, bool) { | ||
values, ok := ctx.Value(clientMetadataKey{}).(ClientMetadataValues) | ||
return values, ok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason you're assigning to variables instead of return ctx.Value(...)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because that doesn't compile :)
return ctx.Value(...)
would compile, but the type assertion requires assignment to intermediate variables.
is this something that's easy to do? or is it requiring running some app in xcode etc etc |
I understand that it currently requires us to use a mac, I suppose running xcode. This will probably fall on @bryce-b to test. |
Codecov Report
@@ Coverage Diff @@
## master #4975 +/- ##
==========================================
+ Coverage 77.21% 77.27% +0.06%
==========================================
Files 175 177 +2
Lines 10413 10442 +29
==========================================
+ Hits 8040 8069 +29
Misses 2373 2373
|
Introduce a new "ClientMetadata" gRPC interceptor, which records information about the gRPC client. The logic was extracted from the logging interceptor, which now relies on the client metadata interceptor being installed before it. Also, move the gRPC auth interceptor after logging and metrics so auth failures are logged and included in metrics. # Conflicts: # changelogs/head.asciidoc
Introduce a new "ClientMetadata" gRPC interceptor, which records information about the gRPC client. The logic was extracted from the logging interceptor, which now relies on the client metadata interceptor being installed before it. Also, move the gRPC auth interceptor after logging and metrics so auth failures are logged and included in metrics. # Conflicts: # changelogs/head.asciidoc
Introduce a new "ClientMetadata" gRPC interceptor, which records information about the gRPC client. The logic was extracted from the logging interceptor, which now relies on the client metadata interceptor being installed before it. Also, move the gRPC auth interceptor after logging and metrics so auth failures are logged and included in metrics. (cherry picked from commit 3f4379a) # Conflicts: # beater/server.go # changelogs/head.asciidoc # systemtest/logging_test.go # systemtest/otlp_test.go
Motivation/summary
Introduce a new "ClientMetadata" gRPC interceptor which records information about the gRPC client. The logic was extracted from the logging interceptor, which now relies on the client metadata interceptor being installed before it.
Also, move the gRPC auth interceptor after logging and metrics so auth failures are logged and included in metrics.
Checklist
How to test these changes
client.ip
field which matches the IP of the iOS application's device.Related issues
Closes #4935