fix: missing dot between header attributes #2
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.
This pull request refactors the tracing middleware to improve OpenTelemetry semantic conventions usage and header handling. The main changes include replacing manual attribute construction with OpenTelemetry semantic attribute helpers, introducing a robust host/port parsing utility, and enhancing header attribute filtering to exclude tracing-related headers from span attributes.
OpenTelemetry semantic conventions and attribute handling:
Replaced manual construction of metric and span attributes with OpenTelemetry semantic conventions (
semconv), including for HTTP methods, URLs, addresses, ports, request/response body sizes, protocol versions, user agent, and status codes. This standardizes telemetry data and improves compatibility. [1] [2] [3] [4] [5] [6] [7]Exception and error attributes on spans now use semantic keys (
exception.error,exception.stacktrace) for better error reporting and trace analysis. [1] [2]Header attribute filtering:
excludedSpanHeaderAttributesto filter out tracing-related headers (e.g.,traceparent,baggage,x-b3-*) from span attributes, reducing noise and potential data leaks in telemetry. [1] [2]Host/port parsing utility:
SplitHostPortinutils.gofor robust parsing of network addresses, supporting various formats and handling errors gracefully. This replaces previous manual parsing and improves reliability in extracting host and port information for telemetry. [1] [2] [3]Other improvements:
MaskStringfunction to mask sensitive data more consistently, and adjusted related test expectations. [1] [2]These changes collectively improve the accuracy, consistency, and security of telemetry data collected by the middleware.