diff --git a/.github/workflows/build_and_test_full.yml b/.github/workflows/build_and_test_full.yml index b417494..da77a23 100644 --- a/.github/workflows/build_and_test_full.yml +++ b/.github/workflows/build_and_test_full.yml @@ -46,7 +46,7 @@ jobs: - name: Build OpenTelemetry-Matlab working-directory: opentelemetry-matlab run: | - cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON -DWITH_OTLP_GRPC=ON -DUSE_BATCH_FOR_MCC=ON -DOTEL_MATLAB_VERSION=${{ needs.get_version.outputs.version }} -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }} + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON -DWITH_OTLP_GRPC=ON -DWITH_OTLP_FILE=ON -DUSE_BATCH_FOR_MCC=ON -DOTEL_MATLAB_VERSION=${{ needs.get_version.outputs.version }} -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }} cmake --build build --config Release --target install - name: Run tests env: @@ -56,6 +56,45 @@ jobs: uses: matlab-actions/run-tests@v2 with: select-by-folder: opentelemetry-matlab/test + code-coverage-build-and-run-tests-ubuntu: + # Running on ubuntu-latest would use a glibc version that is incompatible when using the built mex files on a Debian 11 + # Instead, run on ubuntu-20.04 + runs-on: ubuntu-20.04 + needs: get_version + env: + OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install" + SYSTEM_LIBSTDCPP_PATH: "/usr/lib/x86_64-linux-gnu/libstdc++.so.6" + steps: + - name: Download OpenTelemetry-Matlab source + uses: actions/checkout@v3 + with: + path: opentelemetry-matlab + - name: Install ninja-build + run: sudo apt-get install ninja-build + - name: Install MATLAB + uses: matlab-actions/setup-matlab@v2 + with: + products: MATLAB_Compiler MATLAB_Compiler_SDK + - name: Build OpenTelemetry-Matlab + working-directory: opentelemetry-matlab + run: | + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON -DWITH_OTLP_GRPC=ON -DUSE_BATCH_FOR_MCC=ON -DOTEL_MATLAB_VERSION=${{ needs.get_version.outputs.version }} -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }} + cmake --build build --config Release --target install + - name: Run tests & get coverage + env: + # Add the installation directory to the MATLAB Search Path by + # setting the MATLABPATH environment variable. + MATLABPATH: ${{ env.OPENTELEMETRY_MATLAB_INSTALL }} + uses: matlab-actions/run-tests@v2 + with: + source-folder: ${{ env.OPENTELEMETRY_MATLAB_INSTALL }} + code-coverage-cobertura: cobertura.xml + - name: Upload Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + slug: mathworks/OpenTelemetry-Matlab + file: cobertura.xml build-and-run-tests-windows: runs-on: windows-latest needs: get_version diff --git a/README.md b/README.md index 8f2ca26..df80e89 100644 --- a/README.md +++ b/README.md @@ -1,116 +1,116 @@ -# MATLAB Interface to OpenTelemetry -[![View OpenTelemetry-Matlab on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/130979-opentelemetry-matlab) [![MATLAB](https://github.com/mathworks/OpenTelemetry-Matlab/actions/workflows/build_and_test_full.yml/badge.svg)](https://github.com/mathworks/OpenTelemetry-Matlab/actions/workflows/build_and_test_full.yml) - -MATLAB® interface to [OpenTelemetry™](https://opentelemetry.io/), based on the [OpenTelemetry Specification](https://opentelemetry.io/docs/specs/otel/). OpenTelemetry is an observability framework for creating and managing telemetry data, such as traces, metrics, and logs. This data can then be sent to an observability back-end for monitoring, alerts, and analysis. - -### Status -- Tracing, metrics, and logs are all fully supported. -- Supported and tested on Windows®, Linux®, and macOS. - -### MathWorks Products (https://www.mathworks.com) - -Requires MATLAB release R2022b or newer -- [MATLAB](https://www.mathworks.com/products/matlab.html) - -### 3rd Party Products: -- [OpenTelemetry Collector](https://github.com/open-telemetry/opentelemetry-collector-releases/releases) -- [OpenTelemetry C++](https://github.com/open-telemetry/opentelemetry-cpp) -- [vcpkg C/C++ dependency manager](https://vcpkg.io) - -## Installation -Installation instructions - -### Installing With Toolbox Package -1. Under "Assets" of a release, download the toolbox package .mltbx file. -2. Start MATLAB. -3. In the Current Folder browser, navigate to the .mltbx file. -4. Right click on the .mltbx file and select "Install". - -### Building From Source -Before proceeding, ensure that the below products are installed: -* [MATLAB](https://www.mathworks.com/products/matlab.html) - -1. Download, Build and install OpenTelemetry MATLAB -``` -cd -cmake -S . -B build -DCMAKE_INSTALL_PREFIX= -cmake --build build --config Release --target install - -``` -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 -``` -otelcol --config -``` -2. Start MATLAB -3. Add the OpenTelemetry MATLAB install directories to your MATLAB path -``` ->> addpath -``` -## Examples -### Tracing -1. Create a default tracer provider and save it. -``` ->> p = opentelemetry.sdk.trace.TracerProvider(); ->> setTracerProvider(p); -``` -2. Start a span -``` ->> tr = opentelemetry.trace.getTracer("My Tracer"); ->> sp = tr.startSpan("My Span"); -``` -3. End the span -``` ->> sp.endSpan(); -``` -4. If your collector is configured to display the data, you should see your span displayed. -### Metrics -1. Create a default meter provider and save it. -``` ->> p = opentelemetry.sdk.metrics.MeterProvider(); ->> setMeterProvider(p); -``` -2. Create a counter -``` ->> m = opentelemetry.metrics.getMeter("My Meter"); ->> c = m.createCounter("My Counter"); -``` -3. Increment the counter -``` ->> c.add(10); -``` -4. If your collector is configured to display the data, you should see your counter displayed after 1 minute. - -### Logs -1. Create a default logger provider and save it. -``` ->> p = opentelemetry.sdk.logs.LoggerProvider(); ->> setLoggerProvider(p); -``` -2. Create a logger -``` ->> l = opentelemetry.logs.getLogger("My Logger"); -``` -3. Emit a log record with "info" level -``` ->> info(l, "My Message"); -``` -4. If your collector is configured to display the data, you should see your log record displayed. - -For more examples, see the "examples" folder. - -## Help -To view documentation of individual function, type "help \\". For example, -``` ->> help opentelemetry.sdk.trace.TracerProvider -``` - -## License -The license is available in the License file within this repository - -## Community Support -[MATLAB Central](https://www.mathworks.com/matlabcentral) - -Copyright 2023-2024 The MathWorks, Inc. +# MATLAB Interface to OpenTelemetry +[![View OpenTelemetry-Matlab on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/130979-opentelemetry-matlab) [![MATLAB](https://github.com/mathworks/OpenTelemetry-Matlab/actions/workflows/build_and_test_full.yml/badge.svg)](https://github.com/mathworks/OpenTelemetry-Matlab/actions/workflows/build_and_test_full.yml)[![codecov](https://codecov.io/github/mathworks/OpenTelemetry-MATLAB/graph/badge.svg?token=VNj6f1LlMG)](https://codecov.io/github/mathworks/OpenTelemetry-MATLAB) + +MATLAB® interface to [OpenTelemetry™](https://opentelemetry.io/), based on the [OpenTelemetry Specification](https://opentelemetry.io/docs/specs/otel/). OpenTelemetry is an observability framework for creating and managing telemetry data, such as traces, metrics, and logs. This data can then be sent to an observability back-end for monitoring, alerts, and analysis. + +### Status +- Tracing, metrics, and logs are all fully supported. +- Supported and tested on Windows®, Linux®, and macOS. + +### MathWorks Products (https://www.mathworks.com) + +Requires MATLAB release R2022b or newer +- [MATLAB](https://www.mathworks.com/products/matlab.html) + +### 3rd Party Products: +- [OpenTelemetry Collector](https://github.com/open-telemetry/opentelemetry-collector-releases/releases) +- [OpenTelemetry C++](https://github.com/open-telemetry/opentelemetry-cpp) +- [vcpkg C/C++ dependency manager](https://vcpkg.io) + +## Installation +Installation instructions + +### Installing With Toolbox Package +1. Under "Assets" of a release, download the toolbox package .mltbx file. +2. Start MATLAB. +3. In the Current Folder browser, navigate to the .mltbx file. +4. Right click on the .mltbx file and select "Install". + +### Building From Source +Before proceeding, ensure that the below products are installed: +* [MATLAB](https://www.mathworks.com/products/matlab.html) + +1. Download, Build and install OpenTelemetry MATLAB +``` +cd +cmake -S . -B build -DCMAKE_INSTALL_PREFIX= +cmake --build build --config Release --target install + +``` +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 +``` +otelcol --config +``` +2. Start MATLAB +3. Add the OpenTelemetry MATLAB install directories to your MATLAB path +``` +>> addpath +``` +## Examples +### Tracing +1. Create a default tracer provider and save it. +``` +>> p = opentelemetry.sdk.trace.TracerProvider(); +>> setTracerProvider(p); +``` +2. Start a span +``` +>> tr = opentelemetry.trace.getTracer("My Tracer"); +>> sp = tr.startSpan("My Span"); +``` +3. End the span +``` +>> sp.endSpan(); +``` +4. If your collector is configured to display the data, you should see your span displayed. +### Metrics +1. Create a default meter provider and save it. +``` +>> p = opentelemetry.sdk.metrics.MeterProvider(); +>> setMeterProvider(p); +``` +2. Create a counter +``` +>> m = opentelemetry.metrics.getMeter("My Meter"); +>> c = m.createCounter("My Counter"); +``` +3. Increment the counter +``` +>> c.add(10); +``` +4. If your collector is configured to display the data, you should see your counter displayed after 1 minute. + +### Logs +1. Create a default logger provider and save it. +``` +>> p = opentelemetry.sdk.logs.LoggerProvider(); +>> setLoggerProvider(p); +``` +2. Create a logger +``` +>> l = opentelemetry.logs.getLogger("My Logger"); +``` +3. Emit a log record with "info" level +``` +>> info(l, "My Message"); +``` +4. If your collector is configured to display the data, you should see your log record displayed. + +For more examples, see the "examples" folder. + +## Help +To view documentation of individual function, type "help \\". For example, +``` +>> help opentelemetry.sdk.trace.TracerProvider +``` + +## License +The license is available in the License file within this repository + +## Community Support +[MATLAB Central](https://www.mathworks.com/matlabcentral) + +Copyright 2023-2024 The MathWorks, Inc. diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..e16f6b0 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,14 @@ +ignore: + - "**/*.test" +fixes: + - "\\+opentelemetry/\\+sdk/\\+trace/::sdk/trace/+opentelemetry/+sdk/+trace/" + - "\\+opentelemetry/\\+sdk/\\+metrics/::sdk/metrics/+opentelemetry/+sdk/+metrics/" + - "\\+opentelemetry/\\+sdk/\\+common/::sdk/common/+opentelemetry/+sdk/+common/" + - "\\+opentelemetry/\\+trace/::api/trace/+opentelemetry/+trace/" + - "\\+opentelemetry/\\+metrics/::api/metrics/+opentelemetry/+metrics/" + - "\\+opentelemetry/\\+context/::api/context/+opentelemetry/+context/" + - "\\+opentelemetry/\\+common/::api/common/+opentelemetry/+common/" + - "\\+opentelemetry/\\+baggage/::api/baggage/+opentelemetry/+baggage/" + - "\\+opentelemetry/\\+exporters/\\+otlp/::exporters/otlp/+opentelemetry/+exporters/+otlp/" + - "\\+opentelemetry/\\+sdk/\\+logs::sdk/logs/+opentelemetry/+sdk/+logs/" + - "\\+opentelemetry/\\+logs/::api/logs/+opentelemetry/+logs/" \ No newline at end of file