dapr icon indicating copy to clipboard operation
dapr copied to clipboard

Expand request metrics to include User-Agent

Open halspang opened this issue 3 years ago • 3 comments

In what area(s)?

/area runtime

/area operator /area placement /area docs /area test-and-release

Describe the feature

Dapr should record a metric based off the User-Agent of incoming requests. This can be used for dashboards displaying request origins/makeup of services that are interacting with Dapr. If no User-Agent is passed, record Unknown. This metric can be a counter so we can see how many requests are coming in based on the User-Agent.

As part of this, there will also need to be changes on the SDKs to provide the User-Agent if they do not already. From a cursory glance, it does appear that gRPC clients already provide this. For example, if using the .NET SDK to work with Dapr, the User-Agent dotnet-grpc will appear. I'll create the issues in the SDK once we deem this worth doing.

Release Note

RELEASE NOTE: ADD User-Agent included in request metrics.

halspang avatar Aug 30 '22 20:08 halspang

What is the risk of the User-Agent to be random and create infinite number of metric keys, causing extra cost on aggregators.

artursouza avatar Aug 30 '22 23:08 artursouza

User-Agent tends to be fairly well defined, but it does open up a risk vector in terms of it being set by a lot of clients who may do something odd.

Instead of using User-Agent we could create a new metric, something like Dapr-SDK since what we're trying to capture here is the means in which a user is calling us. We could also include the version in the header, either as part of that header or as a separate header like Dapr-SDK-Version. The latter creates more metrics but does make it easier to sort/query on it.

halspang avatar Aug 31 '22 22:08 halspang

@artursouza - Another thought here is that we could just add the full User-Agent to the API Logging stuff. It doesn't matter if they're unique there, and it feels like relevant info. We can then add the other headers to the SDKs for metrics. Thoughts?

halspang avatar Sep 21 '22 20:09 halspang