feat: add option to allow user format the version from path in grape#1687
feat: add option to allow user format the version from path in grape#1687xuan-cao-swi wants to merge 4 commits intoopen-telemetry:mainfrom
Conversation
|
@muripic Would you have any time to take a look at this? I believe you contributed the Graph instrumentation (albeit, many years ago), your input would be super helpful. At a high level I think we'd prefer to solve this within the instrumentation code itself rather than need to support another config option like a callable. |
|
👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the |
|
👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the |
| version = endpoint.routes.first.options[:version]&.to_s | ||
| version = endpoint.routes.first.options[:version] | ||
| version = config[:version_format].call(version) |
There was a problem hiding this comment.
Rather than making it configurable could we not add the url.template attribute with a default of /:version/foos/ etc. That way http.route is mirroring what grape/server is providing as per semconv.
Description
Based on issue #1431: when a Grape API has multiple versions (for example:
—although using multiple versions in this way is not best practice and may be rare), the route string can become
/api/[\"v5\", \"v6\", \"v7\"]//other, which, as the user points out, is not well formatted (see attributes).This PR adds a configuration option that allows users to format the version string as they prefer. For example, to produce
/api/{v5|v6|v7}/other, a user can provide a lambda like:If the user does not provide a config option, the instrumentation keeps the original formatting (for example:
"/api/[\"v5\", \"v6\", \"v7\"]//other").