Compare commits
743 Commits
Author | SHA1 | Date |
---|---|---|
|
85d04f9696 | |
|
6e8a8038a1 | |
|
6aece9bd83 | |
|
fab6a41ef7 | |
|
5f6d99f089 | |
|
0023154e75 | |
|
f697898062 | |
|
e8161664d2 | |
|
8825da6bf3 | |
|
495f497d45 | |
|
ba38077e54 | |
|
ac1172eb14 | |
|
03e04520d7 | |
|
4c41390d0e | |
|
2fc2a20c6e | |
|
f993e960df | |
|
59e7281f68 | |
|
f28ea95a5b | |
|
dbd06801eb | |
|
fdee87f91e | |
|
aeb5a01336 | |
|
c3a0ac1aec | |
|
4d0ac5d110 | |
|
5984a2d8c5 | |
|
c406864555 | |
|
93475ff631 | |
|
5423b91180 | |
|
0e51e67a9d | |
|
b7b0278682 | |
|
8608773f50 | |
|
6fed48c1b1 | |
|
4da9b67c0e | |
|
62ba4dea5b | |
|
9ee0c27886 | |
|
f224283f2e | |
|
b6ec7a1547 | |
|
7a78dd05f6 | |
|
cafcfaab6c | |
|
4ad3b8b06d | |
|
d017ae1fe9 | |
|
6c4d45c05c | |
|
1ad66746d2 | |
|
a1e6011bfa | |
|
3eec22c9a0 | |
|
711625fdbf | |
|
0bbbdb1aad | |
|
93877b9e0b | |
|
a91d6a1baa | |
|
b9db1b3c6c | |
|
f4897b2a5f | |
|
712d14838e | |
|
0994256b75 | |
|
3b42db59b0 | |
|
dff39f3eb3 | |
|
22715dd820 | |
|
7059f73039 | |
|
f16ea3b7f2 | |
|
85b0adaa08 | |
|
7dfc312274 | |
|
82bddef6ed | |
|
89b6d0fd54 | |
|
b49e1b7b6f | |
|
4b5f081103 | |
|
f74d413c63 | |
|
84657781f7 | |
|
29c0dd4a86 | |
|
016155f9ec | |
|
1d4112523a | |
|
9708acb694 | |
|
1ca14802f8 | |
|
021490ea1b | |
|
3d901a8135 | |
|
4561fc23d2 | |
|
7a68bb394c | |
|
47f530a5f9 | |
|
3b7f564da8 | |
|
f12c5c7804 | |
|
632c9ca83d | |
|
545f9f4108 | |
|
98e747f696 | |
|
b1253a7484 | |
|
53b153caf2 | |
|
549f2b009d | |
|
d64b65368c | |
|
470f66b4ac | |
|
1ede230d0f | |
|
d2e728914d | |
|
05ac10652c | |
|
76460cf70a | |
|
7a847caafc | |
|
b9cf499ff5 | |
|
793c7bd1e9 | |
|
d99593f2fd | |
|
214950e5d7 | |
|
c3ef5454d1 | |
|
7a9c60994e | |
|
87c216f5c8 | |
|
c2ea734f00 | |
|
4b6f52ae23 | |
|
b4254a4acf | |
|
f7babf1bca | |
|
a530f5ec31 | |
|
165983a128 | |
|
29ac517bee | |
|
2faa400782 | |
|
82ec2a5a3d | |
|
ba04dbbf13 | |
|
b7e7333344 | |
|
0f8dedf709 | |
|
44018b0bec | |
|
31b161ef8b | |
|
20c8ded8ad | |
|
db29c5b18d | |
|
bcdea0e1fc | |
|
364b860a3f | |
|
cacfe443bb | |
|
546fcd7979 | |
|
1e33bb595c | |
|
92dd28c2cb | |
|
4e4d8de860 | |
|
9451f0e3be | |
|
ed91e718f7 | |
|
a145a56880 | |
|
9fd8511772 | |
|
7801cd9fb3 | |
|
7bf114913d | |
|
3e761d0140 | |
|
f6d16d292c | |
|
f9f356c754 | |
|
7bc4573bbb | |
|
969bbf1503 | |
|
b8dd791717 | |
|
4da3647579 | |
|
d976876feb | |
|
674cc9ea9a | |
|
acd4a0ed2a | |
|
f987c9c094 | |
|
34375d7f91 | |
|
4d52ab2c4d | |
|
3e58a0b970 | |
|
99a0328a5c | |
|
b6908f0cf3 | |
|
4a0d19fe8b | |
|
bc36c69209 | |
|
b6630eeb73 | |
|
c2a9397627 | |
|
ab8147987d | |
|
6175aa0b21 | |
|
3bd8de9702 | |
|
83ac2ae49d | |
|
b2bc73fb83 | |
|
4ecafb6fbf | |
|
78efc41052 | |
|
a6779d8e21 | |
|
6e214c8503 | |
|
a7f52977fc | |
|
63220adcb4 | |
|
216f3f7399 | |
|
0fa41f9e26 | |
|
4af490ffed | |
|
2566fb62f3 | |
|
2c9b68fbae | |
|
b4328c0bc1 | |
|
a57063f7a2 | |
|
d09bfbac57 | |
|
148cfe9ee2 | |
|
dee5b0bc5c | |
|
64a74bfadb | |
|
edfeabe4ce | |
|
3c4afd0696 | |
|
021eb994cf | |
|
3212b0f68f | |
|
a7f9daf4cf | |
|
4b56f63906 | |
|
181f1e5829 | |
|
cd7103e0d3 | |
|
b89e63c1ce | |
|
821ad9ed28 | |
|
7f047d561d | |
|
2fdc0226c4 | |
|
2f58e95c43 | |
|
3ca3c76c06 | |
|
5bc053e522 | |
|
3506a7a975 | |
|
edb8937377 | |
|
52a80b5a04 | |
|
6603c3a0f1 | |
|
18e06f1fc5 | |
|
72b00809aa | |
|
ced79860f8 | |
|
e21655559c | |
|
031307b445 | |
|
d2ff95acbc | |
|
25f7a13f6f | |
|
02cda5103f | |
|
465cb4a102 | |
|
95baed7158 | |
|
62b71970e5 | |
|
d693e95cdb | |
|
0b712dd2f7 | |
|
57114c5b9c | |
|
d19eb322e9 | |
|
e5a1a15296 | |
|
c33f800b5c | |
|
3b8934619e | |
|
bb68f495c4 | |
|
4998eb1786 | |
|
807d610225 | |
|
40d7b76a91 | |
|
92bf8daad5 | |
|
0b94d71258 | |
|
2b9bff9688 | |
|
d9ad23ee86 | |
|
902ee88bef | |
|
1cbea09cb0 | |
|
b7418152a0 | |
|
6ed0651a42 | |
|
8b418fee83 | |
|
490f882e62 | |
|
6d87bd6a8b | |
|
762b73d851 | |
|
6218a24a47 | |
|
2d80c18304 | |
|
23562e6da3 | |
|
150256c172 | |
|
ac4bba7363 | |
|
f167c36eec | |
|
fb6fde8244 | |
|
d15da3b256 | |
|
8d45dec7ee | |
|
955a807c04 | |
|
2a8c8bc3de | |
|
31956f82ff | |
|
c1ef416c54 | |
|
fcdd52672f | |
|
9d998e3341 | |
|
6a77bcdd5f | |
|
09c0616971 | |
|
f1b5fbdedd | |
|
4341e1237e | |
|
fe68d51efe | |
|
4d9cc288d5 | |
|
8e7a192f3e | |
|
8691248fdd | |
|
169525328a | |
|
a5db7e5935 | |
|
a388e87d72 | |
|
149d29ca78 | |
|
c81a3d4d20 | |
|
f7a9aea063 | |
|
a713947e59 | |
|
1863fe723d | |
|
24a523c0cc | |
|
95d039c08a | |
|
ff2447df63 | |
|
84d4270708 | |
|
b0e8d7a57f | |
|
be1f43ca00 | |
|
6fdf797ace | |
|
d16f7815ef | |
|
f30ab925c8 | |
|
6292a6a74e | |
|
5e62859ffc | |
|
2c912d50a5 | |
|
994761988e | |
|
751ba5b48f | |
|
7402ed9bac | |
|
b1488cd37c | |
|
1185405c46 | |
|
63683c1596 | |
|
70ed9bcac0 | |
|
f69963f587 | |
|
6445819fce | |
|
3d9c2b5382 | |
|
0ea1f2c644 | |
|
fa0a5200dd | |
|
35e8d17420 | |
|
3910b049c1 | |
|
7b824738c3 | |
|
23818a7105 | |
|
2314e061a5 | |
|
c6d394547b | |
|
c37df2318d | |
|
4eb78a6a04 | |
|
d623bc57f6 | |
|
261a151829 | |
|
0d5a387b00 | |
|
080356950e | |
|
7f785b5d5c | |
|
f02d70bdb8 | |
|
a9208987c5 | |
|
a71642fe67 | |
|
242d52ac67 | |
|
b8909692c6 | |
|
1203bcf264 | |
|
9e062b5bdd | |
|
41538b0525 | |
|
cc60934199 | |
|
7c6b9dbcaf | |
|
34ca855055 | |
|
eda6e93f47 | |
|
84368cd761 | |
|
deed1e3a0c | |
|
4520aa598b | |
|
f195b9e3da | |
|
611906eeaf | |
|
0a43c1f2b1 | |
|
aac2b775af | |
|
baecbb95bd | |
|
d8ae09e53d | |
|
323a279ec5 | |
|
63fa4fde4e | |
|
eb2b9753ea | |
|
6dbfdb52eb | |
|
0ff58e8334 | |
|
f6dca999b5 | |
|
42563e4160 | |
|
5e21b8ac2d | |
|
ead2d1b606 | |
|
f0e0ef0bf3 | |
|
77012391b2 | |
|
fd57e7aa23 | |
|
4e86a86a5f | |
|
086e94cdbd | |
|
e1d96901fc | |
|
aff26ac503 | |
|
595801bab9 | |
|
05bfb8a257 | |
|
9af3c99cf0 | |
|
f97dc061bc | |
|
fad93f0727 | |
|
025f42f1ea | |
|
508910529b | |
|
3efd3ce8f4 | |
|
436a981d81 | |
|
1d8a7b5b25 | |
|
bf8fa53ac1 | |
|
cb9cd1d1d1 | |
|
2535c70c4e | |
|
4f37503105 | |
|
c5269cd1d2 | |
|
c42dcca9f8 | |
|
0dd64e0747 | |
|
277190d3f2 | |
|
17c3bc66d4 | |
|
605c3e8ea7 | |
|
78d488ca44 | |
|
9c767df507 | |
|
2db27ddfd3 | |
|
4edcebdbff | |
|
ce14bf6520 | |
|
6de4ccd421 | |
|
4f32bc6f29 | |
|
da8e377be5 | |
|
2d077f8ec5 | |
|
830651a4c7 | |
|
0ca7d707a5 | |
|
054b0dc207 | |
|
6c2a6abad3 | |
|
7aea1a6a94 | |
|
950c336e3f | |
|
8f15440b45 | |
|
78947b2ab1 | |
|
cd22f0f8ac | |
|
848db5722e | |
|
e86ceba79d | |
|
13a4c45009 | |
|
fabd8cc2bc | |
|
3adcc791e7 | |
|
a06fd25ae7 | |
|
8dacf7e65d | |
|
611caa786e | |
|
02e6ad25ad | |
|
9500c12046 | |
|
f2f0738792 | |
|
d24839e318 | |
|
8605fe82c1 | |
|
3f8d954468 | |
|
0375cd4051 | |
|
788631d964 | |
|
4d4f8ed085 | |
|
19f0dc7760 | |
|
25738f391b | |
|
3e4b7d3c73 | |
|
ac7ee5f80a | |
|
e5c2e25144 | |
|
14f7542c18 | |
|
c82306f431 | |
|
07f6cb54ec | |
|
eaaf6cd602 | |
|
ba183049a5 | |
|
d036d8227f | |
|
a799f4aed9 | |
|
719c60fd8e | |
|
a883dc7255 | |
|
32196a51f0 | |
|
84e38b215f | |
|
563094b683 | |
|
75f34e60a3 | |
|
89a3d9be45 | |
|
9649ebeaaf | |
|
4eb99f9e05 | |
|
2f3fbd48b7 | |
|
e1119ed781 | |
|
c7a88c479f | |
|
614b8db9bf | |
|
8684a33fea | |
|
4700e483e0 | |
|
6e8f7c44f3 | |
|
cf5cdaae86 | |
|
d32f9609b9 | |
|
497eaf43e5 | |
|
732f0b22fb | |
|
7cc781e654 | |
|
23206365dc | |
|
f36fc0fc79 | |
|
8cbe7271a0 | |
|
bbd6325f78 | |
|
14b74b9fb4 | |
|
8da71b78ed | |
|
fe15d0a4d1 | |
|
a2323281ad | |
|
8f88553507 | |
|
02b984abf5 | |
|
ff13fdd92d | |
|
2b5c2b4044 | |
|
589dd2ac6b | |
|
1467d663a9 | |
|
0cd3e88bbb | |
|
f3132e5304 | |
|
423ecacdf6 | |
|
c4f39f2be8 | |
|
f084fbce22 | |
|
928a87ce57 | |
|
74db5e6101 | |
|
0134bbe0de | |
|
ddfafff999 | |
|
0dd5eedf75 | |
|
e8afbb8eac | |
|
e79a10f69a | |
|
ebb45c6a3b | |
|
03f2a6916d | |
|
ab440e4d4c | |
|
51c2ee5679 | |
|
0b9371dcc5 | |
|
96e5078cff | |
|
cd626c2ae9 | |
|
a8b11a3503 | |
|
4bd64c9a33 | |
|
9f6d1453e7 | |
|
48e633e740 | |
|
d91e5bac17 | |
|
39ad238f55 | |
|
a86f8f094a | |
|
d1143ab37e | |
|
abad83d03e | |
|
25343e6e3b | |
|
27a58cdc25 | |
|
064fef0d87 | |
|
71d0e50b12 | |
|
9b89843553 | |
|
8cba762d0d | |
|
cb603ad97f | |
|
3dfcf93c41 | |
|
5bd9c65c64 | |
|
6322607520 | |
|
86ee88615b | |
|
35a9362732 | |
|
5bf2f8007f | |
|
ca08c5a34a | |
|
758687cde4 | |
|
17da6d87c1 | |
|
d3a873a673 | |
|
0baf5015ea | |
|
045be9c02b | |
|
f16deb0740 | |
|
91dd15fbdf | |
|
d9ad76f6be | |
|
0e6eae0466 | |
|
231ca4ade1 | |
|
e918960e06 | |
|
46e20a42ae | |
|
f2cbf02ec1 | |
|
cbee4de0ec | |
|
3ff4b4c1f7 | |
|
2c4b2a910c | |
|
df96b7429a | |
|
18a27df365 | |
|
05b26cae87 | |
|
0eaa7944e1 | |
|
0803e6a8f2 | |
|
bd11434940 | |
|
c3c643a597 | |
|
ad626cec45 | |
|
5e96b80bc9 | |
|
368ee79210 | |
|
a45081a83b | |
|
a4961c421c | |
|
ab83f4f747 | |
|
d49ba52591 | |
|
61e7429d63 | |
|
41a7875ef8 | |
|
ca67af031b | |
|
13f01cae93 | |
|
0563a71ce3 | |
|
049f7e8a19 | |
|
f5c00160c4 | |
|
44096c8072 | |
|
b9776d63d4 | |
|
f5f39343ac | |
|
7aee911985 | |
|
e706b20503 | |
|
cdbc90abf3 | |
|
6eb09faa7c | |
|
5acaa14c21 | |
|
01e65810b9 | |
|
f52ec6cade | |
|
7196ec3fda | |
|
628838af8a | |
|
c0f17d99b0 | |
|
11d5d9e0d8 | |
|
36fb921fe0 | |
|
4bfddde7ad | |
|
d3799a63ff | |
|
c0092c4c84 | |
|
0d1326a02e | |
|
b7fd057185 | |
|
8c82d24c20 | |
|
8f97cab686 | |
|
0c5f90dea5 | |
|
92a8a54c6f | |
|
a15a9b8101 | |
|
2974eb8eef | |
|
038e65d7f2 | |
|
bc23e6a43f | |
|
b3d547c205 | |
|
d99cbab06c | |
|
ca8c23481a | |
|
7b95f5b2af | |
|
f5426ce8cf | |
|
556139396c | |
|
1111f3409f | |
|
8b613188a3 | |
|
d6cebe1404 | |
|
6ecd201f95 | |
|
5466c5be26 | |
|
60794ac79f | |
|
31f218c1e2 | |
|
ebbcd48a88 | |
|
42709f4575 | |
|
049ab63103 | |
|
313b04d859 | |
|
efde01033b | |
|
d0452f829f | |
|
cfcda5728e | |
|
2db5f29396 | |
|
4cae6aae8c | |
|
763f11d65b | |
|
fc8853e418 | |
|
4b20067c35 | |
|
773a172ddb | |
|
bd83aa367c | |
|
c89a6fde66 | |
|
d233b9bc1a | |
|
d980e8b406 | |
|
600bd305fe | |
|
500cf98f0b | |
|
834c0c4d1b | |
|
082bb93098 | |
|
41416ce21f | |
|
f5fd9062de | |
|
8ba95296e4 | |
|
0eca570bbf | |
|
8b7f9b4209 | |
|
f55346262b | |
|
3707bc04e0 | |
|
5e290c909d | |
|
770fce3c40 | |
|
32a823514c | |
|
61e8741a70 | |
|
cfa130bb92 | |
|
23dfc20ac6 | |
|
c9f14e9bce | |
|
75d76a1cbb | |
|
8308fc6150 | |
|
990da7dd0f | |
|
80f301805d | |
|
b4ff53ded2 | |
|
8c750414c5 | |
|
2fd3d35550 | |
|
6ca0d68ca1 | |
|
6c7f7c8100 | |
|
fbcf3aac13 | |
|
a39e8b51ea | |
|
22d0448ebc | |
|
71ba593b9b | |
|
7ee86a96b0 | |
|
82f2828ed0 | |
|
7cb7654552 | |
|
6a3ee1632d | |
|
7887d32da6 | |
|
e71e28c2d7 | |
|
efb1a260fe | |
|
0e52dfdb15 | |
|
9bcfcb99ff | |
|
0139cb4e27 | |
|
b793426b51 | |
|
bd7a3c7b41 | |
|
380f0f2543 | |
|
3305bd73fc | |
|
fb3bcb5b52 | |
|
2b2fe449ac | |
|
9b222f2af1 | |
|
3a09d53195 | |
|
e7589c0a7a | |
|
5ccf493a9c | |
|
211d9c92d0 | |
|
e0a85f2b03 | |
|
2462f7c98c | |
|
15ab9ed9ad | |
|
b04676454d | |
|
1ac9caf100 | |
|
504644380a | |
|
7db57f9d2b | |
|
f702676250 | |
|
04a0751f38 | |
|
f732872cc6 | |
|
2b08db2db4 | |
|
0b72b030bc | |
|
da333f8eba | |
|
649829fe96 | |
|
4dff60af85 | |
|
9a5bb8d1af | |
|
76935bcde0 | |
|
3ef579bca3 | |
|
fd06d84ea3 | |
|
075f45d251 | |
|
7c0826efe0 | |
|
5c121cf04e | |
|
eed657237e | |
|
95f6c66de2 | |
|
01eac4ca9c | |
|
392c3965ed | |
|
a6211fa904 | |
|
e47dec5cfa | |
|
4daca390e9 | |
|
6f0a30ee1c | |
|
9d8efafc28 | |
|
6d9c4cacc9 | |
|
d1fd49d372 | |
|
2544803a37 | |
|
b364dce27b | |
|
1d18614edb | |
|
7ed1b1db29 | |
|
6925fc4751 | |
|
1fc4cacf3e | |
|
97f0751ba9 | |
|
2bae1c68da | |
|
c4c8ee053f | |
|
9200d0c8fb | |
|
32af3529ef | |
|
d56a5c702f | |
|
5b0adc747b | |
|
1ae2fe538c | |
|
65ebdb1e61 | |
|
7e7184d0a4 | |
|
52309ddc65 | |
|
998badd466 | |
|
e8fce84de8 | |
|
7406b4fb2d | |
|
c9e76b4a1a | |
|
59d0bc2055 | |
|
0305ad8e4c | |
|
46b16ec3cf | |
|
57d1a478bd | |
|
65c22e94fa | |
|
8a9d085f05 | |
|
201b347588 | |
|
d5571916e1 | |
|
61bc860a49 | |
|
a343da043e | |
|
d5f0c484e3 | |
|
9197bf38f1 | |
|
94a6783025 | |
|
c0deb4065e | |
|
8866c10f10 | |
|
9dd19a2afb | |
|
066c2f3927 | |
|
e7579ed688 | |
|
dfff6936ef | |
|
9f333ff4f6 | |
|
9712161b43 | |
|
f3daca092b | |
|
d30c14008c | |
|
f1f6083c88 | |
|
75f3900a83 | |
|
722ad4e771 | |
|
7727620b6c | |
|
41821d67cd | |
|
57bf8c2b0e | |
|
d74e02f1c3 | |
|
02bca217db | |
|
f23c4a2e89 | |
|
2accc77af1 | |
|
a24488f43b | |
|
82d8cb49cd | |
|
7e26a7e84e | |
|
33d244a943 | |
|
308ec88b56 | |
|
368c8bfef7 | |
|
ec90007e35 | |
|
6a99feed82 | |
|
0122b139f5 | |
|
5642d1ce34 | |
|
e1b56117b4 | |
|
b13e3e2969 | |
|
8bfb9a3f2d | |
|
3f0eee6b91 | |
|
c1aa0b80fb | |
|
6ba1f73b04 | |
|
0dc22681f2 | |
|
a0e98fb506 | |
|
6644ddd7f3 | |
|
8f778b7412 | |
|
d0571d8ac7 | |
|
8da88df80d | |
|
d7a388b154 | |
|
a3e3a90ec6 | |
|
389b84f430 | |
|
b157216274 | |
|
702a68c129 | |
|
a220ac4c6f | |
|
b46ca963e8 | |
|
b89f981e10 | |
|
34b659743f | |
|
b8b715faf9 | |
|
7efeeabeea | |
|
ec8895bc98 | |
|
99a9b4cc07 | |
|
7634edf461 | |
|
7812651354 | |
|
ac179dd64a | |
|
e5590c5b70 |
18
.bazelrc
18
.bazelrc
|
@ -1,9 +1,26 @@
|
|||
# Copyright The OpenTelemetry Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# bazel configurations for running tests under sanitizers.
|
||||
# Based on https://github.com/bazelment/trunk/blob/master/tools/bazel.rc
|
||||
|
||||
# Enable automatic configs based on platform
|
||||
common --enable_platform_specific_config
|
||||
|
||||
# Make globs that don't match anything fail
|
||||
common --incompatible_disallow_empty_glob
|
||||
|
||||
# Needed by gRPC to build on some platforms.
|
||||
build --copt -DGRPC_BAZEL_BUILD
|
||||
|
||||
# Workaround abseil libraries missing symbols
|
||||
build:windows --dynamic_mode=off
|
||||
|
||||
# Set minimum supported C++ version
|
||||
build:macos --host_cxxopt=-std=c++14 --cxxopt=-std=c++14
|
||||
build:linux --host_cxxopt=-std=c++14 --cxxopt=-std=c++14
|
||||
build:windows --host_cxxopt=/std:c++14 --cxxopt=/std:c++14
|
||||
|
||||
# --config=asan : Address Sanitizer.
|
||||
common:asan --copt -DADDRESS_SANITIZER
|
||||
common:asan --copt -fsanitize=address,bool,float-cast-overflow,integer-divide-by-zero,null,return,returns-nonnull-attribute,shift-exponent,signed-integer-overflow,unreachable,vla-bound
|
||||
|
@ -22,4 +39,3 @@ common:tsan --cc_output_directory_tag=tsan
|
|||
# This is needed to address false positive problem with abseil.The same setting as gRPC
|
||||
# https://github.com/google/sanitizers/issues/953
|
||||
common:tsan --test_env=TSAN_OPTIONS=report_atomic_races=0
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
4.2.0
|
||||
7.1.1
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
# Copyright The OpenTelemetry Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# See Clang docs: http://clang.llvm.org/docs/ClangFormatStyleOptions.html
|
||||
BasedOnStyle: Chromium
|
||||
|
||||
|
@ -56,3 +59,15 @@ IndentPPDirectives: AfterHash
|
|||
|
||||
# Include blocks style
|
||||
IncludeBlocks: Preserve
|
||||
|
||||
AttributeMacros:
|
||||
- OPENTELEMETRY_UNLIKELY
|
||||
- OPENTELEMETRY_LIKELY
|
||||
- OPENTELEMETRY_MAYBE_UNUSED
|
||||
- OPENTELEMETRY_DEPRECATED
|
||||
- OPENTELEMETRY_API_SINGLETON
|
||||
- OPENTELEMETRY_LOCAL_SYMBOL
|
||||
- OPENTELEMETRY_EXPORT
|
||||
- OPENTELEMETRY_SANITIZER_NO_MEMORY
|
||||
- OPENTELEMETRY_SANITIZER_NO_THREAD
|
||||
- OPENTELEMETRY_SANITIZER_NO_ADDRESS
|
|
@ -0,0 +1,42 @@
|
|||
# Copyright The OpenTelemetry Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Checks: >
|
||||
-*,
|
||||
performance-*,
|
||||
portability-*,
|
||||
abseil-*,
|
||||
-abseil-string-find-str-contains,
|
||||
bugprone-*,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
-bugprone-implicit-widening-of-multiplication-result,
|
||||
-bugprone-inc-dec-in-conditions,
|
||||
-bugprone-narrowing-conversions,
|
||||
-bugprone-unchecked-optional-access,
|
||||
-bugprone-unhandled-exception-at-new,
|
||||
-bugprone-unused-local-non-trivial-variable,
|
||||
google-*,
|
||||
-google-build-using-namespace,
|
||||
-google-default-arguments,
|
||||
-google-explicit-constructor,
|
||||
-google-readability-avoid-underscore-in-googletest-name,
|
||||
-google-readability-braces-around-statements,
|
||||
-google-readability-namespace-comments,
|
||||
-google-readability-todo,
|
||||
-google-runtime-references,
|
||||
misc-*,
|
||||
-misc-const-correctness,
|
||||
-misc-include-cleaner,
|
||||
-misc-non-private-member-variables-in-classes,
|
||||
-misc-unused-alias-decls,
|
||||
-misc-use-anonymous-namespace,
|
||||
cppcoreguidelines-*,
|
||||
-cppcoreguidelines-owning-memory,
|
||||
-cppcoreguidelines-avoid-do-while,
|
||||
-cppcoreguidelines-avoid-c-arrays,
|
||||
-cppcoreguidelines-avoid-magic-numbers,
|
||||
-cppcoreguidelines-init-variables,
|
||||
-cppcoreguidelines-macro-usage,
|
||||
-cppcoreguidelines-non-private-member-variables-in-classes,
|
||||
-cppcoreguidelines-avoid-non-const-global-variables,
|
||||
-cppcoreguidelines-pro-*
|
|
@ -1,3 +1,6 @@
|
|||
# Copyright The OpenTelemetry Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# If comment markup is enabled, don't reflow the first comment block in
|
||||
# eachlistfile. Use this to preserve formatting of your
|
||||
# copyright/licensestatements.
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
# Copyright The OpenTelemetry Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# Ignore the following directories
|
||||
|
||||
./.git/*
|
||||
./.github/*
|
||||
./third_party/benchmark/*
|
||||
./third_party/boost/*
|
||||
./third_party/googletest/*
|
||||
./third_party/ms-gsl/*
|
||||
./third_party/nlohmann-json/*
|
||||
./third_party/opentelemetry-proto/*
|
||||
./third_party/prometheus-cpp/*
|
||||
./tools/vcpkg/*
|
||||
./tools/ports/*
|
||||
|
||||
# Third party code
|
||||
|
||||
./api/include/opentelemetry/nostd/internal/absl/*
|
||||
./exporters/jaeger/thrift-gen/*
|
||||
./exporters/etw/include/opentelemetry/exporters/etw/TraceLoggingDynamic.h
|
||||
|
||||
# Doc
|
||||
|
||||
./docs/*
|
||||
|
||||
## Ignore the following files patterns
|
||||
|
||||
*.md
|
||||
*.rst
|
||||
*.png
|
||||
*.log
|
||||
*.patch
|
||||
*.json
|
||||
*.nuspec
|
||||
*.pem
|
||||
|
||||
# Packaging
|
||||
*/CONTROL
|
||||
|
||||
# LICENSE files
|
||||
*/LICENSE
|
||||
|
||||
# Ignore the following misc files
|
||||
|
||||
./.bazelignore
|
||||
./.bazelversion
|
||||
./docker/.gitignore
|
||||
.markdownlintignore
|
||||
./ci/toc.yml
|
||||
./ci/valgrind-suppressions
|
|
@ -0,0 +1,55 @@
|
|||
# Copyright The OpenTelemetry Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
FROM ubuntu:24.04@sha256:1e622c5f073b4f6bfad6632f2616c7f59ef256e96fe78bf6a595d1dc4376ac02
|
||||
|
||||
RUN apt update && apt install -y \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
wget \
|
||||
cmake \
|
||||
git \
|
||||
sudo \
|
||||
nano \
|
||||
pkg-config \
|
||||
ninja-build \
|
||||
clang-format \
|
||||
clang-tidy \
|
||||
autoconf \
|
||||
automake \
|
||||
libtool \
|
||||
python3-pip
|
||||
|
||||
RUN pip install "conan==2.15.1" --break-system-packages
|
||||
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=1000
|
||||
ARG USER_NAME=devuser
|
||||
ENV USER_NAME=devuser
|
||||
ENV USER_UID=${USER_UID}
|
||||
ENV USER_GID=${USER_GID}
|
||||
ENV INSTALL_PACKAGES=
|
||||
ENV IS_CONTAINER_BUILD=true
|
||||
|
||||
COPY ./.devcontainer/customize_container.sh /tmp/opentelemetry_cpp/devcontainer/customize_container.sh
|
||||
RUN /tmp/opentelemetry_cpp/devcontainer/customize_container.sh
|
||||
USER devuser
|
||||
|
||||
RUN conan profile detect --force
|
||||
|
||||
ARG CONAN_FILE=conanfile_stable.txt
|
||||
ARG CONAN_BUILD_TYPE=Debug
|
||||
ARG CXX_STANDARD=17
|
||||
WORKDIR /home/devuser/conan
|
||||
COPY ./install/conan/ .
|
||||
|
||||
RUN conan install ./${CONAN_FILE} --build=missing -s build_type=${CONAN_BUILD_TYPE}
|
||||
ENV CMAKE_TOOLCHAIN_FILE=/home/devuser/conan/build/${CONAN_BUILD_TYPE}/generators/conan_toolchain.cmake
|
||||
ENV CXX_STANDARD=${CXX_STANDARD}
|
||||
ENV BUILD_TYPE=${CONAN_BUILD_TYPE}
|
||||
ENV CONAN_FILE=${CONAN_FILE}
|
||||
|
||||
WORKDIR /workspaces/opentelemetry-cpp
|
||||
|
||||
ENTRYPOINT []
|
||||
|
||||
CMD ["/bin/bash"]
|
|
@ -0,0 +1,52 @@
|
|||
# Copyright The OpenTelemetry Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
FROM otel/cpp_format_tools
|
||||
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=1000
|
||||
ARG INSTALL_PACKAGES=
|
||||
|
||||
ARG CXX_STANDARD=17
|
||||
|
||||
ENV CXX_STANDARD=${CXX_STANDARD}
|
||||
|
||||
COPY ci /opt/ci
|
||||
|
||||
RUN apt update && apt install -y wget \
|
||||
ninja-build \
|
||||
llvm-dev \
|
||||
libclang-dev \
|
||||
clang-tidy \
|
||||
shellcheck \
|
||||
sudo \
|
||||
cmake
|
||||
|
||||
RUN cd /opt/ci && bash setup_ci_environment.sh
|
||||
RUN cd /opt/ci && bash install_iwyu.sh
|
||||
|
||||
ADD https://github.com/bazelbuild/bazelisk/releases/download/v1.22.1/bazelisk-linux-amd64 /usr/local/bin
|
||||
|
||||
RUN git config --global core.autocrlf input \
|
||||
&& chmod +x /usr/local/bin/bazelisk-linux-amd64
|
||||
|
||||
ENV INSTALL_PACKAGES=${INSTALL_PACKAGES}
|
||||
ENV USER_NAME=devuser
|
||||
ENV USER_UID=${USER_UID}
|
||||
ENV USER_GID=${USER_GID}
|
||||
ENV IS_CONTAINER_BUILD=true
|
||||
|
||||
COPY install /opt/install
|
||||
COPY ./.devcontainer/customize_container.sh /tmp/opentelemetry_cpp/devcontainer/customize_container.sh
|
||||
RUN /tmp/opentelemetry_cpp/devcontainer/customize_container.sh
|
||||
RUN apt install -y npm && npm install -g markdownlint-cli@0.44.0
|
||||
|
||||
USER devuser
|
||||
|
||||
WORKDIR /workspaces/opentelemetry-cpp
|
||||
RUN cd /opt && bash ci/install_thirdparty.sh --install-dir /home/devuser/third-party/install-stable --tags-file install/cmake/third_party_stable
|
||||
ENV CMAKE_PREFIX_PATH=/home/devuser/third-party/install-stable
|
||||
|
||||
ENTRYPOINT []
|
||||
|
||||
CMD ["/bin/bash"]
|
|
@ -0,0 +1,38 @@
|
|||
# Customizing Your Dev Container
|
||||
|
||||
Customize your dev container using build arguments (for direct Docker builds) or
|
||||
environment variables (for evaluation in `devcontainer.json`).
|
||||
|
||||
* **CXX standard:**
|
||||
This is the C++ standard to build from (eg: 17, 20, ...). (Default: 17)
|
||||
* Docker ARG:
|
||||
`CXX_STANDARD`
|
||||
* Host Environment Variable:
|
||||
`OTEL_CPP_DEVCONTAINER_CXX_STANDARD`
|
||||
|
||||
* **User ID (UID):**
|
||||
User ID (Default: `1000`)
|
||||
* Docker ARG:
|
||||
`USER_UID`
|
||||
* Host Environment Variable:
|
||||
`OTEL_CPP_DEVCONTAINER_USER_UID`
|
||||
|
||||
* **Group ID (GID):**
|
||||
User group ID (Default: `1000`)
|
||||
* Docker ARG:
|
||||
`USER_GID`
|
||||
* Host Environment Variable:
|
||||
`OTEL_CPP_DEVCONTAINER_USER_GID`
|
||||
|
||||
* **Install Packages:**
|
||||
These are the additional packages that will be installed via `apt install` in the devcontainer. This is a space separated list.
|
||||
* Docker ARG:
|
||||
`INSTALL_PACKAGES` (Default: ``)
|
||||
* Host Environment Variable:
|
||||
`OTEL_CPP_DEVCONTAINER_INSTALL_PACKAGES` (Default: ``)
|
||||
|
||||
## Examples
|
||||
|
||||
* `docker build --build-arg CXX_STANDARD="20" --build-arg INSTALL_PACKAGES="nano gitk"...`
|
||||
* `export OTEL_CPP_DEVCONTAINER_CXX_STANDARD=20`
|
||||
* `export OTEL_CPP_DEVCONTAINER_INSTALL_PACKAGES="nano gitk"`
|
|
@ -0,0 +1,39 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright The OpenTelemetry Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
set -eu
|
||||
|
||||
if [[ $IS_CONTAINER_BUILD != "true" ]]; then
|
||||
echo "This script should only run inside a Docker container."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -n "$INSTALL_PACKAGES" ]]; then
|
||||
packages=($INSTALL_PACKAGES)
|
||||
for package in "${packages[@]}"; do
|
||||
apt install -y "$package"
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ $(id "$USER_NAME" 2>/dev/null) ]]; then
|
||||
echo "User '$USER_NAME' already exists. Removing it."
|
||||
userdel -rf "$USER_NAME"
|
||||
elif [[ $(id -u "$USER_UID" 2>/dev/null) ]]; then
|
||||
OTHER_USER=$(getent passwd "$USER_UID" | cut -d: -f1)
|
||||
echo "User '$OTHER_USER' exists with UID $USER_UID. Removing it."
|
||||
userdel -rf "$OTHER_USER"
|
||||
fi
|
||||
|
||||
if [[ ! $(getent group "$USER_GID" 2>/dev/null) ]]; then
|
||||
echo "Group '$USER_GID' does not exist. Adding it."
|
||||
groupadd -g "$USER_GID" "$USER_NAME"
|
||||
fi
|
||||
|
||||
useradd -m -u "$USER_UID" -g "$USER_GID" -s /bin/bash "$USER_NAME"
|
||||
echo "Created user '$USER_NAME' (UID: $USER_UID, GID: $USER_GID)."
|
||||
|
||||
echo "$USER_NAME ALL=(ALL) NOPASSWD:ALL" | tee /etc/sudoers.d/"$USER_NAME"
|
||||
|
||||
echo "User and group setup complete."
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
|
||||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.162.0/containers/javascript-node
|
||||
{
|
||||
"name": "opentelemetry-cpp",
|
||||
"build": {
|
||||
"context": "..",
|
||||
"dockerfile": "Dockerfile.dev",
|
||||
"args": {
|
||||
"USER_UID": "${localEnv:OTEL_CPP_DEVCONTAINER_USER_UID:1000}",
|
||||
"USER_GID": "${localEnv:OTEL_CPP_DEVCONTAINER_USER_GID:1000}",
|
||||
"INSTALL_PACKAGES": "${localEnv:OTEL_CPP_DEVCONTAINER_INSTALL_PACKAGES:}",
|
||||
"CXX_STANDARD": "${localEnv:OTEL_CPP_DEVCONTAINER_CXX_STANDARD:17}"
|
||||
}
|
||||
},
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"ms-vscode.cpptools",
|
||||
"ms-azuretools.vscode-docker",
|
||||
"ms-vscode.cpptools-extension-pack"
|
||||
],
|
||||
"settings": {
|
||||
"terminal.integrated.shell.linux": "/bin/bash",
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"remoteUser": "devuser"
|
||||
}
|
|
@ -42,6 +42,7 @@ ignore:
|
|||
- "cmake/**/*"
|
||||
- "buildscripts/**/*"
|
||||
- "third_party/**/*"
|
||||
- "test_common/**/*"
|
||||
- "tools/**/*"
|
||||
- ".vscode/**/*"
|
||||
- ".github/**/*"
|
||||
|
|
|
@ -17,3 +17,5 @@ What did you see instead?
|
|||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
|
||||
<sub>**Tip**: [React](https://github.blog/news-insights/product-news/add-reactions-to-pull-requests-issues-and-comments/) with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it. Learn more [here](https://opentelemetry.io/community/end-user/issue-participation/).</sub>
|
||||
|
|
|
@ -17,3 +17,5 @@ Which alternative solutions or features have you considered?
|
|||
|
||||
**Additional context**
|
||||
Add any other context about the feature request here.
|
||||
|
||||
<sub>**Tip**: [React](https://github.blog/news-insights/product-news/add-reactions-to-pull-requests-issues-and-comments/) with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it. Learn more [here](https://opentelemetry.io/community/end-user/issue-participation/).</sub>
|
||||
|
|
|
@ -6,3 +6,8 @@ updates:
|
|||
interval: "daily"
|
||||
labels:
|
||||
- "GHA"
|
||||
|
||||
- package-ecosystem: "devcontainers"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
|
|
|
@ -5,19 +5,23 @@ on:
|
|||
- main
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
deployments: write
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
benchmark:
|
||||
name: Run OpenTelemetry-cpp benchmarks
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
- name: Mount Bazel Cache
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
|
||||
env:
|
||||
cache-name: bazel_cache
|
||||
with:
|
||||
|
@ -25,30 +29,38 @@ jobs:
|
|||
key: bazel_benchmark
|
||||
- name: setup
|
||||
run: |
|
||||
sudo ./ci/setup_cmake.sh
|
||||
sudo ./ci/setup_ci_environment.sh
|
||||
sudo ./ci/install_bazelisk.sh
|
||||
- name: Run benchmark
|
||||
id: run_benchmarks
|
||||
run: |
|
||||
ci/do_ci.sh bazel.benchmark
|
||||
./ci/do_ci.sh bazel.benchmark
|
||||
mkdir -p benchmarks
|
||||
mv api-benchmark_result.json benchmarks
|
||||
mv sdk-benchmark_result.json benchmarks
|
||||
mv exporters-benchmark_result.json benchmarks
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@6027e3dd177782cd8ab9af838c04fd81a07f1d47 # main March 2025
|
||||
with:
|
||||
name: benchmark_results
|
||||
path: benchmarks
|
||||
store_benchmark:
|
||||
needs: benchmark
|
||||
permissions:
|
||||
contents: write
|
||||
deployments: write
|
||||
strategy:
|
||||
matrix:
|
||||
components: ["api", "sdk", "exporters"]
|
||||
name: Store benchmark result
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/download-artifact@master
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # main March 2025
|
||||
with:
|
||||
name: benchmark_results
|
||||
path: benchmarks
|
||||
|
@ -57,7 +69,7 @@ jobs:
|
|||
run: |
|
||||
cat benchmarks/*
|
||||
- name: Push benchmark result
|
||||
uses: benchmark-action/github-action-benchmark@v1
|
||||
uses: benchmark-action/github-action-benchmark@d48d326b4ca9ba73ca0cd0d59f108f9e02a381c7 # v1.20.4
|
||||
with:
|
||||
name: OpenTelemetry-cpp ${{ matrix.components }} Benchmark
|
||||
tool: 'googlecpp'
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,98 @@
|
|||
name: clang-tidy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
clang-tidy:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- cmake_options: all-options-abiv1-preview
|
||||
warning_limit: 61
|
||||
- cmake_options: all-options-abiv2-preview
|
||||
warning_limit: 61
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Setup Environment
|
||||
run: |
|
||||
sudo apt update -y
|
||||
sudo apt install -y --no-install-recommends --no-install-suggests \
|
||||
build-essential \
|
||||
cmake \
|
||||
zlib1g-dev \
|
||||
libssl-dev \
|
||||
libcurl4-openssl-dev \
|
||||
nlohmann-json3-dev \
|
||||
libabsl-dev \
|
||||
libprotobuf-dev \
|
||||
libgrpc++-dev \
|
||||
protobuf-compiler \
|
||||
protobuf-compiler-grpc \
|
||||
libgmock-dev \
|
||||
libgtest-dev \
|
||||
libbenchmark-dev
|
||||
|
||||
if ! command -v clang-tidy &> /dev/null; then
|
||||
echo "clang-tidy could not be found"
|
||||
exit 1
|
||||
fi
|
||||
echo "Using clang-tidy version: $(clang-tidy --version)"
|
||||
echo "clang-tidy installed at: $(which clang-tidy)"
|
||||
|
||||
- name: Prepare CMake
|
||||
env:
|
||||
CC: clang
|
||||
CXX: clang++
|
||||
run: |
|
||||
echo "Running cmake..."
|
||||
cmake -B build-${{ matrix.cmake_options }} \
|
||||
-C ./test_common/cmake/${{ matrix.cmake_options }}.cmake \
|
||||
-DCMAKE_CXX_STANDARD=14 \
|
||||
-DWITH_STL=CXX14 \
|
||||
-DWITH_OPENTRACING=OFF \
|
||||
-DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations" \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||
-DCMAKE_CXX_CLANG_TIDY="clang-tidy;--quiet;-p;build-${{ matrix.cmake_options }}"
|
||||
|
||||
- name: Run clang-tidy
|
||||
run: |
|
||||
cmake --build build-${{ matrix.cmake_options }} -- -j$(nproc) 2>&1 | tee clang-tidy-${{ matrix.cmake_options }}.log
|
||||
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Logs-clang-tidy-${{ matrix.cmake_options }}
|
||||
path: ./clang-tidy-${{ matrix.cmake_options }}.log
|
||||
|
||||
- name: Count warnings
|
||||
run: |
|
||||
COUNT=$(grep -c "warning:" clang-tidy-${{ matrix.cmake_options }}.log)
|
||||
echo "clang-tidy reported ${COUNT} warning(s) with cmake options preset '${{ matrix.cmake_options }}'"
|
||||
|
||||
readonly WARNING_LIMIT=${{ matrix.warning_limit }}
|
||||
|
||||
# FAIL the build if COUNT > WARNING_LIMIT
|
||||
if [ $COUNT -gt $WARNING_LIMIT ] ; then
|
||||
echo "clang-tidy reported ${COUNT} warning(s) exceeding the existing warning limit of ${WARNING_LIMIT} with cmake options preset '${{ matrix.cmake_options }}'"
|
||||
exit 1
|
||||
# WARN in annotations if COUNT > 0
|
||||
elif [ $COUNT -gt 0 ] ; then
|
||||
echo "::warning::clang-tidy reported ${COUNT} warning(s) with cmake options preset '${{ matrix.cmake_options }}'"
|
||||
fi
|
||||
|
|
@ -0,0 +1,318 @@
|
|||
name: CMake Install Tests
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
windows_2022_vcpkg_submodule:
|
||||
name: Windows 2022 vcpkg submodule versions cxx17 (static libs - dll)
|
||||
runs-on: windows-2022
|
||||
env:
|
||||
# cxx17 is the default for windows-2022
|
||||
CXX_STANDARD: '17'
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
- name: Build dependencies with vcpkg submodule
|
||||
run: |
|
||||
./ci/setup_windows_ci_environment.ps1
|
||||
- name: Run Tests
|
||||
run: ./ci/do_ci.ps1 cmake.install.test
|
||||
- name: Run DLL Tests
|
||||
run: ./ci/do_ci.ps1 cmake.dll.install.test
|
||||
|
||||
windows_2025_vcpkg_submodule:
|
||||
name: Windows 2025 vcpkg submodule versions cxx20 (static libs)
|
||||
runs-on: windows-2025
|
||||
env:
|
||||
CXX_STANDARD: '20'
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
- name: Build dependencies with vcpkg submodule
|
||||
run: |
|
||||
./ci/setup_windows_ci_environment.ps1
|
||||
- name: Run Tests
|
||||
run: ./ci/do_ci.ps1 cmake.install.test
|
||||
|
||||
ubuntu_2404_system_packages:
|
||||
name: Ubuntu 24.04 apt packages cxx17 (static libs - shared libs)
|
||||
runs-on: ubuntu-24.04
|
||||
env:
|
||||
INSTALL_TEST_DIR: '/home/runner/install_test'
|
||||
# cxx17 is the default for Ubuntu 24.04
|
||||
CXX_STANDARD: '17'
|
||||
BUILD_TYPE: 'Debug'
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
- name: Setup CI Environment
|
||||
run: |
|
||||
sudo -E ./ci/setup_ci_environment.sh
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
sudo -E apt-get update
|
||||
sudo -E apt-get install -y libabsl-dev libcurl4-openssl-dev zlib1g-dev nlohmann-json3-dev libprotobuf-dev libgrpc++-dev protobuf-compiler protobuf-compiler-grpc
|
||||
sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file third_party_release --packages "googletest;benchmark"
|
||||
- name: Run Tests (static libs)
|
||||
env:
|
||||
BUILD_SHARED_LIBS: 'OFF'
|
||||
run: ./ci/do_ci.sh cmake.install.test
|
||||
- name: Run Tests (shared libs)
|
||||
env:
|
||||
BUILD_SHARED_LIBS: 'ON'
|
||||
run: ./ci/do_ci.sh cmake.install.test
|
||||
|
||||
ubuntu_2404_latest:
|
||||
name: Ubuntu 24.04 latest versions cxx20 (static libs - shared libs)
|
||||
runs-on: ubuntu-24.04
|
||||
env:
|
||||
INSTALL_TEST_DIR: '/home/runner/install_test'
|
||||
CXX_STANDARD: '20'
|
||||
BUILD_TYPE: 'Debug'
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
- name: Setup CI Environment
|
||||
run: |
|
||||
sudo -E ./ci/setup_ci_environment.sh
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file install/cmake/third_party_latest
|
||||
- name: Run Tests (static libs)
|
||||
env:
|
||||
BUILD_SHARED_LIBS: 'OFF'
|
||||
run: ./ci/do_ci.sh cmake.install.test
|
||||
- name: Run Tests (shared libs)
|
||||
env:
|
||||
BUILD_SHARED_LIBS: 'ON'
|
||||
run: ./ci/do_ci.sh cmake.install.test
|
||||
|
||||
ubuntu_2204_stable:
|
||||
name: Ubuntu 22.04 stable versions cxx17 (static libs - shared libs)
|
||||
runs-on: ubuntu-22.04
|
||||
env:
|
||||
INSTALL_TEST_DIR: '/home/runner/install_test'
|
||||
CXX_STANDARD: '17'
|
||||
BUILD_TYPE: 'Debug'
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
- name: Setup CI Environment
|
||||
run: |
|
||||
sudo -E ./ci/setup_ci_environment.sh
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file install/cmake/third_party_stable
|
||||
- name: Run Tests (static libs)
|
||||
env:
|
||||
BUILD_SHARED_LIBS: 'OFF'
|
||||
run: ./ci/do_ci.sh cmake.install.test
|
||||
- name: Run Tests (shared libs)
|
||||
env:
|
||||
BUILD_SHARED_LIBS: 'ON'
|
||||
run: ./ci/do_ci.sh cmake.install.test
|
||||
|
||||
ubuntu_2204_minimum:
|
||||
name: Ubuntu 22.04 minimum versions cxx14 (static libs - shared libs)
|
||||
runs-on: ubuntu-22.04
|
||||
env:
|
||||
INSTALL_TEST_DIR: '/home/runner/install_test'
|
||||
# Set to the current minimum version of cmake
|
||||
CMAKE_VERSION: '3.14.0'
|
||||
# cxx14 is the default for Ubuntu 22.04
|
||||
CXX_STANDARD: '14'
|
||||
BUILD_TYPE: 'Debug'
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
- name: Setup CI Environment
|
||||
run: |
|
||||
sudo -E ./ci/setup_ci_environment.sh
|
||||
sudo -E ./ci/setup_cmake.sh
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file install/cmake/third_party_minimum
|
||||
- name: Run Tests (static libs)
|
||||
env:
|
||||
BUILD_SHARED_LIBS: 'OFF'
|
||||
run: ./ci/do_ci.sh cmake.install.test
|
||||
- name: Run Tests (shared libs)
|
||||
env:
|
||||
BUILD_SHARED_LIBS: 'ON'
|
||||
run: ./ci/do_ci.sh cmake.install.test
|
||||
|
||||
ubuntu_2404_conan_stable:
|
||||
name: Ubuntu 24.04 conan stable versions cxx17 (static libs - opentracing shim)
|
||||
runs-on: ubuntu-24.04
|
||||
env:
|
||||
INSTALL_TEST_DIR: '/home/runner/install_test'
|
||||
CXX_STANDARD: '17'
|
||||
CMAKE_TOOLCHAIN_FILE: /home/runner/conan/build/Debug/generators/conan_toolchain.cmake
|
||||
BUILD_TYPE: 'Debug'
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
- name: Install Conan
|
||||
run: |
|
||||
python3 -m pip install pip==25.0.1
|
||||
pip install "conan==2.15.1"
|
||||
conan profile detect --force
|
||||
- name: Install or build all dependencies with Conan
|
||||
run: |
|
||||
conan install install/conan/conanfile_stable.txt --build=missing -of /home/runner/conan -s build_type=${BUILD_TYPE} -s compiler.cppstd=${CXX_STANDARD}
|
||||
conan cache clean --source --build
|
||||
- name: Run Tests (static libs)
|
||||
env:
|
||||
BUILD_SHARED_LIBS: 'OFF'
|
||||
run: ./ci/do_ci.sh cmake.install.test
|
||||
- name: verify pkgconfig packages
|
||||
run: |
|
||||
export PKG_CONFIG_PATH=$INSTALL_TEST_DIR/lib/pkgconfig:$PKG_CONFIG_PATH
|
||||
./ci/verify_packages.sh
|
||||
- name: Run OpenTracing Shim Test
|
||||
run: ./ci/do_ci.sh cmake.opentracing_shim.install.test
|
||||
|
||||
ubuntu_2404_conan_latest:
|
||||
name: Ubuntu 24.04 conan latest versions cxx17 (static libs - opentracing shim)
|
||||
runs-on: ubuntu-24.04
|
||||
env:
|
||||
INSTALL_TEST_DIR: '/home/runner/install_test'
|
||||
CXX_STANDARD: '17'
|
||||
CMAKE_TOOLCHAIN_FILE: /home/runner/conan/build/Debug/generators/conan_toolchain.cmake
|
||||
BUILD_TYPE: 'Debug'
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
- name: Install Conan
|
||||
run: |
|
||||
python3 -m pip install pip==25.0.1
|
||||
pip install "conan==2.15.1"
|
||||
conan profile detect --force
|
||||
- name: Install or build all dependencies with Conan
|
||||
run: |
|
||||
conan install install/conan/conanfile_latest.txt --build=missing -of /home/runner/conan -s build_type=${BUILD_TYPE} -s compiler.cppstd=${CXX_STANDARD}
|
||||
conan cache clean --source --build
|
||||
- name: Run Tests (static libs)
|
||||
env:
|
||||
BUILD_SHARED_LIBS: 'OFF'
|
||||
run: ./ci/do_ci.sh cmake.install.test
|
||||
- name: verify pkgconfig packages
|
||||
run: |
|
||||
export PKG_CONFIG_PATH=$INSTALL_TEST_DIR/lib/pkgconfig:$PKG_CONFIG_PATH
|
||||
./ci/verify_packages.sh
|
||||
- name: Run OpenTracing Shim Test
|
||||
run: ./ci/do_ci.sh cmake.opentracing_shim.install.test
|
||||
|
||||
macos_14_conan_stable:
|
||||
name: macOS 14 conan stable versions cxx17 (static libs)
|
||||
runs-on: macos-14
|
||||
env:
|
||||
INSTALL_TEST_DIR: '/Users/runner/install_test'
|
||||
CXX_STANDARD: '17'
|
||||
CMAKE_TOOLCHAIN_FILE: '/Users/runner/conan/build/Debug/generators/conan_toolchain.cmake'
|
||||
BUILD_TYPE: 'Debug'
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
- name: Install Conan and tools
|
||||
run: |
|
||||
brew install conan autoconf automake libtool coreutils
|
||||
conan profile detect --force
|
||||
- name: Install or build all dependencies with Conan
|
||||
run: |
|
||||
conan install install/conan/conanfile_stable.txt --build=missing -of /Users/runner/conan -s build_type=${BUILD_TYPE} -s compiler.cppstd=${CXX_STANDARD}
|
||||
conan cache clean --source --build
|
||||
- name: Run Tests (static libs)
|
||||
env:
|
||||
BUILD_SHARED_LIBS: 'OFF'
|
||||
run: ./ci/do_ci.sh cmake.install.test
|
||||
|
||||
macos_14_brew_packages:
|
||||
name: macOS 14 brew latest versions cxx17 (static libs)
|
||||
runs-on: macos-14
|
||||
env:
|
||||
INSTALL_TEST_DIR: '/Users/runner/install_test'
|
||||
CXX_STANDARD: '17'
|
||||
BUILD_TYPE: 'Debug'
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
- name: Install Dependencies with Homebrew
|
||||
run: |
|
||||
brew install coreutils
|
||||
brew install googletest
|
||||
brew install google-benchmark
|
||||
brew install zlib
|
||||
brew install abseil
|
||||
brew install protobuf
|
||||
brew install grpc
|
||||
brew install nlohmann-json
|
||||
brew install prometheus-cpp
|
||||
- name: Run Tests (static libs)
|
||||
env:
|
||||
BUILD_SHARED_LIBS: 'OFF'
|
||||
run: ./ci/do_ci.sh cmake.install.test
|
|
@ -7,26 +7,40 @@ on:
|
|||
# The branches below must be a subset of the branches above
|
||||
branches: [main]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
CodeQL-Build:
|
||||
permissions:
|
||||
actions: read # for github/codeql-action/init to get workflow details
|
||||
contents: read # for actions/checkout to fetch code
|
||||
security-events: write # for github/codeql-action/autobuild to send a status report
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
- name: Remove Third_party Modules from Code Scan
|
||||
run: |
|
||||
rm -rf third_party
|
||||
- name: Setup
|
||||
env:
|
||||
CC: /usr/bin/gcc-12
|
||||
CXX: /usr/bin/g++-12
|
||||
run: |
|
||||
sudo ./ci/setup_cmake.sh
|
||||
sudo ./ci/setup_ci_environment.sh
|
||||
sudo -E ./ci/setup_ci_environment.sh
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
uses: github/codeql-action/init@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # v3.29.8
|
||||
with:
|
||||
languages: cpp
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
uses: github/codeql-action/autobuild@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # v3.29.8
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
uses: github/codeql-action/analyze@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # v3.29.8
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
|
||||
name: cppcheck
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
cppcheck:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
|
||||
- name: Set up dependencies
|
||||
run: |
|
||||
sudo apt update -y
|
||||
sudo apt install -y cppcheck
|
||||
|
||||
- name: Run cppcheck
|
||||
run: |
|
||||
cppcheck --version | tee cppcheck.log
|
||||
cppcheck \
|
||||
--force \
|
||||
--enable=warning,performance,portability \
|
||||
--inline-suppr \
|
||||
--suppress=unknownMacro:exporters/etw/include/opentelemetry/exporters/etw/TraceLoggingDynamic.h \
|
||||
--language=c++ \
|
||||
--std=c++14 \
|
||||
-I api/include \
|
||||
-I exporters/elasticsearch/include \
|
||||
-I exporters/etw/include \
|
||||
-I exporters/memory/include \
|
||||
-I exporters/ostream/include \
|
||||
-I exporters/otlp/include \
|
||||
-I exporters/prometheus/include \
|
||||
-I exporters/zipkin/include \
|
||||
-I ext/include \
|
||||
-I opentracing-shim/include \
|
||||
-I sdk/include \
|
||||
-i build \
|
||||
-i test \
|
||||
-i third_party \
|
||||
-j $(nproc) \
|
||||
. 2>&1 | tee --append cppcheck.log
|
||||
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: success() || failure()
|
||||
with:
|
||||
name: Logs (cppcheck)
|
||||
path: ./cppcheck.log
|
||||
|
||||
- name: Count warnings
|
||||
run: |
|
||||
set +e
|
||||
readonly WARNING_COUNT=`grep -c -E "\[.+\]" cppcheck.log`
|
||||
echo "cppcheck reported ${WARNING_COUNT} warning(s)"
|
||||
# Acceptable limit, to decrease over time down to 0
|
||||
readonly WARNING_LIMIT=10
|
||||
# FAIL the build if WARNING_COUNT > WARNING_LIMIT
|
||||
if [ $WARNING_COUNT -gt $WARNING_LIMIT ] ; then
|
||||
exit 1
|
||||
# WARN in annotations if WARNING_COUNT > 0
|
||||
elif [ $WARNING_COUNT -gt 0 ] ; then
|
||||
echo "::warning::cppcheck reported ${WARNING_COUNT} warning(s)"
|
||||
fi
|
|
@ -3,25 +3,33 @@ on:
|
|||
schedule:
|
||||
- cron: "0 3 * * 6"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
docker_image:
|
||||
name: Docker Image
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 300
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
-
|
||||
name: checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
|
||||
-
|
||||
name: Build Image
|
||||
uses: docker/build-push-action@v3
|
||||
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
context: ci/
|
||||
|
@ -39,7 +47,7 @@ jobs:
|
|||
docker save -o /opt/otel-cpp-deps-debian.tar otel-cpp-deps
|
||||
-
|
||||
name: Upload Image
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: otel-cpp-deps
|
||||
path: /opt/otel-cpp-deps-debian.tar
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
name: FOSSA scanning
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
fossa:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
|
||||
- uses: fossas/fossa-action@3ebcea1862c6ffbd5cf1b4d0bd6b3fe7bd6f2cac # v1.7.0
|
||||
with:
|
||||
api-key: ${{secrets.FOSSA_API_KEY}}
|
||||
team: OpenTelemetry
|
|
@ -0,0 +1,98 @@
|
|||
|
||||
name: include-what-you-use
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
iwyu:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- cmake_options: all-options-abiv1
|
||||
warning_limit: 0
|
||||
- cmake_options: all-options-abiv1-preview
|
||||
warning_limit: 0
|
||||
- cmake_options: all-options-abiv2-preview
|
||||
warning_limit: 0
|
||||
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
|
||||
- name: setup dependencies
|
||||
run: |
|
||||
sudo apt update -y
|
||||
sudo apt install -y --no-install-recommends --no-install-suggests \
|
||||
build-essential \
|
||||
ninja-build \
|
||||
libssl-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libabsl-dev \
|
||||
libprotobuf-dev \
|
||||
libgrpc++-dev \
|
||||
protobuf-compiler \
|
||||
protobuf-compiler-grpc \
|
||||
libgmock-dev \
|
||||
libgtest-dev \
|
||||
libbenchmark-dev \
|
||||
llvm-dev \
|
||||
libclang-dev \
|
||||
cmake
|
||||
- name: Install include-what-you-use
|
||||
run: |
|
||||
sudo ./ci/install_iwyu.sh
|
||||
- name: Prepare CMake
|
||||
env:
|
||||
CC: clang
|
||||
CXX: clang++
|
||||
run: |
|
||||
TOPDIR=`pwd`
|
||||
cmake -B build-${{ matrix.cmake_options }} \
|
||||
-C ./test_common/cmake/${{ matrix.cmake_options }}.cmake \
|
||||
-DCMAKE_CXX_STANDARD=14 \
|
||||
-DWITH_STL=CXX14 \
|
||||
-DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations" \
|
||||
-DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--mapping_file=${TOPDIR}/.iwyu.imp;"
|
||||
|
||||
- name: iwyu_tool
|
||||
run: |
|
||||
cmake --build build-${{ matrix.cmake_options }} -- -j$(nproc) -k 2>&1 | tee -a iwyu-${{ matrix.cmake_options }}.log
|
||||
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: success() || failure()
|
||||
with:
|
||||
name: Logs-iwyu-${{ matrix.cmake_options }}
|
||||
path: ./iwyu-${{ matrix.cmake_options }}.log
|
||||
|
||||
- name: count warnings
|
||||
run: |
|
||||
set +e
|
||||
echo "include-what-you-use version:"
|
||||
include-what-you-use --version
|
||||
readonly WARNING_COUNT=`grep -c "include-what-you-use reported diagnostics:" iwyu-${{ matrix.cmake_options }}.log`
|
||||
echo "include-what-you-use reported ${WARNING_COUNT} warning(s) with cmake options preset '${{ matrix.cmake_options }}'"
|
||||
# Acceptable limit, to decrease over time down to 0
|
||||
readonly WARNING_LIMIT=${{ matrix.warning_limit }}
|
||||
# FAIL the build if WARNING_COUNT > WARNING_LIMIT
|
||||
if [ $WARNING_COUNT -gt $WARNING_LIMIT ] ; then
|
||||
echo "include-what-you-use reported ${WARNING_COUNT} warning(s) exceeding the existing warning limit of ${WARNING_LIMIT} with cmake options preset '${{ matrix.cmake_options }}'"
|
||||
exit 1
|
||||
# WARN in annotations if WARNING_COUNT > 0
|
||||
elif [ $WARNING_COUNT -gt 0 ] ; then
|
||||
echo "::warning::include-what-you-use reported ${WARNING_COUNT} warning(s) with cmake options preset '${{ matrix.cmake_options }}'"
|
||||
fi
|
|
@ -0,0 +1,52 @@
|
|||
name: OSSF Scorecard
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
schedule:
|
||||
- cron: "56 23 * * 6" # once a week
|
||||
workflow_dispatch:
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
# Needed for Code scanning upload
|
||||
security-events: write
|
||||
# Needed for GitHub OIDC token if publish_results is true
|
||||
id-token: write
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
publish_results: true
|
||||
|
||||
# Upload the results as artifacts (optional). Commenting out will disable
|
||||
# uploads of run results in SARIF format to the repository Actions tab.
|
||||
# https://docs.github.com/en/actions/advanced-guides/storing-workflow-data-as-artifacts
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
retention-days: 5
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard (optional).
|
||||
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # v3.29.8
|
||||
with:
|
||||
sarif_file: results.sarif
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
name: Add comment
|
||||
on:
|
||||
issues:
|
||||
types:
|
||||
- labeled
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
add-comment:
|
||||
if: github.event.label.name == 'help wanted'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: Add comment
|
||||
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
|
||||
with:
|
||||
issue-number: ${{ github.event.issue.number }}
|
||||
body: |
|
||||
This issue is available for anyone to work on. **Make sure to reference this issue in your pull request.**
|
||||
:sparkles: Thank you for your contribution! :sparkles:
|
|
@ -0,0 +1,29 @@
|
|||
name: OpenTelemetry-cpp project
|
||||
on:
|
||||
issues:
|
||||
types:
|
||||
- reopened
|
||||
- opened
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
label_issues:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||
with:
|
||||
script: |
|
||||
github.rest.issues.addLabels({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
labels: ["needs-triage"]
|
||||
})
|
|
@ -1,14 +1,21 @@
|
|||
name: "Mark and close stale issues"
|
||||
name: "Mark stale issues"
|
||||
on:
|
||||
schedule:
|
||||
- cron: "30 1 * * *"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
permissions:
|
||||
issues: write # for actions/stale to close stale issues
|
||||
pull-requests: write # for actions/stale to close stale PRs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v6
|
||||
- uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
|
||||
with:
|
||||
stale-issue-message: "This issue was marked as stale due to lack of activity."
|
||||
days-before-issue-stale: 60
|
||||
days-before-close: -1
|
||||
exempt-issue-labels: "do-not-stale"
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
# Copyright The OpenTelemetry Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# Ref. https://github.com/github/gitignore/blob/master/C%2B%2B.gitignore
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
@ -16,6 +19,7 @@
|
|||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
*.pdb
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
|
@ -33,6 +37,7 @@
|
|||
*.app
|
||||
|
||||
# Bazel files
|
||||
MODULE.bazel.lock
|
||||
/bazel-*
|
||||
|
||||
# Mac
|
||||
|
@ -51,3 +56,27 @@
|
|||
|
||||
tags
|
||||
.cache/clangd/*
|
||||
|
||||
# Temporary dir used when generating semconv
|
||||
buildscripts/semantic-convention/tmp-semconv/
|
||||
|
||||
# Generated cert keys in functional tests
|
||||
functional/cert/ca.csr
|
||||
functional/cert/ca.pem
|
||||
functional/cert/ca-key.pem
|
||||
functional/cert/client_cert.csr
|
||||
functional/cert/client_cert.pem
|
||||
functional/cert/client_cert-key.pem
|
||||
functional/cert/server_cert.csr
|
||||
functional/cert/server_cert.pem
|
||||
functional/cert/server_cert-key.pem
|
||||
functional/cert/ca_b.csr
|
||||
functional/cert/ca_b.pem
|
||||
functional/cert/ca_b-key.pem
|
||||
functional/cert/client_cert_b.csr
|
||||
functional/cert/client_cert_b.pem
|
||||
functional/cert/client_cert_b-key.pem
|
||||
functional/cert/server_cert_b.csr
|
||||
functional/cert/server_cert_b.pem
|
||||
functional/cert/server_cert_b-key.pem
|
||||
functional/cert/unreadable.pem
|
||||
|
|
|
@ -32,3 +32,8 @@ branch = main
|
|||
path = third_party/nlohmann-json
|
||||
url = https://github.com/nlohmann/json
|
||||
branch = master
|
||||
|
||||
[submodule "third_party/opentracing-cpp"]
|
||||
path = third_party/opentracing-cpp
|
||||
url = https://github.com/opentracing/opentracing-cpp.git
|
||||
branch = master
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
# Copyright The OpenTelemetry Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# include-what-you-use mapping file
|
||||
|
||||
[
|
||||
# Work around for C++ STL
|
||||
{ "include": ["<bits/chrono.h>", "private", "<chrono>", "public"] },
|
||||
{ "include": ["<bits/std_abs.h>", "private", "<cstdlib>", "public"] },
|
||||
{ "include": ["<ext/alloc_traits.h>", "private", "<memory>", "public"] },
|
||||
{ "include": ["<bits/types/struct_tm.h>", "private", "<time.h>", "public"] },
|
||||
{ "include": ["<bits/types/struct_FILE.h>", "private", "<stdio.h>", "public"] },
|
||||
|
||||
# Local opentelemetry-cpp style
|
||||
|
||||
# We prefer to include <gtest/gtest.h> for simplicity
|
||||
{ "include": ["<gtest/gtest-message.h>", "private", "<gtest/gtest.h>", "public"] },
|
||||
{ "include": ["<gtest/gtest-test-part.h>", "private", "<gtest/gtest.h>", "public"] },
|
||||
{ "include": ["<gtest/gtest-param-test.h>", "private", "<gtest/gtest.h>", "public"] },
|
||||
{ "include": ["<gtest/gtest_pred_impl.h>", "private", "<gtest/gtest.h>", "public"] },
|
||||
{ "include": ["<gtest/gtest-typed-test.h>", "private", "<gtest/gtest.h>", "public"] },
|
||||
{ "include": ["<gtest/gtest-assertion-result.h>", "private", "<gtest/gtest.h>", "public"] },
|
||||
|
||||
# We prefer to include <gmock/gmock.h> for simplicity
|
||||
{ "include": ["<gmock/gmock-function-mocker.h>", "private", "<gmock/gmock.h>", "public"] },
|
||||
{ "include": ["<gmock/gmock-spec-builders.h>", "private", "<gmock/gmock.h>", "public"] },
|
||||
|
||||
# We prefer to include <curl/curl.h> for simplicity
|
||||
{ "include": ["<curl/system.h>", "private", "<curl/curl.h>", "public"] },
|
||||
]
|
||||
|
|
@ -1,24 +1,33 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug on Windows",
|
||||
"type": "cppvsdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/build/<path-to-bin-file>",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
"externalConsole": false
|
||||
},
|
||||
{
|
||||
"name": "Debug on Linux",
|
||||
"type": "gdb",
|
||||
"request": "launch",
|
||||
"target": "${workspaceFolder}/bazel-bin/<path to the bin file>",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"valuesFormatting": "parseText"
|
||||
}
|
||||
]
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "(ctest) Launch",
|
||||
"type": "cppdbg",
|
||||
"cwd": "${cmake.testWorkingDirectory}",
|
||||
"request": "launch",
|
||||
"program": "${cmake.testProgram}",
|
||||
"args": [ "${cmake.testArgs}" ],
|
||||
// other options...
|
||||
},
|
||||
{
|
||||
"name": "Debug on Windows",
|
||||
"type": "cppvsdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/build/<path-to-bin-file>",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
"externalConsole": false
|
||||
},
|
||||
{
|
||||
"name": "Debug on Linux",
|
||||
"type": "gdb",
|
||||
"request": "launch",
|
||||
"target": "${workspaceFolder}/bazel-bin/<path to the bin file>",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"valuesFormatting": "parseText"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
2334
CHANGELOG.md
2334
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
739
CMakeLists.txt
739
CMakeLists.txt
|
@ -1,15 +1,36 @@
|
|||
cmake_minimum_required(VERSION 3.1)
|
||||
# Copyright The OpenTelemetry Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# See https://cmake.org/cmake/help/v3.3/policy/CMP0057.html required by certain
|
||||
# versions of gtest
|
||||
cmake_policy(SET CMP0057 NEW)
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
# See https://cmake.org/cmake/help/v3.12/policy/CMP0074.html required by certain
|
||||
# version of zlib which is dependeded by cURL.
|
||||
# See https://cmake.org/cmake/help/latest/policy/CMP0074.html required by
|
||||
# certain version of zlib which CURL depends on.
|
||||
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12")
|
||||
cmake_policy(SET CMP0074 NEW)
|
||||
endif()
|
||||
|
||||
# Allow to use normal variable for option()
|
||||
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13")
|
||||
cmake_policy(SET CMP0077 NEW)
|
||||
endif()
|
||||
|
||||
# Prefer CMAKE_MSVC_RUNTIME_LIBRARY if possible
|
||||
if(POLICY CMP0091)
|
||||
cmake_policy(SET CMP0091 NEW)
|
||||
endif()
|
||||
|
||||
if(POLICY CMP0092)
|
||||
# https://cmake.org/cmake/help/latest/policy/CMP0092.html#policy:CMP0092 Make
|
||||
# sure the /W3 is not removed from CMAKE_CXX_FLAGS since CMake 3.15
|
||||
cmake_policy(SET CMP0092 OLD)
|
||||
endif()
|
||||
|
||||
# MSVC RTTI flag /GR should not be not added to CMAKE_CXX_FLAGS by default. @see
|
||||
# https://cmake.org/cmake/help/latest/policy/CMP0117.html
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20.0")
|
||||
cmake_policy(SET CMP0117 NEW)
|
||||
endif()
|
||||
|
||||
project(opentelemetry-cpp)
|
||||
|
||||
# Mark variables as used so cmake doesn't complain about them
|
||||
|
@ -20,61 +41,32 @@ if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
|||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
|
||||
endif()
|
||||
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/third_party_release")
|
||||
file(STRINGS "${CMAKE_SOURCE_DIR}/third_party_release" third_party_tags)
|
||||
foreach(third_party ${third_party_tags})
|
||||
string(REGEX REPLACE "^[ ]+" "" third_party ${third_party})
|
||||
string(REGEX MATCH "^[^=]+" third_party_name ${third_party})
|
||||
string(REPLACE "${third_party_name}=" "" third_party_tag ${third_party})
|
||||
set(${third_party_name} "${third_party_tag}")
|
||||
# Set the third-party release git tags.
|
||||
if(EXISTS "${opentelemetry-cpp_SOURCE_DIR}/third_party_release")
|
||||
file(STRINGS "${opentelemetry-cpp_SOURCE_DIR}/third_party_release"
|
||||
third_party_tags)
|
||||
foreach(_raw_line IN LISTS third_party_tags)
|
||||
# Strip leading/trailing whitespace
|
||||
string(STRIP "${_raw_line}" _line)
|
||||
# Skip empty lines and comments
|
||||
if(_line STREQUAL "" OR _line MATCHES "^#")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
# Match "package_name=git_tag"
|
||||
if(_line MATCHES "^([^=]+)=(.+)$")
|
||||
set(_third_party_name "${CMAKE_MATCH_1}")
|
||||
set(_git_tag "${CMAKE_MATCH_2}")
|
||||
set("${_third_party_name}_GIT_TAG" "${_git_tag}")
|
||||
else()
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Could not parse third-party tag. Invalid line in ${opentelemetry-cpp_SOURCE_DIR}/third_party_release. Line:\n ${_raw_line}"
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(DEFINED ENV{ARCH})
|
||||
# Architecture may be specified via ARCH environment variable
|
||||
set(ARCH $ENV{ARCH})
|
||||
else()
|
||||
# Autodetection logic that populates ARCH variable
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
|
||||
# Windows may report AMD64 even if target is 32-bit
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(ARCH x64)
|
||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(ARCH x86)
|
||||
endif()
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*")
|
||||
# Windows may report x86 even if target is 64-bit
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(ARCH x64)
|
||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(ARCH x86)
|
||||
endif()
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES
|
||||
"^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)")
|
||||
set(ARCH arm64)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)")
|
||||
set(ARCH arm)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64le")
|
||||
set(ARCH ppc64le)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
|
||||
set(ARCH ppc64)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(mips.*|MIPS.*)")
|
||||
set(ARCH mips)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(riscv.*|RISCV.*)")
|
||||
set(ARCH riscv)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(s390x.*|S390X.*)")
|
||||
set(ARCH s390x)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(sparc.*|SPARC.*)")
|
||||
set(ARCH sparc)
|
||||
else()
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"opentelemetry-cpp: unrecognized target processor ${CMAKE_SYSTEM_PROCESSOR} configuration!"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "Building for architecture ARCH=${ARCH}")
|
||||
|
||||
# Autodetect vcpkg toolchain
|
||||
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||
set(CMAKE_TOOLCHAIN_FILE
|
||||
|
@ -82,21 +74,54 @@ if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
|||
CACHE STRING "")
|
||||
endif()
|
||||
|
||||
if(VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
|
||||
include("${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}")
|
||||
endif()
|
||||
option(WITH_ABI_VERSION_1 "ABI version 1" ON)
|
||||
option(WITH_ABI_VERSION_2 "EXPERIMENTAL: ABI version 2 preview" OFF)
|
||||
|
||||
file(READ "${CMAKE_CURRENT_LIST_DIR}/api/include/opentelemetry/version.h"
|
||||
OPENTELEMETRY_CPP_HEADER_VERSION_H)
|
||||
if(OPENTELEMETRY_CPP_HEADER_VERSION_H MATCHES
|
||||
"OPENTELEMETRY_ABI_VERSION_NO[ \t\r\n]+\"?([0-9]+)\"?")
|
||||
math(EXPR OPENTELEMETRY_ABI_VERSION_NO ${CMAKE_MATCH_1})
|
||||
else()
|
||||
|
||||
#
|
||||
# We do not want to have WITH_ABI_VERSION = "1" or "2", and instead prefer two
|
||||
# distinct flags, WITH_ABI_VERSION_1 and WITH_ABI_VERSION_2.
|
||||
#
|
||||
# This allows:
|
||||
#
|
||||
# * to have a specific option description for each ABI
|
||||
# * to mark experimental/stable/deprecated on flags, for clarity
|
||||
# * to search for exact abi usage move easily, discouraging:
|
||||
#
|
||||
# * cmake -DWITH_ABI_VERSION=${ARG}
|
||||
#
|
||||
# While not supported, having distinct WITH_ABI_VERSION_1 and WITH_ABI_VERSION_2
|
||||
# flags also opens the possibility to support multiple ABI concurrently, should
|
||||
# that become necessary.
|
||||
#
|
||||
if(WITH_ABI_VERSION_1 AND WITH_ABI_VERSION_2)
|
||||
#
|
||||
# Only one ABI is supported in a build.
|
||||
#
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"OPENTELEMETRY_ABI_VERSION_NO not found on ${CMAKE_CURRENT_LIST_DIR}/api/include/opentelemetry/version.h"
|
||||
)
|
||||
FATAL_ERROR "Set either WITH_ABI_VERSION_1 or WITH_ABI_VERSION_2, not both")
|
||||
endif()
|
||||
|
||||
if(WITH_ABI_VERSION_2)
|
||||
set(OPENTELEMETRY_ABI_VERSION_NO "2")
|
||||
elseif(WITH_ABI_VERSION_1)
|
||||
set(OPENTELEMETRY_ABI_VERSION_NO "1")
|
||||
else()
|
||||
if(OPENTELEMETRY_CPP_HEADER_VERSION_H MATCHES
|
||||
"OPENTELEMETRY_ABI_VERSION_NO[ \t\r\n]+\"?([0-9]+)\"?")
|
||||
math(EXPR OPENTELEMETRY_ABI_VERSION_NO ${CMAKE_MATCH_1})
|
||||
else()
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"OPENTELEMETRY_ABI_VERSION_NO not found on ${CMAKE_CURRENT_LIST_DIR}/api/include/opentelemetry/version.h"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(STATUS "OPENTELEMETRY_ABI_VERSION_NO=${OPENTELEMETRY_ABI_VERSION_NO}")
|
||||
|
||||
if(OPENTELEMETRY_CPP_HEADER_VERSION_H MATCHES
|
||||
"OPENTELEMETRY_VERSION[ \t\r\n]+\"?([^\"]+)\"?")
|
||||
set(OPENTELEMETRY_VERSION ${CMAKE_MATCH_1})
|
||||
|
@ -107,28 +132,27 @@ else()
|
|||
)
|
||||
endif()
|
||||
|
||||
option(WITH_STL "Whether to use Standard Library for C++ latest features" OFF)
|
||||
message(STATUS "OPENTELEMETRY_VERSION=${OPENTELEMETRY_VERSION}")
|
||||
|
||||
option(WITH_NO_DEPRECATED_CODE "Do not include deprecated code" OFF)
|
||||
|
||||
set(WITH_STL
|
||||
"OFF"
|
||||
CACHE STRING "Which version of the Standard Library for C++ to use")
|
||||
|
||||
option(WITH_GSL
|
||||
"Whether to use Guidelines Support Library for C++ latest features" OFF)
|
||||
|
||||
option(WITH_ABSEIL "Whether to use Abseil for C++latest features" OFF)
|
||||
|
||||
if(NOT DEFINED CMAKE_CXX_STANDARD)
|
||||
if(WITH_STL)
|
||||
# Require at least C++17. C++20 is needed to avoid gsl::span
|
||||
if(CMAKE_VERSION VERSION_GREATER 3.11.999)
|
||||
# Ask for 20, may get anything below
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
else()
|
||||
# Ask for 17, may get anything below
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
endif()
|
||||
else()
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
endif()
|
||||
set(OPENTELEMETRY_INSTALL_default ON)
|
||||
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
set(OPENTELEMETRY_INSTALL_default OFF)
|
||||
endif()
|
||||
option(OPENTELEMETRY_INSTALL "Whether to install opentelemetry targets"
|
||||
${OPENTELEMETRY_INSTALL_default})
|
||||
|
||||
if(WITH_STL)
|
||||
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/tools.cmake")
|
||||
|
||||
if(NOT WITH_STL STREQUAL "OFF")
|
||||
# These definitions are needed for test projects that do not link against
|
||||
# opentelemetry-api library directly. We ensure that variant implementation
|
||||
# (absl::variant or std::variant) in variant unit test code is consistent with
|
||||
|
@ -147,7 +171,32 @@ if(WITH_STL)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
option(WITH_OTLP "Whether to include the OpenTelemetry Protocol in the SDK" OFF)
|
||||
option(WITH_OTLP_RETRY_PREVIEW
|
||||
"Whether to enable experimental retry functionality" OFF)
|
||||
|
||||
option(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW
|
||||
"Whether to enable mTLS support for gRPC" OFF)
|
||||
|
||||
option(WITH_OTLP_GRPC_CREDENTIAL_PREVIEW
|
||||
"Whether to enable gRPC credentials option in OTLP gRPC Exporter" OFF)
|
||||
|
||||
option(WITH_OTLP_GRPC "Whether to include the OTLP gRPC exporter in the SDK"
|
||||
OFF)
|
||||
|
||||
option(WITH_OTLP_HTTP "Whether to include the OTLP http exporter in the SDK"
|
||||
OFF)
|
||||
|
||||
option(WITH_OTLP_FILE "Whether to include the OTLP file exporter in the SDK"
|
||||
OFF)
|
||||
|
||||
option(
|
||||
WITH_OTLP_HTTP_COMPRESSION
|
||||
"Whether to include gzip compression for the OTLP http exporter in the SDK"
|
||||
OFF)
|
||||
|
||||
option(WITH_CURL_LOGGING "Whether to enable select CURL verbosity in OTel logs"
|
||||
OFF)
|
||||
|
||||
option(WITH_ZIPKIN "Whether to include the Zipkin exporter in the SDK" OFF)
|
||||
|
||||
option(WITH_PROMETHEUS "Whether to include the Prometheus Client in the SDK"
|
||||
|
@ -156,26 +205,31 @@ option(WITH_PROMETHEUS "Whether to include the Prometheus Client in the SDK"
|
|||
option(WITH_ELASTICSEARCH
|
||||
"Whether to include the Elasticsearch Client in the SDK" OFF)
|
||||
|
||||
option(WITH_ZPAGES "Whether to include the Zpages Server in the SDK" OFF)
|
||||
|
||||
option(WITH_JAEGER "Whether to include the Jaeger exporter" OFF)
|
||||
|
||||
option(WITH_NO_GETENV "Whether the platform supports environment variables" OFF)
|
||||
|
||||
option(BUILD_TESTING "Whether to enable tests" ON)
|
||||
|
||||
option(WITH_BENCHMARK "Whether to build benchmark program" ON)
|
||||
|
||||
option(BUILD_W3CTRACECONTEXT_TEST "Whether to build w3c trace context" OFF)
|
||||
|
||||
option(OTELCPP_MAINTAINER_MODE "Build in maintainer mode (-Wall -Werror)" OFF)
|
||||
|
||||
option(WITH_OPENTRACING "Whether to include the Opentracing shim" OFF)
|
||||
|
||||
option(OTELCPP_VERSIONED_LIBS "Whether to generate the versioned shared libs"
|
||||
OFF)
|
||||
|
||||
if(OTELCPP_VERSIONED_LIBS AND NOT BUILD_SHARED_LIBS)
|
||||
message(FATAL_ERROR "OTELCPP_VERSIONED_LIBS=ON requires BUILD_SHARED_LIBS=ON")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
if(BUILD_TESTING)
|
||||
if(MSVC)
|
||||
# GTest bug: https://github.com/google/googletest/issues/860
|
||||
add_compile_options(/wd4275)
|
||||
endif()
|
||||
endif()
|
||||
option(WITH_ETW "Whether to include the ETW Exporter in the SDK" ON)
|
||||
else()
|
||||
if(DEFINED (WITH_ETW))
|
||||
message(FATAL_ERROR "WITH_ETW is only supported on Windows")
|
||||
endif()
|
||||
endif(WIN32)
|
||||
|
||||
# Do not convert deprecated message to error
|
||||
|
@ -189,42 +243,54 @@ option(
|
|||
OFF)
|
||||
option(WITH_EXAMPLES "Whether to build examples" ON)
|
||||
|
||||
option(WITH_METRICS_PREVIEW "Whether to build metrics preview" OFF)
|
||||
option(WITH_LOGS_PREVIEW "Whether to build logs preview" OFF)
|
||||
option(WITH_ASYNC_EXPORT_PREVIEW "Whether enable async export" OFF)
|
||||
# This requires CURL, OFF by default.
|
||||
option(
|
||||
WITH_EXAMPLES_HTTP
|
||||
"Whether to build http client/server examples. Requires WITH_EXAMPLES and CURL"
|
||||
OFF)
|
||||
|
||||
option(WITH_FUNC_TESTS "Whether to build functional tests" ON)
|
||||
|
||||
option(WITH_ASYNC_EXPORT_PREVIEW "Whether to enable async export" OFF)
|
||||
|
||||
# Exemplar specs status is experimental, so behind feature flag by default
|
||||
option(WITH_METRICS_EXEMPLAR_PREVIEW
|
||||
"Whethere to enable exemplar within metrics" OFF)
|
||||
"Whether to enable exemplar within metrics" OFF)
|
||||
|
||||
# Experimental, so behind feature flag by default
|
||||
option(WITH_THREAD_INSTRUMENTATION_PREVIEW
|
||||
"Whether to enable thread instrumentation" OFF)
|
||||
|
||||
option(WITH_RESOURCE_DETECTORS_PREVIEW
|
||||
"Whether to enable inbuilt resource detectors" OFF)
|
||||
|
||||
option(OPENTELEMETRY_SKIP_DYNAMIC_LOADING_TESTS
|
||||
"Whether to build test libraries that are always linked as shared libs"
|
||||
OFF)
|
||||
|
||||
#
|
||||
# Verify options dependencies
|
||||
#
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
if(WITH_EXAMPLES_HTTP AND NOT WITH_EXAMPLES)
|
||||
message(FATAL_ERROR "WITH_EXAMPLES_HTTP=ON requires WITH_EXAMPLES=ON")
|
||||
endif()
|
||||
|
||||
if(WITH_GSL)
|
||||
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/ms-gsl.cmake")
|
||||
endif()
|
||||
|
||||
find_package(Threads)
|
||||
|
||||
function(install_windows_deps)
|
||||
# Bootstrap vcpkg from CMake and auto-install deps in case if we are missing
|
||||
# deps on Windows. Respect the target architecture variable.
|
||||
set(VCPKG_TARGET_ARCHITECTURE
|
||||
${ARCH}
|
||||
PARENT_SCOPE)
|
||||
message("Installing build tools and dependencies...")
|
||||
set(ENV{ARCH} ${ARCH})
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/setup-buildtools.cmd)
|
||||
set(CMAKE_TOOLCHAIN_FILE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tools/vcpkg/scripts/buildsystems/vcpkg.cmake
|
||||
PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
if(WITH_JAEGER)
|
||||
find_package(Thrift QUIET)
|
||||
if(Thrift_FOUND)
|
||||
find_package(Boost REQUIRED)
|
||||
include_directories(${Boost_INCLUDE_DIR})
|
||||
else()
|
||||
# Install Thrift and propagate via vcpkg toolchain file
|
||||
if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE))
|
||||
install_windows_deps()
|
||||
endif()
|
||||
function(set_target_version target_name)
|
||||
if(OTELCPP_VERSIONED_LIBS)
|
||||
set_target_properties(
|
||||
${target_name} PROPERTIES VERSION ${OPENTELEMETRY_VERSION}
|
||||
SOVERSION ${OPENTELEMETRY_ABI_VERSION_NO})
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(MSVC)
|
||||
# Options for Visual C++ compiler: /Zc:__cplusplus - report an updated value
|
||||
|
@ -234,12 +300,6 @@ if(MSVC)
|
|||
# __cplusplus flag is not supported by Visual Studio 2015
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
|
||||
endif()
|
||||
# When using vcpkg, all targets build with the same runtime
|
||||
if(VCPKG_TOOLCHAIN)
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY
|
||||
"MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<STREQUAL:${VCPKG_CRT_LINKAGE},dynamic>:DLL>"
|
||||
CACHE STRING "")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# include GNUInstallDirs before include cmake/opentelemetry-proto.cmake because
|
||||
|
@ -247,125 +307,95 @@ endif()
|
|||
# GNUInstallDirs.
|
||||
include(GNUInstallDirs)
|
||||
|
||||
#
|
||||
# Do we need HTTP CLIENT CURL ?
|
||||
#
|
||||
|
||||
if(WITH_OTLP_HTTP
|
||||
OR WITH_ELASTICSEARCH
|
||||
OR WITH_ZIPKIN
|
||||
OR BUILD_W3CTRACECONTEXT_TEST
|
||||
OR WITH_EXAMPLES_HTTP)
|
||||
set(WITH_HTTP_CLIENT_CURL ON)
|
||||
else()
|
||||
set(WITH_HTTP_CLIENT_CURL OFF)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Do we need ZLIB ?
|
||||
#
|
||||
|
||||
if((NOT WITH_API_ONLY)
|
||||
AND WITH_HTTP_CLIENT_CURL
|
||||
AND WITH_OTLP_HTTP_COMPRESSION)
|
||||
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/zlib.cmake")
|
||||
endif()
|
||||
|
||||
#
|
||||
# Do we need CURL ?
|
||||
#
|
||||
|
||||
if((NOT WITH_API_ONLY) AND WITH_HTTP_CLIENT_CURL)
|
||||
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/curl.cmake")
|
||||
endif()
|
||||
|
||||
#
|
||||
# Do we need prometheus-cpp ?
|
||||
#
|
||||
|
||||
if(WITH_PROMETHEUS)
|
||||
find_package(prometheus-cpp CONFIG QUIET)
|
||||
if(NOT prometheus-cpp_FOUND)
|
||||
message("Trying to use local prometheus-cpp from submodule")
|
||||
if(EXISTS ${PROJECT_SOURCE_DIR}/third_party/prometheus-cpp/.git)
|
||||
set(SAVED_ENABLE_TESTING ${ENABLE_TESTING})
|
||||
set(ENABLE_TESTING OFF)
|
||||
add_subdirectory(third_party/prometheus-cpp)
|
||||
set(ENABLE_TESTING ${SAVED_ENABLE_TESTING})
|
||||
else()
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"\nprometheus-cpp package was not found. Please either provide it manually or clone with submodules. "
|
||||
"To initialize, fetch and checkout any nested submodules, you can use the following command:\n"
|
||||
"git submodule update --init --recursive")
|
||||
endif()
|
||||
else()
|
||||
message("Using external prometheus-cpp")
|
||||
endif()
|
||||
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/prometheus-cpp.cmake")
|
||||
endif()
|
||||
|
||||
if(WITH_OTLP)
|
||||
set(protobuf_MODULE_COMPATIBLE ON)
|
||||
find_package(Protobuf)
|
||||
if(WITH_OTLP_GRPC OR (NOT DEFINED WITH_OTLP_GRPC AND NOT DEFINED
|
||||
CACHE{WITH_OTLP_GRPC}))
|
||||
find_package(gRPC)
|
||||
endif()
|
||||
if((NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND) OR (NOT gRPC_FOUND))
|
||||
if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE))
|
||||
install_windows_deps()
|
||||
endif()
|
||||
#
|
||||
# Do we need protobuf and/or gRPC ?
|
||||
#
|
||||
|
||||
if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE))
|
||||
message(STATUS_FATAL "Windows dependency installation failed!")
|
||||
endif()
|
||||
if(WIN32)
|
||||
include(${CMAKE_TOOLCHAIN_FILE})
|
||||
endif()
|
||||
if(WITH_OTLP_GRPC
|
||||
OR WITH_OTLP_HTTP
|
||||
OR WITH_OTLP_FILE)
|
||||
|
||||
if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND)
|
||||
find_package(Protobuf REQUIRED)
|
||||
endif()
|
||||
if(NOT gRPC_FOUND
|
||||
AND (WITH_OTLP_GRPC OR (NOT DEFINED WITH_OTLP_GRPC
|
||||
AND NOT DEFINED CACHE{WITH_OTLP_GRPC})))
|
||||
find_package(gRPC)
|
||||
endif()
|
||||
if(WIN32)
|
||||
# Always use x64 protoc.exe
|
||||
if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
|
||||
set(Protobuf_PROTOC_EXECUTABLE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tools/vcpkg/packages/protobuf_x64-windows/tools/protobuf/protoc.exe
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
# Latest Protobuf uses mixed case instead of uppercase
|
||||
if(Protobuf_PROTOC_EXECUTABLE)
|
||||
set(PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE})
|
||||
endif()
|
||||
endif()
|
||||
include(CMakeDependentOption)
|
||||
if(WITH_OTLP_HTTP OR (NOT DEFINED WITH_OTLP_HTTP AND NOT DEFINED
|
||||
CACHE{WITH_OTLP_HTTP}))
|
||||
find_package(CURL)
|
||||
# find or fetch grpc before protobuf to allow protobuf to be built in-tree as
|
||||
# a grpc submodule.
|
||||
if(WITH_OTLP_GRPC)
|
||||
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/grpc.cmake")
|
||||
endif()
|
||||
|
||||
cmake_dependent_option(
|
||||
WITH_OTLP_GRPC "Whether to include the OTLP gRPC exporter in the SDK" ON
|
||||
"gRPC_FOUND" OFF)
|
||||
cmake_dependent_option(
|
||||
WITH_OTLP_HTTP "Whether to include the OTLP http exporter in the SDK" ON
|
||||
"CURL_FOUND" OFF)
|
||||
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/protobuf.cmake")
|
||||
|
||||
message(STATUS "PROTOBUF_PROTOC_EXECUTABLE=${PROTOBUF_PROTOC_EXECUTABLE}")
|
||||
include(cmake/opentelemetry-proto.cmake)
|
||||
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/opentelemetry-proto.cmake")
|
||||
endif()
|
||||
|
||||
#
|
||||
# Do we need NLOHMANN_JSON ?
|
||||
#
|
||||
|
||||
if(WITH_ELASTICSEARCH
|
||||
OR WITH_ZIPKIN
|
||||
OR WITH_OTLP_HTTP
|
||||
OR WITH_ZPAGES
|
||||
OR WITH_OTLP_FILE
|
||||
OR BUILD_W3CTRACECONTEXT_TEST
|
||||
OR WITH_ETW)
|
||||
set(USE_NLOHMANN_JSON ON)
|
||||
else()
|
||||
set(USE_NLOHMANN_JSON OFF)
|
||||
endif()
|
||||
|
||||
if((NOT WITH_API_ONLY) AND USE_NLOHMANN_JSON)
|
||||
# nlohmann_json package is required for most SDK build configurations
|
||||
find_package(nlohmann_json QUIET)
|
||||
set(nlohmann_json_clone FALSE)
|
||||
if(nlohmann_json_FOUND)
|
||||
message("Using external nlohmann::json")
|
||||
elseif(EXISTS ${PROJECT_SOURCE_DIR}/.git
|
||||
AND EXISTS
|
||||
${PROJECT_SOURCE_DIR}/third_party/nlohmann-json/CMakeLists.txt)
|
||||
message("Trying to use local nlohmann::json from submodule")
|
||||
set(JSON_BuildTests
|
||||
OFF
|
||||
CACHE INTERNAL "")
|
||||
set(JSON_Install
|
||||
ON
|
||||
CACHE INTERNAL "")
|
||||
# This option allows to link nlohmann_json::nlohmann_json target
|
||||
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/nlohmann-json)
|
||||
# This option allows to add header to include directories
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/third_party/nlohmann-json/single_include)
|
||||
else()
|
||||
set(nlohmann_json_clone TRUE)
|
||||
include(cmake/nlohmann-json.cmake)
|
||||
message("\nnlohmann_json package was not found. Cloning from github")
|
||||
endif()
|
||||
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/nlohmann-json.cmake")
|
||||
endif()
|
||||
|
||||
#
|
||||
# Do we need OpenTracing ?
|
||||
#
|
||||
|
||||
if(WITH_OPENTRACING)
|
||||
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/opentracing-cpp.cmake")
|
||||
endif()
|
||||
|
||||
if(OTELCPP_MAINTAINER_MODE)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
message("Building with gcc in maintainer mode.")
|
||||
message(STATUS "Building with gcc in maintainer mode.")
|
||||
|
||||
add_compile_options(-Wall)
|
||||
add_compile_options(-Werror)
|
||||
|
@ -373,7 +403,7 @@ if(OTELCPP_MAINTAINER_MODE)
|
|||
|
||||
# Tested with GCC 9.4 on github.
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.4)
|
||||
message("Building with additional warnings for gcc.")
|
||||
message(STATUS "Building with additional warnings for gcc.")
|
||||
|
||||
# Relaxed warnings
|
||||
|
||||
|
@ -385,6 +415,8 @@ if(OTELCPP_MAINTAINER_MODE)
|
|||
$<$<STREQUAL:$<COMPILE_LANGUAGE>,CXX>:-Woverloaded-virtual>)
|
||||
add_compile_options(
|
||||
$<$<STREQUAL:$<COMPILE_LANGUAGE>,CXX>:-Wsuggest-override>)
|
||||
add_compile_options(
|
||||
$<$<STREQUAL:$<COMPILE_LANGUAGE>,CXX>:-Wold-style-cast>)
|
||||
|
||||
# C and C++
|
||||
add_compile_options(-Wcast-qual)
|
||||
|
@ -396,7 +428,7 @@ if(OTELCPP_MAINTAINER_MODE)
|
|||
add_compile_options(-Wvla)
|
||||
endif()
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
message("Building with clang in maintainer mode.")
|
||||
message(STATUS "Building with clang in maintainer mode.")
|
||||
|
||||
add_compile_options(-Wall)
|
||||
add_compile_options(-Werror)
|
||||
|
@ -404,7 +436,7 @@ if(OTELCPP_MAINTAINER_MODE)
|
|||
|
||||
# Tested with Clang 11.0 on github.
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0)
|
||||
message("Building with additional warnings for clang.")
|
||||
message(STATUS "Building with additional warnings for clang.")
|
||||
|
||||
# Relaxed warnings
|
||||
add_compile_options(-Wno-error=unused-private-field)
|
||||
|
@ -424,9 +456,10 @@ if(OTELCPP_MAINTAINER_MODE)
|
|||
add_compile_options(-Wundef)
|
||||
add_compile_options(-Wundefined-reinterpret-cast)
|
||||
add_compile_options(-Wvla)
|
||||
add_compile_options(-Wold-style-cast)
|
||||
endif()
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
message("Building with msvc in maintainer mode.")
|
||||
message(STATUS "Building with msvc in maintainer mode.")
|
||||
|
||||
add_compile_options(/WX)
|
||||
add_compile_options(/W4)
|
||||
|
@ -438,8 +471,14 @@ if(OTELCPP_MAINTAINER_MODE)
|
|||
add_compile_options(/wd4127)
|
||||
add_compile_options(/wd4512)
|
||||
add_compile_options(/wd4267)
|
||||
add_compile_options(/wd4996)
|
||||
|
||||
# Enforced warnings
|
||||
add_compile_options(/we4265) # 'class': class has virtual functions, but
|
||||
# destructor is not virtual
|
||||
add_compile_options(/we5204) # A class with virtual functions has
|
||||
# non-virtual trivial destructor.
|
||||
|
||||
elseif()
|
||||
message(FATAL_ERROR "Building with unknown compiler in maintainer mode.")
|
||||
endif()
|
||||
|
@ -449,86 +488,198 @@ list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}")
|
|||
|
||||
include(CTest)
|
||||
if(BUILD_TESTING)
|
||||
add_definitions(-DENABLE_TEST)
|
||||
if(EXISTS ${CMAKE_BINARY_DIR}/lib/libgtest.a)
|
||||
# Prefer GTest from build tree. GTest is not always working with
|
||||
# CMAKE_PREFIX_PATH
|
||||
set(GTEST_INCLUDE_DIRS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/googletest/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/googlemock/include)
|
||||
set(GTEST_BOTH_LIBRARIES
|
||||
${CMAKE_BINARY_DIR}/lib/libgtest.a
|
||||
${CMAKE_BINARY_DIR}/lib/libgtest_main.a
|
||||
${CMAKE_BINARY_DIR}/lib/libgmock.a)
|
||||
elseif(WIN32)
|
||||
# Make sure we are always bootsrapped with vcpkg on Windows
|
||||
find_package(GTest REQUIRED)
|
||||
if(NOT (GTEST_FOUND OR GTest_FOUND))
|
||||
install_windows_deps()
|
||||
find_package(GTest REQUIRED)
|
||||
endif()
|
||||
else()
|
||||
# Prefer GTest installed by OS distro, brew or vcpkg package manager
|
||||
find_package(GTest REQUIRED)
|
||||
endif()
|
||||
include_directories(SYSTEM ${GTEST_INCLUDE_DIRS})
|
||||
message("GTEST_INCLUDE_DIRS = ${GTEST_INCLUDE_DIRS}")
|
||||
message("GTEST_BOTH_LIBRARIES = ${GTEST_BOTH_LIBRARIES}")
|
||||
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/googletest.cmake")
|
||||
enable_testing()
|
||||
# Benchmark respects the CMAKE_PREFIX_PATH
|
||||
find_package(benchmark CONFIG REQUIRED)
|
||||
if(WITH_BENCHMARK)
|
||||
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/benchmark.cmake")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Record build config and versions
|
||||
message(STATUS "---------------------------------------------")
|
||||
message(STATUS "build settings")
|
||||
message(STATUS "---------------------------------------------")
|
||||
message(STATUS "OpenTelemetry: ${OPENTELEMETRY_VERSION}")
|
||||
message(STATUS "OpenTelemetry ABI: ${OPENTELEMETRY_ABI_VERSION_NO}")
|
||||
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
message(STATUS "CXX: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
|
||||
message(STATUS "CXXFLAGS: ${CMAKE_CXX_FLAGS}")
|
||||
message(STATUS "CMAKE_CXX_STANDARD: ${CMAKE_CXX_STANDARD}")
|
||||
message(STATUS "CMAKE_TOOLCHAIN_FILE: ${CMAKE_TOOLCHAIN_FILE}")
|
||||
message(STATUS "BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
|
||||
|
||||
message(STATUS "---------------------------------------------")
|
||||
message(STATUS "opentelemetry-cpp build options")
|
||||
message(STATUS "---------------------------------------------")
|
||||
message(STATUS "WITH_API_ONLY: ${WITH_API_ONLY}")
|
||||
message(STATUS "WITH_NO_DEPRECATED_CODE: ${WITH_NO_DEPRECATED_CODE}")
|
||||
message(STATUS "WITH_ABI_VERSION_1: ${WITH_ABI_VERSION_1}")
|
||||
message(STATUS "WITH_ABI_VERSION_2: ${WITH_ABI_VERSION_2}")
|
||||
message(STATUS "OTELCPP_VERSIONED_LIBS: ${OTELCPP_VERSIONED_LIBS}")
|
||||
message(STATUS "OTELCPP_MAINTAINER_MODE: ${OTELCPP_MAINTAINER_MODE}")
|
||||
message(STATUS "WITH_STL: ${WITH_STL}")
|
||||
message(STATUS "WITH_GSL: ${WITH_GSL}")
|
||||
message(STATUS "WITH_NO_GETENV: ${WITH_NO_GETENV}")
|
||||
|
||||
message(STATUS "---------------------------------------------")
|
||||
message(STATUS "opentelemetry-cpp cmake component options")
|
||||
message(STATUS "---------------------------------------------")
|
||||
message(STATUS "WITH_OTLP_GRPC: ${WITH_OTLP_GRPC}")
|
||||
message(STATUS "WITH_OTLP_HTTP: ${WITH_OTLP_HTTP}")
|
||||
message(STATUS "WITH_OTLP_FILE: ${WITH_OTLP_FILE}")
|
||||
message(STATUS "WITH_HTTP_CLIENT_CURL: ${WITH_HTTP_CLIENT_CURL}")
|
||||
message(STATUS "WITH_ZIPKIN: ${WITH_ZIPKIN}")
|
||||
message(STATUS "WITH_PROMETHEUS: ${WITH_PROMETHEUS}")
|
||||
message(STATUS "WITH_ELASTICSEARCH: ${WITH_ELASTICSEARCH}")
|
||||
message(STATUS "WITH_OPENTRACING: ${WITH_OPENTRACING}")
|
||||
message(STATUS "WITH_ETW: ${WITH_ETW}")
|
||||
message(STATUS "OPENTELEMETRY_BUILD_DLL: ${OPENTELEMETRY_BUILD_DLL}")
|
||||
|
||||
message(STATUS "---------------------------------------------")
|
||||
message(STATUS "feature preview options")
|
||||
message(STATUS "---------------------------------------------")
|
||||
message(STATUS "WITH_ASYNC_EXPORT_PREVIEW: ${WITH_ASYNC_EXPORT_PREVIEW}")
|
||||
message(
|
||||
STATUS
|
||||
"WITH_THREAD_INSTRUMENTATION_PREVIEW: ${WITH_THREAD_INSTRUMENTATION_PREVIEW}"
|
||||
)
|
||||
message(
|
||||
STATUS "WITH_METRICS_EXEMPLAR_PREVIEW: ${WITH_METRICS_EXEMPLAR_PREVIEW}")
|
||||
message(
|
||||
STATUS "WITH_OTLP_GRPC_SSL_MTLS_PREVIEW: ${WITH_OTLP_GRPC_SSL_MTLS_PREVIEW}")
|
||||
message(
|
||||
STATUS
|
||||
"WITH_OTLP_GRPC_CREDENTIAL_PREVIEW: ${WITH_OTLP_GRPC_CREDENTIAL_PREVIEW}")
|
||||
message(STATUS "WITH_OTLP_RETRY_PREVIEW: ${WITH_OTLP_RETRY_PREVIEW}")
|
||||
message(STATUS "---------------------------------------------")
|
||||
message(STATUS "third-party options")
|
||||
message(STATUS "---------------------------------------------")
|
||||
message(STATUS "WITH_NLOHMANN_JSON: ${USE_NLOHMANN_JSON}")
|
||||
message(STATUS "WITH_CURL_LOGGING: ${WITH_CURL_LOGGING}")
|
||||
message(STATUS "WITH_OTLP_HTTP_COMPRESSION: ${WITH_OTLP_HTTP_COMPRESSION}")
|
||||
message(STATUS "---------------------------------------------")
|
||||
message(STATUS "examples and test options")
|
||||
message(STATUS "---------------------------------------------")
|
||||
message(STATUS "WITH_BENCHMARK: ${WITH_BENCHMARK}")
|
||||
message(STATUS "WITH_EXAMPLES: ${WITH_EXAMPLES}")
|
||||
message(STATUS "WITH_EXAMPLES_HTTP: ${WITH_EXAMPLES_HTTP}")
|
||||
message(STATUS "WITH_FUNC_TESTS: ${WITH_FUNC_TESTS}")
|
||||
message(STATUS "BUILD_W3CTRACECONTEXT_TEST: ${BUILD_W3CTRACECONTEXT_TEST}")
|
||||
message(STATUS "BUILD_TESTING: ${BUILD_TESTING}")
|
||||
message(STATUS "---------------------------------------------")
|
||||
message(STATUS "versions")
|
||||
message(STATUS "---------------------------------------------")
|
||||
message(STATUS "CMake: ${CMAKE_VERSION}")
|
||||
message(STATUS "GTest: ${GTest_VERSION} (${GTest_PROVIDER})")
|
||||
message(STATUS "benchmark: ${benchmark_VERSION} (${benchmark_PROVIDER})")
|
||||
if(WITH_GSL)
|
||||
message(
|
||||
STATUS "Microsoft.GSL: ${Microsoft.GSL_VERSION} (${Microsoft.GSL_PROVIDER})"
|
||||
)
|
||||
endif()
|
||||
if(absl_FOUND)
|
||||
message(STATUS "Abseil: ${absl_VERSION}")
|
||||
endif()
|
||||
if(opentelemetry-proto_VERSION)
|
||||
message(
|
||||
STATUS
|
||||
"opentelemetry-proto: ${opentelemetry-proto_VERSION} (${opentelemetry-proto_PROVIDER})"
|
||||
)
|
||||
endif()
|
||||
if(Protobuf_VERSION)
|
||||
message(
|
||||
STATUS
|
||||
"Protobuf: ${Protobuf_VERSION} (${Protobuf_PROVIDER} - ${protobuf_lib_type})"
|
||||
)
|
||||
endif()
|
||||
if(gRPC_VERSION)
|
||||
message(STATUS "gRPC: ${gRPC_VERSION} (${gRPC_PROVIDER} - ${grpc_lib_type})")
|
||||
endif()
|
||||
if(CURL_VERSION)
|
||||
message(STATUS "CURL: ${CURL_VERSION} (${CURL_PROVIDER})")
|
||||
endif()
|
||||
if(ZLIB_VERSION)
|
||||
message(STATUS "ZLIB: ${ZLIB_VERSION} (${ZLIB_PROVIDER})")
|
||||
endif()
|
||||
if(USE_NLOHMANN_JSON)
|
||||
message(
|
||||
STATUS "nlohmann-json: ${nlohmann_json_VERSION} (${nlohmann_json_PROVIDER})"
|
||||
)
|
||||
endif()
|
||||
if(WITH_PROMETHEUS)
|
||||
message(
|
||||
STATUS
|
||||
"prometheus-cpp: ${prometheus-cpp_VERSION} (${prometheus-cpp_PROVIDER})")
|
||||
endif()
|
||||
if(WITH_OPENTRACING)
|
||||
message(
|
||||
STATUS "opentracing-cpp: ${OpenTracing_VERSION} (${OpenTracing_PROVIDER})")
|
||||
endif()
|
||||
message(STATUS "---------------------------------------------")
|
||||
|
||||
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/otel-install-functions.cmake")
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
include_directories(api/include)
|
||||
if(DEFINED OPENTELEMETRY_BUILD_DLL)
|
||||
if(NOT WIN32)
|
||||
message(FATAL_ERROR "Build DLL is only supported on Windows!")
|
||||
endif()
|
||||
if(NOT MSVC)
|
||||
message(WARNING "Build DLL is supposed to work with MSVC!")
|
||||
endif()
|
||||
if(WITH_STL)
|
||||
message(
|
||||
WARNING "Build DLL with C++ STL could cause binary incompatibility!")
|
||||
endif()
|
||||
add_definitions(-DOPENTELEMETRY_BUILD_EXPORT_DLL)
|
||||
endif()
|
||||
|
||||
add_subdirectory(api)
|
||||
|
||||
if(WITH_OPENTRACING)
|
||||
add_subdirectory(opentracing-shim)
|
||||
endif()
|
||||
|
||||
if(NOT WITH_API_ONLY)
|
||||
set(BUILD_TESTING ${BUILD_TESTING})
|
||||
include_directories(sdk/include)
|
||||
include_directories(sdk)
|
||||
include_directories(ext/include)
|
||||
|
||||
add_subdirectory(sdk)
|
||||
add_subdirectory(ext)
|
||||
add_subdirectory(exporters)
|
||||
if(WITH_RESOURCE_DETECTORS_PREVIEW)
|
||||
add_subdirectory(resource_detectors)
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(test_common)
|
||||
endif()
|
||||
if(WITH_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
if(WITH_FUNC_TESTS)
|
||||
add_subdirectory(functional)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Export cmake config and support find_packages(opentelemetry-cpp CONFIG) Write
|
||||
# config file for find_packages(opentelemetry-cpp CONFIG)
|
||||
set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
configure_package_config_file(
|
||||
"${CMAKE_CURRENT_LIST_DIR}/cmake/opentelemetry-cpp-config.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config.cmake"
|
||||
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
||||
PATH_VARS OPENTELEMETRY_ABI_VERSION_NO OPENTELEMETRY_VERSION PROJECT_NAME
|
||||
INCLUDE_INSTALL_DIR CMAKE_INSTALL_LIBDIR
|
||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
|
||||
|
||||
# Write version file for find_packages(opentelemetry-cpp CONFIG)
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config-version.cmake"
|
||||
VERSION ${OPENTELEMETRY_VERSION}
|
||||
COMPATIBILITY ExactVersion)
|
||||
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config-version.cmake"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
||||
|
||||
# Export all components
|
||||
export(
|
||||
EXPORT "${PROJECT_NAME}-target"
|
||||
NAMESPACE "${PROJECT_NAME}::"
|
||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-target.cmake"
|
||||
include(
|
||||
"${opentelemetry-cpp_SOURCE_DIR}/cmake/opentelemetry-build-external-component.cmake"
|
||||
)
|
||||
install(
|
||||
EXPORT "${PROJECT_NAME}-target"
|
||||
NAMESPACE "${PROJECT_NAME}::"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
||||
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/patch-imported-config.cmake")
|
||||
|
||||
if(OPENTELEMETRY_INSTALL)
|
||||
# Install the cmake config and version files
|
||||
otel_install_cmake_config()
|
||||
|
||||
# Install the components and associated files
|
||||
otel_install_components()
|
||||
|
||||
# Install the thirdparty dependency definition file
|
||||
otel_install_thirdparty_definitions()
|
||||
|
||||
if(BUILD_PACKAGE)
|
||||
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/package.cmake")
|
||||
include(CPack)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"ctestCommandArgs": "",
|
||||
"variables": [
|
||||
{
|
||||
"name": "WITH_OTLP",
|
||||
"name": "WITH_OTLP_GRPC",
|
||||
"value": "True",
|
||||
"type": "BOOL"
|
||||
},
|
||||
|
@ -40,7 +40,7 @@
|
|||
"cmakeToolchain": "",
|
||||
"variables": [
|
||||
{
|
||||
"name": "WITH_OTLP",
|
||||
"name": "WITH_OTLP_GRPC",
|
||||
"value": "True",
|
||||
"type": "BOOL"
|
||||
},
|
||||
|
@ -70,7 +70,7 @@
|
|||
"type": "BOOL"
|
||||
},
|
||||
{
|
||||
"name": "WITH_OTLP",
|
||||
"name": "WITH_OTLP_GRPC",
|
||||
"value": "True",
|
||||
"type": "BOOL"
|
||||
},
|
||||
|
@ -106,7 +106,7 @@
|
|||
"type": "BOOL"
|
||||
},
|
||||
{
|
||||
"name": "WITH_OTLP",
|
||||
"name": "WITH_OTLP_GRPC",
|
||||
"value": "True",
|
||||
"type": "BOOL"
|
||||
},
|
||||
|
@ -123,4 +123,4 @@
|
|||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
133
CONTRIBUTING.md
133
CONTRIBUTING.md
|
@ -60,6 +60,121 @@ bazel build //examples/simple:example_simple
|
|||
bazel-bin/examples/simple/example_simple
|
||||
```
|
||||
|
||||
### DevContainer Setup for Project
|
||||
|
||||
This guide provides instructions on how to set up and use the development
|
||||
container (`devcontainer`) environment to streamline testing and development
|
||||
for this project. With the DevContainer, you can work in a consistent environment
|
||||
configured with all the necessary dependencies and tools.
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
Before getting started, ensure you have the following installed:
|
||||
|
||||
* **Docker**: DevContainers require Docker for containerization.
|
||||
* **Visual Studio Code (VSCode)** with the **Remote - Containers** extension.
|
||||
|
||||
#### Getting Started
|
||||
|
||||
* **Open the Project in DevContainer**:
|
||||
|
||||
Open the project in VSCode. When prompted to "Reopen in Container," select
|
||||
this option. If you’re not prompted, you can manually open the container by
|
||||
selecting **Remote-Containers: Reopen in Container** from the command palette
|
||||
(`F1` or `Ctrl+Shift+P`).
|
||||
|
||||
* **Container Setup**:
|
||||
|
||||
The DevContainer environment will automatically build based on the configuration
|
||||
files provided (e.g., `.devcontainer/devcontainer.json`). This setup will install
|
||||
required dependencies, tools, and environment variables needed for the project.
|
||||
|
||||
* **Container Customization**:
|
||||
See `.devcontainer/README.md` for devcontainer configuration options.
|
||||
|
||||
#### Available Commands
|
||||
|
||||
Once inside the DevContainer, you can use the following commands to run tests
|
||||
and CI workflows.
|
||||
|
||||
##### 1. Run Tests with Bazelisk
|
||||
|
||||
To run tests with Bazelisk using specific compilation options, use:
|
||||
|
||||
```bash
|
||||
bazelisk-linux-amd64 test --copt=-DENABLE_LOGS_PREVIEW
|
||||
--test_output=errors --cache_test_results=no --copt=-DENABLE_TEST //exporters/otlp/...
|
||||
```
|
||||
|
||||
###### Command Breakdown
|
||||
|
||||
* `--copt=-DENABLE_LOGS_PREVIEW`: Enables preview logs.
|
||||
* `--test_output=errors`: Shows only the errors in the test output.
|
||||
* `--cache_test_results=no`: Forces Bazel to re-run tests without caching.
|
||||
* `--copt=-DENABLE_TEST`: Enables testing capabilities for the target code.
|
||||
* `//exporters/otlp/...`: Specifies the test target path.
|
||||
|
||||
##### 2. Run CI Script
|
||||
|
||||
You can also run the CI script provided to perform testing with the
|
||||
following command as an
|
||||
example:
|
||||
|
||||
```bash
|
||||
bash ci/do_ci.sh cmake.exporter.otprotocol.test
|
||||
```
|
||||
|
||||
This command initiates the CI pipeline, executing tests specifically for the
|
||||
**cmake.exporter.otprotocol** module.
|
||||
|
||||
#### Troubleshooting
|
||||
|
||||
If you encounter issues:
|
||||
|
||||
* **Rebuild the DevContainer**: From the command palette, run
|
||||
**Remote-Containers: Rebuild Container** to reinitialize the environment.
|
||||
* **Check Bazelisk and CI Script Logs**: Inspect logs for any configuration or
|
||||
dependency issues.
|
||||
|
||||
#### Additional Notes
|
||||
|
||||
* You can adjust compiler options (`--copt`) as needed to test additional flags
|
||||
or enable/disable specific features.
|
||||
* The test results will be displayed in the terminal within the DevContainer for
|
||||
easy debugging.
|
||||
|
||||
#### Resources
|
||||
|
||||
* **Bazelisk Documentation**: [https://github.com/bazelbuild/bazelisk](https://github.com/bazelbuild/bazelisk)
|
||||
* **VSCode DevContainer Documentation**: [https://code.visualstudio.com/docs/remote/containers](https://code.visualstudio.com/docs/remote/containers)
|
||||
|
||||
### Docker Development Image
|
||||
|
||||
The `.devcontainer/Dockerfile.dev`
|
||||
dockerfile can be built directly with the following command.
|
||||
|
||||
```sh
|
||||
docker build -t opentelemetry-cpp-dev -f ./.devcontainer/Dockerfile.dev .
|
||||
```
|
||||
|
||||
You can customize the image using build arguments
|
||||
to match permissions with the host user.
|
||||
|
||||
```sh
|
||||
docker build -t opentelemetry-cpp-dev \
|
||||
--build-arg USER_UID="$(id -u)" \
|
||||
--build-arg USER_GID="$(id -g)" \
|
||||
-f ./.devcontainer/Dockerfile.dev .
|
||||
|
||||
```
|
||||
|
||||
Run an interactive bash session binding your host
|
||||
opentelemetry-cpp directory to the container's workspace:
|
||||
|
||||
```sh
|
||||
docker run -it -v "$PWD:/workspaces/opentelemetry-cpp" opentelemetry-cpp-dev bash
|
||||
```
|
||||
|
||||
## Pull Requests
|
||||
|
||||
### How to Send Pull Requests
|
||||
|
@ -87,6 +202,12 @@ git submodule init
|
|||
git submodule update
|
||||
```
|
||||
|
||||
The source code is automatically formatted using clang-format.
|
||||
|
||||
The output can vary between versions, so make sure to install `clang-format`
|
||||
version `10.0`, and have `clang-format-10` in your execution path,
|
||||
so that the helper script `tools/format.sh` can find it.
|
||||
|
||||
Check out a new branch, make modifications and push the branch to your fork:
|
||||
|
||||
```sh
|
||||
|
@ -104,6 +225,12 @@ If you made changes to the Markdown documents (`*.md` files), install the latest
|
|||
markdownlint .
|
||||
```
|
||||
|
||||
If you modified shell scripts (`*.sh` files), install `shellcheck` and run:
|
||||
|
||||
```sh
|
||||
shellcheck --severity=error <path to shell script>.sh
|
||||
```
|
||||
|
||||
Open a pull request against the main `opentelemetry-cpp` repo.
|
||||
|
||||
To run tests locally, please read the [CI instructions](ci/README.md).
|
||||
|
@ -180,11 +307,11 @@ the C++ repository.
|
|||
|
||||
* [OpenTelemetry
|
||||
Specification](https://github.com/open-telemetry/opentelemetry-specification)
|
||||
* The OpenTelemetry Specification describes the requirements and expectations
|
||||
of for all OpenTelemetry implementations.
|
||||
* The OpenTelemetry Specification describes the requirements and expectations
|
||||
of for all OpenTelemetry implementations.
|
||||
|
||||
* Read through the OpenTelemetry C++ documentation
|
||||
* The
|
||||
* The
|
||||
[API](https://opentelemetry-cpp.readthedocs.io/en/latest/api/api.html)
|
||||
and
|
||||
[SDK](https://opentelemetry-cpp.readthedocs.io/en/latest/sdk/sdk.html)
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
# Deprecated
|
||||
|
||||
This document lists all the items currently deprecated in opentelemetry-cpp.
|
||||
|
||||
Deprecated items will be removed in the future.
|
||||
|
||||
## Guidelines
|
||||
|
||||
### Maintainer guidelines
|
||||
|
||||
See the [deprecation-process](./docs/deprecation-process.md)
|
||||
|
||||
## [TEMPLATE]
|
||||
|
||||
### New Deprecation Title (Template)
|
||||
|
||||
#### Announcement (Template)
|
||||
|
||||
#### Motivation (Template)
|
||||
|
||||
#### Scope (Template)
|
||||
|
||||
#### Mitigation (Template)
|
||||
|
||||
#### Planned removal (Template)
|
||||
|
||||
## [Platforms]
|
||||
|
||||
N/A
|
||||
|
||||
## [Compilers]
|
||||
|
||||
N/A
|
||||
|
||||
## [Third party dependencies]
|
||||
|
||||
N/A
|
||||
|
||||
## [Build tools]
|
||||
|
||||
N/A
|
||||
|
||||
## [Build scripts]
|
||||
|
||||
N/A
|
||||
|
||||
## [opentelemetry-cpp API]
|
||||
|
||||
N/A
|
||||
|
||||
## [opentelemetry-cpp SDK]
|
||||
|
||||
N/A
|
||||
|
||||
## [opentelemetry-cpp Exporter]
|
||||
|
||||
N/A
|
||||
|
||||
## [Documentation]
|
||||
|
||||
N/A
|
||||
|
||||
## Semantic conventions
|
||||
|
||||
N/A
|
246
INSTALL.md
246
INSTALL.md
|
@ -12,18 +12,20 @@ You can link OpenTelemetry C++ SDK with libraries provided in
|
|||
|
||||
## Build instructions using CMake
|
||||
|
||||
### Prerequisites for CMake
|
||||
### Prerequisites for CMake build
|
||||
|
||||
- A supported platform (e.g. Windows, macOS or Linux). Refer to [Platforms
|
||||
Supported](./README.md#supported-development-platforms) for more information.
|
||||
- A compatible C++ compiler supporting at least C++11. Major compilers are
|
||||
- A compatible C++ compiler supporting at least C++14. Major compilers are
|
||||
supported. Refer to [Supported Compilers](./README.md#supported-c-versions)
|
||||
for more information.
|
||||
- [Git](https://git-scm.com/) for fetching opentelemetry-cpp source code from
|
||||
repository. To install Git, consult the [Set up
|
||||
Git](https://help.github.com/articles/set-up-git/) guide on GitHub.
|
||||
- [CMake](https://cmake.org/) for building opentelemetry-cpp API, SDK with their
|
||||
unittests. We use CMake version 3.15.2 in our build system. To install CMake,
|
||||
unittests. The minimum CMake version is 3.14.
|
||||
CMake 3.15+ is recommended on Windows due to known CI test failures with 3.14.
|
||||
To install CMake,
|
||||
consult the [Installing CMake](https://cmake.org/install/) guide.
|
||||
- [GoogleTest](https://github.com/google/googletest) framework to build and run
|
||||
the unittests. Refer to
|
||||
|
@ -38,20 +40,39 @@ You can link OpenTelemetry C++ SDK with libraries provided in
|
|||
[GoogleBenchmark Build
|
||||
Instructions](https://github.com/google/benchmark#installation).
|
||||
- Apart from above core requirements, the Exporters and Propagators have their
|
||||
build dependencies which are not covered here. E.g, Otlp Exporter needs
|
||||
grpc/protobuf library, Zipkin exporter needs nlohmann-json and libcurl, ETW
|
||||
exporter need nlohmann-json to build. This is covered in the build
|
||||
instructions for each of these components.
|
||||
build dependencies.
|
||||
|
||||
### Building dependencies for the OTLP exporters
|
||||
|
||||
The opentelemetry-cpp OTLP exporters depend on Protobuf and gRPC
|
||||
(in the case of the otlp grpc exporters).
|
||||
Protobuf (since version 3.22.0) and gRPC depend on Abseil.
|
||||
For cmake builds, it is best practice to build and install Abseil
|
||||
, Protobuf, and gPRC as independent packages -
|
||||
configuring cmake for Protobuf and gRPC to build against
|
||||
the installed packages instead of using their submodule option.
|
||||
|
||||
If building and installing Protobuf and gRPC manually with cmake the
|
||||
recommended approach is:
|
||||
|
||||
1. Choose the desired tag version of grpc. Find the compatible versions of abseil
|
||||
and protobuf by inspecting the submodules of grpc at that tag.
|
||||
2. Build and install the required version of abseil
|
||||
3. Build and install the required version of protobuf
|
||||
- Set the cmake option of Protobuf to build against the installed
|
||||
package of Abseil (`protobuf_ABSL_PROVIDER=package`)
|
||||
4. Build and install the required version of grpc
|
||||
- Set the cmake option of grpc to build against the installed packages
|
||||
of Abseil and Protobuf (cmake options - `gRPC_ABSL_PROVIDER=package` and `gRPC_PROTOBUF_PROVIDER=package`)
|
||||
|
||||
### Building as standalone CMake Project
|
||||
|
||||
1. Getting the opentelementry-cpp source:
|
||||
1. Getting the opentelemetry-cpp source with its submodules:
|
||||
|
||||
```console
|
||||
# Change to the directory where you want to create the code repository
|
||||
$ cd ~
|
||||
$ mkdir source && cd source
|
||||
$ git clone --recursive https://github.com/open-telemetry/opentelemetry-cpp
|
||||
$ mkdir source && cd source && git clone --recurse-submodules https://github.com/open-telemetry/opentelemetry-cpp
|
||||
Cloning into 'opentelemetry-cpp'...
|
||||
...
|
||||
Resolving deltas: 100% (3225/3225), done.
|
||||
|
@ -63,8 +84,7 @@ You can link OpenTelemetry C++ SDK with libraries provided in
|
|||
|
||||
```console
|
||||
$ cd opentelemetry-cpp
|
||||
$ mkdir build && cd build
|
||||
$ cmake ..
|
||||
$ mkdir build && cd build && cmake ..
|
||||
-- The C compiler identification is GNU 9.3.0
|
||||
-- The CXX compiler identification is GNU 9.3.0
|
||||
...
|
||||
|
@ -83,12 +103,15 @@ You can link OpenTelemetry C++ SDK with libraries provided in
|
|||
inclusion in shared libraries, this variable is used.
|
||||
- `-DBUILD_SHARED_LIBS=ON` : To build shared libraries for the targets.
|
||||
Please refer to note [below](#building-shared-libs-for-windows) for
|
||||
Windows DLL support
|
||||
- `-DWITH_OTLP=ON` : To enable building Otlp exporter.
|
||||
Windows DLL support.
|
||||
- `-DWITH_OTLP_GRPC=ON` : To enable building OTLP GRPC exporter.
|
||||
- `-DWITH_OTLP_HTTP=ON` : To enable building OTLP HTTP exporter.
|
||||
- `-DWITH_PROMETHEUS=ON` : To enable building prometheus exporter.
|
||||
- `-DOPENTELEMETRY_INSTALL=ON`: To install `otel-cpp` library needed
|
||||
for external code linking.
|
||||
|
||||
3. Once build configuration is created, build the CMake targets - this includes
|
||||
building SDKs, and building unittests for API and SDK. Note that since API is
|
||||
3. Once the build configuration is created, build the CMake targets - this
|
||||
includes building SDKs and unittests for API and SDK. Note that since API is
|
||||
header only library, no separate build is triggered for it.
|
||||
|
||||
```console
|
||||
|
@ -121,33 +144,133 @@ You can link OpenTelemetry C++ SDK with libraries provided in
|
|||
files for SDK at custom/default install location.
|
||||
|
||||
```console
|
||||
$ cmake --install . --prefix /<install_root>/
|
||||
$ cmake --install . --prefix /<install-root>/
|
||||
-- Installing: /<install-root>/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config.cmake
|
||||
-- Installing: /<install-root>/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config-version.cmake
|
||||
...
|
||||
-- Installing: /<install-root>/include/opentelemetry//ext/zpages/static/tracez_index.h
|
||||
-- Installing: /<install-root>/include/opentelemetry//ext/zpages/static/tracez_style.h
|
||||
-- Installing: /<install-root>/include/opentelemetry//ext/zpages/threadsafe_span_data.h
|
||||
-- Installing: /<install-root>/lib/libopentelemetry_zpages.a
|
||||
$
|
||||
```
|
||||
|
||||
### Incorporating into an existing CMake Project
|
||||
### Incorporating into an external CMake Project
|
||||
|
||||
To use the library from a CMake project, you can locate it directly with
|
||||
`find_package` and use the imported targets from generated package
|
||||
configurations. As of now, this will import targets for both API and SDK. In
|
||||
future, there may be separate packages for API and SDK which can be installed
|
||||
and imported separtely according to need.
|
||||
There are two approaches to incoporate `opentelemetry-cpp` into
|
||||
an external CMake project:
|
||||
|
||||
1. Build and install `opentelemetry-cpp` then use `find_package`
|
||||
to import its targets
|
||||
|
||||
```cmake
|
||||
# Find all installed components and link all imported targets
|
||||
find_package(opentelemetry-cpp CONFIG REQUIRED)
|
||||
...
|
||||
target_include_directories(foo PRIVATE ${OPENTELEMETRY_CPP_INCLUDE_DIRS})
|
||||
target_link_libraries(foo PRIVATE ${OPENTELEMETRY_CPP_LIBRARIES})
|
||||
```
|
||||
|
||||
```cmake
|
||||
# Find a specific component and link its imported target(s)
|
||||
find_package(opentelemetry-cpp CONFIG REQUIRED COMPONENTS api)
|
||||
...
|
||||
target_link_libraries(foo PRIVATE opentelemetry-cpp::api)
|
||||
```
|
||||
|
||||
2. Use CMake's [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html)
|
||||
module to fetch and build `opentelemetry-cpp` then make its targets available
|
||||
|
||||
```cmake
|
||||
# Fetch from an existing clone and build
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(opentelemetry-cpp SOURCE_DIR "<path/to/opentelemetry-cpp>")
|
||||
FetchContent_MakeAvailable(opentelemetry-cpp)
|
||||
...
|
||||
target_link_libraries(foo PRIVATE opentelemetry-cpp::api)
|
||||
```
|
||||
|
||||
```cmake
|
||||
# Clone and build opentelemetry-cpp from a git tag
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
opentelemetry-cpp
|
||||
GIT_REPOSITORY https://github.com/open-telemetry/opentelemetry-cpp.git
|
||||
GIT_TAG v1.20.0)
|
||||
FetchContent_MakeAvailable(opentelemetry-cpp)
|
||||
...
|
||||
target_link_libraries(foo PRIVATE opentelemetry-cpp::api)
|
||||
```
|
||||
|
||||
In both cases the project's built or imported CMake targets will be
|
||||
available in the `opentelemetry-cpp` namespace (ie: `opentelemetry-cpp::api`)
|
||||
|
||||
#### Using opentelemetry-cpp package components
|
||||
|
||||
> **Note:** `opentelemetry-cpp` CMake package components were introduced in `v1.21.0`
|
||||
|
||||
The `opentelemetry-cpp` package supports using the `COMPONENTS` argument to
|
||||
`find_package`. The following example illustrates using this feature to include
|
||||
and link the `api` header only target to an instrumented `foo_lib` while only including
|
||||
and linking the `sdk` and `otlp_grpc_exporter` targets to the `foo_app`.
|
||||
|
||||
```cmake
|
||||
# CMakeLists.txt
|
||||
find_package(opentelemetry-cpp CONFIG REQUIRED)
|
||||
...
|
||||
target_include_directories(foo PRIVATE ${OPENTELEMETRY_CPP_INCLUDE_DIRS})
|
||||
target_link_libraries(foo PRIVATE ${OPENTELEMETRY_CPP_LIBRARIES})
|
||||
# foo_lib/CMakeLists.txt
|
||||
find_package(opentelemetry-cpp CONFIG REQUIRED COMPONENTS api)
|
||||
add_library(foo_lib foo.cpp)
|
||||
target_link_libraries(foo_lib PRIVATE opentelemetry-cpp::api)
|
||||
```
|
||||
|
||||
```cmake
|
||||
# foo_app/CMakeLists.txt
|
||||
find_package(opentelemetry-cpp CONFIG REQUIRED COMPONENTS api sdk exporters_otlp_grpc)
|
||||
add_executable(foo_app main.cpp)
|
||||
target_link_libraries(foo_app PRIVATE foo_lib opentelemetry-cpp::api opentelemetry-cpp::trace opentelemetry-cpp::otlp_grpc_exporter )
|
||||
```
|
||||
|
||||
The following table provides the mapping between components and targets. Components
|
||||
and targets available in the installation depends on the opentelemetry-cpp package
|
||||
build configuration.
|
||||
|
||||
> **Note:** components `exporters_elasticsearch` and `exporters_etw`
|
||||
may be moved out of the core package and to `opentelemetry-cpp-contrib`
|
||||
in a future release
|
||||
|
||||
| Component | Targets |
|
||||
|----------------------------|--------------------------------------------------------------------------------------------------|
|
||||
| **api** | opentelemetry-cpp::api |
|
||||
| **sdk** | opentelemetry-cpp::sdk |
|
||||
| | opentelemetry-cpp::version |
|
||||
| | opentelemetry-cpp::common |
|
||||
| | opentelemetry-cpp::resources |
|
||||
| | opentelemetry-cpp::trace |
|
||||
| | opentelemetry-cpp::metrics |
|
||||
| | opentelemetry-cpp::logs |
|
||||
| **ext_common** | opentelemetry-cpp::ext |
|
||||
| **ext_http_curl** | opentelemetry-cpp::http_client_curl |
|
||||
| **ext_dll** | opentelemetry-cpp::opentelemetry_cpp |
|
||||
| **exporters_in_memory** | opentelemetry-cpp::in_memory_span_exporter |
|
||||
| | opentelemetry-cpp::in_memory_metric_exporter |
|
||||
| **exporters_ostream** | opentelemetry-cpp::ostream_log_record_exporter |
|
||||
| | opentelemetry-cpp::ostream_metrics_exporter |
|
||||
| | opentelemetry-cpp::ostream_span_exporter |
|
||||
| **exporters_otlp_common** | opentelemetry-cpp::proto |
|
||||
| | opentelemetry-cpp::otlp_recordable |
|
||||
| **exporters_otlp_file** | opentelemetry-cpp::otlp_file_client |
|
||||
| | opentelemetry-cpp::otlp_file_exporter |
|
||||
| | opentelemetry-cpp::otlp_file_log_record_exporter |
|
||||
| | opentelemetry-cpp::otlp_file_metric_exporter |
|
||||
| **exporters_otlp_grpc** | opentelemetry-cpp::proto_grpc |
|
||||
| | opentelemetry-cpp::otlp_grpc_client |
|
||||
| | opentelemetry-cpp::otlp_grpc_exporter |
|
||||
| | opentelemetry-cpp::otlp_grpc_log_record_exporter |
|
||||
| | opentelemetry-cpp::otlp_grpc_metrics_exporter |
|
||||
| **exporters_otlp_http** | opentelemetry-cpp::otlp_http_client |
|
||||
| | opentelemetry-cpp::otlp_http_exporter |
|
||||
| | opentelemetry-cpp::otlp_http_log_record_exporter |
|
||||
| | opentelemetry-cpp::otlp_http_metric_exporter |
|
||||
| **exporters_prometheus** | opentelemetry-cpp::prometheus_exporter |
|
||||
| **exporters_elasticsearch**| opentelemetry-cpp::elasticsearch_log_record_exporter |
|
||||
| **exporters_etw** | opentelemetry-cpp::etw_exporter |
|
||||
| **exporters_zipkin** | opentelemetry-cpp::zipkin_trace_exporter |
|
||||
| **shims_opentracing** | opentelemetry-cpp::opentracing_shim |
|
||||
|
||||
## Build instructions using Bazel
|
||||
|
||||
NOTE: Experimental, and not supported for all the components. Make sure the
|
||||
|
@ -155,11 +278,11 @@ NOTE: Experimental, and not supported for all the components. Make sure the
|
|||
there is a different version of googletest already installed in system-defined
|
||||
path.
|
||||
|
||||
### Prerequisites for Bazel
|
||||
### Prerequisites for Bazel build
|
||||
|
||||
- A supported platform (e.g. Windows, macOS or Linux). Refer to [Platforms
|
||||
Supported](./README.md#supported-development-platforms) for more information.
|
||||
- A compatible C++ compiler supporting at least C++11. Major compilers are
|
||||
- A compatible C++ compiler supporting at least C++14. Major compilers are
|
||||
supported. Refer to [Supported Compilers](./README.md#supported-c-versions) for
|
||||
more information.
|
||||
- [Git](https://git-scm.com/) for fetching opentelemetry-cpp source code from
|
||||
|
@ -173,7 +296,7 @@ Bazel](https://docs.bazel.build/versions/3.7.0/install.html) guide.
|
|||
|
||||
### Building as standalone Bazel Project
|
||||
|
||||
1. Getting the opentelementry-cpp source:
|
||||
1. Getting the opentelemetry-cpp source:
|
||||
|
||||
```console
|
||||
# Change to the directory where you want to create the code repository
|
||||
|
@ -190,7 +313,7 @@ Bazel](https://docs.bazel.build/versions/3.7.0/install.html) guide.
|
|||
the source code:
|
||||
|
||||
```console
|
||||
$ cd opentelemtry-cpp
|
||||
$ cd opentelemetry-cpp
|
||||
$ bazel build //...
|
||||
bazel build -- //... -//exporters/otlp/... -//exporters/prometheus/...
|
||||
Extracting Bazel installation...
|
||||
|
@ -231,6 +354,11 @@ load("@io_opentelemetry_cpp//bazel:repository.bzl", "opentelemetry_cpp_deps")
|
|||
|
||||
opentelemetry_cpp_deps()
|
||||
|
||||
# (required after v1.8.0) Load extra dependencies required for OpenTelemetry
|
||||
load("@io_opentelemetry_cpp//bazel:extra_deps.bzl", "opentelemetry_extra_deps")
|
||||
|
||||
opentelemetry_extra_deps()
|
||||
|
||||
# Load gRPC dependencies after load.
|
||||
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
|
||||
|
||||
|
@ -261,10 +389,44 @@ cc_library(
|
|||
|
||||
## Building shared libs for Windows
|
||||
|
||||
Windows DLL build is not supported. There are some constraints on how C++ DLLs
|
||||
work on Windows, specifically we can't safely allocate memory in one DLL and
|
||||
free it in another. For now, OpenTelemetry C++ targets need to be statically
|
||||
linked into the Windows applications.
|
||||
Windows DLL build is supported under **preview**. Please check the
|
||||
[doc](./docs/build-as-dll.md) for more details.
|
||||
|
||||
## Generating binary packages
|
||||
|
||||
OpenTelemetry C++ supports generating platform specific binary packages from CMake
|
||||
configuration. The packages generated through this mayn't be production ready,
|
||||
and user may have to customize it further before using it as distribution.
|
||||
|
||||
- Linux : deb, rpm, tgz
|
||||
- MacOS : tgz
|
||||
- Windows : NuGet, zip
|
||||
|
||||
This requires platform specific package generators already installed. The package
|
||||
generation can subsequently be enabled by using BUILD_PACKAGE option during cmake
|
||||
configuration
|
||||
|
||||
```console
|
||||
$ cd opentelemetry-cpp
|
||||
$ mkdir build && cd build && cmake -DBUILD_PACKAGE=ON ..
|
||||
|
||||
-- Package name: opentelemetry-cpp-1.8.1-ubuntu-20.04-x86_64.deb
|
||||
-- Configuring done
|
||||
-- Generating done
|
||||
...
|
||||
$
|
||||
```
|
||||
|
||||
Once build is complete as specified in [standalone build section](#building-as-standalone-cmake-project),
|
||||
the package can be generated as below.
|
||||
|
||||
```console
|
||||
$ cpack -C debug
|
||||
CPack: Create package using DEB
|
||||
...
|
||||
CPack: - package: /home/<user>/opentelemetry-cpp/build/opentelemetry-cpp-1.8.1-ubuntu-20.04-x86_64.deb generated.
|
||||
$
|
||||
```
|
||||
|
||||
## Using Package Managers
|
||||
|
||||
|
@ -281,6 +443,10 @@ with `vcpkg install opentelemetry-cpp` and follow the then displayed
|
|||
descriptions. Please see the vcpkg project for any issues regarding the
|
||||
packaging.
|
||||
|
||||
If you are using [alpine linux](https://www.alpinelinux.org/) you can install
|
||||
the [opentelemetry-cpp packages](https://pkgs.alpinelinux.org/packages?name=opentelemetry-cpp-*)
|
||||
with `apk add -X http://dl-cdn.alpinelinux.org/alpine/edge/testing opentelemetry-cpp-dev`.
|
||||
|
||||
Please note, these packages are not officially provided and maintained by
|
||||
OpenTelemetry C++ project, and are just listed here to consolidate all such
|
||||
efforts for ease of developers.
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
# Copyright The OpenTelemetry Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module(
|
||||
name = "opentelemetry-cpp",
|
||||
version = "1.22.0",
|
||||
compatibility_level = 0,
|
||||
repo_name = "io_opentelemetry_cpp",
|
||||
)
|
||||
|
||||
bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name = "com_google_absl")
|
||||
bazel_dep(name = "bazel_skylib", version = "1.5.0")
|
||||
bazel_dep(name = "curl", version = "8.8.0")
|
||||
bazel_dep(name = "grpc", version = "1.63.1.bcr.1", repo_name = "com_github_grpc_grpc")
|
||||
bazel_dep(name = "nlohmann_json", version = "3.12.0", repo_name = "github_nlohmann_json")
|
||||
bazel_dep(name = "opentelemetry-proto", version = "1.7.0", repo_name = "com_github_opentelemetry_proto")
|
||||
bazel_dep(name = "opentracing-cpp", version = "1.6.0", repo_name = "com_github_opentracing")
|
||||
bazel_dep(name = "platforms", version = "0.0.8")
|
||||
bazel_dep(name = "prometheus-cpp", version = "1.3.0", repo_name = "com_github_jupp0r_prometheus_cpp")
|
||||
bazel_dep(name = "protobuf", version = "26.0", repo_name = "com_google_protobuf")
|
||||
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
|
||||
bazel_dep(name = "zlib", version = "1.3.1.bcr.1")
|
||||
|
||||
bazel_dep(name = "google_benchmark", version = "1.8.3", dev_dependency = True, repo_name = "com_github_google_benchmark")
|
||||
bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True, repo_name = "com_google_googletest")
|
79
README.md
79
README.md
|
@ -5,49 +5,27 @@
|
|||
[](https://github.com/open-telemetry/opentelemetry-cpp/actions)
|
||||
[](https://github.com/open-telemetry/opentelemetry-cpp/releases/)
|
||||
[](https://app.fossa.com/projects/custom%2B162%2Fgithub.com%2Fopen-telemetry%2Fopentelemetry-cpp?ref=badge_shield&issueType=license)
|
||||
[](https://app.fossa.com/projects/custom%2B162%2Fgithub.com%2Fopen-telemetry%2Fopentelemetry-cpp?ref=badge_shield&issueType=security)
|
||||
|
||||
The C++ [OpenTelemetry](https://opentelemetry.io/) client.
|
||||
|
||||
## Project Status
|
||||
|
||||
| Signal | Status | Project |
|
||||
| ------- | ----------------------- | ------------------------------------------------------------------------ |
|
||||
| Traces | Public Release | N/A |
|
||||
| Metrics | Release Candidate [1,2] | N/A |
|
||||
| Logs | Experimental [3] | N/A |
|
||||
**Stable** across all 3 signals i.e. `Logs`, `Metrics`, and `Traces`.
|
||||
|
||||
* [1]: The metric implementation is in release candidate phase. There would be
|
||||
few iterations of new feature additions, and bug fixes before it is
|
||||
publically available. Few breaking changes in API and SDK are expected.
|
||||
* [2]: The earlier implementation (based on old
|
||||
specification) is now deprecated, and would be removed once new implementation
|
||||
is declared stable. The older implementation can be included in build by setting
|
||||
`ENABLE_METRICS_PREVIEW` preprocessor macro, and is included under
|
||||
`*/_metrics/*` directory.
|
||||
* [3]: The current Log Signal Implementation is Experimental, and will change as
|
||||
the current OpenTelemetry Log specification matures. The current
|
||||
implementation can be included in build by setting `ENABLE_LOGS_PREVIEW`
|
||||
preprocessor macro.
|
||||
|
||||
## OpenTelemetry Specification Compatibility Matrix
|
||||
|
||||
| API Version | Core Version | Contrib Version [1] |
|
||||
| ----------- |--------------|-------------------------|
|
||||
| 1.0.0 | 1.0.0-rc4 | N/A |
|
||||
| 1.0.0 | 1.0.0 | N/A |
|
||||
| 1.9.0 | 1.6.0 | N/A |
|
||||
|
||||
* [1]: We don't have releases for opentelemetry-cpp contrib repo. This may
|
||||
change in future.
|
||||
See [Spec Compliance
|
||||
Matrix](https://github.com/open-telemetry/opentelemetry-specification/blob/main/spec-compliance-matrix.md)
|
||||
to understand which portions of the specification has been implemented in this
|
||||
repo.
|
||||
|
||||
## Supported C++ Versions
|
||||
|
||||
Code shipped from this repository generally supports the following versions of
|
||||
C++ standards:
|
||||
|
||||
* ISO/IEC 14882:2011 (C++11, C++0x)
|
||||
* ISO/IEC 14882:2014 (C++14, C++1y)
|
||||
* ISO/IEC 14882:2017 (C++17, C++1z)
|
||||
* ISO/IEC 14882:2014 (C++14)
|
||||
* ISO/IEC 14882:2017 (C++17)
|
||||
* ISO/IEC 14882:2020 (C++20)
|
||||
|
||||
Any exceptions to this are noted in the individual `README.md` files.
|
||||
|
@ -62,16 +40,12 @@ of the current project.
|
|||
|
||||
| Platform | Build type |
|
||||
|---------------------------------------------------------------------|---------------|
|
||||
| ubuntu-20.04 (Default GCC Compiler - 9.3.0) | CMake, Bazel |
|
||||
| ubuntu-18.04 (GCC 4.8 with -std=c++11 flag) | CMake [1] |
|
||||
| ubuntu-20.04 (Default GCC Compiler - 9.3.0 with -std=c++20 flags) | CMake, Bazel |
|
||||
| macOS 10.15 (Xcode 12.2) | Bazel |
|
||||
| ubuntu-22.04 (GCC 10, GCC 12, Clang 14) | CMake, Bazel |
|
||||
| ubuntu-20.04 (GCC 9.4.0 - default compiler) | CMake, Bazel |
|
||||
| ubuntu-20.04 (GCC 9.4.0 with -std=c++14/17/20 flags) | CMake, Bazel |
|
||||
| macOS 12.7 (Xcode 14.2) | Bazel |
|
||||
| Windows Server 2019 (Visual Studio Enterprise 2019) | CMake, Bazel |
|
||||
|
||||
[1]: Bazel build is disabled for GCC 4.8, as gRPC library 1.38 and above
|
||||
(required by OTLP expoter) don't build with this compiler. See gRPC [official
|
||||
support](https://grpc.io/docs/#official-support) document. CMake build doesn't
|
||||
build OTLP exporter with GCC 4.8.
|
||||
| Windows Server 2022 (Visual Studio Enterprise 2022) | CMake |
|
||||
|
||||
In general, the code shipped from this repository should build on all platforms
|
||||
having C++ compiler with [supported C++ standards](#supported-c-versions).
|
||||
|
@ -102,7 +76,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|||
We meet weekly, and the time of the meeting alternates between Monday at 13:00
|
||||
PT and Wednesday at 9:00 PT. The meeting is subject to change depending on
|
||||
contributors' availability. Check the [OpenTelemetry community
|
||||
calendar](https://calendar.google.com/calendar/embed?src=google.com_b79e3e90j7bbsa2n2p5an5lf60%40group.calendar.google.com)
|
||||
calendar](https://github.com/open-telemetry/community#calendar)
|
||||
for specific dates and Zoom meeting links.
|
||||
|
||||
Meeting notes are available as a public [Google
|
||||
|
@ -110,39 +84,42 @@ doc](https://docs.google.com/document/d/1i1E4-_y4uJ083lCutKGDhkpi3n4_e774SBLi9hP
|
|||
For edit access, get in touch on
|
||||
[Slack](https://cloud-native.slack.com/archives/C01N3AT62SJ).
|
||||
|
||||
[Maintainers](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer)
|
||||
([@open-telemetry/cpp-maintainers](https://github.com/orgs/open-telemetry/teams/cpp-maintainers)):
|
||||
### Maintainers
|
||||
|
||||
* [Ehsan Saei](https://github.com/esigo)
|
||||
* [Lalit Kumar Bhasin](https://github.com/lalitb), Microsoft
|
||||
* [Marc Alff](https://github.com/marcalff), Oracle
|
||||
* [Tom Tan](https://github.com/ThomsonTan), Microsoft
|
||||
|
||||
[Approvers](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver)
|
||||
([@open-telemetry/cpp-approvers](https://github.com/orgs/open-telemetry/teams/cpp-approvers)):
|
||||
For more information about the maintainer role, see the [community repository](https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md#maintainer).
|
||||
|
||||
### Approvers
|
||||
|
||||
* [Doug Barker](https://github.com/dbarker)
|
||||
* [Josh Suereth](https://github.com/jsuereth), Google
|
||||
* [Marc Alff](https://github.com/marcalff), Oracle
|
||||
* [Reiley Yang](https://github.com/reyang), Microsoft
|
||||
* [Pranav Sharma](https://github.com/psx95), Google
|
||||
* [WenTao Ou](https://github.com/owent), Tencent
|
||||
|
||||
[Emeritus
|
||||
Maintainer/Approver/Triager](https://github.com/open-telemetry/community/blob/main/community-membership.md#emeritus-maintainerapprovertriager):
|
||||
For more information about the approver role, see the [community repository](https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md#approver).
|
||||
|
||||
### Emeritus Maintainer/Approver/Triager
|
||||
|
||||
* [Alolita Sharma](https://github.com/alolita)
|
||||
* [Emil Mikulic](https://github.com/g-easy)
|
||||
* [Jodee Varney](https://github.com/jodeev)
|
||||
* [Johannes Tax](https://github.com/pyohannes)
|
||||
* [Max Golovanov](https://github.com/maxgolov)
|
||||
* [Reiley Yang](https://github.com/reyang)
|
||||
* [Ryan Burn](https://github.com/rnburn)
|
||||
|
||||
For more information about the emeritus role, see the [community repository](https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md#emeritus-maintainerapprovertriager).
|
||||
|
||||
### Thanks to all the people who have contributed
|
||||
|
||||
[](https://github.com/open-telemetry/opentelemetry-cpp/graphs/contributors)
|
||||
|
||||
## Release Schedule
|
||||
|
||||
Refer to [project status](#project-status) for current status of the project.
|
||||
|
||||
See the [release
|
||||
notes](https://github.com/open-telemetry/opentelemetry-cpp/releases) for
|
||||
existing releases.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
## Pre Release
|
||||
|
||||
1: Upgrade to latest [semantic-conventions](docs/semantic-conventions.md)
|
||||
1: Upgrade to latest [dependencies](docs/maintaining-dependencies.md)
|
||||
if required.
|
||||
|
||||
2: Make sure all relevant changes for this release are included under
|
||||
|
|
33
WORKSPACE
33
WORKSPACE
|
@ -1,16 +1,5 @@
|
|||
# Copyright 2019, OpenTelemetry Authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# Copyright The OpenTelemetry Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
workspace(name = "io_opentelemetry_cpp")
|
||||
|
||||
|
@ -19,14 +8,9 @@ load("//bazel:repository.bzl", "opentelemetry_cpp_deps")
|
|||
|
||||
opentelemetry_cpp_deps()
|
||||
|
||||
# Load prometheus C++ dependencies.
|
||||
load("@com_github_jupp0r_prometheus_cpp//bazel:repositories.bzl", "prometheus_cpp_repositories")
|
||||
load("//bazel:extra_deps.bzl", "opentelemetry_extra_deps")
|
||||
|
||||
prometheus_cpp_repositories()
|
||||
|
||||
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
|
||||
|
||||
bazel_skylib_workspace()
|
||||
opentelemetry_extra_deps()
|
||||
|
||||
# Load gRPC dependencies after load.
|
||||
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
|
||||
|
@ -37,12 +21,3 @@ grpc_deps()
|
|||
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
|
||||
|
||||
grpc_extra_deps()
|
||||
|
||||
load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
|
||||
load("@upb//bazel:workspace_deps.bzl", "upb_deps")
|
||||
|
||||
upb_deps()
|
||||
|
||||
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
|
||||
|
||||
rules_foreign_cc_dependencies()
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright The OpenTelemetry Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# Disables the default WORKSPACE when using bzlmod
|
90
api/BUILD
90
api/BUILD
|
@ -1,45 +1,81 @@
|
|||
# Copyright 2019, OpenTelemetry Authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# Copyright The OpenTelemetry Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
|
||||
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "int_flag", "string_flag")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
bool_flag(
|
||||
name = "with_abseil",
|
||||
build_setting_default = False,
|
||||
CPP_STDLIBS = [
|
||||
"none",
|
||||
"best",
|
||||
"2014",
|
||||
"2017",
|
||||
"2020",
|
||||
"2023",
|
||||
]
|
||||
|
||||
string_flag(
|
||||
name = "with_cxx_stdlib",
|
||||
build_setting_default = "best",
|
||||
values = CPP_STDLIBS,
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "api",
|
||||
hdrs = glob(["include/**/*.h"]),
|
||||
defines = select({
|
||||
":with_external_abseil": ["HAVE_ABSEIL"],
|
||||
":set_cxx_stdlib_none": [],
|
||||
### automatic selection
|
||||
":set_cxx_stdlib_best": ["OPENTELEMETRY_STL_VERSION=(__cplusplus/100)"],
|
||||
# See https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus
|
||||
":set_cxx_stdlib_best_and_msvc": ["OPENTELEMETRY_STL_VERSION=(_MSVC_LANG/100)"],
|
||||
### manual selection
|
||||
":set_cxx_stdlib_2014": ["OPENTELEMETRY_STL_VERSION=2014"],
|
||||
":set_cxx_stdlib_2017": ["OPENTELEMETRY_STL_VERSION=2017"],
|
||||
":set_cxx_stdlib_2020": ["OPENTELEMETRY_STL_VERSION=2020"],
|
||||
":set_cxx_stdlib_2023": ["OPENTELEMETRY_STL_VERSION=2023"],
|
||||
"//conditions:default": [],
|
||||
}) + select({
|
||||
":abi_version_no_1": ["OPENTELEMETRY_ABI_VERSION_NO=1"],
|
||||
":abi_version_no_2": ["OPENTELEMETRY_ABI_VERSION_NO=2"],
|
||||
}),
|
||||
strip_include_prefix = "include",
|
||||
tags = ["api"],
|
||||
deps = select({
|
||||
":with_external_abseil": [
|
||||
"@com_google_absl//absl/base",
|
||||
"@com_google_absl//absl/types:variant",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
deps = [
|
||||
"@com_google_absl//absl/base",
|
||||
"@com_google_absl//absl/strings",
|
||||
"@com_google_absl//absl/types:variant",
|
||||
],
|
||||
)
|
||||
|
||||
[config_setting(
|
||||
name = "set_cxx_stdlib_%s" % v,
|
||||
flag_values = {":with_cxx_stdlib": v},
|
||||
) for v in CPP_STDLIBS]
|
||||
|
||||
config_setting(
|
||||
name = "set_cxx_stdlib_best_and_msvc",
|
||||
constraint_values = ["@bazel_tools//tools/cpp:msvc"],
|
||||
flag_values = {":with_cxx_stdlib": "best"},
|
||||
)
|
||||
|
||||
bool_flag(
|
||||
name = "with_abseil",
|
||||
build_setting_default = False,
|
||||
deprecation = "The value of this flag is ignored. Bazel builds always depend on Abseil for its pre-adopted `std::` types. You should remove this flag from your build command.",
|
||||
)
|
||||
|
||||
int_flag(
|
||||
name = "abi_version_no",
|
||||
build_setting_default = 1,
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "with_external_abseil",
|
||||
flag_values = {":with_abseil": "true"},
|
||||
name = "abi_version_no_1",
|
||||
flag_values = {":abi_version_no": "1"},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "abi_version_no_2",
|
||||
flag_values = {":abi_version_no": "2"},
|
||||
)
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
# Release History: opentelemetry-api
|
||||
|
||||
All notable changes to the api project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## Guideline to update the version
|
||||
|
||||
Increment the:
|
||||
|
||||
* MAJOR version when you make incompatible API/ABI changes,
|
||||
* MINOR version when you add functionality in a backwards compatible manner, and
|
||||
* PATCH version when you make backwards compatible bug fixes.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.1.0] 2020-12-17
|
||||
|
||||
### Added
|
||||
|
||||
* Trace API experimental
|
||||
|
||||
### Changed
|
||||
|
||||
### Removed
|
|
@ -1,3 +1,6 @@
|
|||
# Copyright The OpenTelemetry Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
add_library(opentelemetry_api INTERFACE)
|
||||
target_include_directories(
|
||||
opentelemetry_api
|
||||
|
@ -6,88 +9,65 @@ target_include_directories(
|
|||
|
||||
set_target_properties(opentelemetry_api PROPERTIES EXPORT_NAME api)
|
||||
|
||||
install(
|
||||
TARGETS opentelemetry_api
|
||||
EXPORT "${PROJECT_NAME}-target"
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
set(LOGS_EXCLUDE_PATTERN "")
|
||||
if(NOT WITH_LOGS_PREVIEW)
|
||||
set(LOGS_EXCLUDE_PATTERN "logs")
|
||||
endif()
|
||||
|
||||
set(METRICS_EXCLUDE_PATTERN "")
|
||||
if(NOT WITH_METRICS_PREVIEW)
|
||||
set(METRICS_EXCLUDE_PATTERN "metrics")
|
||||
endif()
|
||||
|
||||
install(
|
||||
DIRECTORY include/opentelemetry
|
||||
DESTINATION include
|
||||
FILES_MATCHING
|
||||
PATTERN "*.h"
|
||||
PATTERN "${METRICS_EXCLUDE_PATTERN}" EXCLUDE)
|
||||
|
||||
install(
|
||||
DIRECTORY include/opentelemetry
|
||||
DESTINATION include
|
||||
FILES_MATCHING
|
||||
PATTERN "*.h"
|
||||
PATTERN "${LOGS_EXCLUDE_PATTERN}" EXCLUDE)
|
||||
unset(TARGET_DEPS)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
if(WITH_ABSEIL)
|
||||
|
||||
find_package(absl CONFIG REQUIRED)
|
||||
|
||||
target_compile_definitions(opentelemetry_api INTERFACE HAVE_ABSEIL)
|
||||
target_link_libraries(
|
||||
opentelemetry_api INTERFACE absl::bad_variant_access absl::any absl::base
|
||||
absl::bits absl::city)
|
||||
|
||||
if(WITH_NO_DEPRECATED_CODE)
|
||||
target_compile_definitions(opentelemetry_api
|
||||
INTERFACE OPENTELEMETRY_NO_DEPRECATED_CODE)
|
||||
endif()
|
||||
|
||||
if(WITH_STL)
|
||||
message("Building with standard library types...")
|
||||
target_compile_definitions(opentelemetry_api INTERFACE HAVE_CPP_STDLIB)
|
||||
if(WITH_STL STREQUAL "OFF")
|
||||
message(STATUS "Building WITH_STL=OFF")
|
||||
elseif(WITH_STL STREQUAL "CXX11")
|
||||
message(STATUS "Building WITH_STL=CXX11")
|
||||
target_compile_definitions(opentelemetry_api
|
||||
INTERFACE OPENTELEMETRY_STL_VERSION=2011)
|
||||
elseif(WITH_STL STREQUAL "CXX14")
|
||||
message(STATUS "Building WITH_STL=CXX14")
|
||||
target_compile_definitions(opentelemetry_api
|
||||
INTERFACE OPENTELEMETRY_STL_VERSION=2014)
|
||||
elseif(WITH_STL STREQUAL "CXX17")
|
||||
message(STATUS "Building WITH_STL=CXX17")
|
||||
target_compile_definitions(opentelemetry_api
|
||||
INTERFACE OPENTELEMETRY_STL_VERSION=2017)
|
||||
elseif(WITH_STL STREQUAL "CXX20")
|
||||
message(STATUS "Building WITH_STL=CXX20")
|
||||
target_compile_definitions(opentelemetry_api
|
||||
INTERFACE OPENTELEMETRY_STL_VERSION=2020)
|
||||
elseif(WITH_STL STREQUAL "CXX23")
|
||||
message(STATUS "Building WITH_STL=CXX23")
|
||||
target_compile_definitions(opentelemetry_api
|
||||
INTERFACE OPENTELEMETRY_STL_VERSION=2023)
|
||||
elseif(WITH_STL STREQUAL "CXX26")
|
||||
message(STATUS "Building WITH_STL=CXX26")
|
||||
target_compile_definitions(opentelemetry_api
|
||||
INTERFACE OPENTELEMETRY_STL_VERSION=2026)
|
||||
elseif(WITH_STL STREQUAL "ON")
|
||||
message(STATUS "Building WITH_STL=ON")
|
||||
# "ON" corresponds to "CXX23" at this time.
|
||||
target_compile_definitions(opentelemetry_api
|
||||
INTERFACE OPENTELEMETRY_STL_VERSION=2023)
|
||||
else()
|
||||
message("Building with nostd types...")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"WITH_STL must be ON, OFF, CXX11, CXX14, CXX17, CXX20, CXX23 or CXX26")
|
||||
endif()
|
||||
|
||||
if(WITH_GSL)
|
||||
target_compile_definitions(opentelemetry_api INTERFACE HAVE_GSL)
|
||||
|
||||
# Guidelines Support Library path. Used if we are not on not get C++20.
|
||||
#
|
||||
find_package(Microsoft.GSL QUIET)
|
||||
if(TARGET Microsoft.GSL::GSL)
|
||||
target_link_libraries(opentelemetry_api INTERFACE Microsoft.GSL::GSL)
|
||||
else()
|
||||
set(GSL_DIR third_party/ms-gsl)
|
||||
target_include_directories(
|
||||
opentelemetry_api INTERFACE "$<BUILD_INTERFACE:${GSL_DIR}/include>")
|
||||
endif()
|
||||
target_link_libraries(opentelemetry_api INTERFACE Microsoft.GSL::GSL)
|
||||
list(APPEND TARGET_DEPS "gsl")
|
||||
endif()
|
||||
|
||||
if(WITH_METRICS_PREVIEW)
|
||||
target_compile_definitions(opentelemetry_api INTERFACE ENABLE_METRICS_PREVIEW)
|
||||
endif()
|
||||
|
||||
if(WITH_LOGS_PREVIEW)
|
||||
target_compile_definitions(opentelemetry_api INTERFACE ENABLE_LOGS_PREVIEW)
|
||||
endif()
|
||||
|
||||
if(WITH_NO_GENENV)
|
||||
if(WITH_NO_GETENV)
|
||||
target_compile_definitions(opentelemetry_api INTERFACE NO_GETENV)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
target_compile_definitions(opentelemetry_api INTERFACE NOMINMAX)
|
||||
if(WITH_ETW)
|
||||
target_compile_definitions(opentelemetry_api INTERFACE HAVE_MSGPACK)
|
||||
endif()
|
||||
|
@ -97,7 +77,62 @@ if(WITH_ASYNC_EXPORT_PREVIEW)
|
|||
target_compile_definitions(opentelemetry_api INTERFACE ENABLE_ASYNC_EXPORT)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(
|
||||
opentelemetry_api
|
||||
INTERFACE OPENTELEMETRY_ABI_VERSION_NO=${OPENTELEMETRY_ABI_VERSION_NO})
|
||||
|
||||
if(WITH_OTLP_RETRY_PREVIEW)
|
||||
target_compile_definitions(opentelemetry_api
|
||||
INTERFACE ENABLE_OTLP_RETRY_PREVIEW)
|
||||
endif()
|
||||
|
||||
if(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW)
|
||||
target_compile_definitions(opentelemetry_api
|
||||
INTERFACE ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW)
|
||||
endif()
|
||||
|
||||
if(WITH_OTLP_GRPC_CREDENTIAL_PREVIEW)
|
||||
target_compile_definitions(opentelemetry_api
|
||||
INTERFACE ENABLE_OTLP_GRPC_CREDENTIAL_PREVIEW)
|
||||
endif()
|
||||
|
||||
if(WITH_METRICS_EXEMPLAR_PREVIEW)
|
||||
target_compile_definitions(opentelemetry_api
|
||||
INTERFACE ENABLE_METRICS_EXEMPLAR_PREVIEW)
|
||||
endif()
|
||||
|
||||
if(WITH_THREAD_INSTRUMENTATION_PREVIEW)
|
||||
target_compile_definitions(opentelemetry_api
|
||||
INTERFACE ENABLE_THREAD_INSTRUMENTATION_PREVIEW)
|
||||
endif()
|
||||
|
||||
if(WITH_OTLP_HTTP_COMPRESSION)
|
||||
target_compile_definitions(opentelemetry_api
|
||||
INTERFACE ENABLE_OTLP_COMPRESSION_PREVIEW)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
target_link_libraries(opentelemetry_api INTERFACE "-framework CoreFoundation")
|
||||
endif()
|
||||
|
||||
otel_add_component(
|
||||
COMPONENT
|
||||
api
|
||||
TARGETS
|
||||
opentelemetry_api
|
||||
FILES_DIRECTORY
|
||||
"include/opentelemetry"
|
||||
FILES_DESTINATION
|
||||
"include"
|
||||
FILES_MATCHING
|
||||
PATTERN
|
||||
"*.h")
|
||||
|
||||
include(${PROJECT_SOURCE_DIR}/cmake/pkgconfig.cmake)
|
||||
|
||||
if(OPENTELEMETRY_INSTALL)
|
||||
opentelemetry_add_pkgconfig(
|
||||
api "OpenTelemetry API"
|
||||
"A header-only library to support instrumentation with OpenTelemetry."
|
||||
"${TARGET_DEPS}")
|
||||
endif()
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifdef ENABLE_METRICS_PREVIEW
|
||||
|
||||
# include "opentelemetry/_metrics/instrument.h"
|
||||
# include "opentelemetry/_metrics/observer_result.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace metrics
|
||||
{
|
||||
|
||||
template <class T>
|
||||
class ValueObserver : virtual public AsynchronousInstrument<T>
|
||||
{
|
||||
|
||||
public:
|
||||
ValueObserver() = default;
|
||||
|
||||
ValueObserver(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
bool enabled,
|
||||
void (*callback)(ObserverResult<T>))
|
||||
{}
|
||||
|
||||
/*
|
||||
* Updates the instruments aggregator with the new value. The labels should
|
||||
* contain the keys and values to be associated with this value.
|
||||
*
|
||||
* @param value is the numerical representation of the metric being captured
|
||||
* @param labels the set of labels, as key-value pairs
|
||||
*/
|
||||
virtual void observe(T value, const common::KeyValueIterable &labels) override = 0;
|
||||
|
||||
/**
|
||||
* Captures data by activating the callback function associated with the
|
||||
* instrument and storing its return value. Callbacks for asynchronous
|
||||
* instruments are defined during construction.
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*/
|
||||
virtual void run() override = 0;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class SumObserver : virtual public AsynchronousInstrument<T>
|
||||
{
|
||||
|
||||
public:
|
||||
SumObserver() = default;
|
||||
|
||||
SumObserver(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
bool enabled,
|
||||
void (*callback)(ObserverResult<T>))
|
||||
{}
|
||||
|
||||
virtual void observe(T value, const common::KeyValueIterable &labels) override = 0;
|
||||
|
||||
virtual void run() override = 0;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class UpDownSumObserver : virtual public AsynchronousInstrument<T>
|
||||
{
|
||||
|
||||
public:
|
||||
UpDownSumObserver() = default;
|
||||
|
||||
UpDownSumObserver(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
bool enabled,
|
||||
void (*callback)(ObserverResult<T>))
|
||||
{}
|
||||
|
||||
virtual void observe(T value, const common::KeyValueIterable &labels) override = 0;
|
||||
|
||||
virtual void run() override = 0;
|
||||
};
|
||||
|
||||
} // namespace metrics
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
|
@ -1,209 +0,0 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifdef ENABLE_METRICS_PREVIEW
|
||||
|
||||
# include <iostream>
|
||||
# include "opentelemetry/common/attribute_value.h"
|
||||
# include "opentelemetry/common/key_value_iterable_view.h"
|
||||
# include "opentelemetry/nostd/shared_ptr.h"
|
||||
# include "opentelemetry/nostd/string_view.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace metrics
|
||||
{
|
||||
|
||||
// Enum classes to help determine instrument types in other parts of the API
|
||||
enum class InstrumentKind
|
||||
{
|
||||
Counter = 0,
|
||||
UpDownCounter = 1,
|
||||
ValueRecorder = 2,
|
||||
ValueObserver = 3,
|
||||
SumObserver = 4,
|
||||
UpDownSumObserver = 5,
|
||||
};
|
||||
|
||||
class Instrument
|
||||
{
|
||||
|
||||
public:
|
||||
// Note that Instruments should be created using the Meter class.
|
||||
// Please refer to meter.h for documentation.
|
||||
Instrument() = default;
|
||||
|
||||
/**
|
||||
* Base class constructor for all other instrument types. Whether or not
|
||||
* an instrument is synchronous or bound, it requires a name, description,
|
||||
* unit, and enabled flag.
|
||||
*
|
||||
* @param name is the identifier of the instrumenting library
|
||||
* @param description explains what the metric captures
|
||||
* @param unit specifies the data type held in the instrument
|
||||
* @param enabled determines if the metric is currently capturing data
|
||||
* @return Instrument type with the specified attributes
|
||||
*/
|
||||
Instrument(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
bool enabled)
|
||||
{}
|
||||
|
||||
// Returns true if the instrument is enabled and collecting data
|
||||
virtual bool IsEnabled() = 0;
|
||||
|
||||
// Return the instrument name
|
||||
virtual nostd::string_view GetName() = 0;
|
||||
|
||||
// Return the instrument description
|
||||
virtual nostd::string_view GetDescription() = 0;
|
||||
|
||||
// Return the insrument's units of measurement
|
||||
virtual nostd::string_view GetUnits() = 0;
|
||||
|
||||
// Return the intrument's kind
|
||||
virtual InstrumentKind GetKind() = 0;
|
||||
|
||||
virtual ~Instrument() = default;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class BoundSynchronousInstrument : virtual public Instrument
|
||||
{
|
||||
|
||||
public:
|
||||
BoundSynchronousInstrument() = default;
|
||||
|
||||
BoundSynchronousInstrument(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
bool enabled);
|
||||
|
||||
/**
|
||||
* Frees the resources associated with this Bound Instrument.
|
||||
* The Metric from which this instrument was created is not impacted.
|
||||
*
|
||||
* @param none
|
||||
* @return void
|
||||
*/
|
||||
virtual void unbind() {}
|
||||
|
||||
/**
|
||||
* Incremements the reference count of this bound object when a new instance is
|
||||
* either created or the same instance is returned as a result of binding
|
||||
*
|
||||
* @param none
|
||||
* @return void
|
||||
*/
|
||||
virtual void inc_ref() {}
|
||||
|
||||
/**
|
||||
* Return the object's current reference count. This information is used to remove
|
||||
* stale objects from instrument registries.
|
||||
*/
|
||||
virtual int get_ref() { return 0; }
|
||||
|
||||
/**
|
||||
* Records a single synchronous metric event; a call to the aggregator
|
||||
* Since this is a bound synchronous instrument, labels are not required in * metric capture
|
||||
* calls.
|
||||
*
|
||||
* @param value is the numerical representation of the metric being captured
|
||||
* @return void
|
||||
*/
|
||||
virtual void update(T value) {}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class SynchronousInstrument : virtual public Instrument
|
||||
{
|
||||
|
||||
public:
|
||||
SynchronousInstrument() = default;
|
||||
|
||||
SynchronousInstrument(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
bool enabled)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Returns a Bound Instrument associated with the specified labels. * Multiples requests
|
||||
* with the same set of labels may return the same Bound Instrument instance.
|
||||
*
|
||||
* It is recommended that callers keep a reference to the Bound Instrument
|
||||
* instead of repeatedly calling this operation.
|
||||
*
|
||||
* @param labels the set of labels, as key-value pairs
|
||||
* @return a Bound Instrument
|
||||
*/
|
||||
virtual nostd::shared_ptr<BoundSynchronousInstrument<T>> bind(
|
||||
const common::KeyValueIterable &labels)
|
||||
{
|
||||
return nostd::shared_ptr<BoundSynchronousInstrument<T>>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Records a single synchronous metric event.
|
||||
* Since this is an unbound synchronous instrument, labels are required in * metric capture
|
||||
* calls.
|
||||
*
|
||||
* update can be used in instruments with both add or record since it simply
|
||||
* activated the aggregator
|
||||
*
|
||||
* @param labels the set of labels, as key-value pairs
|
||||
* @param value is the numerical representation of the metric being captured
|
||||
* @return void
|
||||
*/
|
||||
virtual void update(T value, const common::KeyValueIterable &labels) = 0;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class ObserverResult;
|
||||
|
||||
template <class T>
|
||||
class AsynchronousInstrument : virtual public Instrument
|
||||
{
|
||||
|
||||
public:
|
||||
AsynchronousInstrument() = default;
|
||||
|
||||
AsynchronousInstrument(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
bool enabled,
|
||||
void(callback)(ObserverResult<T>))
|
||||
{}
|
||||
|
||||
/**
|
||||
* Captures data through a manual call rather than the automatic collection process instituted
|
||||
* in the run function. Asynchronous instruments are generally expected to obtain data from
|
||||
* their callbacks rather than direct calls. This function is used by the callback to store data.
|
||||
*
|
||||
* @param value is the numerical representation of the metric being captured
|
||||
* @param labels is the numerical representation of the metric being captured
|
||||
* @return none
|
||||
*/
|
||||
virtual void observe(T value, const common::KeyValueIterable &labels) = 0;
|
||||
|
||||
/**
|
||||
* Captures data by activating the callback function associated with the
|
||||
* instrument and storing its return value. Callbacks for asynchronous
|
||||
* instruments are defined during construction.
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*/
|
||||
virtual void run() = 0;
|
||||
|
||||
protected:
|
||||
// Callback function which takes a pointer to an Asynchronous instrument (this) type which is
|
||||
// stored in an observer result type and returns nothing. This function calls the instrument's
|
||||
// observe.
|
||||
void (*callback_)(ObserverResult<T>);
|
||||
};
|
||||
|
||||
} // namespace metrics
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
|
@ -1,288 +0,0 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifdef ENABLE_METRICS_PREVIEW
|
||||
|
||||
# include "opentelemetry/_metrics/async_instruments.h"
|
||||
# include "opentelemetry/_metrics/instrument.h"
|
||||
# include "opentelemetry/_metrics/sync_instruments.h"
|
||||
# include "opentelemetry/nostd/shared_ptr.h"
|
||||
# include "opentelemetry/nostd/span.h"
|
||||
# include "opentelemetry/nostd/string_view.h"
|
||||
# include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace metrics
|
||||
{
|
||||
/**
|
||||
* Handles instrument creation and provides a facility for batch recording.
|
||||
*
|
||||
* This class provides methods to create new metric instruments, record a
|
||||
* batch of values to a specified set of instruments, and collect
|
||||
* measurements from all instruments.
|
||||
*
|
||||
*/
|
||||
class Meter
|
||||
{
|
||||
public:
|
||||
virtual ~Meter() = default;
|
||||
|
||||
/**
|
||||
* Creates a Counter with the passed characteristics and returns a shared_ptr to that Counter.
|
||||
*
|
||||
* @param name the name of the new Counter.
|
||||
* @param description a brief description of what the Counter is used for.
|
||||
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
|
||||
* @param enabled a boolean value that turns on or off the metric instrument.
|
||||
* @return a shared pointer to the created Counter.
|
||||
* @throws NullPointerException if {@code name} is null
|
||||
* @throws IllegalArgumentException if a different metric by the same name exists in this meter.
|
||||
* @throws IllegalArgumentException if the {@code name} does not match spec requirements.
|
||||
*/
|
||||
virtual nostd::shared_ptr<Counter<short>> NewShortCounter(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<Counter<int>> NewIntCounter(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<Counter<float>> NewFloatCounter(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<Counter<double>> NewDoubleCounter(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) = 0;
|
||||
|
||||
/**
|
||||
* Creates an UpDownCounter with the passed characteristics and returns a shared_ptr to that
|
||||
* UpDownCounter.
|
||||
*
|
||||
* @param name the name of the new UpDownCounter.
|
||||
* @param description a brief description of what the UpDownCounter is used for.
|
||||
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
|
||||
* @param enabled a boolean value that turns on or off the metric instrument.
|
||||
* @return a shared pointer to the created UpDownCounter.
|
||||
* @throws NullPointerException if {@code name} is null
|
||||
* @throws IllegalArgumentException if a different metric by the same name exists in this meter.
|
||||
* @throws IllegalArgumentException if the {@code name} does not match spec requirements.
|
||||
*/
|
||||
virtual nostd::shared_ptr<UpDownCounter<short>> NewShortUpDownCounter(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<UpDownCounter<int>> NewIntUpDownCounter(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<UpDownCounter<float>> NewFloatUpDownCounter(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<UpDownCounter<double>> NewDoubleUpDownCounter(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) = 0;
|
||||
|
||||
/**
|
||||
* Creates a ValueRecorder with the passed characteristics and returns a shared_ptr to that
|
||||
* ValueRecorder.
|
||||
*
|
||||
* @param name the name of the new ValueRecorder.
|
||||
* @param description a brief description of what the ValueRecorder is used for.
|
||||
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
|
||||
* @param enabled a boolean value that turns on or off the metric instrument.
|
||||
* @return a shared pointer to the created DoubleValueRecorder.
|
||||
* @throws NullPointerException if {@code name} is null
|
||||
* @throws IllegalArgumentException if a different metric by the same name exists in this meter.
|
||||
* @throws IllegalArgumentException if the {@code name} does not match spec requirements.
|
||||
*/
|
||||
virtual nostd::shared_ptr<ValueRecorder<short>> NewShortValueRecorder(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<ValueRecorder<int>> NewIntValueRecorder(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<ValueRecorder<float>> NewFloatValueRecorder(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<ValueRecorder<double>> NewDoubleValueRecorder(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) = 0;
|
||||
|
||||
/**
|
||||
* Creates a SumObserver with the passed characteristics and returns a shared_ptr to that
|
||||
* SumObserver.
|
||||
*
|
||||
* @param name the name of the new SumObserver.
|
||||
* @param description a brief description of what the SumObserver is used for.
|
||||
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
|
||||
* @param enabled a boolean value that turns on or off the metric instrument.
|
||||
* @param callback the function to be observed by the instrument.
|
||||
* @return a shared pointer to the created SumObserver.
|
||||
* @throws NullPointerException if {@code name} is null
|
||||
* @throws IllegalArgumentException if a different metric by the same name exists in this meter.
|
||||
* @throws IllegalArgumentException if the {@code name} does not match spec requirements.
|
||||
*/
|
||||
virtual nostd::shared_ptr<SumObserver<short>> NewShortSumObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<short>)) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<SumObserver<int>> NewIntSumObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<int>)) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<SumObserver<float>> NewFloatSumObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<float>)) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<SumObserver<double>> NewDoubleSumObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<double>)) = 0;
|
||||
|
||||
/**
|
||||
* Creates an UpDownSumObserver with the passed characteristics and returns a shared_ptr to
|
||||
* that UpDowNSumObserver.
|
||||
*
|
||||
* @param name the name of the new UpDownSumObserver.
|
||||
* @param description a brief description of what the UpDownSumObserver is used for.
|
||||
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
|
||||
* @param enabled a boolean value that turns on or off the metric instrument.
|
||||
* @param callback the function to be observed by the instrument.
|
||||
* @return a shared pointer to the created UpDownSumObserver.
|
||||
* @throws NullPointerException if {@code name} is null
|
||||
* @throws IllegalArgumentException if a different metric by the same name exists in this meter.
|
||||
* @throws IllegalArgumentException if the {@code name} does not match spec requirements.
|
||||
*/
|
||||
virtual nostd::shared_ptr<UpDownSumObserver<short>> NewShortUpDownSumObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<short>)) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<UpDownSumObserver<int>> NewIntUpDownSumObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<int>)) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<UpDownSumObserver<float>> NewFloatUpDownSumObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<float>)) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<UpDownSumObserver<double>> NewDoubleUpDownSumObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<double>)) = 0;
|
||||
|
||||
/**
|
||||
* Creates a ValueObserver with the passed characteristics and returns a shared_ptr to that
|
||||
* ValueObserver.
|
||||
*
|
||||
* @param name the name of the new ValueObserver.
|
||||
* @param description a brief description of what the ValueObserver is used for.
|
||||
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
|
||||
* @param enabled a boolean value that turns on or off the metric instrument.
|
||||
* @param callback the function to be observed by the instrument.
|
||||
* @return a shared pointer to the created ValueObserver.
|
||||
* @throws NullPointerException if {@code name} is null
|
||||
* @throws IllegalArgumentException if a different metric by the same name exists in this meter.
|
||||
* @throws IllegalArgumentException if the {@code name} does not match spec requirements.
|
||||
*/
|
||||
virtual nostd::shared_ptr<ValueObserver<short>> NewShortValueObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<short>)) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<ValueObserver<int>> NewIntValueObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<int>)) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<ValueObserver<float>> NewFloatValueObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<float>)) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<ValueObserver<double>> NewDoubleValueObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<double>)) = 0;
|
||||
|
||||
/**
|
||||
* Utility method that allows users to atomically record measurements to a set of
|
||||
* synchronous metric instruments with a common set of labels.
|
||||
*
|
||||
* @param labels the set of labels to associate with this recorder.
|
||||
* @param instruments a span of pointers to the instruments to record to.
|
||||
* @param values a span of values to record to the instruments in the corresponding
|
||||
* position in the instruments span.
|
||||
*/
|
||||
virtual void RecordShortBatch(const common::KeyValueIterable &labels,
|
||||
nostd::span<SynchronousInstrument<short> *> instruments,
|
||||
nostd::span<const short> values) noexcept = 0;
|
||||
|
||||
virtual void RecordIntBatch(const common::KeyValueIterable &labels,
|
||||
nostd::span<SynchronousInstrument<int> *> instruments,
|
||||
nostd::span<const int> values) noexcept = 0;
|
||||
|
||||
virtual void RecordFloatBatch(const common::KeyValueIterable &labels,
|
||||
nostd::span<SynchronousInstrument<float> *> instruments,
|
||||
nostd::span<const float> values) noexcept = 0;
|
||||
|
||||
virtual void RecordDoubleBatch(const common::KeyValueIterable &labels,
|
||||
nostd::span<SynchronousInstrument<double> *> instruments,
|
||||
nostd::span<const double> values) noexcept = 0;
|
||||
};
|
||||
} // namespace metrics
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
|
@ -1,32 +0,0 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifdef ENABLE_METRICS_PREVIEW
|
||||
|
||||
# include "opentelemetry/_metrics/meter.h"
|
||||
# include "opentelemetry/nostd/shared_ptr.h"
|
||||
# include "opentelemetry/nostd/string_view.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace metrics
|
||||
{
|
||||
/**
|
||||
* Creates new Meter instances.
|
||||
*/
|
||||
class MeterProvider
|
||||
{
|
||||
public:
|
||||
virtual ~MeterProvider() = default;
|
||||
/**
|
||||
* Gets or creates a named Meter instance.
|
||||
*
|
||||
* Optionally a version can be passed to create a named and versioned Meter
|
||||
* instance.
|
||||
*/
|
||||
virtual nostd::shared_ptr<Meter> GetMeter(nostd::string_view library_name,
|
||||
nostd::string_view library_version = "") = 0;
|
||||
};
|
||||
} // namespace metrics
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
|
@ -1,654 +0,0 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifdef ENABLE_METRICS_PREVIEW
|
||||
// Please refer to provider.h for documentation on how to obtain a Meter object.
|
||||
//
|
||||
// This file is part of the internal implementation of OpenTelemetry. Nothing in this file should be
|
||||
// used directly. Please refer to meter.h for documentation on these interfaces.
|
||||
|
||||
# include "opentelemetry/_metrics/async_instruments.h"
|
||||
# include "opentelemetry/_metrics/instrument.h"
|
||||
# include "opentelemetry/_metrics/meter.h"
|
||||
# include "opentelemetry/_metrics/meter_provider.h"
|
||||
# include "opentelemetry/_metrics/sync_instruments.h"
|
||||
# include "opentelemetry/nostd/string_view.h"
|
||||
# include "opentelemetry/nostd/unique_ptr.h"
|
||||
# include "opentelemetry/version.h"
|
||||
|
||||
# include <memory>
|
||||
|
||||
// TODO: Create generic short pattern for opentelemetry::common and opentelemetry::trace and others
|
||||
// as necessary
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace metrics
|
||||
{
|
||||
template <class T>
|
||||
class NoopValueObserver : public ValueObserver<T>
|
||||
{
|
||||
|
||||
public:
|
||||
NoopValueObserver(nostd::string_view /*name*/,
|
||||
nostd::string_view /*description*/,
|
||||
nostd::string_view /*unit*/,
|
||||
bool /*enabled*/,
|
||||
void (*callback)(ObserverResult<T>))
|
||||
{}
|
||||
|
||||
virtual bool IsEnabled() override { return false; }
|
||||
|
||||
virtual nostd::string_view GetName() override { return nostd::string_view(""); }
|
||||
|
||||
virtual nostd::string_view GetDescription() override { return nostd::string_view(""); }
|
||||
|
||||
virtual nostd::string_view GetUnits() override { return nostd::string_view(""); }
|
||||
|
||||
virtual void observe(T value, const common::KeyValueIterable &labels) override {}
|
||||
|
||||
virtual void run() override {}
|
||||
|
||||
virtual InstrumentKind GetKind() override { return InstrumentKind::Counter; }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class NoopSumObserver : public SumObserver<T>
|
||||
{
|
||||
|
||||
public:
|
||||
NoopSumObserver(nostd::string_view /*name*/,
|
||||
nostd::string_view /*description*/,
|
||||
nostd::string_view /*unit*/,
|
||||
bool /*enabled*/,
|
||||
void (*callback)(ObserverResult<T>))
|
||||
{}
|
||||
|
||||
virtual bool IsEnabled() override { return false; }
|
||||
|
||||
virtual nostd::string_view GetName() override { return nostd::string_view(""); }
|
||||
|
||||
virtual nostd::string_view GetDescription() override { return nostd::string_view(""); }
|
||||
|
||||
virtual nostd::string_view GetUnits() override { return nostd::string_view(""); }
|
||||
|
||||
virtual void observe(T value, const common::KeyValueIterable &labels) override {}
|
||||
|
||||
virtual void run() override {}
|
||||
|
||||
virtual InstrumentKind GetKind() override { return InstrumentKind::Counter; }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class NoopUpDownSumObserver : public UpDownSumObserver<T>
|
||||
{
|
||||
|
||||
public:
|
||||
NoopUpDownSumObserver(nostd::string_view /*name*/,
|
||||
nostd::string_view /*description*/,
|
||||
nostd::string_view /*unit*/,
|
||||
bool /*enabled*/,
|
||||
void (*callback)(ObserverResult<T>))
|
||||
{}
|
||||
|
||||
virtual bool IsEnabled() override { return false; }
|
||||
|
||||
virtual nostd::string_view GetName() override { return nostd::string_view(""); }
|
||||
|
||||
virtual nostd::string_view GetDescription() override { return nostd::string_view(""); }
|
||||
|
||||
virtual nostd::string_view GetUnits() override { return nostd::string_view(""); }
|
||||
|
||||
virtual void observe(T value, const common::KeyValueIterable &labels) override {}
|
||||
|
||||
virtual void run() override {}
|
||||
|
||||
virtual InstrumentKind GetKind() override { return InstrumentKind::Counter; }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class BoundNoopCounter : public BoundCounter<T>
|
||||
{
|
||||
|
||||
public:
|
||||
BoundNoopCounter() = default;
|
||||
|
||||
BoundNoopCounter(nostd::string_view /*name*/,
|
||||
nostd::string_view /*description*/,
|
||||
nostd::string_view /*unit*/,
|
||||
bool /*enabled*/)
|
||||
{}
|
||||
|
||||
virtual void add(T value) override {}
|
||||
|
||||
virtual bool IsEnabled() override { return false; }
|
||||
|
||||
virtual nostd::string_view GetName() override { return nostd::string_view(""); }
|
||||
|
||||
virtual nostd::string_view GetDescription() override { return nostd::string_view(""); }
|
||||
|
||||
virtual nostd::string_view GetUnits() override { return nostd::string_view(""); }
|
||||
|
||||
virtual InstrumentKind GetKind() override { return InstrumentKind::Counter; }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class NoopCounter : public Counter<T>
|
||||
{
|
||||
|
||||
public:
|
||||
NoopCounter() = default;
|
||||
|
||||
NoopCounter(nostd::string_view /*name*/,
|
||||
nostd::string_view /*description*/,
|
||||
nostd::string_view /*unit*/,
|
||||
bool /*enabled*/)
|
||||
{}
|
||||
|
||||
nostd::shared_ptr<BoundNoopCounter<T>> bindNoopCounter(
|
||||
const common::KeyValueIterable & /*labels*/)
|
||||
{
|
||||
return nostd::shared_ptr<BoundNoopCounter<T>>(new BoundNoopCounter<T>());
|
||||
}
|
||||
|
||||
virtual void add(T value, const common::KeyValueIterable & /*labels*/) override {}
|
||||
|
||||
virtual void update(T value, const common::KeyValueIterable & /*labels*/) override {}
|
||||
|
||||
virtual bool IsEnabled() override { return false; }
|
||||
|
||||
virtual nostd::string_view GetName() override { return nostd::string_view(""); }
|
||||
|
||||
virtual nostd::string_view GetDescription() override { return nostd::string_view(""); }
|
||||
|
||||
virtual nostd::string_view GetUnits() override { return nostd::string_view(""); }
|
||||
|
||||
virtual InstrumentKind GetKind() override { return InstrumentKind::Counter; }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class BoundNoopUpDownCounter : public BoundUpDownCounter<T>
|
||||
{
|
||||
|
||||
public:
|
||||
BoundNoopUpDownCounter() = default;
|
||||
|
||||
BoundNoopUpDownCounter(nostd::string_view /*name*/,
|
||||
nostd::string_view /*description*/,
|
||||
nostd::string_view /*unit*/,
|
||||
bool /*enabled*/)
|
||||
{}
|
||||
|
||||
virtual void add(T value) override {}
|
||||
|
||||
virtual bool IsEnabled() override { return false; }
|
||||
|
||||
virtual nostd::string_view GetName() override { return nostd::string_view(""); }
|
||||
|
||||
virtual nostd::string_view GetDescription() override { return nostd::string_view(""); }
|
||||
|
||||
virtual nostd::string_view GetUnits() override { return nostd::string_view(""); }
|
||||
|
||||
virtual InstrumentKind GetKind() override { return InstrumentKind::UpDownCounter; }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class NoopUpDownCounter : public UpDownCounter<T>
|
||||
{
|
||||
|
||||
public:
|
||||
NoopUpDownCounter() = default;
|
||||
|
||||
NoopUpDownCounter(nostd::string_view /*name*/,
|
||||
nostd::string_view /*description*/,
|
||||
nostd::string_view /*unit*/,
|
||||
bool /*enabled*/)
|
||||
{}
|
||||
|
||||
nostd::shared_ptr<BoundNoopUpDownCounter<T>> bindNoopUpDownCounter(
|
||||
const common::KeyValueIterable & /*labels*/)
|
||||
{
|
||||
return nostd::shared_ptr<BoundNoopUpDownCounter<T>>(new BoundNoopUpDownCounter<T>());
|
||||
}
|
||||
|
||||
virtual void add(T value, const common::KeyValueIterable & /*labels*/) override {}
|
||||
|
||||
virtual void update(T value, const common::KeyValueIterable & /*labels*/) override {}
|
||||
|
||||
virtual bool IsEnabled() override { return false; }
|
||||
|
||||
virtual nostd::string_view GetName() override { return nostd::string_view(""); }
|
||||
|
||||
virtual nostd::string_view GetDescription() override { return nostd::string_view(""); }
|
||||
|
||||
virtual nostd::string_view GetUnits() override { return nostd::string_view(""); }
|
||||
|
||||
virtual InstrumentKind GetKind() override { return InstrumentKind::UpDownCounter; }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class BoundNoopValueRecorder : public BoundValueRecorder<T>
|
||||
{
|
||||
|
||||
public:
|
||||
BoundNoopValueRecorder() = default;
|
||||
|
||||
BoundNoopValueRecorder(nostd::string_view /*name*/,
|
||||
nostd::string_view /*description*/,
|
||||
nostd::string_view /*unit*/,
|
||||
bool /*enabled*/)
|
||||
{}
|
||||
|
||||
virtual void record(T value) override {}
|
||||
|
||||
virtual bool IsEnabled() override { return false; }
|
||||
|
||||
virtual nostd::string_view GetName() override { return nostd::string_view(""); }
|
||||
|
||||
virtual nostd::string_view GetDescription() override { return nostd::string_view(""); }
|
||||
|
||||
virtual nostd::string_view GetUnits() override { return nostd::string_view(""); }
|
||||
|
||||
virtual InstrumentKind GetKind() override { return InstrumentKind::ValueRecorder; }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class NoopValueRecorder : public ValueRecorder<T>
|
||||
{
|
||||
|
||||
public:
|
||||
NoopValueRecorder() = default;
|
||||
|
||||
NoopValueRecorder(nostd::string_view /*name*/,
|
||||
nostd::string_view /*description*/,
|
||||
nostd::string_view /*unit*/,
|
||||
bool /*enabled*/)
|
||||
{}
|
||||
|
||||
nostd::shared_ptr<BoundNoopValueRecorder<T>> bindNoopValueRecorder(
|
||||
const common::KeyValueIterable & /*labels*/)
|
||||
{
|
||||
return nostd::shared_ptr<BoundNoopValueRecorder<T>>(new BoundNoopValueRecorder<T>());
|
||||
}
|
||||
|
||||
virtual void record(T value, const common::KeyValueIterable & /*labels*/) override {}
|
||||
|
||||
virtual void update(T value, const common::KeyValueIterable & /*labels*/) override {}
|
||||
|
||||
virtual bool IsEnabled() override { return false; }
|
||||
|
||||
virtual nostd::string_view GetName() override { return nostd::string_view(""); }
|
||||
|
||||
virtual nostd::string_view GetDescription() override { return nostd::string_view(""); }
|
||||
|
||||
virtual nostd::string_view GetUnits() override { return nostd::string_view(""); }
|
||||
|
||||
virtual InstrumentKind GetKind() override { return InstrumentKind::ValueRecorder; }
|
||||
};
|
||||
|
||||
/**
|
||||
* No-op implementation of Meter. This class should not be used directly.
|
||||
*/
|
||||
class NoopMeter : public Meter
|
||||
{
|
||||
public:
|
||||
NoopMeter() = default;
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates a new NoopCounter<T> and returns a shared ptr to that counter.
|
||||
*
|
||||
* @param name the name of the instrument.
|
||||
* @param description a brief description of the instrument.
|
||||
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
|
||||
* @param enabled a boolean that turns the metric instrument on and off.
|
||||
* @return
|
||||
*/
|
||||
nostd::shared_ptr<Counter<short>> NewShortCounter(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) override
|
||||
{
|
||||
return nostd::shared_ptr<Counter<short>>{
|
||||
new NoopCounter<short>(name, description, unit, enabled)};
|
||||
}
|
||||
|
||||
nostd::shared_ptr<Counter<int>> NewIntCounter(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) override
|
||||
{
|
||||
return nostd::shared_ptr<Counter<int>>{new NoopCounter<int>(name, description, unit, enabled)};
|
||||
}
|
||||
|
||||
nostd::shared_ptr<Counter<float>> NewFloatCounter(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) override
|
||||
{
|
||||
return nostd::shared_ptr<Counter<float>>{
|
||||
new NoopCounter<float>(name, description, unit, enabled)};
|
||||
}
|
||||
|
||||
nostd::shared_ptr<Counter<double>> NewDoubleCounter(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) override
|
||||
{
|
||||
return nostd::shared_ptr<Counter<double>>{
|
||||
new NoopCounter<double>(name, description, unit, enabled)};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates a new NoopCounter<T> and returns a shared ptr to that counter.
|
||||
*
|
||||
* @param name the name of the instrument.
|
||||
* @param description a brief description of the instrument.
|
||||
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
|
||||
* @param enabled a boolean that turns the metric instrument on and off.
|
||||
* @return
|
||||
*/
|
||||
nostd::shared_ptr<UpDownCounter<short>> NewShortUpDownCounter(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) override
|
||||
{
|
||||
return nostd::shared_ptr<UpDownCounter<short>>{
|
||||
new NoopUpDownCounter<short>(name, description, unit, enabled)};
|
||||
}
|
||||
|
||||
nostd::shared_ptr<UpDownCounter<int>> NewIntUpDownCounter(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) override
|
||||
{
|
||||
return nostd::shared_ptr<UpDownCounter<int>>{
|
||||
new NoopUpDownCounter<int>(name, description, unit, enabled)};
|
||||
}
|
||||
|
||||
nostd::shared_ptr<UpDownCounter<float>> NewFloatUpDownCounter(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) override
|
||||
{
|
||||
return nostd::shared_ptr<UpDownCounter<float>>{
|
||||
new NoopUpDownCounter<float>(name, description, unit, enabled)};
|
||||
}
|
||||
|
||||
nostd::shared_ptr<UpDownCounter<double>> NewDoubleUpDownCounter(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) override
|
||||
{
|
||||
return nostd::shared_ptr<UpDownCounter<double>>{
|
||||
new NoopUpDownCounter<double>(name, description, unit, enabled)};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates a new ValueRecorder<T> and returns a shared ptr to that counter.
|
||||
*
|
||||
* @param name the name of the instrument.
|
||||
* @param description a brief description of the instrument.
|
||||
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
|
||||
* @param enabled a boolean that turns the metric instrument on and off.
|
||||
* @return
|
||||
*/
|
||||
nostd::shared_ptr<ValueRecorder<short>> NewShortValueRecorder(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) override
|
||||
{
|
||||
return nostd::shared_ptr<ValueRecorder<short>>{
|
||||
new NoopValueRecorder<short>(name, description, unit, enabled)};
|
||||
}
|
||||
|
||||
nostd::shared_ptr<ValueRecorder<int>> NewIntValueRecorder(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) override
|
||||
{
|
||||
return nostd::shared_ptr<ValueRecorder<int>>{
|
||||
new NoopValueRecorder<int>(name, description, unit, enabled)};
|
||||
}
|
||||
|
||||
nostd::shared_ptr<ValueRecorder<float>> NewFloatValueRecorder(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) override
|
||||
{
|
||||
return nostd::shared_ptr<ValueRecorder<float>>{
|
||||
new NoopValueRecorder<float>(name, description, unit, enabled)};
|
||||
}
|
||||
|
||||
nostd::shared_ptr<ValueRecorder<double>> NewDoubleValueRecorder(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled) override
|
||||
{
|
||||
return nostd::shared_ptr<ValueRecorder<double>>{
|
||||
new NoopValueRecorder<double>(name, description, unit, enabled)};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates a new SumObserver<T> and returns a shared ptr to that counter.
|
||||
*
|
||||
* @param name the name of the instrument.
|
||||
* @param description a brief description of the instrument.
|
||||
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
|
||||
* @param enabled a boolean that turns the metric instrument on and off.
|
||||
* @return
|
||||
*/
|
||||
nostd::shared_ptr<SumObserver<short>> NewShortSumObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<short>)) override
|
||||
{
|
||||
return nostd::shared_ptr<SumObserver<short>>{
|
||||
new NoopSumObserver<short>(name, description, unit, enabled, callback)};
|
||||
}
|
||||
|
||||
nostd::shared_ptr<SumObserver<int>> NewIntSumObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<int>)) override
|
||||
{
|
||||
return nostd::shared_ptr<SumObserver<int>>{
|
||||
new NoopSumObserver<int>(name, description, unit, enabled, callback)};
|
||||
}
|
||||
|
||||
nostd::shared_ptr<SumObserver<float>> NewFloatSumObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<float>)) override
|
||||
{
|
||||
return nostd::shared_ptr<SumObserver<float>>{
|
||||
new NoopSumObserver<float>(name, description, unit, enabled, callback)};
|
||||
}
|
||||
|
||||
nostd::shared_ptr<SumObserver<double>> NewDoubleSumObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<double>)) override
|
||||
{
|
||||
return nostd::shared_ptr<SumObserver<double>>{
|
||||
new NoopSumObserver<double>(name, description, unit, enabled, callback)};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates a new UpDownSumObserver<T> and returns a shared ptr to that counter.
|
||||
*
|
||||
* @param name the name of the instrument.
|
||||
* @param description a brief description of the instrument.
|
||||
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
|
||||
* @param enabled a boolean that turns the metric instrument on and off.
|
||||
* @return
|
||||
*/
|
||||
nostd::shared_ptr<UpDownSumObserver<short>> NewShortUpDownSumObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<short>)) override
|
||||
{
|
||||
return nostd::shared_ptr<UpDownSumObserver<short>>{
|
||||
new NoopUpDownSumObserver<short>(name, description, unit, enabled, callback)};
|
||||
}
|
||||
|
||||
nostd::shared_ptr<UpDownSumObserver<int>> NewIntUpDownSumObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<int>)) override
|
||||
{
|
||||
return nostd::shared_ptr<UpDownSumObserver<int>>{
|
||||
new NoopUpDownSumObserver<int>(name, description, unit, enabled, callback)};
|
||||
}
|
||||
|
||||
nostd::shared_ptr<UpDownSumObserver<float>> NewFloatUpDownSumObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<float>)) override
|
||||
{
|
||||
return nostd::shared_ptr<UpDownSumObserver<float>>{
|
||||
new NoopUpDownSumObserver<float>(name, description, unit, enabled, callback)};
|
||||
}
|
||||
|
||||
nostd::shared_ptr<UpDownSumObserver<double>> NewDoubleUpDownSumObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<double>)) override
|
||||
{
|
||||
return nostd::shared_ptr<UpDownSumObserver<double>>{
|
||||
new NoopUpDownSumObserver<double>(name, description, unit, enabled, callback)};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates a new ValueObserverObserver<T> and returns a shared ptr to that counter.
|
||||
*
|
||||
* @param name the name of the instrument.
|
||||
* @param description a brief description of the instrument.
|
||||
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
|
||||
* @param enabled a boolean that turns the metric instrument on and off.
|
||||
* @return
|
||||
*/
|
||||
nostd::shared_ptr<ValueObserver<short>> NewShortValueObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<short>)) override
|
||||
{
|
||||
return nostd::shared_ptr<ValueObserver<short>>{
|
||||
new NoopValueObserver<short>(name, description, unit, enabled, callback)};
|
||||
}
|
||||
|
||||
nostd::shared_ptr<ValueObserver<int>> NewIntValueObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<int>)) override
|
||||
{
|
||||
return nostd::shared_ptr<ValueObserver<int>>{
|
||||
new NoopValueObserver<int>(name, description, unit, enabled, callback)};
|
||||
}
|
||||
|
||||
nostd::shared_ptr<ValueObserver<float>> NewFloatValueObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<float>)) override
|
||||
{
|
||||
return nostd::shared_ptr<ValueObserver<float>>{
|
||||
new NoopValueObserver<float>(name, description, unit, enabled, callback)};
|
||||
}
|
||||
|
||||
nostd::shared_ptr<ValueObserver<double>> NewDoubleValueObserver(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
const bool enabled,
|
||||
void (*callback)(ObserverResult<double>)) override
|
||||
{
|
||||
return nostd::shared_ptr<ValueObserver<double>>{
|
||||
new NoopValueObserver<double>(name, description, unit, enabled, callback)};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Utility method that allows users to atomically record measurements to a set of
|
||||
* synchronous metric instruments with a common set of labels.
|
||||
*
|
||||
* @param labels the set of labels to associate with this recorder.
|
||||
* @param instrs the instruments to record to.
|
||||
* @param values the value to record to those instruments.
|
||||
*/
|
||||
void RecordShortBatch(const common::KeyValueIterable &labels,
|
||||
nostd::span<SynchronousInstrument<short> *> instruments,
|
||||
nostd::span<const short> values) noexcept override
|
||||
{
|
||||
// No-op
|
||||
}
|
||||
|
||||
void RecordIntBatch(const common::KeyValueIterable &labels,
|
||||
nostd::span<SynchronousInstrument<int> *> instruments,
|
||||
nostd::span<const int> values) noexcept override
|
||||
{
|
||||
// No-op
|
||||
}
|
||||
|
||||
void RecordFloatBatch(const common::KeyValueIterable &labels,
|
||||
nostd::span<SynchronousInstrument<float> *> instruments,
|
||||
nostd::span<const float> values) noexcept override
|
||||
{
|
||||
// No-op
|
||||
}
|
||||
|
||||
void RecordDoubleBatch(const common::KeyValueIterable &labels,
|
||||
nostd::span<SynchronousInstrument<double> *> instruments,
|
||||
nostd::span<const double> values) noexcept override
|
||||
{
|
||||
// No-op
|
||||
}
|
||||
};
|
||||
|
||||
class NoopMeterProvider final : public opentelemetry::metrics::MeterProvider
|
||||
{
|
||||
public:
|
||||
NoopMeterProvider()
|
||||
: meter_{nostd::shared_ptr<opentelemetry::metrics::NoopMeter>(
|
||||
new opentelemetry::metrics::NoopMeter)}
|
||||
{}
|
||||
|
||||
nostd::shared_ptr<opentelemetry::metrics::Meter> GetMeter(
|
||||
nostd::string_view library_name,
|
||||
nostd::string_view library_version) override
|
||||
{
|
||||
return meter_;
|
||||
}
|
||||
|
||||
private:
|
||||
nostd::shared_ptr<opentelemetry::metrics::Meter> meter_;
|
||||
};
|
||||
} // namespace metrics
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
|
@ -1,41 +0,0 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifdef ENABLE_METRICS_PREVIEW
|
||||
|
||||
# include "opentelemetry/_metrics/instrument.h"
|
||||
# include "opentelemetry/nostd/shared_ptr.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace metrics
|
||||
{
|
||||
|
||||
/**
|
||||
* ObserverResult class is necessary for the callback recording asynchronous
|
||||
* instrument use. Callback functions asynchronous instruments are designed to
|
||||
* accept a single ObserverResult object and update using its pointer to the
|
||||
* instrument itself.
|
||||
*/
|
||||
|
||||
template <class T>
|
||||
class ObserverResult
|
||||
{
|
||||
|
||||
public:
|
||||
ObserverResult() = default;
|
||||
|
||||
ObserverResult(AsynchronousInstrument<T> *instrument) : instrument_(instrument) {}
|
||||
|
||||
virtual void observe(T value, const common::KeyValueIterable &labels)
|
||||
{
|
||||
instrument_->observe(value, labels);
|
||||
}
|
||||
|
||||
private:
|
||||
AsynchronousInstrument<T> *instrument_;
|
||||
};
|
||||
|
||||
} // namespace metrics
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
|
@ -1,60 +0,0 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifdef ENABLE_METRICS_PREVIEW
|
||||
# include <mutex>
|
||||
|
||||
# include "opentelemetry/_metrics/meter_provider.h"
|
||||
# include "opentelemetry/_metrics/noop.h"
|
||||
# include "opentelemetry/common/macros.h"
|
||||
# include "opentelemetry/common/spin_lock_mutex.h"
|
||||
# include "opentelemetry/nostd/shared_ptr.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace metrics
|
||||
{
|
||||
/**
|
||||
* Stores the singleton global MeterProvider.
|
||||
*/
|
||||
class Provider
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Returns the singleton MeterProvider.
|
||||
*
|
||||
* By default, a no-op MeterProvider is returned. This will never return a
|
||||
* nullptr MeterProvider.
|
||||
*/
|
||||
static nostd::shared_ptr<MeterProvider> GetMeterProvider() noexcept
|
||||
{
|
||||
std::lock_guard<common::SpinLockMutex> guard(GetLock());
|
||||
return nostd::shared_ptr<MeterProvider>(GetProvider());
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the singleton MeterProvider.
|
||||
*/
|
||||
static void SetMeterProvider(nostd::shared_ptr<MeterProvider> tp) noexcept
|
||||
{
|
||||
std::lock_guard<common::SpinLockMutex> guard(GetLock());
|
||||
GetProvider() = tp;
|
||||
}
|
||||
|
||||
private:
|
||||
OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr<MeterProvider> &GetProvider() noexcept
|
||||
{
|
||||
static nostd::shared_ptr<MeterProvider> provider(new NoopMeterProvider);
|
||||
return provider;
|
||||
}
|
||||
|
||||
OPENTELEMETRY_API_SINGLETON static common::SpinLockMutex &GetLock() noexcept
|
||||
{
|
||||
static common::SpinLockMutex lock;
|
||||
return lock;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace metrics
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
|
@ -1,181 +0,0 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifdef ENABLE_METRICS_PREVIEW
|
||||
|
||||
# include "opentelemetry/_metrics/instrument.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace metrics
|
||||
{
|
||||
|
||||
template <class T>
|
||||
class BoundCounter : virtual public BoundSynchronousInstrument<T>
|
||||
{
|
||||
|
||||
public:
|
||||
BoundCounter() = default;
|
||||
|
||||
BoundCounter(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
bool enabled);
|
||||
|
||||
/*
|
||||
* Add adds the value to the counter's sum. The labels are already linked * to the instrument
|
||||
* and are not specified.
|
||||
*
|
||||
* @param value the numerical representation of the metric being captured
|
||||
* @param labels the set of labels, as key-value pairs
|
||||
*/
|
||||
virtual void add(T value) = 0;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class Counter : virtual public SynchronousInstrument<T>
|
||||
{
|
||||
|
||||
public:
|
||||
Counter() = default;
|
||||
|
||||
Counter(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
bool enabled)
|
||||
{}
|
||||
|
||||
/*
|
||||
* Bind creates a bound instrument for this counter. The labels are
|
||||
* associated with values recorded via subsequent calls to Record.
|
||||
*
|
||||
* @param labels the set of labels, as key-value pairs.
|
||||
* @return a BoundIntCounter tied to the specified labels
|
||||
*/
|
||||
virtual nostd::shared_ptr<BoundCounter<T>> bindCounter(const common::KeyValueIterable &labels)
|
||||
{
|
||||
return nostd::shared_ptr<BoundCounter<T>>();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add adds the value to the counter's sum. The labels should contain
|
||||
* the keys and values to be associated with this value. Counters only * accept positive
|
||||
* valued updates.
|
||||
*
|
||||
* @param value the numerical representation of the metric being captured
|
||||
* @param labels the set of labels, as key-value pairs
|
||||
*/
|
||||
virtual void add(T value, const common::KeyValueIterable &labels) = 0;
|
||||
|
||||
virtual void update(T value, const common::KeyValueIterable &labels) override = 0;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class BoundUpDownCounter : virtual public BoundSynchronousInstrument<T>
|
||||
{
|
||||
|
||||
public:
|
||||
BoundUpDownCounter() = default;
|
||||
|
||||
BoundUpDownCounter(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
bool enabled);
|
||||
|
||||
/*
|
||||
* Add adds the value to the counter's sum. The labels are already linked to * the instrument and
|
||||
* do not need to specified again. UpDownCounters can accept positive and negative values.
|
||||
*
|
||||
* @param value the numerical representation of the metric being captured
|
||||
* @param labels the set of labels, as key-value pairs
|
||||
*/
|
||||
virtual void add(T value) = 0;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class UpDownCounter : virtual public SynchronousInstrument<T>
|
||||
{
|
||||
|
||||
public:
|
||||
UpDownCounter() = default;
|
||||
|
||||
UpDownCounter(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
bool enabled);
|
||||
|
||||
virtual nostd::shared_ptr<BoundUpDownCounter<T>> bindUpDownCounter(
|
||||
const common::KeyValueIterable &labels)
|
||||
{
|
||||
return nostd::shared_ptr<BoundUpDownCounter<T>>();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add adds the value to the counter's sum. The labels should contain
|
||||
* the keys and values to be associated with this value. UpDownCounters can
|
||||
* accept positive and negative values.
|
||||
*
|
||||
* @param value the numerical representation of the metric being captured
|
||||
* @param labels the set of labels, as key-value pairs
|
||||
*/
|
||||
virtual void add(T value, const common::KeyValueIterable &labels) = 0;
|
||||
|
||||
virtual void update(T value, const common::KeyValueIterable &labels) override = 0;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class BoundValueRecorder : virtual public BoundSynchronousInstrument<T>
|
||||
{
|
||||
|
||||
public:
|
||||
BoundValueRecorder() = default;
|
||||
|
||||
BoundValueRecorder(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
bool enabled);
|
||||
|
||||
/*
|
||||
* Records the value by summing it with previous measurements and checking * previously stored
|
||||
* minimum and maximum values. The labels associated with * new values are already linked to the
|
||||
* instrument as it is bound. * ValueRecorders can accept positive and negative values.
|
||||
*
|
||||
* @param value the numerical representation of the metric being captured
|
||||
*/
|
||||
virtual void record(T value) = 0;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class ValueRecorder : virtual public SynchronousInstrument<T>
|
||||
{
|
||||
|
||||
public:
|
||||
ValueRecorder() = default;
|
||||
|
||||
ValueRecorder(nostd::string_view name,
|
||||
nostd::string_view description,
|
||||
nostd::string_view unit,
|
||||
bool enabled);
|
||||
|
||||
virtual nostd::shared_ptr<BoundValueRecorder<T>> bindValueRecorder(
|
||||
const common::KeyValueIterable &labels)
|
||||
{
|
||||
return nostd::shared_ptr<BoundValueRecorder<T>>();
|
||||
}
|
||||
|
||||
/*
|
||||
* Records the value by summing it with previous measurements and checking * previously stored
|
||||
* minimum and maximum values. The labels should contain the keys and values to be associated with
|
||||
* this value. ValueRecorders can accept positive and negative values.
|
||||
*
|
||||
* @param value the numerical representation of the metric being captured
|
||||
* @param labels the set of labels, as key-value pairs
|
||||
*/
|
||||
virtual void record(T value, const common::KeyValueIterable &labels) = 0;
|
||||
|
||||
virtual void update(T value, const common::KeyValueIterable &labels) override = 0;
|
||||
};
|
||||
|
||||
} // namespace metrics
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
@ -16,7 +16,7 @@ OPENTELEMETRY_BEGIN_NAMESPACE
|
|||
namespace baggage
|
||||
{
|
||||
|
||||
class Baggage
|
||||
class OPENTELEMETRY_EXPORT Baggage
|
||||
{
|
||||
public:
|
||||
static constexpr size_t kMaxKeyValuePairs = 180;
|
||||
|
@ -26,14 +26,12 @@ public:
|
|||
static constexpr char kMembersSeparator = ',';
|
||||
static constexpr char kMetadataSeparator = ';';
|
||||
|
||||
Baggage() noexcept : kv_properties_(new opentelemetry::common::KeyValueProperties()) {}
|
||||
Baggage(size_t size) noexcept
|
||||
: kv_properties_(new opentelemetry::common::KeyValueProperties(size))
|
||||
{}
|
||||
Baggage() noexcept : kv_properties_(new common::KeyValueProperties()) {}
|
||||
Baggage(size_t size) noexcept : kv_properties_(new common::KeyValueProperties(size)) {}
|
||||
|
||||
template <class T>
|
||||
Baggage(const T &keys_and_values) noexcept
|
||||
: kv_properties_(new opentelemetry::common::KeyValueProperties(keys_and_values))
|
||||
: kv_properties_(new common::KeyValueProperties(keys_and_values))
|
||||
{}
|
||||
|
||||
OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr<Baggage> GetDefault()
|
||||
|
@ -293,7 +291,7 @@ private:
|
|||
|
||||
private:
|
||||
// Store entries in a C-style array to avoid using std::array or std::vector.
|
||||
nostd::unique_ptr<opentelemetry::common::KeyValueProperties> kv_properties_;
|
||||
nostd::unique_ptr<common::KeyValueProperties> kv_properties_;
|
||||
};
|
||||
|
||||
} // namespace baggage
|
||||
|
|
|
@ -15,22 +15,19 @@ namespace baggage
|
|||
|
||||
static const std::string kBaggageHeader = "baggage";
|
||||
|
||||
inline nostd::shared_ptr<opentelemetry::baggage::Baggage> GetBaggage(
|
||||
const opentelemetry::context::Context &context) noexcept
|
||||
inline nostd::shared_ptr<Baggage> GetBaggage(const context::Context &context) noexcept
|
||||
{
|
||||
context::ContextValue context_value = context.GetValue(kBaggageHeader);
|
||||
if (nostd::holds_alternative<nostd::shared_ptr<opentelemetry::baggage::Baggage>>(context_value))
|
||||
if (nostd::holds_alternative<nostd::shared_ptr<Baggage>>(context_value))
|
||||
{
|
||||
return nostd::get<nostd::shared_ptr<opentelemetry::baggage::Baggage>>(context_value);
|
||||
return nostd::get<nostd::shared_ptr<Baggage>>(context_value);
|
||||
}
|
||||
static nostd::shared_ptr<opentelemetry::baggage::Baggage> empty_baggage{
|
||||
new opentelemetry::baggage::Baggage()};
|
||||
static nostd::shared_ptr<Baggage> empty_baggage{new Baggage()};
|
||||
return empty_baggage;
|
||||
}
|
||||
|
||||
inline context::Context SetBaggage(
|
||||
opentelemetry::context::Context &context,
|
||||
nostd::shared_ptr<opentelemetry::baggage::Baggage> baggage) noexcept
|
||||
inline context::Context SetBaggage(context::Context &context,
|
||||
const nostd::shared_ptr<Baggage> &baggage) noexcept
|
||||
{
|
||||
return context.SetValue(kBaggageHeader, baggage);
|
||||
}
|
||||
|
|
|
@ -3,9 +3,15 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "opentelemetry/baggage/baggage.h"
|
||||
#include "opentelemetry/baggage/baggage_context.h"
|
||||
#include "opentelemetry/context/context.h"
|
||||
#include "opentelemetry/context/propagation/text_map_propagator.h"
|
||||
#include "opentelemetry/nostd/function_ref.h"
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
|
@ -14,13 +20,13 @@ namespace baggage
|
|||
namespace propagation
|
||||
{
|
||||
|
||||
class BaggagePropagator : public opentelemetry::context::propagation::TextMapPropagator
|
||||
class BaggagePropagator : public context::propagation::TextMapPropagator
|
||||
{
|
||||
public:
|
||||
void Inject(opentelemetry::context::propagation::TextMapCarrier &carrier,
|
||||
const opentelemetry::context::Context &context) noexcept override
|
||||
void Inject(context::propagation::TextMapCarrier &carrier,
|
||||
const context::Context &context) noexcept override
|
||||
{
|
||||
auto baggage = opentelemetry::baggage::GetBaggage(context);
|
||||
auto baggage = baggage::GetBaggage(context);
|
||||
auto header = baggage->ToHeader();
|
||||
if (header.size())
|
||||
{
|
||||
|
@ -28,15 +34,15 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
context::Context Extract(const opentelemetry::context::propagation::TextMapCarrier &carrier,
|
||||
opentelemetry::context::Context &context) noexcept override
|
||||
context::Context Extract(const context::propagation::TextMapCarrier &carrier,
|
||||
context::Context &context) noexcept override
|
||||
{
|
||||
nostd::string_view baggage_str = carrier.Get(opentelemetry::baggage::kBaggageHeader);
|
||||
auto baggage = opentelemetry::baggage::Baggage::FromHeader(baggage_str);
|
||||
nostd::string_view baggage_str = carrier.Get(baggage::kBaggageHeader);
|
||||
auto baggage = baggage::Baggage::FromHeader(baggage_str);
|
||||
|
||||
if (baggage->ToHeader().size())
|
||||
{
|
||||
return opentelemetry::baggage::SetBaggage(context, baggage);
|
||||
return baggage::SetBaggage(context, baggage);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -23,12 +23,13 @@ namespace common
|
|||
/// (IEEE 754-1985) or signed 64 bit integer.
|
||||
/// - Homogenous arrays of primitive type values.
|
||||
///
|
||||
/// \warning
|
||||
/// \warning The OpenTelemetry C++ API does not support the following attribute:
|
||||
/// uint64_t, nostd::span<const uint64_t>, and nostd::span<const uint8_t> types.
|
||||
/// \parblock The OpenTelemetry C++ API currently supports several attribute
|
||||
/// value types that are not covered by the OpenTelemetry specification:
|
||||
/// - \c uint64_t
|
||||
/// - \c nostd::span<const uint64_t>
|
||||
/// - \c nostd::span<uint8_t>
|
||||
/// - \c nostd::span<const uint8_t>
|
||||
///
|
||||
/// Those types are reserved for future use and currently should not be
|
||||
/// used. There are no guarantees around how those values are handled by
|
||||
|
@ -54,8 +55,6 @@ using AttributeValue =
|
|||
// Not currently supported by the specification, but reserved for future use.
|
||||
// Added to provide support for all primitive C++ types.
|
||||
nostd::span<const uint64_t>,
|
||||
// Not currently supported by the specification, but reserved for future use.
|
||||
// See https://github.com/open-telemetry/opentelemetry-specification/issues/780
|
||||
nostd::span<const uint8_t>>;
|
||||
|
||||
enum AttributeType
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "opentelemetry/common/attribute_value.h"
|
||||
#include "opentelemetry/nostd/function_ref.h"
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
|
@ -32,5 +33,31 @@ public:
|
|||
*/
|
||||
virtual size_t size() const noexcept = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Supports internal iteration over a collection of key-value pairs.
|
||||
*/
|
||||
class NoopKeyValueIterable : public KeyValueIterable
|
||||
{
|
||||
public:
|
||||
~NoopKeyValueIterable() override = default;
|
||||
|
||||
/**
|
||||
* No-op implementation: does not invoke the callback, even if key-value pairs are present.
|
||||
* @return true without iterating or invoking the callback
|
||||
*/
|
||||
bool ForEachKeyValue(
|
||||
nostd::function_ref<bool(nostd::string_view, common::AttributeValue)> /*callback*/)
|
||||
const noexcept override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of key-value pairs
|
||||
*/
|
||||
size_t size() const noexcept override { return 0; }
|
||||
};
|
||||
|
||||
} // namespace common
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
|
|
|
@ -3,11 +3,19 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <initializer_list>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "opentelemetry/common/attribute_value.h"
|
||||
#include "opentelemetry/common/key_value_iterable.h"
|
||||
#include "opentelemetry/nostd/function_ref.h"
|
||||
#include "opentelemetry/nostd/span.h"
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/nostd/type_traits.h"
|
||||
#include "opentelemetry/nostd/utility.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
|
@ -73,5 +81,67 @@ public:
|
|||
private:
|
||||
const T *container_;
|
||||
};
|
||||
|
||||
template <class T, nostd::enable_if_t<detail::is_key_value_iterable<T>::value> * = nullptr>
|
||||
KeyValueIterableView<T> MakeKeyValueIterableView(const T &container) noexcept
|
||||
{
|
||||
return KeyValueIterableView<T>(container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to help to make a attribute view from initializer_list
|
||||
*
|
||||
* @param attributes The initializer_list of key-value pairs
|
||||
* @return nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>
|
||||
*/
|
||||
inline static nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>
|
||||
MakeAttributes(std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
|
||||
attributes) noexcept
|
||||
{
|
||||
return nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
|
||||
attributes.begin(), attributes.end()};
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to help to make a attribute view from a span
|
||||
*
|
||||
* @param attributes The span of key-value pairs
|
||||
* @return nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>
|
||||
*/
|
||||
inline static nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>
|
||||
MakeAttributes(
|
||||
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>> attributes) noexcept
|
||||
{
|
||||
return attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to help to make a attribute view from a KeyValueIterable
|
||||
*
|
||||
* @param attributes The KeyValueIterable of key-value pairs
|
||||
* @return common::KeyValueIterable
|
||||
*/
|
||||
inline static const common::KeyValueIterable &MakeAttributes(
|
||||
const common::KeyValueIterable &attributes) noexcept
|
||||
{
|
||||
return attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to help to make a attribute view from a key-value iterable object
|
||||
*
|
||||
* @tparam ArgumentType Expected to be ArgumentType
|
||||
* @param attributes The key-value iterable object
|
||||
* @return nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>
|
||||
*/
|
||||
template <
|
||||
class ArgumentType,
|
||||
nostd::enable_if_t<common::detail::is_key_value_iterable<ArgumentType>::value> * = nullptr>
|
||||
inline static common::KeyValueIterableView<ArgumentType> MakeAttributes(
|
||||
const ArgumentType &attributes) noexcept
|
||||
{
|
||||
return common::KeyValueIterableView<ArgumentType>(attributes);
|
||||
}
|
||||
|
||||
} // namespace common
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "opentelemetry/common/key_value_iterable_view.h"
|
||||
#include "opentelemetry/common/string_util.h"
|
||||
#include "opentelemetry/nostd/function_ref.h"
|
||||
#include "opentelemetry/nostd/shared_ptr.h"
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/nostd/unique_ptr.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
@ -159,7 +158,7 @@ public:
|
|||
}
|
||||
|
||||
// Move contructor and assignment operator
|
||||
Entry(Entry &&other) = default;
|
||||
Entry(Entry &&other) = default;
|
||||
Entry &operator=(Entry &&other) = default;
|
||||
|
||||
// Creates an Entry for a given key-value pair.
|
||||
|
|
|
@ -3,25 +3,179 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
/*
|
||||
OPENTELEMETRY_HAVE_BUILTIN&OPENTELEMETRY_HAVE_FEATURE
|
||||
|
||||
#include "opentelemetry/version.h"
|
||||
Checks whether the compiler supports a Clang Feature Checking Macro, and if
|
||||
so, checks whether it supports the provided builtin function "x" where x
|
||||
is one of the functions noted in
|
||||
https://clang.llvm.org/docs/LanguageExtensions.html
|
||||
|
||||
#if !defined(OPENTELEMETRY_LIKELY_IF) && defined(__cplusplus)
|
||||
Note: Use this macro to avoid an extra level of #ifdef __has_builtin check.
|
||||
http://releases.llvm.org/3.3/tools/clang/docs/LanguageExtensions.html
|
||||
*/
|
||||
#if !defined(OPENTELEMETRY_HAVE_BUILTIN)
|
||||
# ifdef __has_builtin
|
||||
# define OPENTELEMETRY_HAVE_BUILTIN(x) __has_builtin(x)
|
||||
# else
|
||||
# define OPENTELEMETRY_HAVE_BUILTIN(x) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(OPENTELEMETRY_HAVE_FEATURE)
|
||||
# ifdef __has_feature
|
||||
# define OPENTELEMETRY_HAVE_FEATURE(f) __has_feature(f)
|
||||
# else
|
||||
# define OPENTELEMETRY_HAVE_FEATURE(f) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
has feature
|
||||
|
||||
OPENTELEMETRY_HAVE_ATTRIBUTE
|
||||
|
||||
A function-like feature checking macro that is a wrapper around
|
||||
`__has_attribute`, which is defined by GCC 5+ and Clang and evaluates to a
|
||||
nonzero constant integer if the attribute is supported or 0 if not.
|
||||
|
||||
It evaluates to zero if `__has_attribute` is not defined by the compiler.
|
||||
|
||||
GCC: https://gcc.gnu.org/gcc-5/changes.html
|
||||
Clang: https://clang.llvm.org/docs/LanguageExtensions.html
|
||||
*/
|
||||
#if !defined(OPENTELEMETRY_HAVE_ATTRIBUTE)
|
||||
# ifdef __has_attribute
|
||||
# define OPENTELEMETRY_HAVE_ATTRIBUTE(x) __has_attribute(x)
|
||||
# else
|
||||
# define OPENTELEMETRY_HAVE_ATTRIBUTE(x) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
OPENTELEMETRY_HAVE_CPP_ATTRIBUTE
|
||||
|
||||
A function-like feature checking macro that accepts C++11 style attributes.
|
||||
It's a wrapper around `__has_cpp_attribute`, defined by ISO C++ SD-6
|
||||
(https://en.cppreference.com/w/cpp/experimental/feature_test). If we don't
|
||||
find `__has_cpp_attribute`, will evaluate to 0.
|
||||
*/
|
||||
#if !defined(OPENTELEMETRY_HAVE_CPP_ATTRIBUTE)
|
||||
# if defined(__cplusplus) && defined(__has_cpp_attribute)
|
||||
// NOTE: requiring __cplusplus above should not be necessary, but
|
||||
// works around https://bugs.llvm.org/show_bug.cgi?id=23435.
|
||||
# define OPENTELEMETRY_HAVE_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
|
||||
# else
|
||||
# define OPENTELEMETRY_HAVE_CPP_ATTRIBUTE(x) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
Expected usage pattern:
|
||||
|
||||
if OPENTELEMETRY_LIKELY_CONDITION (ptr != nullptr)
|
||||
{
|
||||
do_something_likely();
|
||||
} else {
|
||||
do_something_unlikely();
|
||||
}
|
||||
|
||||
This pattern works with gcc/clang and __builtin_expect(),
|
||||
as well as with C++20.
|
||||
It is unclear if __builtin_expect() will be deprecated
|
||||
in favor of C++20 [[likely]] or not.
|
||||
|
||||
OPENTELEMETRY_LIKELY_CONDITION is preferred over OPENTELEMETRY_LIKELY,
|
||||
to be revisited when C++20 is required.
|
||||
*/
|
||||
|
||||
#if !defined(OPENTELEMETRY_LIKELY_CONDITION) && defined(__cplusplus)
|
||||
// Only use likely with C++20
|
||||
# if __cplusplus >= 202002L
|
||||
// GCC 9 has likely attribute but do not support declare it at the beginning of statement
|
||||
# if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9)
|
||||
# if __has_cpp_attribute(likely)
|
||||
# define OPENTELEMETRY_LIKELY_IF(...) \
|
||||
if (__VA_ARGS__) \
|
||||
[[likely]]
|
||||
# if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9)
|
||||
# if __has_cpp_attribute(likely)
|
||||
# define OPENTELEMETRY_LIKELY_CONDITION(C) (C) [[likely]]
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(OPENTELEMETRY_LIKELY_IF) && (defined(__clang__) || defined(__GNUC__))
|
||||
# define OPENTELEMETRY_LIKELY_IF(...) if (__builtin_expect(!!(__VA_ARGS__), true))
|
||||
#if !defined(OPENTELEMETRY_LIKELY_CONDITION) && (defined(__clang__) || defined(__GNUC__))
|
||||
// Only use if supported by the compiler
|
||||
# define OPENTELEMETRY_LIKELY_CONDITION(C) (__builtin_expect(!!(C), true))
|
||||
#endif
|
||||
#ifndef OPENTELEMETRY_LIKELY_IF
|
||||
# define OPENTELEMETRY_LIKELY_IF(...) if (__VA_ARGS__)
|
||||
#ifndef OPENTELEMETRY_LIKELY_CONDITION
|
||||
// Do not use likely annotations
|
||||
# define OPENTELEMETRY_LIKELY_CONDITION(C) (C)
|
||||
#endif
|
||||
|
||||
#if !defined(OPENTELEMETRY_UNLIKELY_CONDITION) && defined(__cplusplus)
|
||||
// Only use unlikely with C++20
|
||||
# if __cplusplus >= 202002L
|
||||
// GCC 9 has unlikely attribute but do not support declare it at the beginning of statement
|
||||
# if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9)
|
||||
# if __has_cpp_attribute(unlikely)
|
||||
# define OPENTELEMETRY_UNLIKELY_CONDITION(C) (C) [[unlikely]]
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(OPENTELEMETRY_UNLIKELY_CONDITION) && (defined(__clang__) || defined(__GNUC__))
|
||||
// Only use if supported by the compiler
|
||||
# define OPENTELEMETRY_UNLIKELY_CONDITION(C) (__builtin_expect(!!(C), false))
|
||||
#endif
|
||||
#ifndef OPENTELEMETRY_UNLIKELY_CONDITION
|
||||
// Do not use unlikely annotations
|
||||
# define OPENTELEMETRY_UNLIKELY_CONDITION(C) (C)
|
||||
#endif
|
||||
|
||||
/*
|
||||
Expected usage pattern:
|
||||
|
||||
if (ptr != nullptr)
|
||||
OPENTELEMETRY_LIKELY
|
||||
{
|
||||
do_something_likely();
|
||||
} else {
|
||||
do_something_unlikely();
|
||||
}
|
||||
|
||||
This pattern works starting with C++20.
|
||||
See https://en.cppreference.com/w/cpp/language/attributes/likely
|
||||
|
||||
Please use OPENTELEMETRY_LIKELY_CONDITION instead for now.
|
||||
*/
|
||||
|
||||
#if !defined(OPENTELEMETRY_LIKELY) && defined(__cplusplus)
|
||||
// Only use likely with C++20
|
||||
# if __cplusplus >= 202002L
|
||||
// GCC 9 has likely attribute but do not support declare it at the beginning of statement
|
||||
# if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9)
|
||||
# if __has_cpp_attribute(likely)
|
||||
# define OPENTELEMETRY_LIKELY [[likely]]
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef OPENTELEMETRY_LIKELY
|
||||
# define OPENTELEMETRY_LIKELY
|
||||
#endif
|
||||
|
||||
#if !defined(OPENTELEMETRY_UNLIKELY) && defined(__cplusplus)
|
||||
// Only use unlikely with C++20
|
||||
# if __cplusplus >= 202002L
|
||||
// GCC 9 has unlikely attribute but do not support declare it at the beginning of statement
|
||||
# if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9)
|
||||
# if __has_cpp_attribute(unlikely)
|
||||
# define OPENTELEMETRY_UNLIKELY [[unlikely]]
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef OPENTELEMETRY_UNLIKELY
|
||||
# define OPENTELEMETRY_UNLIKELY
|
||||
#endif
|
||||
|
||||
/// \brief Declare variable as maybe unused
|
||||
|
@ -92,10 +246,9 @@
|
|||
|
||||
// Regex support
|
||||
#if (__GNUC__ == 4 && (__GNUC_MINOR__ == 8 || __GNUC_MINOR__ == 9))
|
||||
# define HAVE_WORKING_REGEX 0
|
||||
# define OPENTELEMETRY_HAVE_WORKING_REGEX 0
|
||||
#else
|
||||
# include <regex>
|
||||
# define HAVE_WORKING_REGEX 1
|
||||
# define OPENTELEMETRY_HAVE_WORKING_REGEX 1
|
||||
#endif
|
||||
|
||||
/* clang-format off */
|
||||
|
@ -168,15 +321,203 @@ point.
|
|||
#if defined(__clang__)
|
||||
|
||||
# define OPENTELEMETRY_API_SINGLETON __attribute__((visibility("default")))
|
||||
# define OPENTELEMETRY_LOCAL_SYMBOL __attribute__((visibility("hidden")))
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
|
||||
# define OPENTELEMETRY_API_SINGLETON __attribute__((visibility("default")))
|
||||
# define OPENTELEMETRY_LOCAL_SYMBOL __attribute__((visibility("hidden")))
|
||||
|
||||
#else
|
||||
|
||||
/* Add support for other compilers here. */
|
||||
|
||||
# define OPENTELEMETRY_API_SINGLETON
|
||||
# define OPENTELEMETRY_LOCAL_SYMBOL
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Atomic wrappers based on compiler intrinsics for memory read/write.
|
||||
// The tailing number is read/write length in bits.
|
||||
//
|
||||
// N.B. Compiler intrinsic is used because the usage of C++ standard library is restricted in the
|
||||
// OpenTelemetry C++ API.
|
||||
//
|
||||
#if defined(__GNUC__)
|
||||
|
||||
# define OPENTELEMETRY_ATOMIC_READ_8(ptr) __atomic_load_n(ptr, __ATOMIC_SEQ_CST)
|
||||
# define OPENTELEMETRY_ATOMIC_WRITE_8(ptr, value) __atomic_store_n(ptr, value, __ATOMIC_SEQ_CST)
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
|
||||
# include <intrin.h>
|
||||
|
||||
# define OPENTELEMETRY_ATOMIC_READ_8(ptr) \
|
||||
static_cast<uint8_t>(_InterlockedCompareExchange8(reinterpret_cast<char *>(ptr), 0, 0))
|
||||
# define OPENTELEMETRY_ATOMIC_WRITE_8(ptr, value) \
|
||||
_InterlockedExchange8(reinterpret_cast<char *>(ptr), static_cast<char>(value))
|
||||
|
||||
#else
|
||||
# error port atomics read/write for the current platform
|
||||
#endif
|
||||
|
||||
/* clang-format on */
|
||||
//
|
||||
// The if/elif order matters here. If both OPENTELEMETRY_BUILD_IMPORT_DLL and
|
||||
// OPENTELEMETRY_BUILD_EXPORT_DLL are defined, the former takes precedence.
|
||||
//
|
||||
// TODO: consider define OPENTELEMETRY_EXPORT for cygwin/gcc, see below link.
|
||||
// https://gcc.gnu.org/wiki/Visibility#How_to_use_the_new_C.2B-.2B-_visibility_support
|
||||
//
|
||||
#if defined(_MSC_VER) && defined(OPENTELEMETRY_BUILD_IMPORT_DLL)
|
||||
|
||||
# define OPENTELEMETRY_EXPORT __declspec(dllimport)
|
||||
|
||||
#elif defined(_MSC_VER) && defined(OPENTELEMETRY_BUILD_EXPORT_DLL)
|
||||
|
||||
# define OPENTELEMETRY_EXPORT __declspec(dllexport)
|
||||
|
||||
#else
|
||||
|
||||
//
|
||||
// build OpenTelemetry as static library or not on Windows.
|
||||
//
|
||||
# define OPENTELEMETRY_EXPORT
|
||||
|
||||
#endif
|
||||
|
||||
// OPENTELEMETRY_HAVE_EXCEPTIONS
|
||||
//
|
||||
// Checks whether the compiler both supports and enables exceptions. Many
|
||||
// compilers support a "no exceptions" mode that disables exceptions.
|
||||
//
|
||||
// Generally, when OPENTELEMETRY_HAVE_EXCEPTIONS is not defined:
|
||||
//
|
||||
// * Code using `throw` and `try` may not compile.
|
||||
// * The `noexcept` specifier will still compile and behave as normal.
|
||||
// * The `noexcept` operator may still return `false`.
|
||||
//
|
||||
// For further details, consult the compiler's documentation.
|
||||
#ifndef OPENTELEMETRY_HAVE_EXCEPTIONS
|
||||
# if defined(__clang__) && ((__clang_major__ * 100) + __clang_minor__) < 306
|
||||
// Clang < 3.6
|
||||
// http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html#the-exceptions-macro
|
||||
# if defined(__EXCEPTIONS) && OPENTELEMETRY_HAVE_FEATURE(cxx_exceptions)
|
||||
# define OPENTELEMETRY_HAVE_EXCEPTIONS 1
|
||||
# endif // defined(__EXCEPTIONS) && OPENTELEMETRY_HAVE_FEATURE(cxx_exceptions)
|
||||
# elif OPENTELEMETRY_HAVE_FEATURE(cxx_exceptions)
|
||||
# define OPENTELEMETRY_HAVE_EXCEPTIONS 1
|
||||
// Handle remaining special cases and default to exceptions being supported.
|
||||
# elif !(defined(__GNUC__) && !defined(__EXCEPTIONS) && !defined(__cpp_exceptions)) && \
|
||||
!(defined(_MSC_VER) && !defined(_CPPUNWIND))
|
||||
# define OPENTELEMETRY_HAVE_EXCEPTIONS 1
|
||||
# endif
|
||||
#endif
|
||||
#ifndef OPENTELEMETRY_HAVE_EXCEPTIONS
|
||||
# define OPENTELEMETRY_HAVE_EXCEPTIONS 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND indicates that a resource owned by a function
|
||||
parameter or implicit object parameter is retained by the return value of the
|
||||
annotated function (or, for a parameter of a constructor, in the value of the
|
||||
constructed object). This attribute causes warnings to be produced if a
|
||||
temporary object does not live long enough.
|
||||
|
||||
When applied to a reference parameter, the referenced object is assumed to be
|
||||
retained by the return value of the function. When applied to a non-reference
|
||||
parameter (for example, a pointer or a class type), all temporaries
|
||||
referenced by the parameter are assumed to be retained by the return value of
|
||||
the function.
|
||||
|
||||
See also the upstream documentation:
|
||||
https://clang.llvm.org/docs/AttributeReference.html#lifetimebound
|
||||
*/
|
||||
#ifndef OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND
|
||||
# if OPENTELEMETRY_HAVE_CPP_ATTRIBUTE(clang::lifetimebound)
|
||||
# define OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND [[clang::lifetimebound]]
|
||||
# elif OPENTELEMETRY_HAVE_ATTRIBUTE(lifetimebound)
|
||||
# define OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND __attribute__((lifetimebound))
|
||||
# else
|
||||
# define OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// OPENTELEMETRY_HAVE_MEMORY_SANITIZER
|
||||
//
|
||||
// MemorySanitizer (MSan) is a detector of uninitialized reads. It consists of
|
||||
// a compiler instrumentation module and a run-time library.
|
||||
#ifndef OPENTELEMETRY_HAVE_MEMORY_SANITIZER
|
||||
# if !defined(__native_client__) && OPENTELEMETRY_HAVE_FEATURE(memory_sanitizer)
|
||||
# define OPENTELEMETRY_HAVE_MEMORY_SANITIZER 1
|
||||
# else
|
||||
# define OPENTELEMETRY_HAVE_MEMORY_SANITIZER 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if OPENTELEMETRY_HAVE_MEMORY_SANITIZER && OPENTELEMETRY_HAVE_ATTRIBUTE(no_sanitize_memory)
|
||||
# define OPENTELEMETRY_SANITIZER_NO_MEMORY \
|
||||
__attribute__((no_sanitize_memory)) // __attribute__((no_sanitize("memory")))
|
||||
#else
|
||||
# define OPENTELEMETRY_SANITIZER_NO_MEMORY
|
||||
#endif
|
||||
|
||||
// OPENTELEMETRY_HAVE_THREAD_SANITIZER
|
||||
//
|
||||
// ThreadSanitizer (TSan) is a fast data race detector.
|
||||
#ifndef OPENTELEMETRY_HAVE_THREAD_SANITIZER
|
||||
# if defined(__SANITIZE_THREAD__)
|
||||
# define OPENTELEMETRY_HAVE_THREAD_SANITIZER 1
|
||||
# elif OPENTELEMETRY_HAVE_FEATURE(thread_sanitizer)
|
||||
# define OPENTELEMETRY_HAVE_THREAD_SANITIZER 1
|
||||
# else
|
||||
# define OPENTELEMETRY_HAVE_THREAD_SANITIZER 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if OPENTELEMETRY_HAVE_THREAD_SANITIZER && OPENTELEMETRY_HAVE_ATTRIBUTE(no_sanitize_thread)
|
||||
# define OPENTELEMETRY_SANITIZER_NO_THREAD \
|
||||
__attribute__((no_sanitize_thread)) // __attribute__((no_sanitize("thread")))
|
||||
#else
|
||||
# define OPENTELEMETRY_SANITIZER_NO_THREAD
|
||||
#endif
|
||||
|
||||
// OPENTELEMETRY_HAVE_ADDRESS_SANITIZER
|
||||
//
|
||||
// AddressSanitizer (ASan) is a fast memory error detector.
|
||||
#ifndef OPENTELEMETRY_HAVE_ADDRESS_SANITIZER
|
||||
# if defined(__SANITIZE_ADDRESS__)
|
||||
# define OPENTELEMETRY_HAVE_ADDRESS_SANITIZER 1
|
||||
# elif OPENTELEMETRY_HAVE_FEATURE(address_sanitizer)
|
||||
# define OPENTELEMETRY_HAVE_ADDRESS_SANITIZER 1
|
||||
# else
|
||||
# define OPENTELEMETRY_HAVE_ADDRESS_SANITIZER 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER
|
||||
//
|
||||
// Hardware-Assisted AddressSanitizer (or HWASAN) is even faster than asan
|
||||
// memory error detector which can use CPU features like ARM TBI, Intel LAM or
|
||||
// AMD UAI.
|
||||
#ifndef OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER
|
||||
# if defined(__SANITIZE_HWADDRESS__)
|
||||
# define OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER 1
|
||||
# elif OPENTELEMETRY_HAVE_FEATURE(hwaddress_sanitizer)
|
||||
# define OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER 1
|
||||
# else
|
||||
# define OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if OPENTELEMETRY_HAVE_ADDRESS_SANITIZER && OPENTELEMETRY_HAVE_ATTRIBUTE(no_sanitize_address)
|
||||
# define OPENTELEMETRY_SANITIZER_NO_ADDRESS \
|
||||
__attribute__((no_sanitize_address)) // __attribute__((no_sanitize("address")))
|
||||
#elif OPENTELEMETRY_HAVE_ADDRESS_SANITIZER && defined(_MSC_VER) && _MSC_VER >= 1928
|
||||
# define OPENTELEMETRY_SANITIZER_NO_ADDRESS __declspec(no_sanitize_address)
|
||||
#elif OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER && OPENTELEMETRY_HAVE_ATTRIBUTE(no_sanitize)
|
||||
# define OPENTELEMETRY_SANITIZER_NO_ADDRESS __attribute__((no_sanitize("hwaddress")))
|
||||
#else
|
||||
# define OPENTELEMETRY_SANITIZER_NO_ADDRESS
|
||||
#endif
|
||||
|
|
|
@ -10,14 +10,13 @@
|
|||
#include "opentelemetry/version.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# ifndef NOMINMAX
|
||||
# define NOMINMAX
|
||||
# endif
|
||||
# define _WINSOCKAPI_ // stops including winsock.h
|
||||
# include <windows.h>
|
||||
#elif defined(__i386__) || defined(__x86_64__)
|
||||
# if defined(__clang__)
|
||||
# include <emmintrin.h>
|
||||
# elif defined(__INTEL_COMPILER)
|
||||
# include <immintrin.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
@ -54,10 +53,9 @@ class SpinLockMutex
|
|||
{
|
||||
public:
|
||||
SpinLockMutex() noexcept {}
|
||||
~SpinLockMutex() noexcept = default;
|
||||
SpinLockMutex(const SpinLockMutex &) = delete;
|
||||
~SpinLockMutex() noexcept = default;
|
||||
SpinLockMutex(const SpinLockMutex &) = delete;
|
||||
SpinLockMutex &operator=(const SpinLockMutex &) = delete;
|
||||
SpinLockMutex &operator=(const SpinLockMutex &) volatile = delete;
|
||||
|
||||
static inline void fast_yield() noexcept
|
||||
{
|
||||
|
@ -65,13 +63,15 @@ public:
|
|||
#if defined(_MSC_VER)
|
||||
YieldProcessor();
|
||||
#elif defined(__i386__) || defined(__x86_64__)
|
||||
# if defined(__clang__)
|
||||
# if defined(__clang__) || defined(__INTEL_COMPILER)
|
||||
_mm_pause();
|
||||
# else
|
||||
__builtin_ia32_pause();
|
||||
# endif
|
||||
#elif defined(__arm__)
|
||||
__asm__ volatile("yield" ::: "memory");
|
||||
#elif defined(__armel__) || defined(__ARMEL__)
|
||||
asm volatile("nop" ::: "memory");
|
||||
#elif defined(__arm__) || defined(__aarch64__) // arm big endian / arm64
|
||||
__asm__ __volatile__("yield" ::: "memory");
|
||||
#else
|
||||
// TODO: Issue PAGE/YIELD on other architectures.
|
||||
#endif
|
||||
|
|
|
@ -4,20 +4,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
|
||||
/** DJB2 hash function below is near-perfect hash used by several systems.
|
||||
* Ref. http://www.cse.yorku.ca/~oz/hash.html
|
||||
* </summary>
|
||||
* <param name="str">String to hash</param>
|
||||
* <param name="h">Initial offset</param>
|
||||
* <returns>32 bit code</returns>
|
||||
*/
|
||||
constexpr uint32_t hashCode(const char *str, uint32_t h = 0)
|
||||
{
|
||||
return (uint32_t)(!str[h] ? 5381 : ((uint32_t)hashCode(str, h + 1) * (uint32_t)33) ^ str[h]);
|
||||
}
|
||||
#define OTEL_CPP_CONST_UINT32_T(x) std::integral_constant<uint32_t, (uint32_t)x>::value
|
||||
#define OTEL_CPP_CONST_HASHCODE(name) OTEL_CPP_CONST_UINT32_T(hashCode(#name))
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace common
|
||||
|
@ -28,11 +15,11 @@ class StringUtil
|
|||
public:
|
||||
static nostd::string_view Trim(nostd::string_view str, size_t left, size_t right) noexcept
|
||||
{
|
||||
while (str[static_cast<std::size_t>(left)] == ' ' && left <= right)
|
||||
while (left <= right && isspace(str[left]))
|
||||
{
|
||||
left++;
|
||||
}
|
||||
while (str[static_cast<std::size_t>(right)] == ' ' && left <= right)
|
||||
while (left <= right && isspace(str[right]))
|
||||
{
|
||||
right--;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
|
||||
|
@ -179,7 +178,7 @@ public:
|
|||
std::chrono::duration<Rep, Period> indefinite_value) noexcept
|
||||
{
|
||||
// Do not call now() when this duration is max value, now() may have a expensive cost.
|
||||
if (timeout == std::chrono::duration<Rep, Period>::max())
|
||||
if (timeout == (std::chrono::duration<Rep, Period>::max)())
|
||||
{
|
||||
return indefinite_value;
|
||||
}
|
||||
|
@ -187,13 +186,13 @@ public:
|
|||
// std::future<T>::wait_for, std::this_thread::sleep_for, and std::condition_variable::wait_for
|
||||
// may use steady_clock or system_clock.We need make sure now() + timeout do not overflow.
|
||||
auto max_timeout = std::chrono::duration_cast<std::chrono::duration<Rep, Period>>(
|
||||
std::chrono::steady_clock::time_point::max() - std::chrono::steady_clock::now());
|
||||
(std::chrono::steady_clock::time_point::max)() - std::chrono::steady_clock::now());
|
||||
if (timeout >= max_timeout)
|
||||
{
|
||||
return indefinite_value;
|
||||
}
|
||||
max_timeout = std::chrono::duration_cast<std::chrono::duration<Rep, Period>>(
|
||||
std::chrono::system_clock::time_point::max() - std::chrono::system_clock::now());
|
||||
(std::chrono::system_clock::time_point::max)() - std::chrono::system_clock::now());
|
||||
if (timeout >= max_timeout)
|
||||
{
|
||||
return indefinite_value;
|
||||
|
|
|
@ -3,12 +3,17 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef __has_include
|
||||
# define OPENTELEMETRY_HAS_INCLUDE(x) 0
|
||||
#else
|
||||
# define OPENTELEMETRY_HAS_INCLUDE(x) __has_include(x)
|
||||
#endif
|
||||
#include <type_traits> // IWYU pragma: keep
|
||||
|
||||
#if !defined(__GLIBCXX__) || OPENTELEMETRY_HAS_INCLUDE(<codecvt>) // >= libstdc++-5
|
||||
# define OPENTELEMETRY_TRIVIALITY_TYPE_TRAITS
|
||||
#if defined(OPENTELEMETRY_ABI_VERSION_NO) && OPENTELEMETRY_ABI_VERSION_NO >= 2
|
||||
# error \
|
||||
"opentelemetry/config.h is removed in ABI version 2 and later. Please use opentelemetry/version.h instead."
|
||||
#else
|
||||
# if defined(__clang__) || defined(__GNUC__)
|
||||
# pragma GCC warning \
|
||||
"opentelemetry/config.h is deprecated. Please use opentelemetry/version.h instead."
|
||||
# elif defined(_MSC_VER)
|
||||
# pragma message( \
|
||||
"[WARNING]: opentelemetry/config.h is deprecated. Please use opentelemetry/version.h instead.")
|
||||
# endif
|
||||
#endif
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
|
||||
#include "opentelemetry/context/context_value.h"
|
||||
#include "opentelemetry/nostd/shared_ptr.h"
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/nostd/variant.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace context
|
||||
|
@ -25,16 +29,14 @@ public:
|
|||
// hold a shared_ptr to the head of the DataList linked list
|
||||
template <class T>
|
||||
Context(const T &keys_and_values) noexcept
|
||||
{
|
||||
head_ = nostd::shared_ptr<DataList>{new DataList(keys_and_values)};
|
||||
}
|
||||
: head_{nostd::shared_ptr<DataList>{new DataList(keys_and_values)}}
|
||||
{}
|
||||
|
||||
// Creates a context object from a key and value, this will
|
||||
// hold a shared_ptr to the head of the DataList linked list
|
||||
Context(nostd::string_view key, ContextValue value) noexcept
|
||||
{
|
||||
head_ = nostd::shared_ptr<DataList>{new DataList(key, value)};
|
||||
}
|
||||
: head_{nostd::shared_ptr<DataList>{new DataList(key, value)}}
|
||||
{}
|
||||
|
||||
// Accepts a new iterable and then returns a new context that
|
||||
// contains the new key and value data. It attaches the
|
||||
|
@ -88,22 +90,21 @@ public:
|
|||
|
||||
private:
|
||||
// A linked list to contain the keys and values of this context node
|
||||
class DataList
|
||||
struct DataList
|
||||
{
|
||||
public:
|
||||
char *key_;
|
||||
char *key_ = nullptr;
|
||||
|
||||
nostd::shared_ptr<DataList> next_;
|
||||
nostd::shared_ptr<DataList> next_{nullptr};
|
||||
|
||||
size_t key_length_;
|
||||
size_t key_length_ = 0UL;
|
||||
|
||||
ContextValue value_;
|
||||
|
||||
DataList() { next_ = nullptr; }
|
||||
DataList() = default;
|
||||
|
||||
// Builds a data list off of a key and value iterable and returns the head
|
||||
template <class T>
|
||||
DataList(const T &keys_and_vals) : key_{nullptr}, next_(nostd::shared_ptr<DataList>{nullptr})
|
||||
DataList(const T &keys_and_vals)
|
||||
{
|
||||
bool first = true;
|
||||
auto *node = this;
|
||||
|
@ -128,9 +129,18 @@ private:
|
|||
{
|
||||
key_ = new char[key.size()];
|
||||
key_length_ = key.size();
|
||||
memcpy(key_, key.data(), key.size() * sizeof(char));
|
||||
value_ = value;
|
||||
std::memcpy(key_, key.data(), key.size() * sizeof(char));
|
||||
next_ = nostd::shared_ptr<DataList>{nullptr};
|
||||
value_ = value;
|
||||
}
|
||||
|
||||
DataList(const DataList &other)
|
||||
: key_(new char[other.key_length_]),
|
||||
next_(other.next_),
|
||||
key_length_(other.key_length_),
|
||||
value_(other.value_)
|
||||
{
|
||||
std::memcpy(key_, other.key_, other.key_length_ * sizeof(char));
|
||||
}
|
||||
|
||||
DataList &operator=(DataList &&other) noexcept
|
||||
|
|
|
@ -5,16 +5,22 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#include "opentelemetry/baggage/baggage.h"
|
||||
#include "opentelemetry/nostd/shared_ptr.h"
|
||||
#include "opentelemetry/nostd/span.h"
|
||||
#include "opentelemetry/nostd/unique_ptr.h"
|
||||
#include "opentelemetry/nostd/variant.h"
|
||||
#include "opentelemetry/trace/span.h"
|
||||
#include "opentelemetry/trace/span_context.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace baggage
|
||||
{
|
||||
class Baggage;
|
||||
} // namespace baggage
|
||||
|
||||
namespace trace
|
||||
{
|
||||
class Span;
|
||||
class SpanContext;
|
||||
} // namespace trace
|
||||
|
||||
namespace context
|
||||
{
|
||||
using ContextValue = nostd::variant<nostd::monostate,
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "opentelemetry/context/propagation/text_map_propagator.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace context
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <mutex>
|
||||
|
||||
#include "opentelemetry/context/propagation/noop_propagator.h"
|
||||
#include "opentelemetry/context/propagation/text_map_propagator.h"
|
||||
|
||||
#include "opentelemetry/common/macros.h"
|
||||
#include "opentelemetry/common/spin_lock_mutex.h"
|
||||
|
@ -20,9 +19,11 @@ namespace context
|
|||
namespace propagation
|
||||
{
|
||||
|
||||
class TextMapPropagator;
|
||||
|
||||
/* Stores the singleton TextMapPropagator */
|
||||
|
||||
class GlobalTextMapPropagator
|
||||
class OPENTELEMETRY_EXPORT GlobalTextMapPropagator
|
||||
{
|
||||
public:
|
||||
static nostd::shared_ptr<TextMapPropagator> GetGlobalPropagator() noexcept
|
||||
|
@ -31,7 +32,7 @@ public:
|
|||
return nostd::shared_ptr<TextMapPropagator>(GetPropagator());
|
||||
}
|
||||
|
||||
static void SetGlobalPropagator(nostd::shared_ptr<TextMapPropagator> prop) noexcept
|
||||
static void SetGlobalPropagator(const nostd::shared_ptr<TextMapPropagator> &prop) noexcept
|
||||
{
|
||||
std::lock_guard<common::SpinLockMutex> guard(GetLock());
|
||||
GetPropagator() = prop;
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include "opentelemetry/context/context.h"
|
||||
#include "opentelemetry/nostd/function_ref.h"
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
|
|
|
@ -1,10 +1,18 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "opentelemetry/common/macros.h"
|
||||
#include "opentelemetry/context/context.h"
|
||||
#include "opentelemetry/context/context_value.h"
|
||||
#include "opentelemetry/nostd/shared_ptr.h"
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/nostd/unique_ptr.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace context
|
||||
|
@ -37,7 +45,7 @@ private:
|
|||
* this class and passing an initialized RuntimeContextStorage object to
|
||||
* RuntimeContext::SetRuntimeContextStorage.
|
||||
*/
|
||||
class RuntimeContextStorage
|
||||
class OPENTELEMETRY_EXPORT RuntimeContextStorage
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -48,7 +56,7 @@ public:
|
|||
|
||||
/**
|
||||
* Set the current context.
|
||||
* @param the new current context
|
||||
* @param context The new current context
|
||||
* @return a token for the new current context. This never returns a nullptr.
|
||||
*/
|
||||
virtual nostd::unique_ptr<Token> Attach(const Context &context) noexcept = 0;
|
||||
|
@ -78,7 +86,7 @@ static RuntimeContextStorage *GetDefaultStorage() noexcept;
|
|||
// Provides a wrapper for propagating the context object globally.
|
||||
//
|
||||
// By default, a thread-local runtime context storage is used.
|
||||
class RuntimeContext
|
||||
class OPENTELEMETRY_EXPORT RuntimeContext
|
||||
{
|
||||
public:
|
||||
// Return the current context.
|
||||
|
@ -144,7 +152,8 @@ public:
|
|||
*
|
||||
* @param storage a custom runtime context storage
|
||||
*/
|
||||
static void SetRuntimeContextStorage(nostd::shared_ptr<RuntimeContextStorage> storage) noexcept
|
||||
static void SetRuntimeContextStorage(
|
||||
const nostd::shared_ptr<RuntimeContextStorage> &storage) noexcept
|
||||
{
|
||||
GetStorage() = storage;
|
||||
}
|
||||
|
|
|
@ -11,3 +11,15 @@
|
|||
|
||||
#define OPENTELEMETRY_CONCAT(A, B) OPENTELEMETRY_CONCAT_(A, B)
|
||||
#define OPENTELEMETRY_CONCAT_(A, B) A##B
|
||||
|
||||
// Import the C++20 feature-test macros
|
||||
#ifdef __has_include
|
||||
# if __has_include(<version>)
|
||||
# include <version>
|
||||
# endif
|
||||
#elif defined(_MSC_VER) && ((defined(__cplusplus) && __cplusplus >= 202002L) || \
|
||||
(defined(_MSVC_LANG) && _MSVC_LANG >= 202002L))
|
||||
# if _MSC_VER >= 1922
|
||||
# include <version>
|
||||
# endif
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/nostd/unique_ptr.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace logs
|
||||
{
|
||||
|
||||
/**
|
||||
* EventId class which acts the Id of the event with an optional name.
|
||||
*/
|
||||
class EventId
|
||||
{
|
||||
public:
|
||||
EventId(int64_t id, nostd::string_view name) noexcept
|
||||
: id_{id}, name_{nostd::unique_ptr<char[]>{new char[name.length() + 1]}}
|
||||
{
|
||||
std::copy(name.begin(), name.end(), name_.get());
|
||||
name_.get()[name.length()] = 0;
|
||||
}
|
||||
|
||||
EventId(int64_t id) noexcept : id_{id}, name_{nullptr} {}
|
||||
|
||||
public:
|
||||
int64_t id_;
|
||||
nostd::unique_ptr<char[]> name_;
|
||||
};
|
||||
|
||||
} // namespace logs
|
||||
OPENTELEMETRY_END_NAMESPACE
|
|
@ -0,0 +1,82 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "opentelemetry/logs/log_record.h"
|
||||
#include "opentelemetry/logs/logger.h"
|
||||
#include "opentelemetry/logs/logger_type_traits.h"
|
||||
#include "opentelemetry/nostd/shared_ptr.h"
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/nostd/unique_ptr.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace logs
|
||||
{
|
||||
#if OPENTELEMETRY_ABI_VERSION_NO < 2
|
||||
/**
|
||||
* Handles event log record creation.
|
||||
**/
|
||||
class OPENTELEMETRY_DEPRECATED EventLogger
|
||||
{
|
||||
public:
|
||||
virtual ~EventLogger() = default;
|
||||
|
||||
/* Returns the name of the logger */
|
||||
virtual const nostd::string_view GetName() noexcept = 0;
|
||||
|
||||
/* Returns the delegate logger of this event logger */
|
||||
virtual nostd::shared_ptr<Logger> GetDelegateLogger() noexcept = 0;
|
||||
|
||||
/**
|
||||
* Emit a event Log Record object
|
||||
*
|
||||
* @param event_name Event name
|
||||
* @param log_record Log record
|
||||
*/
|
||||
virtual void EmitEvent(nostd::string_view event_name,
|
||||
nostd::unique_ptr<LogRecord> &&log_record) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Emit a event Log Record object with arguments
|
||||
*
|
||||
* @param event_name Event name
|
||||
* @param args Arguments which can be used to set data of log record by type.
|
||||
* Severity -> severity, severity_text
|
||||
* string_view -> body
|
||||
* AttributeValue -> body
|
||||
* SpanContext -> span_id,tace_id and trace_flags
|
||||
* SpanId -> span_id
|
||||
* TraceId -> tace_id
|
||||
* TraceFlags -> trace_flags
|
||||
* SystemTimestamp -> timestamp
|
||||
* system_clock::time_point -> timestamp
|
||||
* KeyValueIterable -> attributes
|
||||
* Key value iterable container -> attributes
|
||||
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
|
||||
*/
|
||||
template <class... ArgumentType>
|
||||
void EmitEvent(nostd::string_view event_name, ArgumentType &&...args)
|
||||
{
|
||||
nostd::shared_ptr<Logger> delegate_logger = GetDelegateLogger();
|
||||
if (!delegate_logger)
|
||||
{
|
||||
return;
|
||||
}
|
||||
nostd::unique_ptr<LogRecord> log_record = delegate_logger->CreateLogRecord();
|
||||
|
||||
IgnoreTraitResult(detail::LogRecordSetterTrait<typename std::decay<ArgumentType>::type>::Set(
|
||||
log_record.get(), std::forward<ArgumentType>(args))...);
|
||||
|
||||
EmitEvent(event_name, std::move(log_record));
|
||||
}
|
||||
|
||||
private:
|
||||
template <class... ValueType>
|
||||
void IgnoreTraitResult(ValueType &&...)
|
||||
{}
|
||||
};
|
||||
#endif
|
||||
} // namespace logs
|
||||
OPENTELEMETRY_END_NAMESPACE
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "opentelemetry/nostd/shared_ptr.h"
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace logs
|
||||
{
|
||||
|
||||
class EventLogger;
|
||||
class Logger;
|
||||
|
||||
#if OPENTELEMETRY_ABI_VERSION_NO < 2
|
||||
/**
|
||||
* Creates new EventLogger instances.
|
||||
*/
|
||||
class OPENTELEMETRY_DEPRECATED EventLoggerProvider
|
||||
{
|
||||
public:
|
||||
virtual ~EventLoggerProvider() = default;
|
||||
|
||||
/**
|
||||
* Creates a named EventLogger instance.
|
||||
*
|
||||
*/
|
||||
|
||||
virtual nostd::shared_ptr<EventLogger> CreateEventLogger(
|
||||
nostd::shared_ptr<Logger> delegate_logger,
|
||||
nostd::string_view event_domain) noexcept = 0;
|
||||
};
|
||||
#endif
|
||||
} // namespace logs
|
||||
OPENTELEMETRY_END_NAMESPACE
|
|
@ -0,0 +1,92 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "opentelemetry/common/attribute_value.h"
|
||||
#include "opentelemetry/common/timestamp.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace trace
|
||||
{
|
||||
class SpanId;
|
||||
class TraceId;
|
||||
class TraceFlags;
|
||||
} // namespace trace
|
||||
|
||||
namespace logs
|
||||
{
|
||||
|
||||
enum class Severity : uint8_t;
|
||||
|
||||
/**
|
||||
* Maintains a representation of a log in a format that can be processed by a recorder.
|
||||
*
|
||||
* This class is thread-compatible.
|
||||
*/
|
||||
class LogRecord
|
||||
{
|
||||
public:
|
||||
virtual ~LogRecord() = default;
|
||||
|
||||
/**
|
||||
* Set the timestamp for this log.
|
||||
* @param timestamp the timestamp to set
|
||||
*/
|
||||
virtual void SetTimestamp(common::SystemTimestamp timestamp) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Set the observed timestamp for this log.
|
||||
* @param timestamp the timestamp to set
|
||||
*/
|
||||
virtual void SetObservedTimestamp(common::SystemTimestamp timestamp) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Set the severity for this log.
|
||||
* @param severity the severity of the event
|
||||
*/
|
||||
virtual void SetSeverity(logs::Severity severity) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Set body field for this log.
|
||||
* @param message the body to set
|
||||
*/
|
||||
virtual void SetBody(const common::AttributeValue &message) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Set an attribute of a log.
|
||||
* @param key the name of the attribute
|
||||
* @param value the attribute value
|
||||
*/
|
||||
virtual void SetAttribute(nostd::string_view key,
|
||||
const common::AttributeValue &value) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Set the Event Id.
|
||||
* @param id The event id to set
|
||||
* @param name Optional event name to set
|
||||
*/
|
||||
// TODO: mark this as pure virtual once all exporters have been updated
|
||||
virtual void SetEventId(int64_t id, nostd::string_view name = {}) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Set the trace id for this log.
|
||||
* @param trace_id the trace id to set
|
||||
*/
|
||||
virtual void SetTraceId(const trace::TraceId &trace_id) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Set the span id for this log.
|
||||
* @param span_id the span id to set
|
||||
*/
|
||||
virtual void SetSpanId(const trace::SpanId &span_id) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Inject trace_flags for this log.
|
||||
* @param trace_flags the trace flags to set
|
||||
*/
|
||||
virtual void SetTraceFlags(const trace::TraceFlags &trace_flags) noexcept = 0;
|
||||
};
|
||||
} // namespace logs
|
||||
OPENTELEMETRY_END_NAMESPACE
|
File diff suppressed because it is too large
Load Diff
|
@ -2,19 +2,25 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifdef ENABLE_LOGS_PREVIEW
|
||||
|
||||
# include "opentelemetry/logs/logger.h"
|
||||
# include "opentelemetry/nostd/shared_ptr.h"
|
||||
# include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/common/key_value_iterable.h"
|
||||
#include "opentelemetry/common/key_value_iterable_view.h"
|
||||
#include "opentelemetry/nostd/shared_ptr.h"
|
||||
#include "opentelemetry/nostd/span.h"
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/nostd/type_traits.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace logs
|
||||
{
|
||||
|
||||
class Logger;
|
||||
|
||||
/**
|
||||
* Creates new Logger instances.
|
||||
*/
|
||||
class LoggerProvider
|
||||
class OPENTELEMETRY_EXPORT LoggerProvider
|
||||
{
|
||||
public:
|
||||
virtual ~LoggerProvider() = default;
|
||||
|
@ -30,18 +36,36 @@ public:
|
|||
*
|
||||
*/
|
||||
|
||||
virtual nostd::shared_ptr<Logger> GetLogger(nostd::string_view logger_name,
|
||||
nostd::string_view options,
|
||||
nostd::string_view library_name,
|
||||
nostd::string_view library_version = "",
|
||||
nostd::string_view schema_url = "") = 0;
|
||||
virtual nostd::shared_ptr<Logger> GetLogger(
|
||||
nostd::string_view logger_name,
|
||||
nostd::string_view library_name = "",
|
||||
nostd::string_view library_version = "",
|
||||
nostd::string_view schema_url = "",
|
||||
const common::KeyValueIterable &attributes = common::NoopKeyValueIterable()) = 0;
|
||||
|
||||
virtual nostd::shared_ptr<Logger> GetLogger(nostd::string_view logger_name,
|
||||
nostd::span<nostd::string_view> args,
|
||||
nostd::string_view library_name,
|
||||
nostd::string_view library_version = "",
|
||||
nostd::string_view schema_url = "") = 0;
|
||||
nostd::shared_ptr<Logger> GetLogger(
|
||||
nostd::string_view logger_name,
|
||||
nostd::string_view library_name,
|
||||
nostd::string_view library_version,
|
||||
nostd::string_view schema_url,
|
||||
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>> attributes)
|
||||
{
|
||||
return GetLogger(logger_name, library_name, library_version, schema_url,
|
||||
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
|
||||
attributes.begin(), attributes.end()});
|
||||
}
|
||||
|
||||
template <class T,
|
||||
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
|
||||
nostd::shared_ptr<Logger> GetLogger(nostd::string_view logger_name,
|
||||
nostd::string_view library_name,
|
||||
nostd::string_view library_version,
|
||||
nostd::string_view schema_url,
|
||||
const T &attributes)
|
||||
{
|
||||
return GetLogger(logger_name, library_name, library_version, schema_url,
|
||||
common::KeyValueIterableView<T>(attributes));
|
||||
}
|
||||
};
|
||||
} // namespace logs
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,204 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
#include "opentelemetry/common/attribute_value.h"
|
||||
#include "opentelemetry/common/key_value_iterable.h"
|
||||
#include "opentelemetry/common/timestamp.h"
|
||||
#include "opentelemetry/logs/event_id.h"
|
||||
#include "opentelemetry/logs/log_record.h"
|
||||
#include "opentelemetry/logs/severity.h"
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/nostd/type_traits.h"
|
||||
#include "opentelemetry/trace/span_context.h"
|
||||
#include "opentelemetry/trace/span_id.h"
|
||||
#include "opentelemetry/trace/trace_flags.h"
|
||||
#include "opentelemetry/trace/trace_id.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace logs
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <class ValueType>
|
||||
struct LogRecordSetterTrait;
|
||||
|
||||
template <>
|
||||
struct LogRecordSetterTrait<Severity>
|
||||
{
|
||||
template <class ArgumentType>
|
||||
inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept
|
||||
{
|
||||
log_record->SetSeverity(std::forward<ArgumentType>(arg));
|
||||
|
||||
return log_record;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct LogRecordSetterTrait<EventId>
|
||||
{
|
||||
template <class ArgumentType>
|
||||
inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept
|
||||
{
|
||||
log_record->SetEventId(arg.id_, nostd::string_view{arg.name_.get()});
|
||||
|
||||
return log_record;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct LogRecordSetterTrait<trace::SpanContext>
|
||||
{
|
||||
template <class ArgumentType>
|
||||
inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept
|
||||
{
|
||||
log_record->SetSpanId(arg.span_id());
|
||||
log_record->SetTraceId(arg.trace_id());
|
||||
log_record->SetTraceFlags(arg.trace_flags());
|
||||
|
||||
return log_record;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct LogRecordSetterTrait<trace::SpanId>
|
||||
{
|
||||
template <class ArgumentType>
|
||||
inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept
|
||||
{
|
||||
log_record->SetSpanId(std::forward<ArgumentType>(arg));
|
||||
|
||||
return log_record;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct LogRecordSetterTrait<trace::TraceId>
|
||||
{
|
||||
template <class ArgumentType>
|
||||
inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept
|
||||
{
|
||||
log_record->SetTraceId(std::forward<ArgumentType>(arg));
|
||||
|
||||
return log_record;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct LogRecordSetterTrait<trace::TraceFlags>
|
||||
{
|
||||
template <class ArgumentType>
|
||||
inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept
|
||||
{
|
||||
log_record->SetTraceFlags(std::forward<ArgumentType>(arg));
|
||||
|
||||
return log_record;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct LogRecordSetterTrait<common::SystemTimestamp>
|
||||
{
|
||||
template <class ArgumentType>
|
||||
inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept
|
||||
{
|
||||
log_record->SetTimestamp(std::forward<ArgumentType>(arg));
|
||||
|
||||
return log_record;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct LogRecordSetterTrait<std::chrono::system_clock::time_point>
|
||||
{
|
||||
template <class ArgumentType>
|
||||
inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept
|
||||
{
|
||||
log_record->SetTimestamp(common::SystemTimestamp(std::forward<ArgumentType>(arg)));
|
||||
|
||||
return log_record;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct LogRecordSetterTrait<common::KeyValueIterable>
|
||||
{
|
||||
template <class ArgumentType>
|
||||
inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept
|
||||
{
|
||||
arg.ForEachKeyValue(
|
||||
[&log_record](nostd::string_view key, common::AttributeValue value) noexcept {
|
||||
log_record->SetAttribute(key, value);
|
||||
return true;
|
||||
});
|
||||
|
||||
return log_record;
|
||||
}
|
||||
};
|
||||
|
||||
template <class ValueType>
|
||||
struct LogRecordSetterTrait
|
||||
{
|
||||
static_assert(!std::is_same<nostd::unique_ptr<LogRecord>, ValueType>::value &&
|
||||
!std::is_same<std::unique_ptr<LogRecord>, ValueType>::value,
|
||||
"unique_ptr<LogRecord> is not allowed, please use std::move()");
|
||||
|
||||
template <class ArgumentType,
|
||||
nostd::enable_if_t<std::is_convertible<ArgumentType, nostd::string_view>::value ||
|
||||
std::is_convertible<ArgumentType, common::AttributeValue>::value,
|
||||
void> * = nullptr>
|
||||
inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept
|
||||
{
|
||||
log_record->SetBody(std::forward<ArgumentType>(arg));
|
||||
|
||||
return log_record;
|
||||
}
|
||||
|
||||
template <class ArgumentType,
|
||||
nostd::enable_if_t<std::is_base_of<common::KeyValueIterable, ArgumentType>::value, bool>
|
||||
* = nullptr>
|
||||
inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept
|
||||
{
|
||||
return LogRecordSetterTrait<common::KeyValueIterable>::Set(log_record,
|
||||
std::forward<ArgumentType>(arg));
|
||||
}
|
||||
|
||||
template <class ArgumentType,
|
||||
nostd::enable_if_t<common::detail::is_key_value_iterable<ArgumentType>::value, int> * =
|
||||
nullptr>
|
||||
inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept
|
||||
{
|
||||
for (auto &argv : arg)
|
||||
{
|
||||
log_record->SetAttribute(argv.first, argv.second);
|
||||
}
|
||||
|
||||
return log_record;
|
||||
}
|
||||
};
|
||||
|
||||
template <class ValueType, class... ArgumentType>
|
||||
struct LogRecordHasType;
|
||||
|
||||
template <class ValueType>
|
||||
struct LogRecordHasType<ValueType> : public std::false_type
|
||||
{};
|
||||
|
||||
template <class ValueType, class TargetType, class... ArgumentType>
|
||||
struct LogRecordHasType<ValueType, TargetType, ArgumentType...>
|
||||
: public std::conditional<std::is_same<ValueType, TargetType>::value,
|
||||
std::true_type,
|
||||
LogRecordHasType<ValueType, ArgumentType...>>::type
|
||||
{};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace logs
|
||||
OPENTELEMETRY_END_NAMESPACE
|
|
@ -2,34 +2,27 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifdef ENABLE_LOGS_PREVIEW
|
||||
|
||||
// Please refer to provider.h for documentation on how to obtain a Logger object.
|
||||
//
|
||||
// This file is part of the internal implementation of OpenTelemetry. Nothing in this file should be
|
||||
// used directly. Please refer to logger.h for documentation on these interfaces.
|
||||
|
||||
# include <memory>
|
||||
|
||||
# include "opentelemetry/common/attribute_value.h"
|
||||
# include "opentelemetry/common/key_value_iterable.h"
|
||||
# include "opentelemetry/common/timestamp.h"
|
||||
# include "opentelemetry/context/runtime_context.h"
|
||||
# include "opentelemetry/logs/logger.h"
|
||||
# include "opentelemetry/logs/logger_provider.h"
|
||||
# include "opentelemetry/logs/severity.h"
|
||||
# include "opentelemetry/nostd/shared_ptr.h"
|
||||
# include "opentelemetry/nostd/span.h"
|
||||
# include "opentelemetry/nostd/string_view.h"
|
||||
# include "opentelemetry/nostd/unique_ptr.h"
|
||||
# include "opentelemetry/trace/span_id.h"
|
||||
# include "opentelemetry/trace/trace_flags.h"
|
||||
# include "opentelemetry/trace/trace_id.h"
|
||||
# include "opentelemetry/version.h"
|
||||
|
||||
# include "opentelemetry/version.h"
|
||||
#include "opentelemetry/logs/event_logger.h"
|
||||
#include "opentelemetry/logs/event_logger_provider.h"
|
||||
#include "opentelemetry/logs/logger.h"
|
||||
#include "opentelemetry/logs/logger_provider.h"
|
||||
#include "opentelemetry/nostd/shared_ptr.h"
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/nostd/unique_ptr.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace common
|
||||
{
|
||||
class KeyValueIterable;
|
||||
} // namespace common
|
||||
|
||||
namespace logs
|
||||
{
|
||||
/**
|
||||
|
@ -41,58 +34,98 @@ class NoopLogger final : public Logger
|
|||
public:
|
||||
const nostd::string_view GetName() noexcept override { return "noop logger"; }
|
||||
|
||||
void Log(Severity /* severity */,
|
||||
nostd::string_view /* body */,
|
||||
const common::KeyValueIterable & /* attributes */,
|
||||
trace::TraceId /* trace_id */,
|
||||
trace::SpanId /* span_id */,
|
||||
trace::TraceFlags /* trace_flags */,
|
||||
common::SystemTimestamp /* timestamp */) noexcept override
|
||||
{}
|
||||
nostd::unique_ptr<LogRecord> CreateLogRecord() noexcept override
|
||||
{
|
||||
/*
|
||||
* Do not return memory shared between threads,
|
||||
* a `new` + `delete` for each noop record can not be avoided,
|
||||
* due to the semantic of unique_ptr.
|
||||
*/
|
||||
return nostd::unique_ptr<LogRecord>(new NoopLogRecord());
|
||||
}
|
||||
|
||||
void Log(Severity /* severity */,
|
||||
nostd::string_view /* name */,
|
||||
nostd::string_view /* body */,
|
||||
const common::KeyValueIterable & /* attributes */,
|
||||
trace::TraceId /* trace_id */,
|
||||
trace::SpanId /* span_id */,
|
||||
trace::TraceFlags /* trace_flags */,
|
||||
common::SystemTimestamp /* timestamp */) noexcept override
|
||||
{}
|
||||
using Logger::EmitLogRecord;
|
||||
|
||||
void EmitLogRecord(nostd::unique_ptr<LogRecord> &&) noexcept override {}
|
||||
|
||||
private:
|
||||
class NoopLogRecord : public LogRecord
|
||||
{
|
||||
public:
|
||||
NoopLogRecord() = default;
|
||||
~NoopLogRecord() override = default;
|
||||
|
||||
void SetTimestamp(common::SystemTimestamp /* timestamp */) noexcept override {}
|
||||
void SetObservedTimestamp(common::SystemTimestamp /* timestamp */) noexcept override {}
|
||||
void SetSeverity(logs::Severity /* severity */) noexcept override {}
|
||||
void SetBody(const common::AttributeValue & /* message */) noexcept override {}
|
||||
void SetAttribute(nostd::string_view /* key */,
|
||||
const common::AttributeValue & /* value */) noexcept override
|
||||
{}
|
||||
void SetEventId(int64_t /* id */, nostd::string_view /* name */) noexcept override {}
|
||||
void SetTraceId(const trace::TraceId & /* trace_id */) noexcept override {}
|
||||
void SetSpanId(const trace::SpanId & /* span_id */) noexcept override {}
|
||||
void SetTraceFlags(const trace::TraceFlags & /* trace_flags */) noexcept override {}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* No-op implementation of a LoggerProvider.
|
||||
*/
|
||||
class NoopLoggerProvider final : public opentelemetry::logs::LoggerProvider
|
||||
class NoopLoggerProvider final : public LoggerProvider
|
||||
{
|
||||
public:
|
||||
NoopLoggerProvider()
|
||||
: logger_{
|
||||
nostd::shared_ptr<opentelemetry::logs::NoopLogger>(new opentelemetry::logs::NoopLogger)}
|
||||
{}
|
||||
NoopLoggerProvider() : logger_{nostd::shared_ptr<NoopLogger>(new NoopLogger())} {}
|
||||
|
||||
nostd::shared_ptr<Logger> GetLogger(nostd::string_view /* logger_name */,
|
||||
nostd::string_view /* options */,
|
||||
nostd::string_view /* library_name */,
|
||||
nostd::string_view /* library_version */,
|
||||
nostd::string_view /* schema_url */) override
|
||||
{
|
||||
return logger_;
|
||||
}
|
||||
|
||||
nostd::shared_ptr<Logger> GetLogger(nostd::string_view /* logger_name */,
|
||||
nostd::span<nostd::string_view> /* args */,
|
||||
nostd::string_view /* library_name */,
|
||||
nostd::string_view /* library_version */,
|
||||
nostd::string_view /* schema_url */) override
|
||||
nostd::string_view /* schema_url */,
|
||||
const common::KeyValueIterable & /* attributes */) override
|
||||
{
|
||||
return logger_;
|
||||
}
|
||||
|
||||
private:
|
||||
nostd::shared_ptr<opentelemetry::logs::Logger> logger_;
|
||||
nostd::shared_ptr<Logger> logger_;
|
||||
};
|
||||
|
||||
#if OPENTELEMETRY_ABI_VERSION_NO < 2
|
||||
class NoopEventLogger final : public EventLogger
|
||||
{
|
||||
public:
|
||||
NoopEventLogger() : logger_{nostd::shared_ptr<NoopLogger>(new NoopLogger())} {}
|
||||
|
||||
const nostd::string_view GetName() noexcept override { return "noop event logger"; }
|
||||
|
||||
nostd::shared_ptr<Logger> GetDelegateLogger() noexcept override { return logger_; }
|
||||
|
||||
void EmitEvent(nostd::string_view, nostd::unique_ptr<LogRecord> &&) noexcept override {}
|
||||
|
||||
private:
|
||||
nostd::shared_ptr<Logger> logger_;
|
||||
};
|
||||
|
||||
/**
|
||||
* No-op implementation of a EventLoggerProvider.
|
||||
*/
|
||||
class NoopEventLoggerProvider final : public EventLoggerProvider
|
||||
{
|
||||
public:
|
||||
NoopEventLoggerProvider() : event_logger_{nostd::shared_ptr<EventLogger>(new NoopEventLogger())}
|
||||
{}
|
||||
|
||||
nostd::shared_ptr<EventLogger> CreateEventLogger(
|
||||
nostd::shared_ptr<Logger> /*delegate_logger*/,
|
||||
nostd::string_view /*event_domain*/) noexcept override
|
||||
{
|
||||
return event_logger_;
|
||||
}
|
||||
|
||||
private:
|
||||
nostd::shared_ptr<EventLogger> event_logger_;
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace logs
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
||||
|
|
|
@ -2,23 +2,28 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifdef ENABLE_LOGS_PREVIEW
|
||||
|
||||
# include <mutex>
|
||||
#include <mutex>
|
||||
|
||||
# include "opentelemetry/common/macros.h"
|
||||
# include "opentelemetry/common/spin_lock_mutex.h"
|
||||
# include "opentelemetry/logs/logger_provider.h"
|
||||
# include "opentelemetry/logs/noop.h"
|
||||
# include "opentelemetry/nostd/shared_ptr.h"
|
||||
#include "opentelemetry/common/macros.h"
|
||||
#include "opentelemetry/common/spin_lock_mutex.h"
|
||||
#include "opentelemetry/logs/noop.h"
|
||||
#include "opentelemetry/nostd/shared_ptr.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace logs
|
||||
{
|
||||
|
||||
#if OPENTELEMETRY_ABI_VERSION_NO < 2
|
||||
class EventLoggerProvider;
|
||||
#endif
|
||||
class LoggerProvider;
|
||||
|
||||
/**
|
||||
* Stores the singleton global LoggerProvider.
|
||||
*/
|
||||
class Provider
|
||||
class OPENTELEMETRY_EXPORT Provider
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -36,12 +41,37 @@ public:
|
|||
/**
|
||||
* Changes the singleton LoggerProvider.
|
||||
*/
|
||||
static void SetLoggerProvider(nostd::shared_ptr<LoggerProvider> tp) noexcept
|
||||
static void SetLoggerProvider(const nostd::shared_ptr<LoggerProvider> &tp) noexcept
|
||||
{
|
||||
std::lock_guard<common::SpinLockMutex> guard(GetLock());
|
||||
GetProvider() = tp;
|
||||
}
|
||||
|
||||
#if OPENTELEMETRY_ABI_VERSION_NO < 2
|
||||
/**
|
||||
* Returns the singleton EventLoggerProvider.
|
||||
*
|
||||
* By default, a no-op EventLoggerProvider is returned. This will never return a
|
||||
* nullptr EventLoggerProvider.
|
||||
*/
|
||||
OPENTELEMETRY_DEPRECATED static nostd::shared_ptr<EventLoggerProvider>
|
||||
GetEventLoggerProvider() noexcept
|
||||
{
|
||||
std::lock_guard<common::SpinLockMutex> guard(GetLock());
|
||||
return nostd::shared_ptr<EventLoggerProvider>(GetEventProvider());
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the singleton EventLoggerProvider.
|
||||
*/
|
||||
OPENTELEMETRY_DEPRECATED static void SetEventLoggerProvider(
|
||||
const nostd::shared_ptr<EventLoggerProvider> &tp) noexcept
|
||||
{
|
||||
std::lock_guard<common::SpinLockMutex> guard(GetLock());
|
||||
GetEventProvider() = tp;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr<LoggerProvider> &GetProvider() noexcept
|
||||
{
|
||||
|
@ -49,6 +79,16 @@ private:
|
|||
return provider;
|
||||
}
|
||||
|
||||
#if OPENTELEMETRY_ABI_VERSION_NO < 2
|
||||
OPENTELEMETRY_DEPRECATED
|
||||
OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr<EventLoggerProvider> &
|
||||
GetEventProvider() noexcept
|
||||
{
|
||||
static nostd::shared_ptr<EventLoggerProvider> provider(new NoopEventLoggerProvider);
|
||||
return provider;
|
||||
}
|
||||
#endif
|
||||
|
||||
OPENTELEMETRY_API_SINGLETON static common::SpinLockMutex &GetLock() noexcept
|
||||
{
|
||||
static common::SpinLockMutex lock;
|
||||
|
@ -58,4 +98,3 @@ private:
|
|||
|
||||
} // namespace logs
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifdef ENABLE_LOGS_PREVIEW
|
||||
|
||||
# include "opentelemetry/version.h"
|
||||
#include <cstdint>
|
||||
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace logs
|
||||
|
@ -13,36 +15,41 @@ namespace logs
|
|||
/**
|
||||
* Severity Levels assigned to log events, based on Log Data Model,
|
||||
* with the addition of kInvalid (mapped to a severity number of 0).
|
||||
*
|
||||
* See
|
||||
* https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-severitynumber
|
||||
*/
|
||||
enum class Severity : uint8_t
|
||||
{
|
||||
kInvalid,
|
||||
kTrace,
|
||||
kTrace2,
|
||||
kTrace3,
|
||||
kTrace4,
|
||||
kDebug,
|
||||
kDebug2,
|
||||
kDebug3,
|
||||
kDebug4,
|
||||
kInfo,
|
||||
kInfo2,
|
||||
kInfo3,
|
||||
kInfo4,
|
||||
kWarn,
|
||||
kWarn2,
|
||||
kWarn3,
|
||||
kWarn4,
|
||||
kError,
|
||||
kError2,
|
||||
kError3,
|
||||
kError4,
|
||||
kFatal,
|
||||
kFatal2,
|
||||
kFatal3,
|
||||
kFatal4
|
||||
kInvalid = 0,
|
||||
kTrace = 1,
|
||||
kTrace2 = 2,
|
||||
kTrace3 = 3,
|
||||
kTrace4 = 4,
|
||||
kDebug = 5,
|
||||
kDebug2 = 6,
|
||||
kDebug3 = 7,
|
||||
kDebug4 = 8,
|
||||
kInfo = 9,
|
||||
kInfo2 = 10,
|
||||
kInfo3 = 11,
|
||||
kInfo4 = 12,
|
||||
kWarn = 13,
|
||||
kWarn2 = 14,
|
||||
kWarn3 = 15,
|
||||
kWarn4 = 16,
|
||||
kError = 17,
|
||||
kError2 = 18,
|
||||
kError3 = 19,
|
||||
kError4 = 20,
|
||||
kFatal = 21,
|
||||
kFatal2 = 22,
|
||||
kFatal3 = 23,
|
||||
kFatal4 = 24
|
||||
};
|
||||
|
||||
const uint8_t kMaxSeverity = 255;
|
||||
|
||||
/**
|
||||
* Mapping of the severity enum above, to a severity text string (in all caps).
|
||||
* This severity text can be printed out by exporters. Capital letters follow the
|
||||
|
@ -51,11 +58,10 @@ enum class Severity : uint8_t
|
|||
* Included to follow the specification's recommendation to print both
|
||||
* severity number and text in each log record.
|
||||
*/
|
||||
const opentelemetry::nostd::string_view SeverityNumToText[25] = {
|
||||
const nostd::string_view SeverityNumToText[25] = {
|
||||
"INVALID", "TRACE", "TRACE2", "TRACE3", "TRACE4", "DEBUG", "DEBUG2", "DEBUG3", "DEBUG4",
|
||||
"INFO", "INFO2", "INFO3", "INFO4", "WARN", "WARN2", "WARN3", "WARN4", "ERROR",
|
||||
"ERROR2", "ERROR3", "ERROR4", "FATAL", "FATAL2", "FATAL3", "FATAL4"};
|
||||
|
||||
} // namespace logs
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifndef ENABLE_METRICS_PREVIEW
|
||||
|
||||
# include "opentelemetry/metrics/observer_result.h"
|
||||
#include "opentelemetry/metrics/observer_result.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace metrics
|
||||
|
@ -31,4 +31,3 @@ public:
|
|||
|
||||
} // namespace metrics
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
||||
|
|
|
@ -2,19 +2,30 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifndef ENABLE_METRICS_PREVIEW
|
||||
|
||||
# include "opentelemetry/metrics/async_instruments.h"
|
||||
# include "opentelemetry/metrics/sync_instruments.h"
|
||||
# include "opentelemetry/nostd/shared_ptr.h"
|
||||
# include "opentelemetry/nostd/span.h"
|
||||
# include "opentelemetry/nostd/string_view.h"
|
||||
# include "opentelemetry/nostd/unique_ptr.h"
|
||||
# include "opentelemetry/version.h"
|
||||
#include "opentelemetry/nostd/shared_ptr.h"
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/nostd/unique_ptr.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace metrics
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
class Counter;
|
||||
|
||||
template <typename T>
|
||||
class Histogram;
|
||||
|
||||
template <typename T>
|
||||
class UpDownCounter;
|
||||
|
||||
template <typename T>
|
||||
class Gauge;
|
||||
|
||||
class ObservableInstrument;
|
||||
|
||||
/**
|
||||
* Handles instrument creation and provides a facility for batch recording.
|
||||
*
|
||||
|
@ -83,9 +94,30 @@ public:
|
|||
nostd::string_view description = "",
|
||||
nostd::string_view unit = "") noexcept = 0;
|
||||
|
||||
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
|
||||
/**
|
||||
* Creates a Asynchronouse (Observable) Gauge with the passed characteristics and returns a
|
||||
* shared_ptr to that Observable Counter
|
||||
* Creates a Gauge with the passed characteristics and returns a unique_ptr to that Gauge.
|
||||
*
|
||||
* @param name the name of the new Gauge.
|
||||
* @param description a brief description of what the Gauge is used for.
|
||||
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
|
||||
* @return a unique pointer to the created Gauge.
|
||||
*/
|
||||
|
||||
virtual nostd::unique_ptr<Gauge<int64_t>> CreateInt64Gauge(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description = "",
|
||||
nostd::string_view unit = "") noexcept = 0;
|
||||
|
||||
virtual nostd::unique_ptr<Gauge<double>> CreateDoubleGauge(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description = "",
|
||||
nostd::string_view unit = "") noexcept = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Creates a Asynchronous (Observable) Gauge with the passed characteristics and returns a
|
||||
* shared_ptr to that Observable Gauge
|
||||
*
|
||||
* @param name the name of the new Observable Gauge.
|
||||
* @param description a brief description of what the Observable Gauge is used for.
|
||||
|
@ -121,7 +153,7 @@ public:
|
|||
nostd::string_view unit = "") noexcept = 0;
|
||||
|
||||
/**
|
||||
* Creates a Asynchronouse (Observable) UpDownCounter with the passed characteristics and returns
|
||||
* Creates a Asynchronous (Observable) UpDownCounter with the passed characteristics and returns
|
||||
* a shared_ptr to that Observable UpDownCounter
|
||||
*
|
||||
* @param name the name of the new Observable UpDownCounter.
|
||||
|
@ -140,4 +172,3 @@ public:
|
|||
};
|
||||
} // namespace metrics
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
||||
|
|
|
@ -2,15 +2,20 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifndef ENABLE_METRICS_PREVIEW
|
||||
|
||||
# include "opentelemetry/metrics/meter.h"
|
||||
# include "opentelemetry/nostd/shared_ptr.h"
|
||||
# include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/common/key_value_iterable.h"
|
||||
#include "opentelemetry/common/key_value_iterable_view.h"
|
||||
#include "opentelemetry/nostd/shared_ptr.h"
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/nostd/type_traits.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace metrics
|
||||
{
|
||||
|
||||
class Meter;
|
||||
|
||||
/**
|
||||
* Creates new Meter instances.
|
||||
*/
|
||||
|
@ -18,16 +23,126 @@ class MeterProvider
|
|||
{
|
||||
public:
|
||||
virtual ~MeterProvider() = default;
|
||||
|
||||
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
|
||||
|
||||
/**
|
||||
* Gets or creates a named Meter instance.
|
||||
* Gets or creates a named Meter instance (ABI).
|
||||
*
|
||||
* Optionally a version can be passed to create a named and versioned Meter
|
||||
* instance.
|
||||
* @since ABI_VERSION 2
|
||||
*
|
||||
* @param[in] name Meter instrumentation scope
|
||||
* @param[in] version Instrumentation scope version
|
||||
* @param[in] schema_url Instrumentation scope schema URL
|
||||
* @param[in] attributes Instrumentation scope attributes (optional, may be nullptr)
|
||||
*/
|
||||
virtual nostd::shared_ptr<Meter> GetMeter(nostd::string_view library_name,
|
||||
nostd::string_view library_version = "",
|
||||
nostd::string_view schema_url = "") noexcept = 0;
|
||||
virtual nostd::shared_ptr<Meter> GetMeter(
|
||||
nostd::string_view name,
|
||||
nostd::string_view version,
|
||||
nostd::string_view schema_url,
|
||||
const common::KeyValueIterable *attributes) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Gets or creates a named Meter instance (API helper).
|
||||
*
|
||||
* @since ABI_VERSION 2
|
||||
*
|
||||
* @param[in] name Meter instrumentation scope
|
||||
* @param[in] version Instrumentation scope version, optional
|
||||
* @param[in] schema_url Instrumentation scope schema URL, optional
|
||||
*/
|
||||
nostd::shared_ptr<Meter> GetMeter(nostd::string_view name,
|
||||
nostd::string_view version = "",
|
||||
nostd::string_view schema_url = "")
|
||||
{
|
||||
return GetMeter(name, version, schema_url, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets or creates a named Meter instance (API helper).
|
||||
*
|
||||
* @since ABI_VERSION 2
|
||||
*
|
||||
* @param[in] name Meter instrumentation scope
|
||||
* @param[in] version Instrumentation scope version
|
||||
* @param[in] schema_url Instrumentation scope schema URL
|
||||
* @param[in] attributes Instrumentation scope attributes
|
||||
*/
|
||||
nostd::shared_ptr<Meter> GetMeter(
|
||||
nostd::string_view name,
|
||||
nostd::string_view version,
|
||||
nostd::string_view schema_url,
|
||||
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>> attributes)
|
||||
{
|
||||
/* Build a container from std::initializer_list. */
|
||||
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>> attributes_span{
|
||||
attributes.begin(), attributes.end()};
|
||||
|
||||
/* Build a view on the container. */
|
||||
common::KeyValueIterableView<
|
||||
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>>
|
||||
iterable_attributes{attributes_span};
|
||||
|
||||
/* Add attributes using the view. */
|
||||
return GetMeter(name, version, schema_url, &iterable_attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets or creates a named Meter instance (API helper).
|
||||
*
|
||||
* @since ABI_VERSION 2
|
||||
*
|
||||
* @param[in] name Meter instrumentation scope
|
||||
* @param[in] version Instrumentation scope version
|
||||
* @param[in] schema_url Instrumentation scope schema URL
|
||||
* @param[in] attributes Instrumentation scope attributes container
|
||||
*/
|
||||
template <class T,
|
||||
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
|
||||
nostd::shared_ptr<Meter> GetMeter(nostd::string_view name,
|
||||
nostd::string_view version,
|
||||
nostd::string_view schema_url,
|
||||
const T &attributes)
|
||||
{
|
||||
/* Build a view on the container. */
|
||||
common::KeyValueIterableView<T> iterable_attributes(attributes);
|
||||
|
||||
/* Add attributes using the view. */
|
||||
return GetMeter(name, version, schema_url, &iterable_attributes);
|
||||
}
|
||||
|
||||
#else
|
||||
/**
|
||||
* Gets or creates a named Meter instance (ABI)
|
||||
*
|
||||
* @since ABI_VERSION 1
|
||||
*
|
||||
* @param[in] name Meter instrumentation scope
|
||||
* @param[in] version Instrumentation scope version, optional
|
||||
* @param[in] schema_url Instrumentation scope schema URL, optional
|
||||
*/
|
||||
virtual nostd::shared_ptr<Meter> GetMeter(nostd::string_view name,
|
||||
nostd::string_view version = "",
|
||||
nostd::string_view schema_url = "") noexcept = 0;
|
||||
#endif
|
||||
|
||||
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
|
||||
/**
|
||||
* Remove a named Meter instance (ABI).
|
||||
*
|
||||
* This API is experimental, see
|
||||
* https://github.com/open-telemetry/opentelemetry-specification/issues/2232
|
||||
*
|
||||
* @since ABI_VERSION 2
|
||||
*
|
||||
* @param[in] name Meter instrumentation scope
|
||||
* @param[in] version Instrumentation scope version, optional
|
||||
* @param[in] schema_url Instrumentation scope schema URL, optional
|
||||
*/
|
||||
virtual void RemoveMeter(nostd::string_view name,
|
||||
nostd::string_view version = "",
|
||||
nostd::string_view schema_url = "") noexcept = 0;
|
||||
#endif
|
||||
};
|
||||
} // namespace metrics
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifndef ENABLE_METRICS_PREVIEW
|
||||
|
||||
# include "opentelemetry/metrics/async_instruments.h"
|
||||
# include "opentelemetry/metrics/meter.h"
|
||||
# include "opentelemetry/metrics/meter_provider.h"
|
||||
# include "opentelemetry/metrics/observer_result.h"
|
||||
# include "opentelemetry/metrics/sync_instruments.h"
|
||||
# include "opentelemetry/version.h"
|
||||
#include "opentelemetry/metrics/async_instruments.h"
|
||||
#include "opentelemetry/metrics/meter.h"
|
||||
#include "opentelemetry/metrics/meter_provider.h"
|
||||
#include "opentelemetry/metrics/observer_result.h"
|
||||
#include "opentelemetry/metrics/sync_instruments.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace metrics
|
||||
|
@ -24,12 +23,11 @@ public:
|
|||
nostd::string_view /* unit */) noexcept
|
||||
{}
|
||||
void Add(T /* value */) noexcept override {}
|
||||
void Add(T /* value */, const opentelemetry::context::Context & /* context */) noexcept override
|
||||
{}
|
||||
void Add(T /* value */, const context::Context & /* context */) noexcept override {}
|
||||
void Add(T /* value */, const common::KeyValueIterable & /* attributes */) noexcept override {}
|
||||
void Add(T /* value */,
|
||||
const common::KeyValueIterable & /* attributes */,
|
||||
const opentelemetry::context::Context & /* context */) noexcept override
|
||||
const context::Context & /* context */) noexcept override
|
||||
{}
|
||||
};
|
||||
|
||||
|
@ -41,13 +39,18 @@ public:
|
|||
nostd::string_view /* description */,
|
||||
nostd::string_view /* unit */) noexcept
|
||||
{}
|
||||
void Record(T /* value */,
|
||||
const opentelemetry::context::Context & /* context */) noexcept override
|
||||
{}
|
||||
void Record(T /* value */, const context::Context & /* context */) noexcept override {}
|
||||
void Record(T /* value */,
|
||||
const common::KeyValueIterable & /* attributes */,
|
||||
const opentelemetry::context::Context & /* context */) noexcept override
|
||||
const context::Context & /* context */) noexcept override
|
||||
{}
|
||||
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
|
||||
void Record(T /*value*/,
|
||||
const opentelemetry::common::KeyValueIterable & /*attributes*/) noexcept override
|
||||
{}
|
||||
|
||||
void Record(T /*value*/) noexcept override {}
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class T>
|
||||
|
@ -60,15 +63,34 @@ public:
|
|||
{}
|
||||
~NoopUpDownCounter() override = default;
|
||||
void Add(T /* value */) noexcept override {}
|
||||
void Add(T /* value */, const opentelemetry::context::Context & /* context */) noexcept override
|
||||
{}
|
||||
void Add(T /* value */, const context::Context & /* context */) noexcept override {}
|
||||
void Add(T /* value */, const common::KeyValueIterable & /* attributes */) noexcept override {}
|
||||
void Add(T /* value */,
|
||||
const common::KeyValueIterable & /* attributes */,
|
||||
const opentelemetry::context::Context & /* context */) noexcept override
|
||||
const context::Context & /* context */) noexcept override
|
||||
{}
|
||||
};
|
||||
|
||||
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
|
||||
template <class T>
|
||||
class NoopGauge : public Gauge<T>
|
||||
{
|
||||
public:
|
||||
NoopGauge(nostd::string_view /* name */,
|
||||
nostd::string_view /* description */,
|
||||
nostd::string_view /* unit */) noexcept
|
||||
{}
|
||||
~NoopGauge() override = default;
|
||||
void Record(T /* value */) noexcept override {}
|
||||
void Record(T /* value */, const context::Context & /* context */) noexcept override {}
|
||||
void Record(T /* value */, const common::KeyValueIterable & /* attributes */) noexcept override {}
|
||||
void Record(T /* value */,
|
||||
const common::KeyValueIterable & /* attributes */,
|
||||
const context::Context & /* context */) noexcept override
|
||||
{}
|
||||
};
|
||||
#endif
|
||||
|
||||
class NoopObservableInstrument : public ObservableInstrument
|
||||
{
|
||||
public:
|
||||
|
@ -138,6 +160,22 @@ public:
|
|||
return nostd::unique_ptr<Histogram<double>>{new NoopHistogram<double>(name, description, unit)};
|
||||
}
|
||||
|
||||
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
|
||||
nostd::unique_ptr<Gauge<int64_t>> CreateInt64Gauge(nostd::string_view name,
|
||||
nostd::string_view description = "",
|
||||
nostd::string_view unit = "") noexcept override
|
||||
{
|
||||
return nostd::unique_ptr<Gauge<int64_t>>{new NoopGauge<int64_t>(name, description, unit)};
|
||||
}
|
||||
|
||||
nostd::unique_ptr<Gauge<double>> CreateDoubleGauge(nostd::string_view name,
|
||||
nostd::string_view description = "",
|
||||
nostd::string_view unit = "") noexcept override
|
||||
{
|
||||
return nostd::unique_ptr<Gauge<double>>{new NoopGauge<double>(name, description, unit)};
|
||||
}
|
||||
#endif
|
||||
|
||||
nostd::shared_ptr<ObservableInstrument> CreateInt64ObservableGauge(
|
||||
nostd::string_view name,
|
||||
nostd::string_view description = "",
|
||||
|
@ -201,16 +239,33 @@ class NoopMeterProvider final : public MeterProvider
|
|||
public:
|
||||
NoopMeterProvider() : meter_{nostd::shared_ptr<Meter>(new NoopMeter)} {}
|
||||
|
||||
nostd::shared_ptr<Meter> GetMeter(nostd::string_view /* library_name */,
|
||||
nostd::string_view /* library_version */,
|
||||
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
|
||||
nostd::shared_ptr<Meter> GetMeter(
|
||||
nostd::string_view /* name */,
|
||||
nostd::string_view /* version */,
|
||||
nostd::string_view /* schema_url */,
|
||||
const common::KeyValueIterable * /* attributes */) noexcept override
|
||||
{
|
||||
return meter_;
|
||||
}
|
||||
#else
|
||||
nostd::shared_ptr<Meter> GetMeter(nostd::string_view /* name */,
|
||||
nostd::string_view /* version */,
|
||||
nostd::string_view /* schema_url */) noexcept override
|
||||
{
|
||||
return meter_;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
|
||||
void RemoveMeter(nostd::string_view /* name */,
|
||||
nostd::string_view /* version */,
|
||||
nostd::string_view /* schema_url */) noexcept override
|
||||
{}
|
||||
#endif
|
||||
|
||||
private:
|
||||
nostd::shared_ptr<Meter> meter_;
|
||||
};
|
||||
} // namespace metrics
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
||||
|
|
|
@ -2,14 +2,15 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifndef ENABLE_METRICS_PREVIEW
|
||||
|
||||
# include "opentelemetry/common/attribute_value.h"
|
||||
# include "opentelemetry/common/key_value_iterable_view.h"
|
||||
# include "opentelemetry/nostd/shared_ptr.h"
|
||||
# include "opentelemetry/nostd/span.h"
|
||||
# include "opentelemetry/nostd/string_view.h"
|
||||
# include "opentelemetry/nostd/type_traits.h"
|
||||
#include "opentelemetry/common/attribute_value.h"
|
||||
#include "opentelemetry/common/key_value_iterable_view.h"
|
||||
#include "opentelemetry/nostd/shared_ptr.h"
|
||||
#include "opentelemetry/nostd/span.h"
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/nostd/type_traits.h"
|
||||
#include "opentelemetry/nostd/variant.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace metrics
|
||||
|
@ -51,4 +52,3 @@ using ObserverResult = nostd::variant<nostd::shared_ptr<ObserverResultT<int64_t>
|
|||
|
||||
} // namespace metrics
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifndef ENABLE_METRICS_PREVIEW
|
||||
|
||||
# include <mutex>
|
||||
#include <mutex>
|
||||
|
||||
# include "opentelemetry/common/macros.h"
|
||||
# include "opentelemetry/common/spin_lock_mutex.h"
|
||||
# include "opentelemetry/metrics/meter_provider.h"
|
||||
# include "opentelemetry/metrics/noop.h"
|
||||
# include "opentelemetry/nostd/shared_ptr.h"
|
||||
#include "opentelemetry/common/spin_lock_mutex.h"
|
||||
#include "opentelemetry/metrics/meter_provider.h"
|
||||
#include "opentelemetry/metrics/noop.h"
|
||||
#include "opentelemetry/nostd/shared_ptr.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace metrics
|
||||
{
|
||||
|
||||
/**
|
||||
* Stores the singleton global MeterProvider.
|
||||
*/
|
||||
|
@ -36,7 +36,7 @@ public:
|
|||
/**
|
||||
* Changes the singleton MeterProvider.
|
||||
*/
|
||||
static void SetMeterProvider(nostd::shared_ptr<MeterProvider> tp) noexcept
|
||||
static void SetMeterProvider(const nostd::shared_ptr<MeterProvider> &tp) noexcept
|
||||
{
|
||||
std::lock_guard<common::SpinLockMutex> guard(GetLock());
|
||||
GetProvider() = tp;
|
||||
|
@ -58,4 +58,3 @@ private:
|
|||
|
||||
} // namespace metrics
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#ifndef ENABLE_METRICS_PREVIEW
|
||||
|
||||
# include "opentelemetry/common/attribute_value.h"
|
||||
# include "opentelemetry/common/key_value_iterable_view.h"
|
||||
# include "opentelemetry/context/context.h"
|
||||
# include "opentelemetry/nostd/span.h"
|
||||
# include "opentelemetry/nostd/string_view.h"
|
||||
# include "opentelemetry/nostd/type_traits.h"
|
||||
#include "opentelemetry/common/attribute_value.h"
|
||||
#include "opentelemetry/common/key_value_iterable_view.h"
|
||||
#include "opentelemetry/context/context.h"
|
||||
#include "opentelemetry/nostd/span.h"
|
||||
#include "opentelemetry/nostd/string_view.h"
|
||||
#include "opentelemetry/nostd/type_traits.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace metrics
|
||||
|
@ -22,46 +22,57 @@ public:
|
|||
virtual ~SynchronousInstrument() = default;
|
||||
};
|
||||
|
||||
/* A Counter instrument that adds values. */
|
||||
template <class T>
|
||||
class Counter : public SynchronousInstrument
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* Add adds the value to the counter's sum
|
||||
* Record a value
|
||||
*
|
||||
* @param value The increment amount. MUST be non-negative.
|
||||
*/
|
||||
virtual void Add(T value) noexcept = 0;
|
||||
|
||||
virtual void Add(T value, const opentelemetry::context::Context &context) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Add adds the value to the counter's sum. The attributes should contain
|
||||
* the keys and values to be associated with this value. Counters only
|
||||
* accept positive valued updates.
|
||||
* Record a value
|
||||
*
|
||||
* @param value The increment amount. MUST be non-negative.
|
||||
* @param attributes the set of attributes, as key-value pairs
|
||||
* @param context The explicit context to associate with this measurement.
|
||||
*/
|
||||
virtual void Add(T value, const context::Context &context) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Record a value with a set of attributes.
|
||||
*
|
||||
* @param value The increment amount. MUST be non-negative.
|
||||
* @param attributes A set of attributes to associate with the value.
|
||||
*/
|
||||
|
||||
virtual void Add(T value, const common::KeyValueIterable &attributes) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Record a value with a set of attributes.
|
||||
*
|
||||
* @param value The increment amount. MUST be non-negative.
|
||||
* @param attributes A set of attributes to associate with the value.
|
||||
* @param context The explicit context to associate with this measurement.
|
||||
*/
|
||||
virtual void Add(T value,
|
||||
const common::KeyValueIterable &attributes,
|
||||
const opentelemetry::context::Context &context) noexcept = 0;
|
||||
const context::Context &context) noexcept = 0;
|
||||
|
||||
template <class U,
|
||||
nostd::enable_if_t<common::detail::is_key_value_iterable<U>::value> * = nullptr>
|
||||
void Add(T value, const U &attributes) noexcept
|
||||
{
|
||||
auto context = opentelemetry::context::Context{};
|
||||
this->Add(value, common::KeyValueIterableView<U>{attributes}, context);
|
||||
this->Add(value, common::KeyValueIterableView<U>{attributes});
|
||||
}
|
||||
|
||||
template <class U,
|
||||
nostd::enable_if_t<common::detail::is_key_value_iterable<U>::value> * = nullptr>
|
||||
void Add(T value, const U &attributes, const opentelemetry::context::Context &context) noexcept
|
||||
void Add(T value, const U &attributes, const context::Context &context) noexcept
|
||||
{
|
||||
this->Add(value, common::KeyValueIterableView<U>{attributes}, context);
|
||||
}
|
||||
|
@ -70,16 +81,13 @@ public:
|
|||
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
|
||||
attributes) noexcept
|
||||
{
|
||||
auto context = opentelemetry::context::Context{};
|
||||
this->Add(value,
|
||||
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
|
||||
attributes.begin(), attributes.end()},
|
||||
context);
|
||||
this->Add(value, nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
|
||||
attributes.begin(), attributes.end()});
|
||||
}
|
||||
|
||||
void Add(T value,
|
||||
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>> attributes,
|
||||
const opentelemetry::context::Context &context) noexcept
|
||||
const context::Context &context) noexcept
|
||||
{
|
||||
this->Add(value,
|
||||
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
|
||||
|
@ -94,26 +102,62 @@ template <class T>
|
|||
class Histogram : public SynchronousInstrument
|
||||
{
|
||||
public:
|
||||
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
|
||||
/**
|
||||
* @since ABI_VERSION 2
|
||||
* Records a value.
|
||||
*
|
||||
* @param value The measurement value. MUST be non-negative.
|
||||
*/
|
||||
virtual void Record(T value) noexcept = 0;
|
||||
|
||||
/**
|
||||
* @since ABI_VERSION 2
|
||||
* Records a value with a set of attributes.
|
||||
*
|
||||
* @param value The measurement value. MUST be non-negative.
|
||||
* @param attribute A set of attributes to associate with the value.
|
||||
*/
|
||||
virtual void Record(T value, const common::KeyValueIterable &attribute) noexcept = 0;
|
||||
|
||||
template <class U,
|
||||
nostd::enable_if_t<common::detail::is_key_value_iterable<U>::value> * = nullptr>
|
||||
void Record(T value, const U &attributes) noexcept
|
||||
{
|
||||
this->Record(value, common::KeyValueIterableView<U>{attributes});
|
||||
}
|
||||
|
||||
void Record(T value,
|
||||
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
|
||||
attributes) noexcept
|
||||
{
|
||||
this->Record(value, nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
|
||||
attributes.begin(), attributes.end()});
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Records a value.
|
||||
*
|
||||
* @param value The increment amount. May be positive, negative or zero.
|
||||
* @param value The measurement value. MUST be non-negative.
|
||||
* @param context The explicit context to associate with this measurement.
|
||||
*/
|
||||
virtual void Record(T value, const opentelemetry::context::Context &context) noexcept = 0;
|
||||
virtual void Record(T value, const context::Context &context) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Records a value with a set of attributes.
|
||||
*
|
||||
* @param value The increment amount. May be positive, negative or zero.
|
||||
* @param attributes A set of attributes to associate with the count.
|
||||
* @param value The measurement value. MUST be non-negative.
|
||||
* @param attributes A set of attributes to associate with the value..
|
||||
* @param context The explicit context to associate with this measurement.
|
||||
*/
|
||||
virtual void Record(T value,
|
||||
const common::KeyValueIterable &attributes,
|
||||
const opentelemetry::context::Context &context) noexcept = 0;
|
||||
const context::Context &context) noexcept = 0;
|
||||
|
||||
template <class U,
|
||||
nostd::enable_if_t<common::detail::is_key_value_iterable<U>::value> * = nullptr>
|
||||
void Record(T value, const U &attributes, const opentelemetry::context::Context &context) noexcept
|
||||
void Record(T value, const U &attributes, const context::Context &context) noexcept
|
||||
{
|
||||
this->Record(value, common::KeyValueIterableView<U>{attributes}, context);
|
||||
}
|
||||
|
@ -121,7 +165,7 @@ public:
|
|||
void Record(
|
||||
T value,
|
||||
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>> attributes,
|
||||
const opentelemetry::context::Context &context) noexcept
|
||||
const context::Context &context) noexcept
|
||||
{
|
||||
this->Record(value,
|
||||
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
|
||||
|
@ -137,37 +181,49 @@ class UpDownCounter : public SynchronousInstrument
|
|||
{
|
||||
public:
|
||||
/**
|
||||
* Adds a value.
|
||||
* Record a value.
|
||||
*
|
||||
* @param value The amount of the measurement.
|
||||
* @param value The increment amount. May be positive, negative or zero.
|
||||
*/
|
||||
virtual void Add(T value) noexcept = 0;
|
||||
|
||||
virtual void Add(T value, const opentelemetry::context::Context &context) noexcept = 0;
|
||||
/**
|
||||
* Record a value.
|
||||
*
|
||||
* @param value The increment amount. May be positive, negative or zero.
|
||||
* @param context The explicit context to associate with this measurement.
|
||||
*/
|
||||
virtual void Add(T value, const context::Context &context) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Add a value with a set of attributes.
|
||||
* Record a value with a set of attributes.
|
||||
*
|
||||
* @param value The increment amount. May be positive, negative or zero.
|
||||
* @param attributes A set of attributes to associate with the count.
|
||||
*/
|
||||
virtual void Add(T value, const common::KeyValueIterable &attributes) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Record a value with a set of attributes.
|
||||
*
|
||||
* @param value The increment amount. May be positive, negative or zero.
|
||||
* @param attributes A set of attributes to associate with the count.
|
||||
* @param context The explicit context to associate with this measurement.
|
||||
*/
|
||||
virtual void Add(T value,
|
||||
const common::KeyValueIterable &attributes,
|
||||
const opentelemetry::context::Context &context) noexcept = 0;
|
||||
const context::Context &context) noexcept = 0;
|
||||
|
||||
template <class U,
|
||||
nostd::enable_if_t<common::detail::is_key_value_iterable<U>::value> * = nullptr>
|
||||
void Add(T value, const U &attributes) noexcept
|
||||
{
|
||||
auto context = opentelemetry::context::Context{};
|
||||
this->Add(value, common::KeyValueIterableView<U>{attributes}, context);
|
||||
this->Add(value, common::KeyValueIterableView<U>{attributes});
|
||||
}
|
||||
|
||||
template <class U,
|
||||
nostd::enable_if_t<common::detail::is_key_value_iterable<U>::value> * = nullptr>
|
||||
void Add(T value, const U &attributes, const opentelemetry::context::Context &context) noexcept
|
||||
void Add(T value, const U &attributes, const context::Context &context) noexcept
|
||||
{
|
||||
this->Add(value, common::KeyValueIterableView<U>{attributes}, context);
|
||||
}
|
||||
|
@ -176,16 +232,13 @@ public:
|
|||
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
|
||||
attributes) noexcept
|
||||
{
|
||||
auto context = opentelemetry::context::Context{};
|
||||
this->Add(value,
|
||||
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
|
||||
attributes.begin(), attributes.end()},
|
||||
context);
|
||||
this->Add(value, nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
|
||||
attributes.begin(), attributes.end()});
|
||||
}
|
||||
|
||||
void Add(T value,
|
||||
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>> attributes,
|
||||
const opentelemetry::context::Context &context) noexcept
|
||||
const context::Context &context) noexcept
|
||||
{
|
||||
this->Add(value,
|
||||
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
|
||||
|
@ -194,6 +247,82 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
|
||||
/* A Gauge instrument that records values. */
|
||||
template <class T>
|
||||
class Gauge : public SynchronousInstrument
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* Record a value
|
||||
*
|
||||
* @param value The measurement value. May be positive, negative or zero.
|
||||
*/
|
||||
virtual void Record(T value) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Record a value
|
||||
*
|
||||
* @param value The measurement value. May be positive, negative or zero.
|
||||
* @param context The explicit context to associate with this measurement.
|
||||
*/
|
||||
virtual void Record(T value, const context::Context &context) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Record a value with a set of attributes.
|
||||
*
|
||||
* @param value The measurement value. May be positive, negative or zero.
|
||||
* @param attributes A set of attributes to associate with the value.
|
||||
*/
|
||||
|
||||
virtual void Record(T value, const common::KeyValueIterable &attributes) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Record a value with a set of attributes.
|
||||
*
|
||||
* @param value The measurement value. May be positive, negative or zero.
|
||||
* @param attributes A set of attributes to associate with the value.
|
||||
* @param context The explicit context to associate with this measurement.
|
||||
*/
|
||||
virtual void Record(T value,
|
||||
const common::KeyValueIterable &attributes,
|
||||
const context::Context &context) noexcept = 0;
|
||||
|
||||
template <class U,
|
||||
nostd::enable_if_t<common::detail::is_key_value_iterable<U>::value> * = nullptr>
|
||||
void Record(T value, const U &attributes) noexcept
|
||||
{
|
||||
this->Record(value, common::KeyValueIterableView<U>{attributes});
|
||||
}
|
||||
|
||||
template <class U,
|
||||
nostd::enable_if_t<common::detail::is_key_value_iterable<U>::value> * = nullptr>
|
||||
void Record(T value, const U &attributes, const context::Context &context) noexcept
|
||||
{
|
||||
this->Record(value, common::KeyValueIterableView<U>{attributes}, context);
|
||||
}
|
||||
|
||||
void Record(T value,
|
||||
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
|
||||
attributes) noexcept
|
||||
{
|
||||
this->Record(value, nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
|
||||
attributes.begin(), attributes.end()});
|
||||
}
|
||||
|
||||
void Record(
|
||||
T value,
|
||||
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>> attributes,
|
||||
const context::Context &context) noexcept
|
||||
{
|
||||
this->Record(value,
|
||||
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
|
||||
attributes.begin(), attributes.end()},
|
||||
context);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace metrics
|
||||
OPENTELEMETRY_END_NAMESPACE
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
#define OPENTELEMETRY_RETURN(...) \
|
||||
noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) { return __VA_ARGS__; }
|
||||
#define OPENTELEMETRY_RETURN(...) \
|
||||
noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) \
|
||||
{ \
|
||||
return __VA_ARGS__; \
|
||||
}
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace nostd
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
@ -7,8 +10,11 @@
|
|||
#include "opentelemetry/nostd/detail/void.h"
|
||||
#include "opentelemetry/version.h"
|
||||
|
||||
#define OPENTELEMETRY_RETURN(...) \
|
||||
noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) { return __VA_ARGS__; }
|
||||
#define OPENTELEMETRY_RETURN(...) \
|
||||
noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) \
|
||||
{ \
|
||||
return __VA_ARGS__; \
|
||||
}
|
||||
|
||||
OPENTELEMETRY_BEGIN_NAMESPACE
|
||||
namespace nostd
|
||||
|
@ -31,7 +37,7 @@ template <>
|
|||
struct Invoke<true /* pmf */, 0 /* is_base_of */>
|
||||
{
|
||||
template <typename R, typename T, typename Arg, typename... Args>
|
||||
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&... args)
|
||||
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&...args)
|
||||
OPENTELEMETRY_RETURN((std::forward<Arg>(arg).*pmf)(std::forward<Args>(args)...))
|
||||
};
|
||||
|
||||
|
@ -39,7 +45,7 @@ template <>
|
|||
struct Invoke<true /* pmf */, 1 /* is_reference_wrapper */>
|
||||
{
|
||||
template <typename R, typename T, typename Arg, typename... Args>
|
||||
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&... args)
|
||||
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&...args)
|
||||
OPENTELEMETRY_RETURN((std::forward<Arg>(arg).get().*pmf)(std::forward<Args>(args)...))
|
||||
};
|
||||
|
||||
|
@ -47,7 +53,7 @@ template <>
|
|||
struct Invoke<true /* pmf */, 2 /* otherwise */>
|
||||
{
|
||||
template <typename R, typename T, typename Arg, typename... Args>
|
||||
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&... args)
|
||||
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&...args)
|
||||
OPENTELEMETRY_RETURN(((*std::forward<Arg>(arg)).*pmf)(std::forward<Args>(args)...))
|
||||
};
|
||||
|
||||
|
@ -76,20 +82,21 @@ struct Invoke<false /* pmo */, 2 /* otherwise */>
|
|||
};
|
||||
|
||||
template <typename R, typename T, typename Arg, typename... Args>
|
||||
inline constexpr auto invoke_impl(R T::*f, Arg &&arg, Args &&... args)
|
||||
OPENTELEMETRY_RETURN(Invoke<std::is_function<R>::value,
|
||||
(std::is_base_of<T, decay_t<Arg>>::value
|
||||
? 0
|
||||
: is_reference_wrapper<decay_t<Arg>>::value ? 1 : 2)>::
|
||||
invoke(f, std::forward<Arg>(arg), std::forward<Args>(args)...))
|
||||
inline constexpr auto invoke_impl(R T::*f, Arg &&arg, Args &&...args) OPENTELEMETRY_RETURN(
|
||||
Invoke<std::is_function<R>::value,
|
||||
(std::is_base_of<T, decay_t<Arg>>::value ? 0
|
||||
: is_reference_wrapper<decay_t<Arg>>::value ? 1
|
||||
: 2)>::invoke(f,
|
||||
std::forward<Arg>(arg),
|
||||
std::forward<Args>(args)...))
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4100)
|
||||
#endif
|
||||
template <typename F, typename... Args>
|
||||
inline constexpr auto invoke_impl(F &&f, Args &&... args)
|
||||
OPENTELEMETRY_RETURN(std::forward<F>(f)(std::forward<Args>(args)...))
|
||||
template <typename F, typename... Args>
|
||||
inline constexpr auto invoke_impl(F &&f, Args &&...args)
|
||||
OPENTELEMETRY_RETURN(std::forward<F>(f)(std::forward<Args>(args)...))
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
@ -24,9 +27,9 @@ template <typename T,
|
|||
class IsAvailable>
|
||||
inline constexpr Trait trait()
|
||||
{
|
||||
return IsTriviallyAvailable<T>::value
|
||||
? Trait::TriviallyAvailable
|
||||
: IsAvailable<T>::value ? Trait::Available : Trait::Unavailable;
|
||||
return IsTriviallyAvailable<T>::value ? Trait::TriviallyAvailable
|
||||
: IsAvailable<T>::value ? Trait::Available
|
||||
: Trait::Unavailable;
|
||||
}
|
||||
|
||||
inline constexpr Trait common_trait_impl(Trait result)
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "opentelemetry/version.h"
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "opentelemetry/version.h"
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue