-
Notifications
You must be signed in to change notification settings - Fork 124
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
migrate go version from 1.19 -> 1.20
, upgrade semiconv package version and fix deprecated usages...
#1226
base: main
Are you sure you want to change the base?
migrate go version from 1.19 -> 1.20
, upgrade semiconv package version and fix deprecated usages...
#1226
Conversation
WalkthroughThis pull request removes the Changes
Sequence Diagram(s)sequenceDiagram
participant C as Client
participant M as Fiber Middleware
participant I as Internal Helper
participant OT as OpenTelemetry
C->>+M: HTTP Request
M->>+I: Compute Span Status (using HTTP status & span kind)
I-->>-M: Span Status Result
M->>OT: Record Telemetry Attributes (HTTP status, response size, etc.)
M-->>C: HTTP Response
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
otelfiber/internal/http.go (1)
26-28
: Consider adding a test for the helper function.While the implementation is correct, adding unit tests would help ensure the 4xx status code range check remains accurate.
Would you like me to generate unit tests for the
isCode4xx
function?otelfiber/semconv.go (1)
73-79
: Consider caching protocol attributes.Since protocol attributes are used in both metric and trace collection, consider caching them to avoid redundant computation.
+var ( + httpProtocolNameAttr = semconv.NetworkProtocolName("http") + http11VersionAttr = semconv.NetworkProtocolVersion("1.1") + http10VersionAttr = semconv.NetworkProtocolVersion("1.0") +) + func httpNetworkProtocolAttributes(c *fiber.Ctx) []attribute.KeyValue { - httpProtocolAttributes := []attribute.KeyValue{semconv.NetworkProtocolName("http")} + httpProtocolAttributes := []attribute.KeyValue{httpProtocolNameAttr} if c.Request().Header.IsHTTP11() { - return append(httpProtocolAttributes, semconv.NetworkProtocolVersion("1.1")) + return append(httpProtocolAttributes, http11VersionAttr) } - return append(httpProtocolAttributes, semconv.NetworkProtocolVersion("1.0")) + return append(httpProtocolAttributes, http10VersionAttr) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
otelfiber/example/go.mod
is excluded by!**/*.mod
otelfiber/example/go.sum
is excluded by!**/*.sum
,!**/*.sum
otelfiber/go.mod
is excluded by!**/*.mod
otelfiber/go.sum
is excluded by!**/*.sum
,!**/*.sum
📒 Files selected for processing (6)
otelfiber/README.md
(0 hunks)otelfiber/config.go
(1 hunks)otelfiber/fiber.go
(5 hunks)otelfiber/internal/http.go
(1 hunks)otelfiber/otelfiber_test/fiber_test.go
(9 hunks)otelfiber/semconv.go
(3 hunks)
💤 Files with no reviewable changes (1)
- otelfiber/README.md
🔇 Additional comments (11)
otelfiber/internal/http.go (1)
13-24
: LGTM! The span status implementation follows OpenTelemetry specification.The function correctly handles:
- Invalid HTTP status codes
- Success codes (1xx-3xx)
- Special case for 4xx codes in server spans
otelfiber/semconv.go (2)
13-31
: LGTM! Updated metric attributes align with latest OpenTelemetry conventions.The changes correctly update the attribute keys and add protocol attributes.
33-71
: LGTM! Trace attributes collection is comprehensive.The implementation now includes additional attributes like request body size, URL components, and user agent.
otelfiber/config.go (1)
76-79
: LGTM! Documentation update reflects semantic convention changes.The comment correctly updates the attribute name from
net.host.port
toserver.port
to align with the latest OpenTelemetry conventions.otelfiber/fiber.go (2)
132-135
: LGTM! Response attributes follow latest OpenTelemetry conventions.The implementation correctly uses the updated attribute keys.
155-155
: LGTM! Span updates use new internal package.The implementation correctly:
- Uses the new response body size attribute key
- Delegates span status computation to the internal package
Also applies to: 158-159
otelfiber/otelfiber_test/fiber_test.go (5)
27-27
: LGTM! Semantic conventions package upgrade.The upgrade to
go.opentelemetry.io/otel/semconv/v1.21.0
aligns with the PR objectives to upgrade the OpenTelemetry semi-convention package.
303-309
: LGTM! Updated metric attributes follow semantic conventions.The metric attributes have been correctly updated to use the latest OpenTelemetry semantic convention functions:
- Network protocol attributes using
semconv.NetworkProtocolName
andsemconv.NetworkProtocolVersion
- URL scheme using
semconv.URLScheme
- HTTP method using
semconv.HTTPRequestMethodKey
- Server details using
semconv.ServerAddress
andsemconv.ServerPort
- Response status using
semconv.HTTPResponseStatusCode
Also applies to: 310-313
458-458
: LGTM! Custom metric attributes updated to use semantic conventions.The custom metric attributes have been correctly updated to use the semantic convention functions:
- URL query parameters using
semconv.URLQuery
- Network and server attributes using appropriate semantic convention functions
Also applies to: 479-490
575-577
: LGTM! Client IP attribute key updated.The client IP attribute key has been updated to use
client.address
in accordance with the latest semantic conventions.
116-119
: Verify the updated attribute keys align with OpenTelemetry specifications.The attribute keys have been updated to follow the latest OpenTelemetry semantic conventions:
server.address
for server identificationhttp.response.status_code
for response statushttp.request.method
for HTTP methodurl.path
for request path✅ Verification successful
🌐 Web query:
What are the latest OpenTelemetry semantic conventions for HTTP attributes?
💡 Result:
The latest OpenTelemetry HTTP semantic conventions (as of 2025) introduce stabilized attribute names and structures following a merger with Elastic Common Schema (ECS). Here's what developers need to know: ## Key Changes in HTTP Semantic Conventions - **Stable Release**: HTTP conventions reached stability in November 2023 through alignment with ECS[1][3] - **Attribute Renaming**: - `http.method` → `http.request.method` - `http.url` → `url.full` - `http.client_id` → `client.address` - `http.flavor` → `network.protocol.name`[1][9] - **New Namespace Structure**: Attributes now follow clearer hierarchical naming (e.g., `http.request.header.content-type`)[3][6] ## Transition Requirements Use environment variables to control convention versions: ```bash OTEL_SEMCONV_STABILITY_OPT_IN=http # Stable only OTEL_SEMCONV_STABILITY_OPT_IN=http/dup # Dual emission[5][6] ``` ## Impacted Components | Legacy Attribute | New Attribute | Stability | |------------------|---------------|-----------| | `http.host` | `server.address` | Deprecated[9] | | `http.target` | `url.path` + `url.query` | Split[9] | | `http.user_agent` | `user_agent.original` | Replaced[9] | ## Migration Considerations 1. Update Collector configurations using legacy attributes[1] 2. Modify transform/filter processors referencing old names[1] 3. Adapt dashboards and queries using HTTP attributes in visualization tools[1] 4. Check instrumentation libraries for stable releases (most now support v1.0)[7] Official documentation recommends using the `@opentelemetry/semantic-conventions` npm package's stable entry point, which includes only finalized conventions[7][8]. For gradual migration, use the `http/dup` mode to emit both old and new attributes during transition periods[6]. The changes aim to improve cross-platform compatibility while maintaining backward compatibility through careful deprecation policies[3][10]. Monitoring OpenTelemetry release notes and provider-specific guidance (like Honeycomb's transition updates[1]) is recommended during migration. Citations: - 1: https://www.honeycomb.io/blog/opentelemetry-http-attributes - 2: https://github.com/open-telemetry/semantic-conventions/releases - 3: https://betterstack.com/community/guides/observability/opentelemetry-semantic-conventions/ - 4: https://docs.datadoghq.com/opentelemetry/schema_semantics/semantic_mapping/ - 5: https://opentelemetry.io/docs/specs/semconv/http/ - 6: https://opentelemetry.io/docs/specs/semconv/http/http-spans/ - 7: https://www.npmjs.com/package/@opentelemetry/semantic-conventions - 8: https://opentelemetry.io/docs/specs/semconv/ - 9: https://opentelemetry.io/docs/specs/semconv/attributes-registry/http/ - 10: https://opentelemetry.io/docs/concepts/semantic-conventions/
Attribute Keys Are Consistent with the Latest Conventions
The updated keys in the test are in line with the current OpenTelemetry HTTP semantic conventions. Specifically:
- "server.address" replaces the legacy "http.host".
- "http.request.method" reflects the new nomenclature for HTTP methods.
- "url.path" is used appropriately as part of the split of "http.target".
- The use of "http.response.status_code" aligns with the updated request/response naming pattern.
All four attribute keys match the updated conventions as described in the latest documentation.
…ackage version and fix deprecated usages...
e07464b
to
0de3bae
Compare
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
otelfiber/internal/http_test.go (1)
44-56
: Consider adding test cases for edge cases.While the current test coverage is good, consider adding test cases for:
- Status code 399 (edge of 3xx)
- Status code 400 (start of 4xx)
- Status code 499 (end of 4xx)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
otelfiber/example/go.mod
is excluded by!**/*.mod
otelfiber/example/go.sum
is excluded by!**/*.sum
,!**/*.sum
otelfiber/go.mod
is excluded by!**/*.mod
otelfiber/go.sum
is excluded by!**/*.sum
,!**/*.sum
📒 Files selected for processing (7)
otelfiber/README.md
(0 hunks)otelfiber/config.go
(1 hunks)otelfiber/fiber.go
(5 hunks)otelfiber/internal/http.go
(1 hunks)otelfiber/internal/http_test.go
(1 hunks)otelfiber/otelfiber_test/fiber_test.go
(9 hunks)otelfiber/semconv.go
(3 hunks)
💤 Files with no reviewable changes (1)
- otelfiber/README.md
🚧 Files skipped from review as they are similar to previous changes (2)
- otelfiber/config.go
- otelfiber/internal/http.go
🔇 Additional comments (11)
otelfiber/internal/http_test.go (2)
11-21
: LGTM! Good test coverage for 4xx status codes.The tests effectively validate both positive and negative cases for 4xx status code detection.
23-56
: LGTM! Comprehensive error handling test cases.The tests thoroughly cover various error scenarios:
- Invalid HTTP status codes (600)
- Ignored HTTP status codes (306)
- Server errors (500)
otelfiber/semconv.go (4)
13-17
: LGTM! Good initialization of protocol attributes.The protocol attributes are correctly defined using the latest semantic conventions.
19-37
: LGTM! Clean implementation of metric attributes collection.The function correctly collects and combines protocol attributes with other server metrics.
39-77
: LGTM! Comprehensive trace attributes collection.The function effectively collects all required trace attributes including URL components and user agent.
79-85
: LGTM! Improved protocol attributes handling.The refactored function now returns a slice of attributes, making it more flexible and maintainable.
otelfiber/fiber.go (2)
132-136
: LGTM! Clean response attributes construction.The response attributes are correctly constructed using the latest semantic conventions.
155-159
: LGTM! Improved span status handling.The code now uses the internal package for span status determination, which provides better encapsulation.
otelfiber/otelfiber_test/fiber_test.go (3)
302-309
: LGTM! Comprehensive request attributes testing.The test correctly validates all required request attributes using the latest semantic conventions.
310-314
: LGTM! Updated response attributes testing.The test properly validates response attributes with the new semantic conventions.
478-486
: LGTM! Complete metric attributes testing.The test thoroughly validates all metric attributes including protocol, URL, and server information.
This pr represents version upgrades and deprecated usages fix for otelfiber package
Changes Includes :
Summary by CodeRabbit