Skip to content

Commit

Permalink
Merge pull request #14 from mathworks/changes_after_v_1_2_0
Browse files Browse the repository at this point in the history
Changes after v 1 2 0
  • Loading branch information
duncanpo authored Sep 13, 2023
2 parents 23abff8 + f54327c commit e2525ed
Show file tree
Hide file tree
Showing 23 changed files with 390 additions and 178 deletions.
24 changes: 1 addition & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,17 @@ jobs:
uses: actions/checkout@v3
with:
path: opentelemetry-matlab
- name: Download OpenTelemetry-cpp source
uses: actions/checkout@v3
with:
repository: open-telemetry/opentelemetry-cpp
path: opentelemetry-cpp
ref: v1.9.0
- name: Download vcpkg
uses: actions/checkout@v3
with:
repository: microsoft/vcpkg
path: vcpkg
- name: Install MATLAB
uses: matlab-actions/setup-matlab@v1
- name: Install vcpkg packages
run: |
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg install curl nlohmann-json protobuf zlib
- name: Download OpenTelemetry Collector binary
run: |
mkdir otelcol && cd otelcol
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.75.0/otelcol_0.75.0_linux_amd64.tar.gz
tar -xzf otelcol_0.75.0_linux_amd64.tar.gz
- name: Build OpenTelemetry-cpp
run: |
cd opentelemetry-cpp
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_CXX_STANDARD=20 -DWITH_OTLP=ON -DWITH_OTLP_HTTP=ON -DWITH_OTLP_GRPC=OFF -DBUILD_TESTING=OFF -DWITH_BENCHMARK=OFF -DOPENTELEMETRY_INSTALL=ON -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build --config Release --target all
cmake --install build --prefix ${{ env.OPENTELEMETRY_CPP_INSTALL }}
- name: Build OpenTelemetry-Matlab
run: |
cd opentelemetry-matlab
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }} -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_PREFIX_PATH=${{ env.OPENTELEMETRY_CPP_INSTALL }}/lib/cmake/opentelemetry-cpp
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }}
cmake --build build --config Release --target install
- name: Run tests
env:
Expand Down
199 changes: 178 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,63 @@
cmake_minimum_required(VERSION 3.0.0)
cmake_minimum_required(VERSION 3.7.0)

cmake_policy(SET CMP0074 NEW)

set(CLIENT_PROJECT_NAME otel-matlab)

project(${CLIENT_PROJECT_NAME} VERSION 0.1.0)
# ###########################
# vcpkg
# ###########################

include(FetchContent)

# check if VCPKG_ROOT is defined, which should point to an existing installation
if(DEFINED ENV{VCPKG_ROOT})
# Autodetect vcpkg toolchain
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
string(REPLACE "\\" "/" CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
endif()
else()
# VCPKG_ROOT not defined, get it using FetchContent

if(DEFINED VCPKG_PREFIX})
# download location specified
string(REPLACE "\\" "/" VCPKG_PREFIX "${VCPKG_PREFIX}")
else()
set(VCPKG_PREFIX ${CMAKE_BINARY_DIR}/vcpkg)
endif()

# On Mac, there is a conflict between libcurl and the version in MATLAB, so
# use libcurl as a shared library and load the MATLAB version at runtime
if(APPLE)
# run uname -m to determine whether arm64 or x86_64
exec_program(uname ARGS -m OUTPUT_VARIABLE MAC_HOST_SYSTEM)
set(VCPKG_OTEL_TRIPLET ${MAC_HOST_SYSTEM}-osx-otel-matlab)
set(VCPKG_OVERLAY_TRIPLETS ${CMAKE_SOURCE_DIR}/cmake/vcpkg_triplets)
set(VCPKG_TARGET_TRIPLET ${VCPKG_OTEL_TRIPLET})
endif()

