Repository navigation
[O2B-1645] Distinguish the type of API clients in the API logs - #2298
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The additive logging changes are consistent across both protocols, have focused test coverage, and have no identified blocking issues.
No open issues 🎉
What changed in this PR
Adds client and device classification to the shared HTTP and gRPC API logs, enabling traffic analysis by client type in OpenSearch.
Changes:
- Introduces a shared User-Agent classifier and client/device enums.
- Passes request headers into the logger and adds classification tests for both protocols.
- Documents the new fields and corrects the documented
paramstruncation limit to 500 characters.
| File | Description |
|---|---|
test/lib/server/utilities/index.js |
Registers classifier tests. |
test/lib/server/utilities/identifyClient.test.js |
Tests client types, browser devices, and missing User-Agent values. |
test/lib/server/utilities/ApiRequestLogger.test.js |
Verifies classification fields in log entries. |
test/lib/server/middleware/accessLog.middleware.test.js |
Tests HTTP classification and mobile hints. |
test/gRPC/serviceImplementation.test.js |
Verifies gRPC client classification in logs. |
lib/server/utilities/identifyClient.js |
Implements client and browser-device classification. |
lib/server/utilities/ApiRequestLogger.js |
Adds client and device to shared log entries. |
lib/server/middleware/accessLog.middleware.js |
Passes User-Agent and mobile hints to the logger. |
lib/server/gRPC/bindGRPCController.js |
Passes gRPC User-Agent metadata to the logger. |
lib/domain/enums/ApiDevices.js |
Defines browser-device categories. |
lib/domain/enums/ApiClients.js |
Defines client categories. |
docs/backend-architecture.md |
Documents classification fields, limitations, and the corrected truncation limit. |
Review effort: Balanced
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2298 +/- ##
==========================================
+ Coverage 45.94% 46.01% +0.06%
==========================================
Files 1067 1070 +3
Lines 17589 17609 +20
Branches 3252 3261 +9
==========================================
+ Hits 8082 8102 +20
Misses 9507 9507 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have a JIRA ticket
Notable changes for users:
Notable changes for developers:
clientanddevice, so that the traffic can be split by kind of client in OpenSearchclientis identified from theUser-Agentthe caller declares:browser,curl,wget,python,node,go,java,postman,grpc-node,grpc-cxx,grpc-python,grpc-go,grpc-java,grpc-otherorunknown. Postman is identified for both HTTP (PostmanRuntime/x) and gRPC (grpc-node-js/x-postman.y)deviceis only set for browsers (nullotherwise):phone,tabletordesktop, deduced from theUser-Agentand theSec-CH-UA-Mobileclient hint. An iPad requesting the desktop version of websites can not be told apart from a MacidentifyClient(new, with itsApiClientsandApiDevicesenums). It is called byApiRequestLogger, so the HTTP middleware and the gRPC binding only provide the rawuser-agentUser-Agentheader, which is the default behaviorparamsis fixed in it (500 characters, not 1000)Changes made to the database: