From 52caf487fbabac3bafebb215ea94e525c9b55793 Mon Sep 17 00:00:00 2001 From: Garry Hill Date: Thu, 31 Oct 2024 13:28:26 +0000 Subject: [PATCH] Update opentelemetry dependencies (#1887) The latest version of `opentelemetry` no longer includes `opentelemetry_semantic_conventions` as a dependency, which means bringing `electric` in as a dependency resulted in compilation errors. This PR explicitly includes `opentelemetry_semantic_conventions` as a dependency, so fixes compilation, and updates our usage to remove the deprecated functions as well as moving to the latest attributes. --- .changeset/new-eagles-deliver.md | 5 ++++ .../lib/electric/plug/serve_shape_plug.ex | 26 +++++++++---------- .../lib/electric/telemetry/open_telemetry.ex | 6 ++--- packages/sync-service/mix.exs | 5 ++-- packages/sync-service/mix.lock | 10 +++---- 5 files changed, 29 insertions(+), 23 deletions(-) create mode 100644 .changeset/new-eagles-deliver.md diff --git a/.changeset/new-eagles-deliver.md b/.changeset/new-eagles-deliver.md new file mode 100644 index 0000000000..426128917c --- /dev/null +++ b/.changeset/new-eagles-deliver.md @@ -0,0 +1,5 @@ +--- +"@core/sync-service": patch +--- + +Update OpenTelemetry dependencies diff --git a/packages/sync-service/lib/electric/plug/serve_shape_plug.ex b/packages/sync-service/lib/electric/plug/serve_shape_plug.ex index 142368b8db..51d39f6442 100644 --- a/packages/sync-service/lib/electric/plug/serve_shape_plug.ex +++ b/packages/sync-service/lib/electric/plug/serve_shape_plug.ex @@ -5,7 +5,7 @@ defmodule Electric.Plug.ServeShapePlug do # The halt/1 function is redefined further down below import Plug.Conn, except: [halt: 1] - alias OpenTelemetry.SemanticConventions, as: SC + alias OpenTelemetry.SemConv, as: SC alias Electric.Shapes alias Electric.Schema @@ -14,7 +14,6 @@ defmodule Electric.Plug.ServeShapePlug do alias Plug.Conn require Logger - require SC.Trace # Aliasing for pattern matching @before_all_offset LogOffset.before_all() @@ -624,17 +623,18 @@ defmodule Electric.Plug.ServeShapePlug do "error.type" => assigns[:error_str], "http.request_id" => assigns[:plug_request_id], "http.query_string" => conn.query_string, - SC.Trace.http_client_ip() => client_ip(conn), - SC.Trace.http_scheme() => conn.scheme, - SC.Trace.net_peer_name() => conn.host, - SC.Trace.net_peer_port() => conn.port, - SC.Trace.http_target() => conn.request_path, - SC.Trace.http_method() => conn.method, - SC.Trace.http_status_code() => conn.status, - SC.Trace.http_response_content_length() => assigns[:streaming_bytes_sent], - SC.Trace.net_transport() => :"IP.TCP", - SC.Trace.http_user_agent() => user_agent(conn), - SC.Trace.http_url() => + SC.ClientAttributes.client_address() => client_ip(conn), + SC.ServerAttributes.server_address() => conn.host, + SC.ServerAttributes.server_port() => conn.port, + SC.HTTPAttributes.http_request_method() => conn.method, + SC.HTTPAttributes.http_response_status_code() => conn.status, + SC.Incubating.HTTPAttributes.http_response_size() => assigns[:streaming_bytes_sent], + SC.NetworkAttributes.network_transport() => :tcp, + SC.NetworkAttributes.network_local_port() => conn.port, + SC.UserAgentAttributes.user_agent_original() => user_agent(conn), + SC.Incubating.URLAttributes.url_path() => conn.request_path, + SC.URLAttributes.url_scheme() => conn.scheme, + SC.URLAttributes.url_full() => %URI{ scheme: to_string(conn.scheme), host: conn.host, diff --git a/packages/sync-service/lib/electric/telemetry/open_telemetry.ex b/packages/sync-service/lib/electric/telemetry/open_telemetry.ex index 98868c5774..2ec57c2a66 100644 --- a/packages/sync-service/lib/electric/telemetry/open_telemetry.ex +++ b/packages/sync-service/lib/electric/telemetry/open_telemetry.ex @@ -116,9 +116,9 @@ defmodule Electric.Telemetry.OpenTelemetry do defp add_exception_event(type, message, stacktrace, attributes) do semantic_attributes = [ - {OpenTelemetry.SemanticConventions.Trace.exception_type(), type}, - {OpenTelemetry.SemanticConventions.Trace.exception_message(), message}, - {OpenTelemetry.SemanticConventions.Trace.exception_stacktrace(), + {OpenTelemetry.SemConv.ExceptionAttributes.exception_type(), type}, + {OpenTelemetry.SemConv.ExceptionAttributes.exception_message(), message}, + {OpenTelemetry.SemConv.ExceptionAttributes.exception_stacktrace(), Exception.format_stacktrace(stacktrace)} ] diff --git a/packages/sync-service/mix.exs b/packages/sync-service/mix.exs index 24e493dcd0..fecbb495b6 100644 --- a/packages/sync-service/mix.exs +++ b/packages/sync-service/mix.exs @@ -76,9 +76,10 @@ defmodule Electric.MixProject do {:gen_stage, "~> 1.2"}, {:jason, "~> 1.4"}, {:nimble_options, "~> 1.1"}, - {:opentelemetry, "~> 1.4"}, - {:opentelemetry_exporter, "~> 1.6"}, + {:opentelemetry, "~> 1.5"}, + {:opentelemetry_exporter, "~> 1.8"}, {:opentelemetry_telemetry, "~> 1.1"}, + {:opentelemetry_semantic_conventions, "~> 1.27"}, {:pg_query_ex, "0.5.3"}, {:plug, "~> 1.16"}, {:postgrex, "~> 0.19"}, diff --git a/packages/sync-service/mix.lock b/packages/sync-service/mix.lock index 09aa6bbca3..9fb5f2abc5 100644 --- a/packages/sync-service/mix.lock +++ b/packages/sync-service/mix.lock @@ -28,10 +28,10 @@ "mox": {:hex, :mox, "1.1.0", "0f5e399649ce9ab7602f72e718305c0f9cdc351190f72844599545e4996af73c", [:mix], [], "hexpm", "d44474c50be02d5b72131070281a5d3895c0e7a95c780e90bc0cfe712f633a13"}, "nimble_options": {:hex, :nimble_options, "1.1.1", "e3a492d54d85fc3fd7c5baf411d9d2852922f66e69476317787a7b2bb000a61b", [:mix], [], "hexpm", "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44"}, "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.0", "03e2177f28dd8d11aaa88e8522c81c2f6a788170fe52f7a65262340961e663f9", [:mix, :rebar3], [{:opentelemetry_semantic_conventions, "~> 0.2", [hex: :opentelemetry_semantic_conventions, repo: "hexpm", optional: false]}], "hexpm", "b9e5ff775fd064fa098dba3c398490b77649a352b40b0b730a6b7dc0bdd68858"}, - "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"}, "opentelemetry_telemetry": {:hex, :opentelemetry_telemetry, "1.1.1", "4a73bfa29d7780ffe33db345465919cef875034854649c37ac789eb8e8f38b21", [:mix, :rebar3], [{:opentelemetry_api, "~> 1.0", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ee43b14e6866123a3ee1344e3c0d3d7591f4537542c2a925fcdbf46249c9b50b"}, "pg_query_ex": {:hex, :pg_query_ex, "0.5.3", "84bf09f4ea10ada6e1cbfd739ccb9ffb6e5b21d87ab81cf52a42fefcc1808566", [:make, :mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:protox, "~> 1.7", [hex: :protox, repo: "hexpm", optional: false]}], "hexpm", "ec0554d6d287da4cc15cc773577ef61cf41d5d6fcc784bb85f6209439cb246a7"}, "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"}, @@ -46,7 +46,7 @@ "telemetry_metrics_statsd": {:hex, :telemetry_metrics_statsd, "0.7.0", "92732fae63db31ef2508df6faee7d81401883e33f2976715a82f296a33a45cee", [:mix], [{:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.6", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "797e34a856376dfd4e96347da0f747fcff4e0cadf6e6f0f989598f563cad05ff"}, "telemetry_poller": {:hex, :telemetry_poller, "1.1.0", "58fa7c216257291caaf8d05678c8d01bd45f4bdbc1286838a28c4bb62ef32999", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "9eb9d9cbfd81cbd7cdd24682f8711b6e2b691289a0de6826e58452f28c103c8f"}, "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.23.0", "bb7869c629de4ec72d4652520c1ad2255bb5712ad09a6568c41b0294b3cec78f", [:rebar3], [{:ssl_verify_fun, "~> 1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "79d0c84effc7c81ac1e85fa38b1c33572fe2976fb8fafdfb2f0140de0442d494"}, + "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"}, "tz": {:hex, :tz, "0.27.1", "d8091d0c2d4f590e010c94830c3d842f548b4872a5b92028d74f0d0a3887aebe", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:mint, "~> 1.6", [hex: :mint, repo: "hexpm", optional: true]}], "hexpm", "215c9120dab5b7f7db4c93e91085c290b2efe478e147d84285a6583fd220727f"}, "websock": {:hex, :websock, "0.5.3", "2f69a6ebe810328555b6fe5c831a851f485e303a7c8ce6c5f675abeb20ebdadc", [:mix], [], "hexpm", "6105453d7fac22c712ad66fab1d45abdf049868f253cf719b625151460b8b453"}, }