set(VCPKG_FETCH_CONTENT_NAME vcpkg)
set(VCPKG_GIT_REPOSITORY "https://github.com/microsoft/vcpkg.git")
set(VCPKG_GIT_TAG "9edb1b8")
FetchContent_Declare(
${VCPKG_FETCH_CONTENT_NAME}
GIT_REPOSITORY ${VCPKG_GIT_REPOSITORY}
GIT_TAG ${VCPKG_GIT_TAG}
PREFIX ${VCPKG_PREFIX}
UPDATE_DISCONNECTED 1
)

FetchContent_MakeAvailable(
${VCPKG_FETCH_CONTENT_NAME}
)

FetchContent_GetProperties(${VCPKG_FETCH_CONTENT_NAME})
string(REPLACE "\\" "/" CMAKE_TOOLCHAIN_FILE "${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake")

endif()

if(NOT DEFINED VCPKG_INSTALLED_DIR)
set(DVCPKG_INSTALLED_DIR ${CMAKE_BINARY_DIR}/vcpkg_installed)
endif()

# ######################################
# Options
Expand All @@ -15,9 +68,29 @@ option(WITH_OTLP_GRPC "Whether to include the OTLP gRPC exporter" OFF)
if(NOT WITH_OTLP_HTTP AND NOT WITH_OTLP_GRPC)
message(FATAL_ERROR "At least one of WITH_OTLP_HTTP and WITH_OTLP_GRPC must be ON")
endif()
if(APPLE)
option(SKIP_OTEL_CPP_PATCH "Whether to skip patching OpenTelemetry-cpp" OFF)
endif()

# set vcpkg features depending on specified options
set(VCPKG_MANIFEST_FEATURES "") # start with empty
if(WITH_OTLP_HTTP)
set(VCPKG_MANIFEST_FEATURES ${VCPKG_MANFIEST_FEATURES} "otlp-http")
endif()
if(WITH_OTLP_GRPC)
set(VCPKG_MANIFEST_FEATURES ${VCPKG_MANIFEST_FEATURES} "otlp-grpc")
endif()

# ######################################
# Project Declaration
# ######################################

set(CLIENT_PROJECT_NAME otel-matlab)

project(${CLIENT_PROJECT_NAME} VERSION 0.1.0)

# ######################################
# libmexclass FetchContent Configuration
# libmexclass
# ######################################

set(LIBMEXCLASS_FETCH_CONTENT_NAME libmexclass)
Expand All @@ -28,7 +101,6 @@ set(LIBMEXCLASS_FETCH_CONTENT_GIT_TAG "77f3d72")

set(LIBMEXCLASS_FETCH_CONTENT_SOURCE_SUBDIR "libmexclass/cpp")

