diff --git a/instrumentation/opentelemetry_phoenix/.formatter.exs b/instrumentation/opentelemetry_phoenix/.formatter.exs index 3ebaf3c2..7f79ed2e 100644 --- a/instrumentation/opentelemetry_phoenix/.formatter.exs +++ b/instrumentation/opentelemetry_phoenix/.formatter.exs @@ -1,5 +1,6 @@ # Used by "mix format" [ + import_deps: [:phoenix], line_length: 120, inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] ] diff --git a/instrumentation/opentelemetry_phoenix/mix.lock b/instrumentation/opentelemetry_phoenix/mix.lock index 54e8e310..736740f2 100644 --- a/instrumentation/opentelemetry_phoenix/mix.lock +++ b/instrumentation/opentelemetry_phoenix/mix.lock @@ -1,13 +1,13 @@ %{ "acceptor_pool": {:hex, :acceptor_pool, "1.0.0", "43c20d2acae35f0c2bcd64f9d2bde267e459f0f3fd23dab26485bf518c281b21", [:rebar3], [], "hexpm", "0cbcd83fdc8b9ad2eee2067ef8b91a14858a5883cb7cd800e6fcd5803e158788"}, - "bandit": {:hex, :bandit, "1.5.7", "6856b1e1df4f2b0cb3df1377eab7891bec2da6a7fd69dc78594ad3e152363a50", [:mix], [{:hpax, "~> 1.0.0", [hex: :hpax, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:thousand_island, "~> 1.0", [hex: :thousand_island, repo: "hexpm", optional: false]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "f2dd92ae87d2cbea2fa9aa1652db157b6cba6c405cb44d4f6dd87abba41371cd"}, - "castore": {:hex, :castore, "1.0.9", "5cc77474afadf02c7c017823f460a17daa7908e991b0cc917febc90e466a375c", [:mix], [], "hexpm", "5ea956504f1ba6f2b4eb707061d8e17870de2bee95fb59d512872c2ef06925e7"}, + "bandit": {:hex, :bandit, "1.6.3", "36591efd4bcf0e0508c16aee42b574b6c374077f7b96575ff46c519c827db144", [:mix], [{:hpax, "~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:thousand_island, "~> 1.0", [hex: :thousand_island, repo: "hexpm", optional: false]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "158a9802ec02ac297689948da8ce529a915528be11cb8fe0f27d1346864f50c0"}, + "castore": {:hex, :castore, "1.0.11", "4bbd584741601eb658007339ea730b082cc61f3554cf2e8f39bf693a11b49073", [:mix], [], "hexpm", "e03990b4db988df56262852f20de0f659871c35154691427a5047f4967a16a62"}, "chatterbox": {:hex, :ts_chatterbox, "0.15.1", "5cac4d15dd7ad61fc3c4415ce4826fc563d4643dee897a558ec4ea0b1c835c9c", [:rebar3], [{:hpack, "~> 0.3.0", [hex: :hpack_erl, repo: "hexpm", optional: false]}], "hexpm", "4f75b91451338bc0da5f52f3480fa6ef6e3a2aeecfc33686d6b3d0a0948f31aa"}, "cowboy": {:hex, :cowboy, "2.12.0", "f276d521a1ff88b2b9b4c54d0e753da6c66dd7be6c9fca3d9418b561828a3731", [:make, :rebar3], [{:cowlib, "2.13.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "8a7abe6d183372ceb21caa2709bec928ab2b72e18a3911aa1771639bef82651e"}, "cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"}, "cowlib": {:hex, :cowlib, "2.13.0", "db8f7505d8332d98ef50a3ef34b34c1afddec7506e4ee4dd4a3a266285d282ca", [:make, :rebar3], [], "hexpm", "e1e1284dc3fc030a64b1ad0d8382ae7e99da46c3246b815318a4b848873800a4"}, "ctx": {:hex, :ctx, "0.6.0", "8ff88b70e6400c4df90142e7f130625b82086077a45364a78d208ed3ed53c7fe", [:rebar3], [], "hexpm", "a14ed2d1b67723dbebbe423b28d7615eb0bdcba6ff28f2d1f1b0a7e1d4aa5fc2"}, - "dialyxir": {:hex, :dialyxir, "1.4.4", "fb3ce8741edeaea59c9ae84d5cec75da00fa89fe401c72d6e047d11a61f65f70", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "cd6111e8017ccd563e65621a4d9a4a1c5cd333df30cebc7face8029cacb4eff6"}, + "dialyxir": {:hex, :dialyxir, "1.4.5", "ca1571ac18e0f88d4ab245f0b60fa31ff1b12cbae2b11bd25d207f865e8ae78a", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b0fb08bb8107c750db5c0b324fa2df5ceaa0f9307690ee3c1f6ba5b9eb5d35c3"}, "earmark_parser": {:hex, :earmark_parser, "1.4.42", "f23d856f41919f17cd06a493923a722d87a2d684f143a1e663c04a2b93100682", [:mix], [], "hexpm", "6915b6ca369b5f7346636a2f41c6a6d78b5af419d61a611079189233358b8b8b"}, "erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"}, "ex_doc": {:hex, :ex_doc, "0.36.1", "4197d034f93e0b89ec79fac56e226107824adcce8d2dd0a26f5ed3a95efc36b1", [:mix], [{:earmark_parser, "~> 1.4.42", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "d7d26a7cf965dacadcd48f9fa7b5953d7d0cfa3b44fa7a65514427da44eafd89"}, @@ -15,7 +15,7 @@ "gproc": {:hex, :gproc, "0.9.1", "f1df0364423539cf0b80e8201c8b1839e229e5f9b3ccb944c5834626998f5b8c", [:rebar3], [], "hexpm", "905088e32e72127ed9466f0bac0d8e65704ca5e73ee5a62cb073c3117916d507"}, "grpcbox": {:hex, :grpcbox, "0.17.1", "6e040ab3ef16fe699ffb513b0ef8e2e896da7b18931a1ef817143037c454bcce", [:rebar3], [{:acceptor_pool, "~> 1.0.0", [hex: :acceptor_pool, repo: "hexpm", optional: false]}, {:chatterbox, "~> 0.15.1", [hex: :ts_chatterbox, repo: "hexpm", optional: false]}, {:ctx, "~> 0.6.0", [hex: :ctx, repo: "hexpm", optional: false]}, {:gproc, "~> 0.9.1", [hex: :gproc, repo: "hexpm", optional: false]}], "hexpm", "4a3b5d7111daabc569dc9cbd9b202a3237d81c80bf97212fbc676832cb0ceb17"}, "hpack": {:hex, :hpack_erl, "0.3.0", "2461899cc4ab6a0ef8e970c1661c5fc6a52d3c25580bc6dd204f84ce94669926", [:rebar3], [], "hexpm", "d6137d7079169d8c485c6962dfe261af5b9ef60fbc557344511c1e65e3d95fb0"}, - "hpax": {:hex, :hpax, "1.0.0", "28dcf54509fe2152a3d040e4e3df5b265dcb6cb532029ecbacf4ce52caea3fd2", [:mix], [], "hexpm", "7f1314731d711e2ca5fdc7fd361296593fc2542570b3105595bb0bc6d0fad601"}, + "hpax": {:hex, :hpax, "1.0.2", "762df951b0c399ff67cc57c3995ec3cf46d696e41f0bba17da0518d94acd4aac", [:mix], [], "hexpm", "2f09b4c1074e0abd846747329eaa26d535be0eb3d189fa69d812bfb8bfefd32f"}, "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, "makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"}, "makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"}, @@ -34,19 +34,19 @@ "opentelemetry_semantic_conventions": {:hex, :opentelemetry_semantic_conventions, "1.27.0", "acd0194a94a1e57d63da982ee9f4a9f88834ae0b31b0bd850815fe9be4bbb45f", [:mix, :rebar3], [], "hexpm", "9681ccaa24fd3d810b4461581717661fd85ff7019b082c2dff89c7d5b1fc2864"}, "opentelemetry_telemetry": {:hex, :opentelemetry_telemetry, "1.1.2", "410ab4d76b0921f42dbccbe5a7c831b8125282850be649ee1f70050d3961118a", [:mix, :rebar3], [{:opentelemetry_api, "~> 1.3", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "641ab469deb181957ac6d59bce6e1321d5fe2a56df444fc9c19afcad623ab253"}, "otel_http": {:hex, :otel_http, "0.2.0", "b17385986c7f1b862f5d577f72614ecaa29de40392b7618869999326b9a61d8a", [:rebar3], [], "hexpm", "f2beadf922c8cfeb0965488dd736c95cc6ea8b9efce89466b3904d317d7cc717"}, - "phoenix": {:hex, :phoenix, "1.7.14", "a7d0b3f1bc95987044ddada111e77bd7f75646a08518942c72a8440278ae7825", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.7", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "c7859bc56cc5dfef19ecfc240775dae358cbaa530231118a9e014df392ace61a"}, - "phoenix_html": {:hex, :phoenix_html, "4.1.1", "4c064fd3873d12ebb1388425a8f2a19348cef56e7289e1998e2d2fa758aa982e", [:mix], [], "hexpm", "f2f2df5a72bc9a2f510b21497fd7d2b86d932ec0598f0210fed4114adc546c6f"}, + "phoenix": {:hex, :phoenix, "1.7.18", "5310c21443514be44ed93c422e15870aef254cf1b3619e4f91538e7529d2b2e4", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.7", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "1797fcc82108442a66f2c77a643a62980f342bfeb63d6c9a515ab8294870004e"}, + "phoenix_html": {:hex, :phoenix_html, "4.2.0", "83a4d351b66f472ebcce242e4ae48af1b781866f00ef0eb34c15030d4e2069ac", [:mix], [], "hexpm", "9713b3f238d07043583a94296cc4bbdceacd3b3a6c74667f4df13971e7866ec8"}, "phoenix_pubsub": {:hex, :phoenix_pubsub, "2.1.3", "3168d78ba41835aecad272d5e8cd51aa87a7ac9eb836eabc42f6e57538e3731d", [:mix], [], "hexpm", "bba06bc1dcfd8cb086759f0edc94a8ba2bc8896d5331a1e2c2902bf8e36ee502"}, "phoenix_template": {:hex, :phoenix_template, "1.0.4", "e2092c132f3b5e5b2d49c96695342eb36d0ed514c5b252a77048d5969330d639", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "2c0c81f0e5c6753faf5cca2f229c9709919aba34fab866d3bc05060c9c444206"}, "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"}, - "req": {:hex, :req, "0.5.7", "b722680e03d531a2947282adff474362a48a02aa54b131196fbf7acaff5e4cee", [:mix], [{:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.17", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 2.0.6 or ~> 2.1", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "c6035374615120a8923e8089d0c21a3496cf9eda2d287b806081b8f323ceee29"}, + "req": {:hex, :req, "0.5.8", "50d8d65279d6e343a5e46980ac2a70e97136182950833a1968b371e753f6a662", [:mix], [{:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.17", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 2.0.6 or ~> 2.1", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "d7fc5898a566477e174f26887821a3c5082b243885520ee4b45555f5d53f40ef"}, "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"}, - "thousand_island": {:hex, :thousand_island, "1.3.5", "6022b6338f1635b3d32406ff98d68b843ba73b3aa95cfc27154223244f3a6ca5", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2be6954916fdfe4756af3239fb6b6d75d0b8063b5df03ba76fd8a4c87849e180"}, - "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"}, + "thousand_island": {:hex, :thousand_island, "1.3.9", "095db3e2650819443e33237891271943fad3b7f9ba341073947581362582ab5a", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "25ab4c07badadf7f87adb4ab414e0ed374e5f19e72503aa85132caa25776e54f"}, + "tls_certificate_check": {:hex, :tls_certificate_check, "1.25.0", "702b1835fe718a52310509537392abd067dbe941ebc05fe72409d2b2f8061651", [:rebar3], [{:ssl_verify_fun, "~> 1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "167343ccf50538cf2faf61a3f1460e749b3edf2ecef55516af2b5834362abcb1"}, "websock": {:hex, :websock, "0.5.3", "2f69a6ebe810328555b6fe5c831a851f485e303a7c8ce6c5f675abeb20ebdadc", [:mix], [], "hexpm", "6105453d7fac22c712ad66fab1d45abdf049868f253cf719b625151460b8b453"}, - "websock_adapter": {:hex, :websock_adapter, "0.5.7", "65fa74042530064ef0570b75b43f5c49bb8b235d6515671b3d250022cb8a1f9e", [:mix], [{:bandit, ">= 0.6.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "d0f478ee64deddfec64b800673fd6e0c8888b079d9f3444dd96d2a98383bdbd1"}, + "websock_adapter": {:hex, :websock_adapter, "0.5.8", "3b97dc94e407e2d1fc666b2fb9acf6be81a1798a2602294aac000260a7c4a47d", [:mix], [{:bandit, ">= 0.6.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "315b9a1865552212b5f35140ad194e67ce31af45bcee443d4ecb96b5fd3f3782"}, } diff --git a/instrumentation/opentelemetry_phoenix/test/integration_test.exs b/instrumentation/opentelemetry_phoenix/test/integration_test.exs index dbc18179..7a2d2182 100644 --- a/instrumentation/opentelemetry_phoenix/test/integration_test.exs +++ b/instrumentation/opentelemetry_phoenix/test/integration_test.exs @@ -1,5 +1,3 @@ -Code.require_file("support/endpoint_helper.exs", __DIR__) - otp_vsn = :erlang.system_info(:otp_release) |> to_string() @@ -9,11 +7,10 @@ if otp_vsn >= 27 do defmodule OpentelemetryPhoenix.Integration.TracingTest do use ExUnit.Case, async: false import ExUnit.CaptureLog - import Phoenix.Integration.EndpointHelper @moduletag :integration - @adapters [:cowboy, :bandit] + @adapters [:cowboy2, :bandit] defmodule TestController do use Phoenix.Controller, @@ -55,17 +52,17 @@ if otp_vsn >= 27 do # Import common connection and controller functions to use in pipelines import Plug.Conn - get("/", TestController, :root) + get "/", TestController, :root - get("/hello", TestController, :hello) + get "/hello", TestController, :hello - get("/users/:user_id", TestController, :user) + get "/users/:user_id", TestController, :user - get("/with_body", TestController, :with_body) + get "/with_body", TestController, :with_body - get("/router/oops", TestController, :oops) + get "/router/oops", TestController, :oops - get("/halted", TestController, :halted) + get "/halted", TestController, :halted end for adapter <- @adapters do @@ -86,19 +83,18 @@ if otp_vsn >= 27 do use Phoenix.Endpoint, otp_app: :endpoint_int - plug(Plug.Telemetry, event_prefix: [:phoenix, adapter, :endpoint]) + plug Plug.Telemetry, event_prefix: [:phoenix, adapter, :endpoint] - plug(Plug.Parsers, + plug Plug.Parsers, parsers: [:urlencoded, :multipart, :json], pass: ["*/*"], json_decoder: Phoenix.json_library() - ) - plug(Plug.MethodOverride) - plug(Plug.Head) + plug Plug.MethodOverride + plug Plug.Head - plug(:oops) - plug(Router) + plug :oops + plug Router @doc """ Verify errors from the plug stack too (before the router). @@ -134,87 +130,94 @@ if otp_vsn >= 27 do alias OpenTelemetry.SemConv.Incubating.HTTPAttributes alias OpenTelemetry.SemConv.Incubating.URLAttributes - setup do + setup context do :otel_simple_processor.set_exporter(:otel_exporter_pid, self()) - # Find available ports to use for this test - [bandit, cowboy] = get_unused_port_numbers(2) - - adapters = %{ - bandit: %{ - port: bandit, - spec: - {BanditEndpoint, - [ - http: [port: bandit], - url: [host: "bandit-example.com"], - adapter: Bandit.PhoenixAdapter, - server: true, - drainer: false, - render_errors: [accepts: ~w(html json)] - ]} - }, - cowboy: %{ - port: cowboy, - spec: - {CowboyEndpoint, - [ - http: [port: cowboy], - url: [host: "cowboy-example.com"], - adapter: Phoenix.Endpoint.Cowboy2Adapter, - server: true, - drainer: false, - render_errors: [accepts: ~w(html json)] - ]} - } - } + # Get unused port number + {:ok, socket} = :gen_tcp.listen(0, []) + {:ok, port} = :inet.port(socket) + :gen_tcp.close(socket) - on_exit(fn -> - :telemetry.list_handlers([]) - |> Enum.each(fn h -> :telemetry.detach(h.id) end) - end) + setup_adapter(Map.put(context, :port, port)) - adapters + {:ok, port: port} end - defp setup_adapter(adapter, opts \\ []) + defp setup_adapter(%{adapter: :bandit, port: port} = context) do + {:ok, _} = + start_supervised({ + BanditEndpoint, + http: [port: port], + url: [host: "bandit-example.com"], + adapter: Bandit.PhoenixAdapter, + server: true, + drainer: false, + render_errors: [accepts: ~w(html json)] + }) - defp setup_adapter(:bandit, opts) do - OpentelemetryBandit.setup(opts) + OpentelemetryBandit.setup(Map.get(context, :opts, [])) OpentelemetryPhoenix.setup( adapter: :bandit, endpoint_prefix: [:phoenix, :bandit, :endpoint] ) + + on_exit(fn -> + [ + :telemetry.list_handlers([:phoenix]), + :telemetry.list_handlers([:bandit]) + ] + |> List.flatten() + |> Enum.each(&:telemetry.detach(&1.id)) + end) end - defp setup_adapter(:cowboy, opts) do - :opentelemetry_cowboy.setup(opts) + defp setup_adapter(%{adapter: :cowboy2, port: port} = context) do + {:ok, _} = + start_supervised({ + Cowboy2Endpoint, + http: [port: port], + url: [host: "cowboy-example.com"], + adapter: Phoenix.Endpoint.Cowboy2Adapter, + server: true, + drainer: false, + render_errors: [accepts: ~w(html json)] + }) + + :opentelemetry_cowboy.setup(Map.get(context, :opts, [])) OpentelemetryPhoenix.setup( adapter: :cowboy2, - endpoint_prefix: [:phoenix, :cowboy, :endpoint] + endpoint_prefix: [:phoenix, :cowboy2, :endpoint] ) + + on_exit(fn -> + [ + :telemetry.list_handlers([:phoenix]), + :telemetry.list_handlers([:cowboy]) + ] + |> List.flatten() + |> Enum.each(&:telemetry.detach(&1.id)) + end) end adapter_suites = - for adapter <- [:bandit, :cowboy], protocol <- [:http1, :http2], do: {adapter, protocol} + for adapter <- [:bandit, :cowboy2], protocol <- [:http1, :http2], do: {adapter, protocol} for {adapter, protocol} <- adapter_suites do describe "#{adapter} - #{protocol}" do - test "basic request with default options", %{unquote(adapter) => adapter_info} do - capture_log(fn -> - {:ok, _} = start_supervised(adapter_info.spec) - setup_adapter(unquote(adapter)) + @describetag adapter: adapter, protocol: protocol - Req.get("http://localhost:#{adapter_info.port}/users/1234", + test "basic request with default options", %{protocol: protocol} = context do + capture_log(fn -> + request!( + context, + "/users/1234", params: [a: 1, b: "abc"], headers: %{ "traceparent" => "00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01", "tracestate" => "congo=t61rcWkgMzE" - }, - retry: false, - connect_options: [protocols: [unquote(protocol)]] + } ) assert_receive {:span, @@ -227,7 +230,7 @@ if otp_vsn >= 27 do attrs = :otel_attributes.map(span_attrs) - expected_proto = if unquote(protocol) == :http1, do: :"1.1", else: :"2" + expected_proto = if protocol == :http1, do: :"1.1", else: :"2" expected_attrs = [ {ClientAttributes.client_address(), "127.0.0.1"}, @@ -253,18 +256,16 @@ if otp_vsn >= 27 do end) end - test "public endpoint true", %{unquote(adapter) => adapter_info} do + @tag opts: [public_endpoint: true] + test "public endpoint true", context do capture_log(fn -> - {:ok, _} = start_supervised(adapter_info.spec) - setup_adapter(unquote(adapter), public_endpoint: true) - - Req.get("http://localhost:#{adapter_info.port}/hello", + request!( + context, + "/hello", headers: %{ "traceparent" => "00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01", "tracestate" => "congo=t61rcWkgMzE" - }, - retry: false, - connect_options: [protocols: [unquote(protocol)]] + } ) refute_receive {:span, @@ -286,23 +287,18 @@ if otp_vsn >= 27 do end) end - test "public endpoint fn", %{unquote(adapter) => adapter_info} do + @tag opts: [public_endpoint_fn: {__MODULE__, :public_endpoint_fn, []}] + test "public endpoint fn", context do capture_log(fn -> - {:ok, _} = start_supervised(adapter_info.spec) - - setup_adapter(unquote(adapter), - public_endpoint_fn: {__MODULE__, :public_endpoint_fn, []} - ) - System.put_env("TENANT", "customer") - Req.get("http://localhost:#{adapter_info.port}/hello", + request!( + context, + "/hello", headers: %{ "traceparent" => "00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01", "tracestate" => "congo=t61rcWkgMzE" - }, - retry: false, - connect_options: [protocols: [unquote(protocol)]] + } ) refute_receive {:span, @@ -324,13 +320,13 @@ if otp_vsn >= 27 do System.put_env("TENANT", "internal") - Req.get("http://localhost:#{adapter_info.port}/hello", + request!( + context, + "/hello", headers: %{ "traceparent" => "00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01", "tracestate" => "congo=t61rcWkgMzE" - }, - retry: false, - connect_options: [protocols: [unquote(protocol)]] + } ) assert_receive {:span, @@ -351,27 +347,24 @@ if otp_vsn >= 27 do end) end - test "with all opt-ins", %{unquote(adapter) => adapter_info} do + @tag opts: [ + opt_in_attrs: [ + ClientAttributes.client_port(), + HTTPAttributes.http_request_body_size(), + HTTPAttributes.http_response_body_size(), + NetworkAttributes.network_local_address(), + NetworkAttributes.network_local_port(), + NetworkAttributes.network_transport() + ], + request_headers: ["test-header"], + response_headers: ["content-type"] + ] + test "with all opt-ins", %{port: port} = context do capture_log(fn -> - {:ok, _} = start_supervised(adapter_info.spec) - - setup_adapter(unquote(adapter), - opt_in_attrs: [ - ClientAttributes.client_port(), - HTTPAttributes.http_request_body_size(), - HTTPAttributes.http_response_body_size(), - NetworkAttributes.network_local_address(), - NetworkAttributes.network_local_port(), - NetworkAttributes.network_transport() - ], - request_headers: ["test-header"], - response_headers: ["content-type"] - ) - - Req.get!("http://localhost:#{adapter_info.port}/with_body", - headers: %{"test-header" => "request header"}, - retry: false, - connect_options: [protocols: [unquote(protocol)]] + request!( + context, + "/with_body", + headers: %{"test-header" => "request header"} ) assert_receive {:span, @@ -391,7 +384,7 @@ if otp_vsn >= 27 do {String.to_atom("#{HTTPAttributes.http_response_header()}.content-type"), ["application/json; charset=utf-8"]}, {NetworkAttributes.network_local_address(), "localhost"}, - {NetworkAttributes.network_local_port(), adapter_info.port}, + {NetworkAttributes.network_local_port(), port}, {NetworkAttributes.network_peer_address(), "127.0.0.1"}, {URLAttributes.url_path(), "/with_body"}, {URLAttributes.url_scheme(), :http} @@ -409,27 +402,26 @@ if otp_vsn >= 27 do assert is_integer(client_port) body_size = Map.get(attrs, HTTPAttributes.http_response_body_size()) - # for some reason bandit and cowboy measure this differently with + # for some reason bandit and cowboy2 measure this differently with # bandit being much larger despite the bodies being the same and compression # not being enabled assert is_integer(body_size) && body_size > 0 end) end - test "with custom header settings", %{unquote(adapter) => adapter_info} do + @tag opts: [ + client_address_headers: ["x-forwarded-for", "custom-client"], + client_headers_sort_fn: &__MODULE__.custom_client_header_sort/2, + scheme_headers: ["custom-scheme", "x-forwarded-proto"], + scheme_headers_sort_fn: &__MODULE__.custom_scheme_header_sort/2, + server_address_headers: ["custom-host", "forwarded", "host"], + server_headers_sort_fn: &__MODULE__.custom_server_header_sort/2 + ] + test "with custom header settings", context do capture_log(fn -> - {:ok, _} = start_supervised(adapter_info.spec) - - setup_adapter(unquote(adapter), - client_address_headers: ["x-forwarded-for", "custom-client"], - client_headers_sort_fn: &__MODULE__.custom_client_header_sort/2, - scheme_headers: ["custom-scheme", "x-forwarded-proto"], - scheme_headers_sort_fn: &__MODULE__.custom_scheme_header_sort/2, - server_address_headers: ["custom-host", "forwarded", "host"], - server_headers_sort_fn: &__MODULE__.custom_server_header_sort/2 - ) - - Req.get("http://localhost:#{adapter_info.port}/hello", + request!( + context, + "/hello", headers: %{ "forwarded" => ~S(host=developer.mozilla.org:4321; for=192.0.2.60, for="[2001:db8:cafe::17]";proto=http;by=203.0.113.43), @@ -438,9 +430,7 @@ if otp_vsn >= 27 do "custom-client" => "23.23.23.23", "traceparent" => "00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01", "tracestate" => "congo=t61rcWkgMzE" - }, - retry: false, - connect_options: [protocols: [unquote(protocol)]] + } ) assert_receive {:span, @@ -471,16 +461,12 @@ if otp_vsn >= 27 do end) end - test "with missing user-agent", %{unquote(adapter) => adapter_info} do + test "with missing user-agent", %{port: port} do capture_log(fn -> - {:ok, _} = start_supervised(adapter_info.spec) - - setup_adapter(unquote(adapter)) - {:ok, {{_, 200, _}, _, _}} = :httpc.request( :get, - {~c"http://localhost:#{adapter_info.port}/hello", []}, + {~c"http://localhost:#{port}/hello", []}, [], [] ) @@ -493,16 +479,9 @@ if otp_vsn >= 27 do end) end - test "with exception", %{unquote(adapter) => adapter_info} do + test "with exception", context do capture_log(fn -> - {:ok, _} = start_supervised(adapter_info.spec) - - setup_adapter(unquote(adapter)) - - Req.get("http://localhost:#{adapter_info.port}/router/oops", - retry: false, - connect_options: [protocols: [unquote(protocol)]] - ) + request!(context, "/router/oops") expected_status = OpenTelemetry.status(:error, "") @@ -548,16 +527,9 @@ if otp_vsn >= 27 do end) end - test "with halted request", %{unquote(adapter) => adapter_info} do + test "with halted request", context do capture_log(fn -> - {:ok, _} = start_supervised(adapter_info.spec) - - setup_adapter(unquote(adapter)) - - Req.get("http://localhost:#{adapter_info.port}/halted", - retry: false, - connect_options: [protocols: [unquote(protocol)]] - ) + request!(context, "/halted") expected_status = OpenTelemetry.status(:error, "") @@ -585,6 +557,17 @@ if otp_vsn >= 27 do end end + defp request!(%{port: port, protocol: protocol}, "/" <> uri, opts \\ []) do + [ + url: "http://localhost:#{port}/#{uri}", + retry: false, + connect_options: [protocols: [protocol]] + ] + |> Keyword.merge(opts) + |> Req.new() + |> Req.get!() + end + def custom_client_header_sort(h1, h2) do h1_priority = custom_client_header_priority(h1) h2_priority = custom_client_header_priority(h2) diff --git a/instrumentation/opentelemetry_phoenix/test/opentelemetry_phoenix_test.exs b/instrumentation/opentelemetry_phoenix/test/opentelemetry_phoenix_test.exs index 273b4d4c..4db0a596 100644 --- a/instrumentation/opentelemetry_phoenix/test/opentelemetry_phoenix_test.exs +++ b/instrumentation/opentelemetry_phoenix/test/opentelemetry_phoenix_test.exs @@ -18,19 +18,18 @@ defmodule OpentelemetryPhoenixTest do end setup do - Application.ensure_all_started([:telemetry]) :otel_simple_processor.set_exporter(:otel_exporter_pid, self()) + OpentelemetryPhoenix.setup(adapter: :cowboy2) + on_exit(fn -> - Application.stop(:telemetry) + Enum.each(:telemetry.list_handlers([]), &:telemetry.detach(&1.id)) end) :ok end test "records spans for Phoenix LiveView mount" do - OpentelemetryPhoenix.setup(adapter: :cowboy2) - :telemetry.execute( [:phoenix, :live_view, :mount, :start], %{system_time: System.system_time()}, @@ -53,8 +52,6 @@ defmodule OpentelemetryPhoenixTest do end test "records spans for Phoenix LiveView handle_params" do - OpentelemetryPhoenix.setup(adapter: :cowboy2) - :telemetry.execute( [:phoenix, :live_view, :handle_params, :start], %{system_time: System.system_time()}, @@ -77,8 +74,6 @@ defmodule OpentelemetryPhoenixTest do end test "records spans for Phoenix LiveView handle_event" do - OpentelemetryPhoenix.setup(adapter: :cowboy2) - :telemetry.execute( [:phoenix, :live_view, :handle_event, :start], %{system_time: System.system_time()}, @@ -101,8 +96,6 @@ defmodule OpentelemetryPhoenixTest do end test "handles exception during Phoenix LiveView handle_params" do - OpentelemetryPhoenix.setup(adapter: :cowboy2) - :telemetry.execute( [:phoenix, :live_view, :mount, :start], %{system_time: System.system_time()}, @@ -160,8 +153,6 @@ defmodule OpentelemetryPhoenixTest do end test "handles exceptions during Phoenix LiveView handle_event" do - OpentelemetryPhoenix.setup(adapter: :cowboy2) - :telemetry.execute( [:phoenix, :live_view, :handle_event, :start], %{system_time: System.system_time()}, diff --git a/instrumentation/opentelemetry_phoenix/test/support/endpoint_helper.exs b/instrumentation/opentelemetry_phoenix/test/support/endpoint_helper.exs deleted file mode 100644 index bd977fea..00000000 --- a/instrumentation/opentelemetry_phoenix/test/support/endpoint_helper.exs +++ /dev/null @@ -1,30 +0,0 @@ -defmodule Phoenix.Integration.EndpointHelper do - # From Phoenix repo - # https://github.com/phoenixframework/phoenix/blob/main/test/support/endpoint_helper.exs - - @moduledoc """ - Utility functions for integration testing endpoints. - """ - - @doc """ - Finds `n` unused network port numbers. - """ - def get_unused_port_numbers(n) when is_integer(n) and n > 1 do - 1..n - # Open up `n` sockets at the same time, so we don't get - # duplicate port numbers - |> Enum.map(&listen_on_os_assigned_port/1) - |> Enum.map(&get_port_number_and_close/1) - end - - defp listen_on_os_assigned_port(_) do - {:ok, socket} = :gen_tcp.listen(0, []) - socket - end - - defp get_port_number_and_close(socket) do - {:ok, port_number} = :inet.port(socket) - :gen_tcp.close(socket) - port_number - end -end