Skip to content

Commit

Permalink
Bump the opentelemetry group with 4 updates (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Oct 10, 2024
1 parent fa28e81 commit 52519d0
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 46 deletions.
37 changes: 25 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed

- The following deprecated and reduntant attributes have been removed
- "http.method"
- "http.url"
- "net_peer_name"

---

## [1.3.2] - 2024-06-26
Expand All @@ -25,7 +33,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- `Telepoison.setup/1` deprecation using @deprecated annotation instead of a warning log.
- `Telepoison.setup/1` deprecation using @deprecated annotation instead of a
warning log.

---

Expand All @@ -38,8 +47,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- configuration options are correctly validated during `setup` instead of upon retrieval
- request options (e.g. `:ot_resource_route` and `:ot_attributes`) can be correctly passed together to Telepoison calls (e.g. `get`)
- configuration options are correctly validated during `setup` instead of upon
retrieval
- request options (e.g. `:ot_resource_route` and `:ot_attributes`) can be
correctly passed together to Telepoison calls (e.g. `get`)
- non valid `:ot_attributes` are ignored instead of being mapped to `nil`
- usages of `:infer_fn` are now all `:infer_route`, which is the correct option

Expand All @@ -49,8 +60,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Trace propagation breaking if one of the header keys was an atom instead of string.
Note that this also causes HTTPoison.Response{request: %{headers}} to always use string for header keys.
- Trace propagation breaking if one of the header keys was an atom instead of
string. Note that this also causes HTTPoison.Response{request: %{headers}} to
always use string for header keys.

---

Expand All @@ -66,13 +78,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- New `:ot_attributes` option to set default Open Telemetry metadata attributes to be added to each Telepoison request
- New otel semantic conventions library to ensure proper conventions are followed
- New `:ot_attributes` option to set default Open Telemetry metadata attributes
to be added to each Telepoison request
- New otel semantic conventions library to ensure proper conventions are
followed

### Changed

- Span name contains `method` only now, as per semantic conventions
- `http.url` will be stripped of credentials. (eg. if the url is `"https://username:[email protected]/"` the attribute's value will be `"https://www.example.com/"`)
- `http.url` will be stripped of credentials. (eg. if the url is
`"https://username:[email protected]/"` the attribute's value will be
`"https://www.example.com/"`)

---

Expand All @@ -83,9 +99,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- New `"net.peer.name"` attribute
- HTTPoison 2.0.0 is now supported




[Unreleased]: https://github.com/primait/telepoison/compare/1.3.2...HEAD
[1.3.2]: https://github.com/primait/telepoison/compare/1.3.1-rc.1...1.3.2
[1.3.1-rc.1]: https://github.com/primait/telepoison/compare/1.3.1-rc.0...1.3.1-rc.1
Expand Down
34 changes: 14 additions & 20 deletions lib/telepoison.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ defmodule Telepoison do
use HTTPoison.Base

require OpenTelemetry
require OpenTelemetry.SemanticConventions.Trace, as: Conventions
require OpenTelemetry.SemConv.HTTPAttributes, as: HTTPAttributes
require OpenTelemetry.SemConv.URLAttributes, as: URLAttributes
require OpenTelemetry.SemConv.Incubating.URLAttributes, as: IncubatingURLAttributes
require OpenTelemetry.SemConv.ServerAttributes, as: ServerAttributes
require OpenTelemetry.Span
require OpenTelemetry.Tracer
require Record
Expand All @@ -19,18 +22,16 @@ defmodule Telepoison do
alias OpenTelemetry.Tracer
alias Telepoison.Configuration

@http_method Atom.to_string(Conventions.http_method())
@http_request_method "http.request.method"
@http_response_status_code "http.response.status_code"
@http_route Atom.to_string(Conventions.http_route())
@http_status_code Atom.to_string(Conventions.http_status_code())
@http_url Atom.to_string(Conventions.http_url())
@net_peer_name Atom.to_string(Conventions.net_peer_name())
@server_address "server.address"
@server_port "server.port"
@url_full "url.full"
@url_scheme "url.scheme"
@url_template "url.template"
@http_request_method Atom.to_string(HTTPAttributes.http_request_method())
@http_response_status_code Atom.to_string(HTTPAttributes.http_response_status_code())
@http_route Atom.to_string(HTTPAttributes.http_route())

@server_address Atom.to_string(ServerAttributes.server_address())
@server_port Atom.to_string(ServerAttributes.server_port())

@url_full Atom.to_string(URLAttributes.url_full())
@url_scheme Atom.to_string(URLAttributes.url_scheme())
@url_template Atom.to_string(IncubatingURLAttributes.url_template())

@doc ~S"""
Configures Telepoison using the provided `opts` `Keyword list`.
Expand Down Expand Up @@ -203,7 +204,6 @@ defmodule Telepoison do
end

Tracer.set_attribute(@http_response_status_code, status_code)
Tracer.set_attribute(@http_status_code, status_code)
end_span()
status_code
end
Expand All @@ -230,16 +230,10 @@ defmodule Telepoison do

defp get_standard_ot_attributes(request, scheme, host, port) do
[
{@http_method,
request.method
|> Atom.to_string()
|> String.upcase()},
{@http_request_method,
request.method
|> Atom.to_string()
|> String.upcase()},
{@http_url, strip_uri_credentials(request.url)},
{@net_peer_name, host},
{@server_address, host},
{@server_port, port},
{@url_full, strip_uri_credentials(request.url)},
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ defmodule Telepoison.MixProject do
[
{:httpoison, "~> 1.6 or ~> 2.0"},
{:opentelemetry_api, "~> 1.0"},
{:opentelemetry_semantic_conventions, "~> 0.2"},
{:opentelemetry_semantic_conventions, "~> 1.27"},
] ++ dev_deps()
end

Expand Down
10 changes: 5 additions & 5 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
"mime": {:hex, :mime, "2.0.6", "8f18486773d9b15f95f4f4f1e39b710045fa1de891fada4516559967276e4dc2", [:mix], [], "hexpm", "c9945363a6b26d747389aac3643f8e0e09d30499a138ad64fe8fd1d13d9b153e"},
"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
"opentelemetry": {:hex, :opentelemetry, "1.4.0", "f928923ed80adb5eb7894bac22e9a198478e6a8f04020ae1d6f289fdcad0b498", [:rebar3], [{:opentelemetry_api, "~> 1.3.0", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:opentelemetry_semantic_conventions, "~> 0.2", [hex: :opentelemetry_semantic_conventions, repo: "hexpm", optional: false]}], "hexpm", "50b32ce127413e5d87b092b4d210a3449ea80cd8224090fe68d73d576a3faa15"},
"opentelemetry_api": {:hex, :opentelemetry_api, "1.3.1", "83b4713593f80562d9643c4ab0b6f80f3c5fa4c6d0632c43e11b2ccb6b04dfa7", [:mix, :rebar3], [{:opentelemetry_semantic_conventions, "~> 0.2", [hex: :opentelemetry_semantic_conventions, repo: "hexpm", optional: false]}], "hexpm", "9e8a5cc38671e3ac61be48abe5f6b3afdbbb50a1dc08b7950c56f169611505c1"},
"opentelemetry_exporter": {:hex, :opentelemetry_exporter, "1.7.0", "dec4e90c0667cf11a3642f7fe71982dbc0c6bfbb8725a0b13766830718cf0d98", [:rebar3], [{:grpcbox, ">= 0.0.0", [hex: :grpcbox, repo: "hexpm", optional: false]}, {:opentelemetry, "~> 1.4.0", [hex: :opentelemetry, repo: "hexpm", optional: false]}, {:opentelemetry_api, "~> 1.3.0", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:tls_certificate_check, "~> 1.18", [hex: :tls_certificate_check, repo: "hexpm", optional: false]}], "hexpm", "d0f25f6439ec43f2561537c3fabbe177b38547cddaa3a692cbb8f4770dbefc1e"},
"opentelemetry_semantic_conventions": {:hex, :opentelemetry_semantic_conventions, "0.2.0", "b67fe459c2938fcab341cb0951c44860c62347c005ace1b50f8402576f241435", [:mix, :rebar3], [], "hexpm", "d61fa1f5639ee8668d74b527e6806e0503efc55a42db7b5f39939d84c07d6895"},
"opentelemetry": {:hex, :opentelemetry, "1.5.0", "7dda6551edfc3050ea4b0b40c0d2570423d6372b97e9c60793263ef62c53c3c2", [:rebar3], [{:opentelemetry_api, "~> 1.4", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "cdf4f51d17b592fc592b9a75f86a6f808c23044ba7cf7b9534debbcc5c23b0ee"},
"opentelemetry_api": {:hex, :opentelemetry_api, "1.4.0", "63ca1742f92f00059298f478048dfb826f4b20d49534493d6919a0db39b6db04", [:mix, :rebar3], [], "hexpm", "3dfbbfaa2c2ed3121c5c483162836c4f9027def469c41578af5ef32589fcfc58"},
"opentelemetry_exporter": {:hex, :opentelemetry_exporter, "1.8.0", "5d546123230771ef4174e37bedfd77e3374913304cd6ea3ca82a2add49cd5d56", [:rebar3], [{:grpcbox, ">= 0.0.0", [hex: :grpcbox, repo: "hexpm", optional: false]}, {:opentelemetry, "~> 1.5.0", [hex: :opentelemetry, repo: "hexpm", optional: false]}, {:opentelemetry_api, "~> 1.4.0", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:tls_certificate_check, "~> 1.18", [hex: :tls_certificate_check, repo: "hexpm", optional: false]}], "hexpm", "a1f9f271f8d3b02b81462a6bfef7075fd8457fdb06adff5d2537df5e2264d9af"},
"opentelemetry_semantic_conventions": {:hex, :opentelemetry_semantic_conventions, "1.27.0", "acd0194a94a1e57d63da982ee9f4a9f88834ae0b31b0bd850815fe9be4bbb45f", [:mix, :rebar3], [], "hexpm", "9681ccaa24fd3d810b4461581717661fd85ff7019b082c2dff89c7d5b1fc2864"},
"parse_trans": {:hex, :parse_trans, "3.4.1", "6e6aa8167cb44cc8f39441d05193be6e6f4e7c2946cb2759f015f8c56b76e5ff", [:rebar3], [], "hexpm", "620a406ce75dada827b82e453c19cf06776be266f5a67cff34e1ef2cbb60e49a"},
"plug": {:hex, :plug, "1.16.1", "40c74619c12f82736d2214557dedec2e9762029b2438d6d175c5074c933edc9d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a13ff6b9006b03d7e33874945b2755253841b238c34071ed85b0e86057f8cddc"},
"plug_cowboy": {:hex, :plug_cowboy, "2.7.2", "fdadb973799ae691bf9ecad99125b16625b1c6039999da5fe544d99218e662e4", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "245d8a11ee2306094840c000e8816f0cbed69a23fc0ac2bcf8d7835ae019bb2f"},
"plug_crypto": {:hex, :plug_crypto, "2.1.0", "f44309c2b06d249c27c8d3f65cfe08158ade08418cf540fd4f72d4d6863abb7b", [:mix], [], "hexpm", "131216a4b030b8f8ce0f26038bc4421ae60e4bb95c5cf5395e1421437824c4fa"},
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"},
"telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
"tls_certificate_check": {:hex, :tls_certificate_check, "1.22.1", "0f450cc1568a67a65ce5e15df53c53f9a098c3da081c5f126199a72505858dc1", [:rebar3], [{:ssl_verify_fun, "~> 1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "3092be0babdc0e14c2e900542351e066c0fa5a9cf4b3597559ad1e67f07938c0"},
"tls_certificate_check": {:hex, :tls_certificate_check, "1.24.0", "d00e2887551ff8cdae4d0340d90d9fcbc4943c7b5f49d32ed4bc23aff4db9a44", [:rebar3], [{:ssl_verify_fun, "~> 1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "90b25a58ee433d91c17f036d4d354bf8859a089bfda60e68a86f8eecae45ef1b"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
}
9 changes: 1 addition & 8 deletions test/telepoison_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,17 @@ defmodule TelepoisonTest do
attributes = elem(attributes_record, 4)

assert [
"http.method",
"http.request.method",
"http.response.status_code",
"http.status_code",
"http.url",
"net.peer.name",
"server.address",
"server.port",
"url.full",
"url.scheme"
] ==
attributes |> Map.keys() |> Enum.sort()

assert {"http.method", "GET"} in attributes
assert {"http.request.method", "GET"} in attributes
assert {"http.response.status_code", 200} in attributes
assert {"net.peer.name", "localhost"} in attributes
assert {"server.address", "localhost"} in attributes
assert {"server.port", 8000} in attributes
assert {"url.full", "http://localhost:8000"} in attributes
Expand Down Expand Up @@ -74,11 +68,10 @@ defmodule TelepoisonTest do
assert "atom" in Enum.map(headers, &elem(&1, 0))
end

test "http.url and url.full don't contain credentials" do
test "url.full don't contain credentials" do
Telepoison.get!("http://user:pass@localhost:8000/user/edit/24")

assert_receive {:span, span(attributes: attributes)}, 1000
assert confirm_attributes(attributes, {"http.url", "http://localhost:8000/user/edit/24"})
assert confirm_attributes(attributes, {"url.full", "http://localhost:8000/user/edit/24"})
end
end
Expand Down

0 comments on commit 52519d0

Please sign in to comment.