include(FetchContent)
FetchContent_Declare(
${LIBMEXCLASS_FETCH_CONTENT_NAME}
GIT_REPOSITORY ${LIBMEXCLASS_FETCH_CONTENT_GIT_REPOSITORY}
Expand All @@ -39,15 +111,59 @@ FetchContent_MakeAvailable(
${LIBMEXCLASS_FETCH_CONTENT_NAME}
)


# ###########################
# OpenTelemetry-cpp
# ###########################

if(DEFINED OTEL_CPP_INSTALLED_DIR)
# OTEL_CPP_INSTALLED_DIR should point to an installed location of OpenTelemetry-cpp
string(REPLACE "\\" "/" OTEL_CPP_PREFIX ${OTEL_CPP_INSTALLED_DIR})
else()
# No installed location supplied. Fetch it as an external project
include(ExternalProject)
set(OTEL_CPP_PROJECT_NAME opentelemetry-cpp)
set(OTEL_CPP_GIT_REPOSITORY "https://github.com/open-telemetry/opentelemetry-cpp.git")
set(OTEL_CPP_GIT_TAG "11d5d9e")

if(DEFINED OTEL_CPP_PREFIX)
string(REPLACE "\\" "/" OTEL_CPP_PREFIX ${OTEL_CPP_PREFIX})
else()
set(OTEL_CPP_PREFIX ${CMAKE_BINARY_DIR}/otel-cpp)
endif()

if(WITH_OTLP_GRPC)
set(OTEL_CPP_CXX_STANDARD 14) # Abseil requires at least Cxx14
else()
set(OTEL_CPP_CXX_STANDARD 11)
endif()

if(NOT APPLE OR SKIP_OTEL_CPP_PATCH)
set(patch_command "")
else()
set(patch_command git apply ${CMAKE_SOURCE_DIR}/otel-cpp.patch)
endif()

ExternalProject_Add(
${OTEL_CPP_PROJECT_NAME}
GIT_REPOSITORY ${OTEL_CPP_GIT_REPOSITORY}
GIT_TAG ${OTEL_CPP_GIT_TAG}
PREFIX ${OTEL_CPP_PREFIX}
UPDATE_DISCONNECTED 1
PATCH_COMMAND ${patch_command}
CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DWITH_OTLP_HTTP=${WITH_OTLP_HTTP} -DWITH_OTLP_GRPC=${WITH_OTLP_GRPC} -DBUILD_TESTING=OFF -DWITH_BENCHMARK=OFF -DOPENTELEMETRY_INSTALL=ON -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_CXX_STANDARD=${OTEL_CPP_CXX_STANDARD} -DVCPKG_INSTALLED_DIR=${VCPKG_INSTALLED_DIR}
INSTALL_DIR ${OTEL_CPP_PREFIX}
INSTALL_COMMAND ${CMAKE_COMMAND} --install . --prefix ${OTEL_CPP_PREFIX}
)
endif()

# ###########################
# OpenTelemetry Proxy Library
# ###########################


set(OPENTELEMETRY_PROXY_LIBRARY_NAME "OtelMatlabProxy")

# Specify location for find_package to locate opentelemetry-cpp-config.cmake
find_package(opentelemetry-cpp CONFIG REQUIRED)
find_package(Protobuf REQUIRED)
find_package(nlohmann_json REQUIRED)
if(WIN32)
Expand All @@ -73,24 +189,28 @@ endif()
set(TRACE_API_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/api/trace/include)
set(CONTEXT_API_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/api/context/include)
set(BAGGAGE_API_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/api/baggage/include)
set(COMMON_API_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/api/common/include)
set(TRACE_SDK_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sdk/trace/include)
set(COMMON_SDK_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sdk/common/include)
set(OTLP_EXPORTER_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/include)
set(OPENTELEMETRY_PROXY_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${TRACE_API_INCLUDE_DIR} ${CONTEXT_API_INCLUDE_DIR} ${BAGGAGE_API_INCLUDE_DIR} ${TRACE_SDK_INCLUDE_DIR} ${OTLP_EXPORTER_INCLUDE_DIR} ${OPENTELEMETRY_CPP_INCLUDE_DIRS})
set(OPENTELEMETRY_PROXY_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${TRACE_API_INCLUDE_DIR} ${CONTEXT_API_INCLUDE_DIR} ${BAGGAGE_API_INCLUDE_DIR} ${COMMON_API_INCLUDE_DIR} ${TRACE_SDK_INCLUDE_DIR} ${COMMON_SDK_INCLUDE_DIR} ${OTLP_EXPORTER_INCLUDE_DIR} ${OTEL_CPP_PREFIX}/include)

set(OPENTELEMETRY_PROXY_FACTORY_CLASS_NAME OtelMatlabProxyFactory)
set(OPENTELEMETRY_PROXY_FACTORY_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(TRACE_API_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/api/trace/src)
set(CONTEXT_API_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/api/context/src)
set(BAGGAGE_API_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/api/baggage/src)
set(COMMON_API_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/api/common/src)
set(TRACE_SDK_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sdk/trace/src)
set(COMMON_SDK_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sdk/common/src)
set(OTLP_EXPORTER_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/src)
set(OPENTELEMETRY_PROXY_SOURCES
${OPENTELEMETRY_PROXY_FACTORY_SOURCES_DIR}/${OPENTELEMETRY_PROXY_FACTORY_CLASS_NAME}.cpp
${TRACE_API_SOURCE_DIR}/TracerProviderProxy.cpp
${TRACE_API_SOURCE_DIR}/TracerProxy.cpp
${TRACE_API_SOURCE_DIR}/SpanProxy.cpp
${TRACE_API_SOURCE_DIR}/SpanContextProxy.cpp
${TRACE_API_SOURCE_DIR}/attribute.cpp
${COMMON_API_SOURCE_DIR}/attribute.cpp
${CONTEXT_API_SOURCE_DIR}/TextMapPropagatorProxy.cpp
${CONTEXT_API_SOURCE_DIR}/CompositePropagatorProxy.cpp
${CONTEXT_API_SOURCE_DIR}/TextMapCarrierProxy.cpp
Expand All @@ -99,7 +219,8 @@ set(OPENTELEMETRY_PROXY_SOURCES
${TRACE_SDK_SOURCE_DIR}/TracerProviderProxy.cpp
${TRACE_SDK_SOURCE_DIR}/SimpleSpanProcessorProxy.cpp
${TRACE_SDK_SOURCE_DIR}/BatchSpanProcessorProxy.cpp
${TRACE_SDK_SOURCE_DIR}/ParentBasedSamplerProxy.cpp)
${TRACE_SDK_SOURCE_DIR}/ParentBasedSamplerProxy.cpp
${COMMON_SDK_SOURCE_DIR}/resource.cpp)
if(WITH_OTLP_HTTP)
set(OPENTELEMETRY_PROXY_SOURCES ${OPENTELEMETRY_PROXY_SOURCES}
${OTLP_EXPORTER_SOURCE_DIR}/OtlpHttpSpanExporterProxy.cpp)
Expand Down Expand Up @@ -132,16 +253,50 @@ if(WITH_OTLP_GRPC)
endif()
endif()

target_compile_options(${OPENTELEMETRY_PROXY_LIBRARY_NAME} PRIVATE ${OTLP_MACROS})
# On Windows, suppress a compiler warning about deprecation of result_of
if(WIN32)
set(CUSTOM_CXX_FLAGS -D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING)
else()
set(CUSTOM_CXX_FLAGS "")
endif()

if(WIN32)
set(OTEL_PROTO_LIBRARY_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX})
else()
set(OTEL_PROTO_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()

target_compile_options(${OPENTELEMETRY_PROXY_LIBRARY_NAME} PRIVATE ${OTLP_MACROS} ${CUSTOM_CXX_FLAGS})

# link against OpenTelemetry-cpp libraries and their dependencies
target_link_libraries(${OPENTELEMETRY_PROXY_LIBRARY_NAME} PRIVATE ${OPENTELEMETRY_CPP_LIBRARIES})
target_link_libraries(${OPENTELEMETRY_PROXY_LIBRARY_NAME} PRIVATE ${OTEL_CPP_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}opentelemetry_common${CMAKE_STATIC_LIBRARY_SUFFIX}
${OTEL_CPP_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}opentelemetry_otlp_recordable${CMAKE_STATIC_LIBRARY_SUFFIX}
${OTEL_CPP_PREFIX}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}opentelemetry_proto${OTEL_PROTO_LIBRARY_SUFFIX}
${OTEL_CPP_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}opentelemetry_resources${CMAKE_STATIC_LIBRARY_SUFFIX}
${OTEL_CPP_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}opentelemetry_trace${CMAKE_STATIC_LIBRARY_SUFFIX}
${OTEL_CPP_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}opentelemetry_version${CMAKE_STATIC_LIBRARY_SUFFIX}
${OTEL_CPP_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}opentelemetry_logs${CMAKE_STATIC_LIBRARY_SUFFIX}
${Protobuf_LIBRARIES})
if(WITH_OTLP_HTTP)
target_link_libraries(${OPENTELEMETRY_PROXY_LIBRARY_NAME} PRIVATE ${OTEL_CPP_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}opentelemetry_exporter_otlp_http${CMAKE_STATIC_LIBRARY_SUFFIX}
${OTEL_CPP_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}opentelemetry_exporter_otlp_http_client${CMAKE_STATIC_LIBRARY_SUFFIX}
${OTEL_CPP_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}opentelemetry_http_client_curl${CMAKE_STATIC_LIBRARY_SUFFIX}
${CURL_LIBRARIES})
endif()
if(WITH_OTLP_GRPC)
target_link_libraries(${OPENTELEMETRY_PROXY_LIBRARY_NAME} PRIVATE ${OTEL_CPP_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}opentelemetry_exporter_otlp_grpc${CMAKE_STATIC_LIBRARY_SUFFIX}
${OTEL_CPP_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}opentelemetry_exporter_otlp_grpc_client${CMAKE_STATIC_LIBRARY_SUFFIX}
${OTEL_CPP_PREFIX}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}opentelemetry_proto_grpc${OTEL_PROTO_LIBRARY_SUFFIX}
gRPC::grpc++
absl::synchronization)
endif()

