|
1 |
| -# MATLAB Interface to OpenTelemetry |
2 |
| -[](https://www.mathworks.com/matlabcentral/fileexchange/130979-opentelemetry-matlab) [](https://github.com/mathworks/OpenTelemetry-Matlab/actions/workflows/build_and_test_full.yml) |
3 |
| - |
4 |
| -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. |
5 |
| - |
6 |
| -### Status |
7 |
| -- Tracing, metrics, and logs are all fully supported. |
8 |
| -- Supported and tested on Windows®, Linux®, and macOS. |
9 |
| - |
10 |
| -### MathWorks Products (https://www.mathworks.com) |
11 |
| - |
12 |
| -Requires MATLAB release R2022b or newer |
13 |
| -- [MATLAB](https://www.mathworks.com/products/matlab.html) |
14 |
| - |
15 |
| -### 3rd Party Products: |
16 |
| -- [OpenTelemetry Collector](https://github.com/open-telemetry/opentelemetry-collector-releases/releases) |
17 |
| -- [OpenTelemetry C++](https://github.com/open-telemetry/opentelemetry-cpp) |
18 |
| -- [vcpkg C/C++ dependency manager](https://vcpkg.io) |
19 |
| - |
20 |
| -## Installation |
21 |
| -Installation instructions |
22 |
| - |
23 |
| -### Installing With Toolbox Package |
24 |
| -1. Under "Assets" of a release, download the toolbox package .mltbx file. |
25 |
| -2. Start MATLAB. |
26 |
| -3. In the Current Folder browser, navigate to the .mltbx file. |
27 |
| -4. Right click on the .mltbx file and select "Install". |
28 |
| - |
29 |
| -### Building From Source |
30 |
| -Before proceeding, ensure that the below products are installed: |
31 |
| -* [MATLAB](https://www.mathworks.com/products/matlab.html) |
32 |
| - |
33 |
| -1. Download, Build and install OpenTelemetry MATLAB |
34 |
| -``` |
35 |
| -cd <opentelemetry-matlab-root> |
36 |
| -cmake -S . -B build -DCMAKE_INSTALL_PREFIX=<opentelemetry-matlab-installdir> |
37 |
| -cmake --build build --config Release --target install |
38 |
| -
|
39 |
| -``` |
40 |
| -2. Download [OpenTelemetry Collector](https://github.com/open-telemetry/opentelemetry-collector-releases/releases). You can just obtain a pre-built binary for your platform. |
41 |
| - |
42 |
| -## Getting Started |
43 |
| -1. Start OpenTelemetry Collector |
44 |
| -``` |
45 |
| -otelcol --config <otelcol-config-yaml> |
46 |
| -``` |
47 |
| -2. Start MATLAB |
48 |
| -3. Add the OpenTelemetry MATLAB install directories to your MATLAB path |
49 |
| -``` |
50 |
| ->> addpath <OpenTelemetry MATLAB installdir> |
51 |
| -``` |
52 |
| -## Examples |
53 |
| -### Tracing |
54 |
| -1. Create a default tracer provider and save it. |
55 |
| -``` |
56 |
| ->> p = opentelemetry.sdk.trace.TracerProvider(); |
57 |
| ->> setTracerProvider(p); |
58 |
| -``` |
59 |
| -2. Start a span |
60 |
| -``` |
61 |
| ->> tr = opentelemetry.trace.getTracer("My Tracer"); |
62 |
| ->> sp = tr.startSpan("My Span"); |
63 |
| -``` |
64 |
| -3. End the span |
65 |
| -``` |
66 |
| ->> sp.endSpan(); |
67 |
| -``` |
68 |
| -4. If your collector is configured to display the data, you should see your span displayed. |
69 |
| -### Metrics |
70 |
| -1. Create a default meter provider and save it. |
71 |
| -``` |
72 |
| ->> p = opentelemetry.sdk.metrics.MeterProvider(); |
73 |
| ->> setMeterProvider(p); |
74 |
| -``` |
75 |
| -2. Create a counter |
76 |
| -``` |
77 |
| ->> m = opentelemetry.metrics.getMeter("My Meter"); |
78 |
| ->> c = m.createCounter("My Counter"); |
79 |
| -``` |
80 |
| -3. Increment the counter |
81 |
| -``` |
82 |
| ->> c.add(10); |
83 |
| -``` |
84 |
| -4. If your collector is configured to display the data, you should see your counter displayed after 1 minute. |
85 |
| - |
86 |
| -### Logs |
87 |
| -1. Create a default logger provider and save it. |
88 |
| -``` |
89 |
| ->> p = opentelemetry.sdk.logs.LoggerProvider(); |
90 |
| ->> setLoggerProvider(p); |
91 |
| -``` |
92 |
| -2. Create a logger |
93 |
| -``` |
94 |
| ->> l = opentelemetry.logs.getLogger("My Logger"); |
95 |
| -``` |
96 |
| -3. Emit a log record with "info" level |
97 |
| -``` |
98 |
| ->> info(l, "My Message"); |
99 |
| -``` |
100 |
| -4. If your collector is configured to display the data, you should see your log record displayed. |
101 |
| - |
102 |
| -For more examples, see the "examples" folder. |
103 |
| - |
104 |
| -## Help |
105 |
| -To view documentation of individual function, type "help \<function_name>\". For example, |
106 |
| -``` |
107 |
| ->> help opentelemetry.sdk.trace.TracerProvider |
108 |
| -``` |
109 |
| - |
110 |
| -## License |
111 |
| -The license is available in the License file within this repository |
112 |
| - |
113 |
| -## Community Support |
114 |
| -[MATLAB Central](https://www.mathworks.com/matlabcentral) |
115 |
| - |
116 |
| -Copyright 2023-2024 The MathWorks, Inc. |
| 1 | +# MATLAB Interface to OpenTelemetry |
| 2 | +[](https://www.mathworks.com/matlabcentral/fileexchange/130979-opentelemetry-matlab) [](https://github.com/mathworks/OpenTelemetry-Matlab/actions/workflows/build_and_test_full.yml)[](https://codecov.io/github/mathworks/OpenTelemetry-MATLAB) |
| 3 | + |
| 4 | +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. |
| 5 | + |
| 6 | +### Status |
| 7 | +- Tracing, metrics, and logs are all fully supported. |
| 8 | +- Supported and tested on Windows®, Linux®, and macOS. |
| 9 | + |
| 10 | +### MathWorks Products (https://www.mathworks.com) |
| 11 | + |
| 12 | +Requires MATLAB release R2022b or newer |
| 13 | +- [MATLAB](https://www.mathworks.com/products/matlab.html) |
| 14 | + |
| 15 | +### 3rd Party Products: |
| 16 | +- [OpenTelemetry Collector](https://github.com/open-telemetry/opentelemetry-collector-releases/releases) |
| 17 | +- [OpenTelemetry C++](https://github.com/open-telemetry/opentelemetry-cpp) |
| 18 | +- [vcpkg C/C++ dependency manager](https://vcpkg.io) |
| 19 | + |
| 20 | +## Installation |
| 21 | +Installation instructions |
| 22 | + |
| 23 | +### Installing With Toolbox Package |
| 24 | +1. Under "Assets" of a release, download the toolbox package .mltbx file. |
| 25 | +2. Start MATLAB. |
| 26 | +3. In the Current Folder browser, navigate to the .mltbx file. |
| 27 | +4. Right click on the .mltbx file and select "Install". |
| 28 | + |
| 29 | +### Building From Source |
| 30 | +Before proceeding, ensure that the below products are installed: |
| 31 | +* [MATLAB](https://www.mathworks.com/products/matlab.html) |
| 32 | + |
| 33 | +1. Download, Build and install OpenTelemetry MATLAB |
| 34 | +``` |
| 35 | +cd <opentelemetry-matlab-root> |
| 36 | +cmake -S . -B build -DCMAKE_INSTALL_PREFIX=<opentelemetry-matlab-installdir> |
| 37 | +cmake --build build --config Release --target install |
| 38 | +
|
| 39 | +``` |
| 40 | +2. Download [OpenTelemetry Collector](https://github.com/open-telemetry/opentelemetry-collector-releases/releases). You can just obtain a pre-built binary for your platform. |
| 41 | + |
| 42 | +## Getting Started |
| 43 | +1. Start OpenTelemetry Collector |
| 44 | +``` |
| 45 | +otelcol --config <otelcol-config-yaml> |
| 46 | +``` |
| 47 | +2. Start MATLAB |
| 48 | +3. Add the OpenTelemetry MATLAB install directories to your MATLAB path |
| 49 | +``` |
| 50 | +>> addpath <OpenTelemetry MATLAB installdir> |
| 51 | +``` |
| 52 | +## Examples |
| 53 | +### Tracing |
| 54 | +1. Create a default tracer provider and save it. |
| 55 | +``` |
| 56 | +>> p = opentelemetry.sdk.trace.TracerProvider(); |
| 57 | +>> setTracerProvider(p); |
| 58 | +``` |
| 59 | +2. Start a span |
| 60 | +``` |
| 61 | +>> tr = opentelemetry.trace.getTracer("My Tracer"); |
| 62 | +>> sp = tr.startSpan("My Span"); |
| 63 | +``` |
| 64 | +3. End the span |
| 65 | +``` |
| 66 | +>> sp.endSpan(); |
| 67 | +``` |
| 68 | +4. If your collector is configured to display the data, you should see your span displayed. |
| 69 | +### Metrics |
| 70 | +1. Create a default meter provider and save it. |
| 71 | +``` |
| 72 | +>> p = opentelemetry.sdk.metrics.MeterProvider(); |
| 73 | +>> setMeterProvider(p); |
| 74 | +``` |
| 75 | +2. Create a counter |
| 76 | +``` |
| 77 | +>> m = opentelemetry.metrics.getMeter("My Meter"); |
| 78 | +>> c = m.createCounter("My Counter"); |
| 79 | +``` |
| 80 | +3. Increment the counter |
| 81 | +``` |
| 82 | +>> c.add(10); |
| 83 | +``` |
| 84 | +4. If your collector is configured to display the data, you should see your counter displayed after 1 minute. |
| 85 | + |
| 86 | +### Logs |
| 87 | +1. Create a default logger provider and save it. |
| 88 | +``` |
| 89 | +>> p = opentelemetry.sdk.logs.LoggerProvider(); |
| 90 | +>> setLoggerProvider(p); |
| 91 | +``` |
| 92 | +2. Create a logger |
| 93 | +``` |
| 94 | +>> l = opentelemetry.logs.getLogger("My Logger"); |
| 95 | +``` |
| 96 | +3. Emit a log record with "info" level |
| 97 | +``` |
| 98 | +>> info(l, "My Message"); |
| 99 | +``` |
| 100 | +4. If your collector is configured to display the data, you should see your log record displayed. |
| 101 | + |
| 102 | +For more examples, see the "examples" folder. |
| 103 | + |
| 104 | +## Help |
| 105 | +To view documentation of individual function, type "help \<function_name>\". For example, |
| 106 | +``` |
| 107 | +>> help opentelemetry.sdk.trace.TracerProvider |
| 108 | +``` |
| 109 | + |
| 110 | +## License |
| 111 | +The license is available in the License file within this repository |
| 112 | + |
| 113 | +## Community Support |
| 114 | +[MATLAB Central](https://www.mathworks.com/matlabcentral) |
| 115 | + |
| 116 | +Copyright 2023-2024 The MathWorks, Inc. |
0 commit comments