blob: 2174cd780e73b0254c5647a593417213e07b5cf4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# Fluent OTel (OpenTelemetry) Proto files
This projects builds a static library that provides C interfaces for OpenTelemetry proto files data model and also includes some helper utilities.
In the source, the `.proto` files are already included in their `C` version, so here you will find instructions for:
- build this as a static library
- regenerate C interfaces from .proto files
The project exposes the following build options:
## Build static library
To get start just clone this repository
```
git clone https://github.com/fluent/fluent-otel-proto
```
Join the build directory and compile:
```
cd fluent-otel-proto/build
cmake ../
```
By default an example test gets available:
```
examples/test-api
- opentelemetry proto 'common' : found
- opentelemetry proto 'resource': found
- opentelemetry proto 'trace' : found
- opentelemetry proto 'logs' : found
- opentelemetry proto 'metrics' : not found (enable it with -DFLUENT_PROTO_METRICS)
```
> Yes, Metrics are disabled for now.
## Regenerate C files
To regenerate the C files inside this repo, you need to main dependencies or repositories:
- [fluent/protobuf-c](https://github.com/fluent/protobuf-c)
- [open-telemetry/opentelemetry-proto](https://github.com/open-telemetry/opentelemetry-proto)
### Download dependencies
#### 1. Protobuf-c
The repository [fluent/protobuf-c](https://github.com/fluent/protobuf-c) is a fork of the official protobuf-c that includes a small modification to support `options` feature from proto3. This feature is only required by the OpenTelemetry Metrics data model.
Download and install `protobuf-c` by running the following commands:
```
git clone https://github.com/fluent/protobuf-c
cd protobuf-c
./autogen.sh
./configure --prefix=/opt/protobuf-c
make
sudo make install
```
#### 2. OpenTelemetry Proto
Download the main repository with the following command:
```
git clone https://github.com/open-telemetry/opentelemetry-proto
```
#### 3. Clone this repository
```bash
git clone https://github.com/fluent/fluent-otel-proto
```
#### 4. Regenerate C Files
The CMake command will require the following variable definitions to succeed in the C files regeneration:
| Variable name | Description |
| ----------------------- | ------------------------------------------------------------ |
| FLUENT_PROTO_REGENERATE | Enable the C source file regeneration. Disabled by default. |
| PROTOBUF_C_SOURCE_DIR | Absolute path of the directory containing the sources of `protobuf-c` downloaded in Step 1. __NOTE__: this is the source code path, not where the binaries were installed. |
| OTEL_PROTO_DIR | Absolute path of the directory containing the sources of `opentelemetry-proto` downloaded in Step 2. |
In addition, the following build options are available if you desire to enable/disable certain feature:
| Build Option | Description | Default |
| --------------------- | ------------------------------------------------------------ | ------- |
| FLUENT_PROTO_COMMON | Include the regeneration of a C interface for `common.proto` file. | On |
| FLUENT_PROTO_RESOURCE | Include the regeneration of a C interface for `resource.proto` file. | On |
| FLUENT_PROTO_TRACE | Include the regeneration of a C interfaces for `trace.proto` and `trace_service.proto` files. | On |
| FLUENT_PROTO_LOGS | Include the regeneration of a C interfaces for `logs.proto` and `logs_service.proto` files. | On |
| FLUENT_PROTO_METRICS | Include the regeneration of a C interfaces for `metrics.proto` and `metrics_service.proto` files. | Off |
#### 5. Example
Get into this project source code directory:
```bash
cd fluent-otel-proto/build/
```
Run CMake:
```bash
cmake -DFLUENT_PROTO_REGENERATE=ON \
-DPROTOBUF_C_SOURCE_DIR=/tmp/protobuf-c \
-DOTEL_PROTO_DIR=/tmp/opentelemetry-proto \
../
```
now build by running `make` command.
|