# On Linux, when linking with certain static libraries, need to force include entire archive to avoid the linker mistakenly leaving out symbols
if(UNIX AND NOT APPLE AND NOT CYGWIN)
set(OPENTELEMETRY_PROXY_LINK_OPTIONS -Wl,--whole-archive
"${OPENTELEMETRY_CPP_LIBRARY_DIRS}/libopentelemetry_trace.a"
"${OPENTELEMETRY_CPP_LIBRARY_DIRS}/libopentelemetry_common.a"
"${OTEL_CPP_PREFIX}/lib/libopentelemetry_trace.a"
"${OTEL_CPP_PREFIX}/lib/libopentelemetry_common.a"
"${OTEL_CPP_PREFIX}/lib/libopentelemetry_otlp_recordable.a"
${ABSL_LIBRARIES}
${UPB_LIBRARIES} -Wl,--no-whole-archive)
target_link_options(${OPENTELEMETRY_PROXY_LIBRARY_NAME} PRIVATE ${OPENTELEMETRY_PROXY_LINK_OPTIONS})
Expand Down Expand Up @@ -178,11 +333,13 @@ if(WIN32)
${OPENSSL_RUNTIME}
${RE2_RUNTIME})
endif()
elseif(UNIX AND NOT APPLE AND NOT CYGWIN)
FILE(GLOB OTEL_CPP_RUNTIME ${OPENTELEMETRY_CPP_LIBRARY_DIRS}/*.so)
set(OPENTELEMETRY_PROXY_RUNTIME_LIBRARIES ${OTEL_CPP_RUNTIME})
elseif(APPLE)
FILE(GLOB OTEL_CPP_RUNTIME ${OPENTELEMETRY_CPP_LIBRARY_DIRS}/*.dylib)
elseif(UNIX AND NOT CYGWIN)
if(WITH_OTLP_GRPC)
set(OTEL_CPP_RUNTIME ${OTEL_CPP_PREFIX}/lib/libopentelemetry_proto${CMAKE_SHARED_LIBRARY_SUFFIX}
${OTEL_CPP_PREFIX}/lib/libopentelemetry_proto_grpc${CMAKE_SHARED_LIBRARY_SUFFIX})
else()
set(OTEL_CPP_RUNTIME ${OTEL_CPP_PREFIX}/lib/libopentelemetry_proto${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()
set(OPENTELEMETRY_PROXY_RUNTIME_LIBRARIES ${OTEL_CPP_RUNTIME})
endif()

Expand Down Expand Up @@ -215,7 +372,7 @@ libmexclass_client_install(
set(TRACE_API_MATLAB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/api/trace/+opentelemetry)
set(CONTEXT_API_MATLAB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/api/context/+opentelemetry)
set(BAGGAGE_API_MATLAB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/api/baggage/+opentelemetry)
set(UTILS_API_MATLAB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/api/utils/+opentelemetry)
set(COMMON_API_MATLAB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/api/common/+opentelemetry)
set(TRACE_SDK_MATLAB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sdk/trace/+opentelemetry)
set(DEFAULT_EXPORTER_MATLAB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/defaultSpanExporter.m)
set(OTLP_HTTP_EXPORTER_MATLAB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpHttpSpanExporter.m)
Expand All @@ -226,7 +383,7 @@ set(OTLP_EXPORTERS_DIR +opentelemetry/+exporters/+otlp)
install(DIRECTORY ${TRACE_API_MATLAB_SOURCES} DESTINATION .)
install(DIRECTORY ${CONTEXT_API_MATLAB_SOURCES} DESTINATION .)
install(DIRECTORY ${BAGGAGE_API_MATLAB_SOURCES} DESTINATION .)
install(DIRECTORY ${UTILS_API_MATLAB_SOURCES} DESTINATION .)
install(DIRECTORY ${COMMON_API_MATLAB_SOURCES} DESTINATION .)
install(DIRECTORY ${TRACE_SDK_MATLAB_SOURCES} DESTINATION .)
install(FILES ${DEFAULT_EXPORTER_MATLAB_SOURCES} DESTINATION ${OTLP_EXPORTERS_DIR})
if(WITH_OTLP_HTTP)
Expand Down
21 changes: 3 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,14 @@ Installation instructions
Before proceeding, ensure that the below products are installed:
* [MATLAB](https://www.mathworks.com/products/matlab.html)

1. Download [vcpkg](https://vcpkg.io). Install the following packages:
- curl
- nlohmann-json
- protobuf
- zlib

2. Download, build and install [OpenTelemetry C++](https://github.com/open-telemetry/opentelemetry-cpp)
```
cd <opentelemetry-cpp-root>
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_CXX_STANDARD=20 -DWITH_OTLP_HTTP=ON -DBUILD_TESTING=OFF -DWITH_BENCHMARK=OFF -DOPENTELEMETRY_INSTALL=ON -DCMAKE_TOOLCHAIN_FILE=<vcpkg_root>\scripts\buildsystems\vcpkg.cmake
cmake --build build --config Release --target ALL_BUILD
cmake --install build --prefix <opentelemetry-cpp-installdir>
```
3. Download OpenTelemetry MATLAB

4. Build and install OpenTelemetry MATLAB
1. Download, Build and install OpenTelemetry MATLAB
```
cd <opentelemetry-matlab-root>
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=<opentelemetry-matlab-installdir> -DCMAKE_TOOLCHAIN_FILE=<vcpkg_root>\scripts\buildsystems\vcpkg.cmake -DCMAKE_PREFIX_PATH=<path to opentelemetry-cpp-config.cmake>
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=<opentelemetry-matlab-installdir>
cmake --build build --config Release --target install
```
5. Download [OpenTelemetry Collector](https://github.com/open-telemetry/opentelemetry-collector-releases/releases). You can just obtain a pre-built binary for your platform.
2. Download [OpenTelemetry Collector](https://github.com/open-telemetry/opentelemetry-collector-releases/releases). You can just obtain a pre-built binary for your platform.

## Getting Started
1. Start OpenTelemetry Collector
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2023 The MathWorks, Inc.

#pragma once

#include "opentelemetry/common/attribute_value.h"
#include "opentelemetry/nostd/string_view.h"

#include <list>

namespace common = opentelemetry::common;
namespace nostd = opentelemetry::nostd;

namespace libmexclass::opentelemetry {

struct ProcessedAttributes {
std::list<std::pair<std::string, common::AttributeValue> > Attributes;
std::list<std::vector<double> > DimensionsBuffer; // list of vector, to hold the dimensions of array attributes
std::list<std::string> StringBuffer; // list of strings as a buffer to hold the string attributes
std::list<std::vector<nostd::string_view> > StringViewBuffer; // list of vector of strings views, used for string array attributes only
};
} // namespace libmexclass::opentelemetry
Loading

0 comments on commit e2525ed

Please sign in to comment.