Skip to content

Commit c8ee3d4

Browse files
committed
otel-cpp 1.24
1 parent 721da05 commit c8ee3d4

6 files changed

Lines changed: 35 additions & 28 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ if(NOT DEFINED OTEL_CPP_INSTALLED_DIR)
282282
include(ExternalProject)
283283
set(OTEL_CPP_PROJECT_NAME opentelemetry-cpp)
284284
set(OTEL_CPP_GIT_REPOSITORY "https://github.com/open-telemetry/opentelemetry-cpp.git")
285-
set(OTEL_CPP_GIT_TAG "955a807")
285+
set(OTEL_CPP_GIT_TAG "a7b1008")
286286

287287
set(OTEL_CPP_CXX_STANDARD 14)
288288

examples/context_propagation/cpp/client.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright 2023-2024 The MathWorks, Inc.
1+
// Copyright 2023-2026 The MathWorks, Inc.
22

33
#include "opentelemetry/ext/http/client/http_client_factory.h"
44
#include "opentelemetry/ext/http/common/url_parser.h"
5-
#include "opentelemetry/trace/semantic_conventions.h"
5+
#include "opentelemetry/semconv/url_attributes.h"
6+
#include "opentelemetry/semconv/http_attributes.h"
67
#include "HttpTextMapCarrier.h"
78

89
#include "opentelemetry/exporters/otlp/otlp_http_exporter_factory.h"
@@ -26,6 +27,7 @@ using namespace opentelemetry::trace;
2627
namespace http_client = opentelemetry::ext::http::client;
2728
namespace context = opentelemetry::context;
2829
namespace nostd = opentelemetry::nostd;
30+
namespace semconv = opentelemetry::semconv;
2931

