Skip to content

Commit

Permalink
Update http semantic conventions.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalff committed Jul 23, 2023
1 parent 84634c6 commit ff2e9da
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions examples/grpc/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions examples/http/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions examples/http/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint64_t>(request.content.length())},
{SemanticConventions::kClientAddress, request.client}},
options);
Expand Down

0 comments on commit ff2e9da

Please sign in to comment.