From ff2e9da1f80deac1fb831ac76f206331c198b9f0 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Sun, 23 Jul 2023 22:40:52 +0200 Subject: [PATCH] Update http semantic conventions. See https://github.com/open-telemetry/opentelemetry-specification/pull/3355 --- examples/grpc/client.cc | 4 ++-- examples/http/client.cc | 8 ++++---- examples/http/server.cc | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/grpc/client.cc b/examples/grpc/client.cc index 11fde192b3..92088c12f6 100644 --- a/examples/grpc/client.cc +++ b/examples/grpc/client.cc @@ -53,8 +53,8 @@ class GreeterClient {{SemanticConventions::kRpcSystem, "grpc"}, {SemanticConventions::kRpcService, "grpc-example.GreetService"}, {SemanticConventions::kRpcMethod, "Greet"}, - {SemanticConventions::kNetSockPeerAddr, ip}, - {SemanticConventions::kNetPeerPort, port}}, + {SemanticConventions::kServerSocketAddress, ip}, + {SemanticConventions::kServerPort, port}}, options); auto scope = get_tracer("grpc-client")->WithActiveSpan(span); diff --git a/examples/http/client.cc b/examples/http/client.cc index 46be83bf2e..433f51a64f 100644 --- a/examples/http/client.cc +++ b/examples/http/client.cc @@ -26,9 +26,9 @@ void sendRequest(const std::string &url) std::string span_name = url_parser.path_; auto span = get_tracer("http-client") ->StartSpan(span_name, - {{SemanticConventions::kHttpUrl, url_parser.url_}, - {SemanticConventions::kHttpScheme, url_parser.scheme_}, - {SemanticConventions::kHttpMethod, "GET"}}, + {{SemanticConventions::kUrlFull, url_parser.url_}, + {SemanticConventions::kUrlScheme, url_parser.scheme_}, + {SemanticConventions::kHttpRequestMethod, "GET"}}, options); auto scope = get_tracer("http-client")->WithActiveSpan(span); @@ -44,7 +44,7 @@ void sendRequest(const std::string &url) { // set span attributes auto status_code = result.GetResponse().GetStatusCode(); - span->SetAttribute(SemanticConventions::kHttpStatusCode, status_code); + span->SetAttribute(SemanticConventions::kHttpResponseStatusCode, status_code); result.GetResponse().ForEachHeader( [&span](nostd::string_view header_name, nostd::string_view header_value) { span->SetAttribute("http.header." + std::string(header_name.data()), header_value); diff --git a/examples/http/server.cc b/examples/http/server.cc index 874af9e3b8..c2d7a2c5a3 100644 --- a/examples/http/server.cc +++ b/examples/http/server.cc @@ -40,11 +40,11 @@ class RequestHandler : public HTTP_SERVER_NS::HttpRequestCallback // start span with parent context extracted from http header auto span = get_tracer("http-server") ->StartSpan(span_name, - {{SemanticConventions::kNetHostName, server_name}, - {SemanticConventions::kNetHostPort, server_port}, - {SemanticConventions::kHttpMethod, request.method}, - {SemanticConventions::kHttpScheme, "http"}, - {SemanticConventions::kHttpRequestContentLength, + {{SemanticConventions::kServerAddress, server_name}, + {SemanticConventions::kServerPort, server_port}, + {SemanticConventions::kHttpRequestMethod, request.method}, + {SemanticConventions::kUrlScheme, "http"}, + {SemanticConventions::kHttpRequestBodySize, static_cast(request.content.length())}, {SemanticConventions::kClientAddress, request.client}}, options);