3032
void InitTracer()
3133
{
@@ -71,9 +73,9 @@ void sendRequest(const std::string &url)
7173
std::string span_name = url_parser.path_;
7274
auto span = get_tracer("http-client")
7375
->StartSpan(span_name,
74-
{{SemanticConventions::kUrlFull, url_parser.url_},
75-
{SemanticConventions::kUrlScheme, url_parser.scheme_},
76-
{SemanticConventions::kHttpRequestMethod, "POST"}},
76+
{{semconv::url::kUrlFull, url_parser.url_},
77+
{semconv::url::kUrlScheme, url_parser.scheme_},
78+
{semconv::http::kHttpRequestMethod, "POST"}},
7779
options);
7880
auto scope = get_tracer("http-client")->WithActiveSpan(span);
7981

@@ -89,7 +91,7 @@ void sendRequest(const std::string &url)
8991
{
9092
// set span attributes
9193
auto status_code = result.GetResponse().GetStatusCode();
92-
span->SetAttribute(SemanticConventions::kHttpResponseStatusCode, status_code);
94+
span->SetAttribute(semconv::http::kHttpResponseStatusCode, status_code);
9395
result.GetResponse().ForEachHeader(
9496
[&span](nostd::string_view header_name, nostd::string_view header_value) {
9597
span->SetAttribute("http.header." + std::string(header_name.data()), header_value);

examples/webread/cpp/server.cc

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
// Copyright 2023-2024 The MathWorks, Inc.
1+
// Copyright 2023-2026 The MathWorks, Inc.
22

33
#include "server.h"
44
#include "opentelemetry/trace/context.h"
5-
#include "opentelemetry/trace/semantic_conventions.h"
5+
#include "opentelemetry/semconv/url_attributes.h"
6+
#include "opentelemetry/semconv/server_attributes.h"
7+
#include "opentelemetry/semconv/client_attributes.h"
8+
#include "opentelemetry/semconv/incubating/http_attributes.h"
69
#include "HttpTextMapCarrier.h"
710

811
#include "opentelemetry/exporters/otlp/otlp_http_exporter_factory.h"
@@ -25,6 +28,7 @@ namespace
2528
using namespace opentelemetry::trace;
2629
namespace context = opentelemetry::context;
2730
namespace common = opentelemetry::common;
31+
namespace semconv= opentelemetry::semconv;
2832

2933
uint16_t server_port = 8800;
3034
constexpr const char *server_name = "localhost";
@@ -79,13 +83,13 @@ class RequestHandler : public HTTP_SERVER_NS::HttpRequestCallback
7983
// start span with parent context extracted from http header
8084
auto span = get_tracer("http_server")
8185
->StartSpan(span_name,
82-
{{SemanticConventions::kServerAddress, server_name},
83-
{SemanticConventions::kServerPort, server_port},
84-
{SemanticConventions::kHttpRequestMethod, request.method},
85-
{SemanticConventions::kUrlScheme, "http"},
86-
{SemanticConventions::kHttpRequestBodySize,
86+
{{semconv::server::kServerAddress, server_name},
87+
{semconv::server::kServerPort, server_port},
88+
{semconv::http::kHttpRequestMethod, request.method},
89+
{semconv::url::kUrlScheme, "http"},
90+
{semconv::http::kHttpRequestBodySize,
8791
static_cast<uint64_t>(request.content.length())},
88-
{SemanticConventions::kClientAddress, request.client}},
92+
{semconv::client::kClientAddress, request.client}},
8993
options);
9094

9195
auto scope = get_tracer("http_server")->WithActiveSpan(span);

patches/otel-cpp-windows.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
diff --git a/CMakeLists.txt b/CMakeLists.txt
2-
index cc085b1a..6c4dc0ae 100644
2+
index 6da525dc..07592866 100644
33
--- a/CMakeLists.txt
44
+++ b/CMakeLists.txt
5-
@@ -15,6 +15,12 @@ endif()
6-
7-
project(opentelemetry-cpp)
5+
@@ -21,6 +21,12 @@ project(
6+
VERSION "${OPENTELEMETRY_VERSION_NUMBER}"
7+
LANGUAGES CXX)
88

99
+if(WIN32)
1010
+ # Add a preprocessor macro _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR to work around an invalid MEX file issue

sdk/metrics/include/opentelemetry-matlab/sdk/metrics/ViewProxy.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023-2024 The MathWorks, Inc.
1+
// Copyright 2023-2026 The MathWorks, Inc.
22

33
#pragma once
44

@@ -19,9 +19,6 @@
1919
#include "opentelemetry/sdk/metrics/view/meter_selector.h"
2020
#include "opentelemetry/sdk/metrics/view/meter_selector_factory.h"
2121

22-
23-
#include "opentelemetry-matlab/sdk/metrics/ViewProxy.h"
24-
2522
namespace metrics_sdk = opentelemetry::sdk::metrics;
2623
namespace nostd = opentelemetry::nostd;
2724

@@ -87,7 +84,7 @@ class ViewProxy : public libmexclass::proxy::Proxy {
8784
std::string Description;
8885
metrics_sdk::AggregationType Aggregation;
8986
std::vector<double> HistogramBinEdges;
90-
std::unordered_map<std::string, bool> AllowedAttributes;
87+
metrics_sdk::FilterAttributeMap AllowedAttributes;
9188
bool FilterAttributes;
9289
};
9390
}

sdk/metrics/src/ViewProxy.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023-2025 The MathWorks, Inc.
1+
// Copyright 2023-2026 The MathWorks, Inc.
22

33
#include "opentelemetry-matlab/sdk/metrics/ViewProxy.h"
44

@@ -117,14 +117,18 @@ std::unique_ptr<metrics_sdk::View> ViewProxy::getView(){
117117
}
118118

119119
// HistogramAggregationConfig
120-
auto aggregation_config = std::shared_ptr<metrics_sdk::HistogramAggregationConfig>(new metrics_sdk::HistogramAggregationConfig());
120+
std::shared_ptr<metrics_sdk::AggregationConfig> aggregation_config;
121121
if(Aggregation == metrics_sdk::AggregationType::kHistogram ||
122122
(Aggregation == metrics_sdk::AggregationType::kDefault && InstrumentType == metrics_sdk::InstrumentType::kHistogram)){
123-
aggregation_config->boundaries_ = HistogramBinEdges;
123+
auto histogram_aggregation_config = std::make_shared<metrics_sdk::HistogramAggregationConfig>();
124+
histogram_aggregation_config->boundaries_ = HistogramBinEdges;
125+
aggregation_config = histogram_aggregation_config;
126+
} else {
127+
aggregation_config = std::make_shared<metrics_sdk::AggregationConfig>();
124128
}
125129

126130
// View
127-
return metrics_sdk::ViewFactory::Create(Name, Description, "", Aggregation, aggregation_config, std::move(attributes_processor));
131+
return metrics_sdk::ViewFactory::Create(Name, Description, Aggregation, aggregation_config, std::move(attributes_processor));
128132
}
129133

130134
std::unique_ptr<metrics_sdk::InstrumentSelector> ViewProxy::getInstrumentSelector(){

0 commit comments

Comments
 (0)