Compare commits

...

1061 Commits
v1.0.1 ... main

Author SHA1 Message Date
dependabot[bot] 85d04f9696
Bump actions/checkout from 4.2.2 to 5.0.0 (#3587)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.2 to 5.0.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](11bd71901b...08c6903cd8)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 5.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
2025-08-12 20:55:55 -07:00
Doug Barker 6e8a8038a1
[CI] update do_ci scripts to use common cmake cache scripts (#3582)
* update ci scripts to use the test_common/cmake cache variable scripts

* re-disable opentracing for maintainer tests

* fix ci issues. Maintainer build warnings on windows. CMake configure failure with dll build

* fix ci issues. W3C trace context test warnings failing windows maintainer builds

---------
2025-08-12 15:43:45 -07:00
dependabot[bot] 6aece9bd83
Bump github/codeql-action from 3.29.7 to 3.29.8 (#3584)
* Bump github/codeql-action from 3.29.7 to 3.29.8

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.29.7 to 3.29.8.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](51f77329af...76621b61de)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.29.8
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update ossf-scorecard.yml

* Update codeql-analysis.yml

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
2025-08-11 10:12:19 -07:00
Nikhil Bhatia fab6a41ef7
[SDK] Implementation of container resource as per semconv (#3572) 2025-08-10 12:22:54 -07:00
dependabot[bot] 5f6d99f089
Bump actions/cache from 4.2.3 to 4.2.4 (#3580)
Bumps [actions/cache](https://github.com/actions/cache) from 4.2.3 to 4.2.4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](5a3ec84eff...0400d5f644)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: 4.2.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-08 17:52:59 +02:00
dependabot[bot] 0023154e75
Bump actions/download-artifact from 4.3.0 to 5.0.0 (#3578)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4.3.0 to 5.0.0.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](d3f86a106a...634f93cb29)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: 5.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-06 09:53:01 -07:00
Marc Alff f697898062
[CONFIGURATION] File configuration - configuration example (#3573) 2025-08-05 15:18:29 +02:00
OpenTelemetry Bot e8161664d2
Add subscript to issue templates (#3576)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
2025-08-01 18:15:10 +02:00
dependabot[bot] 8825da6bf3
Bump github/codeql-action from 3.29.4 to 3.29.5 (#3574)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.29.4 to 3.29.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](4e828ff8d4...51f77329af)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.29.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-30 07:43:34 +02:00
Markus Mäkelä 495f497d45
[DOC] Document minimum required versions (#3562) 2025-07-29 16:32:00 +02:00
WenTao Ou ba38077e54
[EXPORTER] Fixes tsan warnings (#3531) 2025-07-29 12:05:22 +02:00
Marc Alff ac1172eb14
[SDK] View should not have a unit (#3552) 2025-07-28 23:11:58 +02:00
Doug Barker 03e04520d7
[CMAKE] Don't set iwyu and clang-tidy properties on nlohmann_json with cmake <3.19 (#3568) 2025-07-28 17:26:54 +02:00
Marc Alff 4c41390d0e
[CONFIGURATION] File configuration - otlp exporter builders (#3566) 2025-07-28 13:31:52 +02:00
Marc Alff 2fc2a20c6e
[CONFIGURATION] File configuration - zipkin exporter builder (#3565) 2025-07-28 09:24:07 +02:00
Marc Alff f993e960df
[CONFIGURATION] File configuration - prometheus exporter builder (#3564) 2025-07-28 08:07:07 +02:00
Marc Alff 59e7281f68
[CONFIGURATION] File configuration - ostream exporter builders (#3563) 2025-07-28 02:20:00 +02:00
Marc Alff f28ea95a5b
[CONFIGURATION] File configuration - sdk resource (#3567) 2025-07-28 00:43:30 +02:00
Marc Alff dbd06801eb
[CONFIGURATION] File configuration - spec version 1.0.0-rc1 (#3557) 2025-07-24 21:10:19 +02:00
dependabot[bot] fdee87f91e
Bump github/codeql-action from 3.29.3 to 3.29.4 (#3558)
---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.29.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-24 09:58:06 +02:00
Marc Alff aeb5a01336
[CONFIGURATION] File configuration - sdk builder (#3550) 2025-07-23 02:14:30 +02:00
Doug Barker c3a0ac1aec
[CMAKE] Add CMake scripts to find or fetch protobuf and grpc (#3533) 2025-07-23 00:06:19 +02:00
dependabot[bot] 4d0ac5d110
Bump github/codeql-action from 3.29.2 to 3.29.3 (#3556)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.29.2 to 3.29.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](181d5eefc2...d6bbdef45e)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.29.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-22 11:49:35 +02:00
Mathieu Robin 5984a2d8c5
[SDK] Implements options for the ParentBasedSampler with default values (#3553) 2025-07-22 00:28:38 +02:00
ssams c406864555
[SDK] Update default exemplar reservoir size for exponential histograms (#3551) 2025-07-19 20:57:30 +02:00
Mathieu Robin 93475ff631
[SDK] Implement env var configuration for PeriodicExportingMetricReader (#3549) 2025-07-19 00:43:54 +02:00
Marc Alff 5423b91180
[CONFIGURATION] File configuration - component registry (#3537) 2025-07-17 22:26:17 +02:00
Doug Barker 0e51e67a9d
[TEST] Shared otel-cpp libs linked to latest static protobuf and grpc (#3544) 2025-07-17 15:01:17 +02:00
strophy b7b0278682
[SDK] Ensure TraceId is portable on big-endian architectures (#3543)
Co-authored-by: Marc Alff <marc.alff@oracle.com>
2025-07-16 23:17:32 +02:00
dependabot[bot] 8608773f50
Bump step-security/harden-runner from 2.12.2 to 2.13.0 (#3542)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.12.2 to 2.13.0.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](6c439dc8bd...ec9f2d5744)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  dependency-version: 2.13.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-16 15:04:15 +02:00
Doug Barker 6fed48c1b1
[REMOVAL] remove unused ci bash scripts (#3541) 2025-07-15 22:49:02 +02:00
Doug Barker 4da9b67c0e
[CMAKE] Add CMake scripts to find or fetch curl and find zlib (#3526) 2025-07-15 17:12:24 +02:00
Doug Barker 62ba4dea5b
[CodeHealth] Fix clang-tidy warnings part 6 (#3507) 2025-07-12 21:34:28 +02:00
Marc Alff 9ee0c27886
[RELEASE] Release opentelemetry-cpp version 1.22.0 (#3532) 2025-07-12 00:11:41 +02:00
Reiley Yang f224283f2e
[ADMIN] Remove file .github/repository-settings.md (#3534) 2025-07-11 22:10:52 +02:00
Marc Alff b6ec7a1547
[CONFIGURATION] File configuration - configuration parser (#3520) 2025-07-11 14:13:53 +02:00
Marc Alff 7a78dd05f6
[CONFIGURATION] File configuration - yaml parser (#3519) 2025-07-11 11:14:46 +02:00
WenTao Ou cafcfaab6c
[SDK] Fixes duration overflow (#3529) 2025-07-10 20:22:45 +02:00
Marc Alff 4ad3b8b06d
[SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.36.0 (#3527) 2025-07-10 14:08:36 +02:00
Doug Barker d017ae1fe9
[CMAKE] Add CMake script to find or fetch Microsoft.GSL (#3521) 2025-07-10 11:19:18 +02:00
Doug Barker 6c4d45c05c
[CMAKE] Switch opentelemetry-proto to use FetchContent (#3524) 2025-07-09 23:08:56 +02:00
Doug Barker 1ad66746d2
[CMAKE] Add CMake script to find or fetch prometheus-cpp (#3522) 2025-07-09 12:31:52 +02:00
Doug Barker a1e6011bfa
[CMAKE] Address the vcpkg opentelemetry-cpp port CMake patches (#3518) 2025-07-09 10:37:24 +02:00
Doug Barker 3eec22c9a0
[CMAKE] find or fetch nlohmann-json (#3523) 2025-07-08 15:24:21 +02:00
Marc Alff 711625fdbf
[CONFIGURATION] File configuration - metric aggregation model (#3502) 2025-07-06 22:25:03 +02:00
Marc Alff 0bbbdb1aad
[CONFIGURATION] File configuration - misc model (#3504) 2025-07-06 14:57:35 +02:00
Marc Alff 93877b9e0b
[CONFIGURATION] File configuration - extension model (#3503) 2025-07-06 13:34:06 +02:00
Doug Barker a91d6a1baa
[CMAKE] clean up googletest and benchmark dependency management (#3485) 2025-07-04 22:43:34 +02:00
WenTao Ou b9db1b3c6c
[BUILD] Fixes compiling problems in NDK r27 (#3517)
* Fixes compiling problems in NDK r27

* All APIs of C style file should use `std::` version.
2025-07-04 18:07:21 +02:00
dependabot[bot] f4897b2a5f
Bump github/codeql-action from 3.29.1 to 3.29.2 (#3510)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.29.1 to 3.29.2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](39edc492db...181d5eefc2)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.29.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-01 14:51:09 +02:00
dependabot[bot] 712d14838e
Bump step-security/harden-runner from 2.12.1 to 2.12.2 (#3509)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.12.1 to 2.12.2.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](002fdce3c6...6c439dc8bd)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  dependency-version: 2.12.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-01 13:30:23 +02:00
OpenTelemetry Bot 0994256b75
Add minimum token permissions for all github workflow files (#3508)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
2025-07-01 09:40:14 +02:00
Doug Barker 3b42db59b0
[CodeHealth] Fix clang-tidy warnings part 5 (#3506) 2025-07-01 02:27:19 +02:00
Doug Barker dff39f3eb3
[CodeHealth] Fix clang tidy warnings part 4 (#3501) 2025-06-30 23:42:55 +02:00
WenTao Ou 22715dd820
[EXPORTER] Add bytes support for OTLP recordables (#3495) 2025-06-30 22:24:58 +02:00
dependabot[bot] 7059f73039
Bump github/codeql-action from 3.29.0 to 3.29.1 (#3505)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.29.0 to 3.29.1.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](ce28f5bb42...39edc492db)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.29.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-30 08:47:35 +02:00
Marc Alff f16ea3b7f2
[CONFIGURATION] File configuration - metric model (#3474) 2025-06-29 01:09:10 +02:00
Marc Alff 85b0adaa08
[CONFIGURATION] File configuration - log model (#3473) 2025-06-28 23:48:08 +02:00
WenTao Ou 7dfc312274
[BUILD] Fixes grpc linking for OTLP exporter's tests (#3435) 2025-06-28 22:25:35 +02:00
Marc Alff 82bddef6ed
[CONFIGURATION] File configuration - sampler model (#3468) 2025-06-28 00:35:27 +02:00
Marc Alff 89b6d0fd54
[CONFIGURATION] File configuration - trace model (#3467) 2025-06-27 19:50:25 +02:00
OpenTelemetry Bot b49e1b7b6f
Fix outdated community membership link (#3500)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
2025-06-27 02:34:58 +02:00
Doug Barker 4b5f081103
[CodeHealth] Fix clang-tidy warnings part 3 (#3498) 2025-06-26 20:54:03 +02:00
Doug Barker f74d413c63
[CodeHealth] Fix clang-tidy warnings part 2 (#3496) 2025-06-26 10:22:39 +02:00
OpenTelemetry Bot 84657781f7
Update community member listings (#3499)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
2025-06-26 08:58:47 +02:00
Doug Barker 29c0dd4a86
[CMAKE] Add thirdparty install cmake project and install bash script (#3486) 2025-06-25 21:28:18 +02:00
Doug Barker 016155f9ec
[CodeHealth] Fix clang-tidy warnings part 1 (#3493) 2025-06-24 19:21:55 +02:00
Marc Alff 1d4112523a
[Code Health] include-what-you-use cleanup, part 9 (#3492) 2025-06-22 22:39:02 +02:00
dependabot[bot] 9708acb694
Bump docker/setup-buildx-action from 3.11.0 to 3.11.1 (#3488)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 3.11.0 to 3.11.1.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](18ce135bb5...e468171a9d)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-version: 3.11.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-19 08:49:02 +02:00
dependabot[bot] 1ca14802f8
Bump docker/setup-buildx-action from 3.10.0 to 3.11.0 (#3483)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 3.10.0 to 3.11.0.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](b5ca514318...18ce135bb5)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-version: 3.11.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-16 22:40:32 -07:00
Marc Alff 021490ea1b
[REMOVAL] Removed deprecated semantic convention header files. (#3475) 2025-06-17 00:24:02 +02:00
Marc Alff 3d901a8135
[REMOVAL] Remove CMake option WITH_REMOVE_METER_PREVIEW (#3476) 2025-06-16 10:30:20 -07:00
Doug Barker 4561fc23d2
[CI] Increase code coverage of iwyu and clang-tidy ci jobs (#3469) 2025-06-16 15:27:56 +02:00
Doug Barker 7a68bb394c
[CI] rely on github installed cmake for ci runners (#3482) 2025-06-16 08:46:38 +02:00
KJ Tsanaktsidis 47f530a5f9
[SDK] BatchLogRecordProcessor::ForceFlush is not waking up bg thread (#3448) 2025-06-13 12:20:10 +02:00
dependabot[bot] 3b7f564da8
Bump step-security/harden-runner from 2.12.0 to 2.12.1 (#3471)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.12.0 to 2.12.1.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](0634a2670c...002fdce3c6)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  dependency-version: 2.12.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-12 10:10:09 +02:00
dependabot[bot] f12c5c7804
Bump github/codeql-action from 3.28.19 to 3.29.0 (#3472)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.19 to 3.29.0.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](fca7ace96b...ce28f5bb42)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.29.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-12 08:53:43 +02:00
Marc Alff 632c9ca83d
[BUILD] Upgrade to opentelemetry-proto 1.7.0 (#3443) 2025-06-10 10:51:02 +02:00
Marc Alff 545f9f4108
[CodeHealth] fix include-what-you-use, part 8 (#3465) 2025-06-09 10:23:10 +02:00
Marc Alff 98e747f696
[CI] Remove windows 2019 (#3466) 2025-06-09 09:01:03 +02:00
Douglas Heriot b1253a7484
[SDK] Add credentials option to OTLP gRPC client (#3402) (#3403)
This allows passing custom `ChannelCredentials` when creating gRPC channels, to support authentication protocols that require short-lived tokens.
2025-06-07 11:10:50 +02:00
vencislav-georgiev-1A 53b153caf2
[BUILD] Allow compilation with CXX26 (#3464) 2025-06-06 17:35:17 +02:00
Doug Barker 549f2b009d
[TEST] test examples in CI with CMake Part 1 (#3449) 2025-06-05 20:49:45 +02:00
Evan d64b65368c
[DOC] Update doc comments to pass -WDocumention check (#3375) 2025-06-05 09:27:35 +02:00
dependabot[bot] 470f66b4ac
Bump github/codeql-action from 3.28.18 to 3.28.19 (#3462)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.18 to 3.28.19.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](ff0a06e83c...fca7ace96b)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.28.19
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-04 11:26:30 +02:00
Doug Barker 1ede230d0f
[CI] build iwyu (#3459) 2025-06-04 09:31:25 +02:00
Lalit Kumar Bhasin d2e728914d
[SDK] Use shared_ptr internally for AttributesProcessor to prevent use-after-free (#3457)
* fix

* fix

* add test

* fix

* iwuc
2025-06-03 10:40:10 -07:00
dependabot[bot] 05ac10652c
Bump ossf/scorecard-action from 2.4.1 to 2.4.2 (#3455)
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.4.1 to 2.4.2.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](f49aabe0b5...05b42c6244)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-version: 2.4.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-02 09:06:12 +02:00
Marc Alff 76460cf70a
[CI] build examples with IWYU (#3450) 2025-05-31 02:09:27 +02:00
Tom Tan 7a847caafc
[DOC] Udpate link to membership document (#3452) 2025-05-30 21:13:55 +02:00
Marc Alff b9cf499ff5
[RELEASE] Release opentelemetry-cpp 1.21.0 (#3445) 2025-05-29 11:30:28 +02:00
Tom Tan 793c7bd1e9
[BUILD] Propagate INTERFACE_COMPILE_DEFINITIONS from API through common_foo_library (#3440) 2025-05-29 00:18:55 +02:00
ethan d99593f2fd
[EXPORTER] support unix sockets in grpc client (#3410) 2025-05-28 21:41:18 +02:00
Marc Alff 214950e5d7
[SEMANTIC CONVENTIONS] Fix comment style to preserve markup (#3444) 2025-05-28 16:47:56 +02:00
dependabot[bot] c3ef5454d1
Bump docker/build-push-action from 6.17.0 to 6.18.0 (#3446)
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6.17.0 to 6.18.0.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](1dc7386353...263435318d)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-version: 6.18.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-28 08:17:14 +02:00
Doug Barker 7a9c60994e
[CMAKE] Remove third-party version mismatch warning (#3432)
Co-authored-by: Marc Alff <marc.alff@oracle.com>
2025-05-24 18:33:38 +02:00
Tom Tan 87c216f5c8
[CMake] Add missing CMake keyword for target_link_libraries (#3442) 2025-05-23 18:42:32 +02:00
Tom Tan c2ea734f00
[BUILD] Error out when building DLL without MSVC (#3438) 2025-05-23 15:12:17 +02:00
Doug Barker 4b6f52ae23
[TEST] add all components to the cmake fetch content test (#3433) 2025-05-22 09:00:53 +02:00
Marc Alff b4254a4acf
[EXPORTER] ostream log exporter, fix memory ownership issues (#3417) 2025-05-21 13:29:02 +02:00
Marc Alff f7babf1bca
[SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.34.0 (#3428) 2025-05-21 11:29:28 +02:00
Marc Alff a530f5ec31
[BUILD] remove unused WITH_CURL build flag (#3429) 2025-05-21 09:12:53 +02:00
Doug Barker 165983a128
[CMAKE] remove global include_directories usage and rely on target properties (#3426) 2025-05-20 23:44:47 +02:00
Yash Tibrewal 29ac517bee
[SDK] Fix MetricProducer interface (#3413) 2025-05-20 11:05:30 -07:00
Doug Barker 2faa400782
[SDK] Fix Base2ExponentialHistogramAggregation Merge with empty buckets (#3425) 2025-05-20 08:52:56 +02:00
Doug Barker 82ec2a5a3d
[CMAKE] update cmake files in examples directory (#3421) 2025-05-19 15:06:37 +02:00
dependabot[bot] ba04dbbf13
Bump github/codeql-action from 3.28.17 to 3.28.18 (#3423)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.17 to 3.28.18.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](60168efe1c...ff0a06e83c)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.28.18
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-19 08:35:56 +02:00
Doug Barker b7e7333344
update the INSTALL doc to referece the trace target instead of the interface sdk target and add note about potential move of the etw and elasticsearch components (#3422) 2025-05-17 10:08:23 -07:00
Marc Alff 0f8dedf709
[SEMANTIC CONVENTIONS] Upgrade semantic conventions to 1.33.0 (#3416) 2025-05-16 19:01:04 +02:00
dependabot[bot] 44018b0bec
Bump codecov/codecov-action from 5.4.2 to 5.4.3 (#3419)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.4.2 to 5.4.3.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](ad3126e916...18283e04ce)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-version: 5.4.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-16 17:30:07 +02:00
dependabot[bot] 31b161ef8b
Bump docker/build-push-action from 6.16.0 to 6.17.0 (#3420)
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6.16.0 to 6.17.0.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](14487ce63c...1dc7386353)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-version: 6.17.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-16 09:10:16 +02:00
dependabot[bot] 20c8ded8ad
Bump fossas/fossa-action from 1.6.0 to 1.7.0 (#3414)
Bumps [fossas/fossa-action](https://github.com/fossas/fossa-action) from 1.6.0 to 1.7.0.
- [Release notes](https://github.com/fossas/fossa-action/releases)
- [Commits](c0a7d013f8...3ebcea1862)

---
updated-dependencies:
- dependency-name: fossas/fossa-action
  dependency-version: 1.7.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-15 11:06:03 +02:00
Doug Barker db29c5b18d
fix accidental rollback of nlohmann-json submodule (#3415) 2025-05-15 09:04:07 +02:00
Doug Barker bcdea0e1fc
[CMAKE] add generated protobuf headers to the opentelemetry_proto target (#3400)
* adds the generated protobuf includes to the opentelemetry_proto target instead of using include_directories

* add changelog entry

---------

Co-authored-by: Marc Alff <marc.alff@oracle.com>
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
2025-05-15 03:09:42 +00:00
Marc Alff 364b860a3f
[BUILD] Upgrade opentelemetry-proto to 1.6.0 (#3407) 2025-05-14 19:29:56 -07:00
Marc Alff cacfe443bb
[BUILD] Upgrade nlohmann_json to 3.12.0 (#3406) 2025-05-14 14:09:01 -07:00
Doug Barker 546fcd7979
[INSTALL] Unify cmake install functions and dynamically set component dependencies (#3368) 2025-05-14 09:44:27 +02:00
WenTao Ou 1e33bb595c
Fixes unused var (#3397)
* Fixes unused var

* Ignore IWYU in example
2025-05-09 11:40:28 -07:00
Doug Barker 92dd28c2cb
[SDK] support aggregation of identical instruments (#3358)
* use the existing storage for sync or async instruments of the same name. add tests

* add hash and name case insensitive hash for InstrumentDescriptor. Update storage registry to use the hash and equality structs. Add tests.

* don't allocate heap in the hash. fix some ci failures

* fix a few more ci failures.

* move the instrument descriptor ostream operator to meter.cc to not leak the ostream header and keep the meter instrument creation warning implementation in the same file

* adds instrument descriptor tests

* add comments

* Move case-insensitive equals method and IsDuplicate method into InstrumentDescriptorUtils struct. Add log streamable wrappers for scopes and instrument descriptors. Add tests for correcitve views for name and description duplicates

* fix iwyu errors

* duplicate instrument log message improvements to match spec. minor test additions/cleanup

* changelog entry

* address review feedback. Add Ascii to the name of the instrument util case-insensitive equal function

* address feedback: short circuit the instrument descriptor CaseInsensitiveAsciiEquals and IsDuplicate checks

* fix comments

---------

Co-authored-by: Tom Tan <lilotom@gmail.com>
Co-authored-by: Marc Alff <marc.alff@oracle.com>
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
2025-05-09 05:53:05 +00:00
Yash Tibrewal 4e4d8de860
[Metrics SDK] Use nostd::function_ref in AttributesHashMap (#3393) 2025-05-08 23:26:50 +00:00
Cole VanOphem 9451f0e3be
[SDK] Optimize PeriodicExportingMetricReader Thread Usage (#3383) 2025-05-06 11:05:23 -07:00
dependabot[bot] ed91e718f7
Bump github/codeql-action from 3.28.16 to 3.28.17 (#3389)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.16 to 3.28.17.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](28deaeda66...60168efe1c)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.28.17
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-04 19:40:59 -07:00
Tom Tan a145a56880
[TEST] Add stress test for histogram metric for multiple threads validation (#3388) 2025-05-03 10:56:25 +02:00
WenTao Ou 9fd8511772
Fixes glibc++ 5 checking (#3355)
* Fixes glibc++ 5 checking

* Always checking `OPENTELEMETRY_TRIVIALITY_TYPE_TRAITS` when `OPENTELEMETRY_STL_VERSION` is defined

* Restore confg.h but left a warning
2025-04-28 22:25:31 -07:00
StepSecurity Bot 7801cd9fb3
[StepSecurity] ci: Harden GitHub Actions (#3379)
Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
2025-04-25 19:02:02 +00:00
ethan 7bf114913d
Base2 exponential histogram aggregation (#3346)
* add base2 expo histo aggregation

* add base2 expo histo, test, benchmark

* add prom, otlp exporter and example

* add ostream exporter and example

* update vscode launch

* run tools/format.sh

* add grpc exporter target switch for unix sockets

* Added ConvertExponentialHistogramMetric unit test

* Update the osstream_metric_test with ExponentialHistogram

* update CHANGELOG.md

* markdown lint

* Comment non-used function add missing includes

* add metrics dependency to otlp exporters test build

* run format

* remove unused function definition

* Added empty line in the end of a test file and removed comments

* Fix windows build errors

* fix iwyu warnings

* add comment to trigger pr update

* fix additional iwyu warnings

* Fix iwyu warning

* Fix include order in base2_exponential_histogram_aggregation.h

* Add kcumulative and kdelta aggregation temporality test with collect calls for base2 histogram aggregation

* add prelim bucketing checks

* Tested the exp2 constructor with point data

* Fix missing include in sync histogram test

* move diff and merge to use union of all buckets approach

* make get a const method

* update base2 expo hiso diff test

* add base2 expo histo test with sync storage collect

* uncomment examples

* format

* use static_cast

* fix comments

* update changelog

* Fix comments and errors in the pipeline

* Update sdk/src/metrics/aggregation/base2_exponential_histogram_aggregation.cc

Co-authored-by: Tom Tan <lilotom@gmail.com>

* remove unused code

* set max_buckets minimum to 2

* Revert otlp grpc client changes

Propose change in follow up PR

* [wip] make buckets unique ptr

* refactor unique_ptr for buckets with deep copies

* format

* update otlp serialization test with unique ptr

* format

* Small pipeline fixes

* iwyu fix

* remove boundary and format

---------

Co-authored-by: Ruslan Nigmatullin <euroelessar@gmail.com>
Co-authored-by: Felipe C. Dos Santos <felipe.santos.k@gmail.com>
Co-authored-by: Tom Tan <lilotom@gmail.com>
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
Co-authored-by: Felipe C. Dos Santos <42920697+felipesantosk@users.noreply.github.com>
2025-04-25 18:13:23 +00:00
StepSecurity Bot 3e761d0140
[StepSecurity] ci: Harden GitHub Actions (#3378)
Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
Co-authored-by: Marc Alff <marc.alff@oracle.com>
2025-04-25 19:03:38 +02:00
Lalit Kumar Bhasin f6d16d292c
Harden Github actions - pinned-dependencies (part -1) (#3380) 2025-04-25 05:15:53 +00:00
dependabot[bot] f9f356c754
Bump actions/download-artifact from 4.2.1 to 4.3.0 (#3381)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4.2.1 to 4.3.0.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](95815c38cf...d3f86a106a)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: 4.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
2025-04-24 21:39:50 -07:00
dependabot[bot] 7bc4573bbb
Bump docker/build-push-action from 6.15.0 to 6.16.0 (#3382)
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6.15.0 to 6.16.0.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](471d1dc4e0...14487ce63c)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-version: 6.16.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-24 20:24:42 -07:00
dependabot[bot] 969bbf1503
Bump step-security/harden-runner from 2.11.1 to 2.12.0 (#3373)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.11.1 to 2.12.0.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](c6295a65d1...0634a2670c)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  dependency-version: 2.12.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
2025-04-23 22:40:53 -07:00
dependabot[bot] b8dd791717
Bump github/codeql-action from 3.28.15 to 3.28.16 (#3377)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.15 to 3.28.16.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](45775bd823...28deaeda66)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.28.16
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-23 21:45:12 -07:00
WenTao Ou 4da3647579
Fixes warnings of ciso646 in C++17 (#3360) 2025-04-23 07:22:38 -07:00
Pranav Sharma d976876feb
[API] Add Enabled method to Tracer (#3357) 2025-04-22 07:13:52 -07:00
Ehsan Saei 674cc9ea9a
[CI] fix artifacts download/upload (#3369) 2025-04-21 16:28:31 -07:00
Evan acd4a0ed2a
Fix the documention comments (#3371) 2025-04-21 14:28:33 -07:00
dependabot[bot] f987c9c094
Bump codecov/codecov-action from 5.4.0 to 5.4.2 (#3362)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.4.0 to 5.4.2.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](0565863a31...ad3126e916)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-version: 5.4.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-15 09:17:32 +02:00
Doug Barker 34375d7f91
[CMAKE] bump cmake minimum required version to 3.14 (#3349)
* update setup_cmake* scripts to verify the versions installed

* set cmake minimum version to 3.14. Fix issues found in tested with the min version

* update cmake install action workflow to test specific cmake versions including the min version. update the conan stable file to test older versions of benchmark and prometheus-cpp

* fix format issue

* run the windows cmake min test with 3.16 due to failing otlp file tests with 3.14

* update changelog

* add back explict policies including CMP0091 that was introduced in cmake 3.15. Set the windows job to cmake 3.15

* Address review feedback. Always set the new curl and zlib version variables. Remove legacy PROTOBUF_FOUND.

* add comment about cmake 3.15 as minimum for windows builds. Fix cmake error on protobuf version warning. Remove bzip2 as dependency for conan builds

* set cmake version expliclity in the workflow file for each cmake install test job. Add newline to the end of setup_cmake.ps1

* use config search mode for gtest for install tests

* update install md file with note on the cmake minimum version and recommend cmake 3.15+ on windows.

* fix markdownlint error

* Update install.md with explict message about the known windows ci test failures with cmake 3.14

* comments from review feedback

* update install.md
2025-04-12 19:29:53 -07:00
dependabot[bot] 4d52ab2c4d
Bump github/codeql-action from 3.28.13 to 3.28.15 (#3353)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.13 to 3.28.15.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](1b549b9259...45775bd823)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.28.15
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-08 10:54:27 +02:00
Marc Alff 3e58a0b970
[SEMANTIC CONVENTIONS] Upgrade semantic conventions to 1.32.0 (#3351) 2025-04-08 08:53:28 +02:00
Doug Barker 99a0328a5c
[CI] disable bzip2 in conan builds (#3352) 2025-04-08 01:02:57 +02:00
Doug Barker b6908f0cf3
[DEVCONTAINER] expose cmake version setting as docker arg and environment variable (#3347)
* expose cmake version setting as docker arg and env var for the devcontainer

* update devcontainer readme
2025-04-06 18:08:41 +02:00
dependabot[bot] 4a0d19fe8b
Bump github/codeql-action from 3.28.12 to 3.28.13 (#3341)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.12 to 3.28.13.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v3.28.12...1b549b9259bda1cb5ddde3b41741a82a2d15a841)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.28.13
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-04 09:13:21 +02:00
Marc Alff bc36c69209
[StepSecurity] Harden GibHub Actions, part 2 (#3340) 2025-04-03 18:39:39 +02:00
Khanh Tran b6630eeb73
[StepSecurity] ci: Harden GitHub Actions (#3338)
Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: StepSecurity Bot <bot@stepsecurity.io>
2025-04-03 15:40:34 +02:00
Doug Barker c2a9397627
[INSTALL] add cmake components to the package (#3220) 2025-04-02 09:54:17 +02:00
WenTao Ou ab8147987d
[BUILD] Remove `WITH_ABSEIL` (#3318) 2025-04-02 01:45:26 +02:00
Marc Alff 6175aa0b21
[RELEASE] Release opentelemetry-cpp 1.20.0 (#3328) 2025-04-02 00:21:41 +02:00
Tom Tan 3bd8de9702
[METRICS SDK] Fix hash collision in MetricAttributes (#3322) 2025-04-01 23:12:24 +02:00
Doug Barker 83ac2ae49d
[CI] pin cmake in ci and devcontainer (#3336)
* pin cmake on ubuntu in ci and devcontainer

* add setup cmake script for windows. install pinned cmake in more ubuntu jobs

* pin cmake on bazel builds. force the cmake downgrade on windows
2025-04-01 22:08:08 +02:00
OpenTelemetry Bot b2bc73fb83
[CI] Add ossf-scorecard scanning workflow (#3332)
* Add ossf-scorecard scanning workflow

* Add end of file newline

---------

Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
2025-04-01 11:37:12 +02:00
Marc Alff 4ecafb6fbf
[CI] Upgrade CI to ubuntu 22.04 (#3330) 2025-03-30 17:14:44 +02:00
Doug Barker 78efc41052
[ADMIN] Add dbarker to approvers (#3331) 2025-03-28 23:09:08 +01:00
Doug Barker a6779d8e21
[DEVCONTAINER] fix grpc install (#3325) 2025-03-27 08:39:53 +01:00
Pranav Sharma 6e214c8503
Add Pranav Sharma in cpp-approvers (#3323) 2025-03-26 16:00:19 -07:00
WenTao Ou a7f52977fc
[BUILD] Remove gRPC header including in `OtlpGrpcClientFactory`. (#3321) 2025-03-25 16:36:54 +01:00
Tom Tan 63220adcb4
[BUILD] Fix misssing exported definition for OTLP file exporter and forceflush (#3319) 2025-03-25 12:17:16 +01:00
Doug Barker 216f3f7399
[BUILD] Fix elasticsearch exporter json compatibility (#3313)
* fix build issue with elasticsearch exporter and older versions of nlohmann-json

* run the cmake.test on 22.04 to verify compatibility with the older json package

* use class instead of typename in template args

---------
2025-03-24 22:07:49 -07:00
Pranav Sharma 0fa41f9e26
[SDK] Use OPENTELEMETRY_EXPORT and static local variables (#3314) 2025-03-24 22:09:19 +01:00
Doug Barker 4af490ffed
[TEST] otlp grpc exporter retry test fix (#3311) 2025-03-24 12:08:35 +01:00
Doug Barker 2566fb62f3
[EXPORTER] fix test failure with elasticsearch exporter on cxx20 (#3308) 2025-03-24 10:02:42 +01:00
Doug Barker 2c9b68fbae
[TEST] load the .dylib files on macos in the singleton test (#3316) 2025-03-23 11:43:10 +01:00
dependabot[bot] b4328c0bc1
Bump fossas/fossa-action from 1.5.0 to 1.6.0 (#3305)
Bumps [fossas/fossa-action](https://github.com/fossas/fossa-action) from 1.5.0 to 1.6.0.
- [Release notes](https://github.com/fossas/fossa-action/releases)
- [Commits](93a52ecf7c...c0a7d013f8)

---
updated-dependencies:
- dependency-name: fossas/fossa-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-21 09:18:42 +01:00
Luke (GuangHui) Zhang a57063f7a2
fix: buffer overrun in the gRPC sample project (#3304)
Building the sample on Windows, the gRPC sample server/client app fails to function correctly. The propagated trace context is corrupted, containing garbage characters after the trace parent string.

The string buffer from gRPC cannot be safely treated as a null-terminated C-string. To ensure safe copying, we must use its length property instead.
2025-03-21 00:52:50 +01:00
Pranav Sharma d09bfbac57
[SDK] Add logger scope configurator (#3282) 2025-03-20 22:22:11 +01:00
Marc Alff 148cfe9ee2
[SEMANTIC CONVENTIONS] Upgrade semantic conventions to 1.31.0 (#3297) 2025-03-12 08:55:12 +01:00
IcySteam dee5b0bc5c
[SDK] Implement spec: MetricFilter (#3235) 2025-03-12 00:18:55 +01:00
Tom Tan 64a74bfadb
[API] Change the param-pack unpacking order to start from left to right (#3296)
* Change the param-pack unpacking order to start from left to right

* Add fallback for c++14 and below
2025-03-11 09:18:09 +01:00
WenTao Ou edfeabe4ce
Add link directory to support curl 8.12 (#3272) 2025-03-05 18:37:32 +01:00
WenTao Ou 3c4afd0696
[API] Deprecate event logger (#3285) 2025-02-25 10:36:31 +01:00
Tom Tan 021eb994cf
[ETW] Add configuration to export 64-bit integer as timestamp (#3286) 2025-02-22 11:43:05 +01:00
Doug Barker 3212b0f68f
[DEVCONTAINER] support customization and run as non-root user (#3270) 2025-02-21 13:47:20 +01:00
Pranav Sharma a7f9daf4cf
[SDK] Add meter scope configurator (#3268) 2025-02-21 12:10:14 +01:00
Tom Tan 4b56f63906 [BUILD] Enable old behavior of CMP0092 (#3269) 2025-02-21 11:05:15 +01:00
WenTao Ou 181f1e5829
[BUILD] Fix compiling problems with abiv2 and MSVC (#3284) 2025-02-21 09:06:57 +01:00
Marc Alff cd7103e0d3
Add FOSSA badges (#3280) 2025-02-20 12:44:30 -08:00
Milan Jeremić b89e63c1ce
Adding typecast without whom c++26 build fails (#3281) 2025-02-19 22:28:19 -08:00
OpenTelemetry Bot 821ad9ed28
Add FOSSA scanning workflow (#3279)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
2025-02-18 09:17:05 +01:00
Harish 7f047d561d
[EXPORTER] Support exporting event_name using OTLP Exporter (#3277) 2025-02-16 11:53:31 +01:00
Kyle L 2fdc0226c4
Fix compilation with Regex being disabled (#3276)
* Fix compilation with Regex disabled:
* It was missing an include for std::any_of
* Avoid declaring unused constants (at least my LLVM errors out)

* Only include algorithm if needed.

* Fix where we reference the WORKING_REGEX.
2025-02-15 21:11:23 -08:00
WenTao Ou 2f58e95c43
[BUILD] Fixes compatibility of type_traits (#3274) 2025-02-14 09:55:13 +01:00
Alex Emirov 3ca3c76c06
[CI] OTLP in Windows builds (#3263) 2025-02-10 09:38:03 +01:00
Marc Alff 5bc053e522
[SDK] Support OTEL_SDK_DISABLED environment variable (#3245) 2025-02-05 21:42:51 +01:00
Marc Alff 3506a7a975
[SDK] Fix BatchLogRecordProcessor to instrument shutdown (#3262) 2025-02-04 12:05:47 +01:00
WenTao Ou edb8937377
[DOC] Add document and example for sharing gRPC Client (#3260) 2025-02-01 21:20:39 +01:00
Pranav Sharma 52a80b5a04
[SDK] Add tracer scope configurator (#3137) 2025-01-30 21:27:36 +01:00
Marc Alff 6603c3a0f1
Upgrade semantic conventions to 1.30 (#3258) 2025-01-28 22:55:47 +01:00
Marc Alff 18e06f1fc5
[BUILD] Build break with CURL 7.29.0 (#3255) 2025-01-25 01:36:10 +01:00
Santiago Gimeno 72b00809aa
[BUILD] Update opentelemetry-proto version (#3254)
In `cmake/opentelemetry-proto.cmake` and `third_party_release` which
were not updated when upgrading to `1.5.0`.
2025-01-24 14:49:57 +01:00
Marc Alff ced79860f8
[RELEASE] release opentelemetry-cpp 1.19.0 (#3249) 2025-01-22 09:09:48 +01:00
Lalit Kumar Bhasin e21655559c
[SDK] Optimize Metric Processing for Single Collector with Delta Temporality (#3236) 2025-01-22 08:23:16 +01:00
Alex E. 031307b445
[EXPORTER] Support handling retry-able errors for OTLP/gRPC (#3219) 2025-01-21 22:28:33 +01:00
Marc Alff d2ff95acbc
[CI] Add GRPC in maintainer CI (#3248) 2025-01-21 15:21:30 +01:00
Alex E. 25f7a13f6f
[EXPORTER] Support handling retry-able errors for OTLP/HTTP (#3223) 2025-01-17 16:35:19 +01:00
Doug Barker 02cda5103f
[SDK] enable deriving from ResourceDetector to create a Resource (#3247) 2025-01-16 18:38:05 +01:00
Ehsan Saei 465cb4a102
[MAINTAINER] Add devcontainer (#3123) 2025-01-15 22:42:05 +01:00
WenTao Ou 95baed7158
[SDK] Fix lifetime of GlobalLogHandler (#3221) 2025-01-15 21:18:26 +01:00
Marc Alff 62b71970e5
[Code Health] Include what you use, part 7 (#3238) 2025-01-13 22:51:47 +01:00
Marc Alff d693e95cdb
[SDK] Better control of threads executed by opentelemetry-cpp (#3175) 2025-01-13 10:12:30 +01:00
Doug Barker 0b712dd2f7
[EXPORTER] fix throw in OtlpGrpcMetricExporter with shared grpc client (#3243) 2025-01-13 08:54:41 +01:00
Sv. Lockal 57114c5b9c
Fix error ‘uint8_t’ does not name a type with gcc-15 (#3240) 2025-01-10 09:13:30 -08:00
Marc Alff d19eb322e9
[CI] Spurious test failures (#3233) 2025-01-08 13:41:19 +01:00
Marc Alff e5a1a15296
[Code Health] Include what you use, part 6 (#3216) 2025-01-08 10:31:06 +01:00
WenTao Ou c33f800b5c
[BUILD] Add OTLP/file exporter for dll and examples (#3231) 2025-01-08 09:23:29 +01:00
Marc Alff 3b8934619e
[SEMCONV] Metrics are incorrectly prefixed with `metric.` (#3228) 2025-01-07 09:01:26 +01:00
Alex E. bb68f495c4
[TEST] Functional tests for OTLP/gRPC with mutual TLS (#3227) 2025-01-06 17:38:34 +01:00
Doug Barker 4998eb1786
[EDITORIAL] fix changelog entry for PR 3185 (#3217) 2024-12-19 18:24:29 +01:00
Marc Alff 807d610225
[TEST] Added support for SELINUX in functional tests (#3212) 2024-12-19 16:41:23 +01:00
Marc Alff 40d7b76a91
Upgrade to opentelemetry-proto 1.5.0 (#3210) 2024-12-19 01:25:17 +01:00
Doug Barker 92bf8daad5
[SDK] Fix include instrumentation scope attributes in equal method (#3214) 2024-12-18 21:13:44 +01:00
Alex E. 0b94d71258
[EXPORTER] Optimize OTLP HTTP compression (#3178) 2024-12-18 17:48:05 +01:00
xiehuc 2b9bff9688
[SDK] Do not frequently create and destroy http client threads (#3198) 2024-12-18 10:22:09 +01:00
WenTao Ou d9ad23ee86
[BUILD] Add cxx feature detections (#3203) 2024-12-18 08:37:47 +01:00
Marc Alff 902ee88bef
[TEST] Build the singleton test on windows. (#3183) 2024-12-17 19:49:16 +01:00
Marc Alff 1cbea09cb0
[BUILD] Build break using protoc 3.14 (#3211) 2024-12-17 18:07:01 +01:00
Marc Alff b7418152a0
[CI] Fix CI on ubuntu-latest (#3207) 2024-12-17 17:24:48 +01:00
David Ashpole 6ed0651a42
[SEMANTIC CONVENTIONS] Update links to openmetrics to reference the v1.0.0 release (#3205) 2024-12-14 11:59:28 +01:00
WenTao Ou 8b418fee83
[TEST] Change `is_called_` and `got_response_` to use atomic (#3204) 2024-12-13 14:41:46 +01:00
zurex 490f882e62
[DOC] Update existing maintaining dependencies doc (#3195) 2024-12-11 16:15:10 +01:00
Marc Alff 6d87bd6a8b
[SEMANTIC CONVENTIONS] Upgrade to weaver 0.11.0 (#3194) 2024-12-11 09:14:54 +01:00
Marc Alff 762b73d851
[SDK] Tracer provider shutdown blocks in-definitively (#3191) 2024-12-07 14:50:04 +01:00
Doug Barker 6218a24a47
[EXPORTER] add instrumentation scope attributes to otlp proto messages for traces and metrics (#3185) 2024-12-07 13:06:53 +01:00
Alex E. 2d80c18304
[Code health] Perform cppcheck cleanup (#3150) 2024-12-07 00:34:19 +01:00
seanchann.zhou 23562e6da3
[BUILD] Fix cross-compilation with protoc (#3186) 2024-12-06 14:40:15 +01:00
Marc Alff 150256c172
[SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.29.0 (#3182) 2024-12-03 00:29:24 +01:00
Volodymyr Kolesnykov ac4bba7363
[EXPORTER] Refactor `ElasticSearchRecordable` (#3164) 2024-12-02 23:33:19 +01:00
Alex E. f167c36eec
[SHIM] Add size to all string view mappings between OT and OTel (#3181) 2024-12-02 23:00:03 +01:00
WenTao Ou fb6fde8244
[BUILD] Upgrade cmake (#3167) 2024-12-02 09:05:03 +01:00
Marc Alff d15da3b256
[Code health] Include what you use cleanup, part 5 (#3140) 2024-11-27 11:57:47 +01:00
Yash Tibrewal 8d45dec7ee
[PROMETHEUS_EXPORTER] Fix default for emitting otel_scope attributes (#3171) 2024-11-26 09:22:18 +01:00
Marc Alff 955a807c04
[RELEASE] Release opentelemetry-cpp 1.18.0 (#3168)
Fixes #3145
2024-11-26 00:19:04 +01:00
Keith Smiley 2a8c8bc3de
[bazel] Update opentelemetry-proto in MODULE.bazel (#3163)
Mirrors fe68d51efe
2024-11-25 21:09:05 +01:00
Albert Kharisov 31956f82ff
[BUILD] Fix build for esp32 (#3155) 2024-11-24 21:50:40 +01:00
Marc Alff c1ef416c54
[BUILD] Do not set OTELCPP_PROTO_PATH in the CMake cache (#3160) 2024-11-24 20:39:35 +01:00
Marc Alff fcdd52672f
[INSTALL] Fix cmake/opentelemetry-cpp-config.cmake.in (#3165) 2024-11-24 14:24:16 +01:00
Keith Smiley 9d998e3341
[bazel] Enable --incompatible_disallow_empty_glob (#2642) 2024-11-23 11:10:48 +01:00
Keith Smiley 6a77bcdd5f
[bazel] Update prometheus-cpp in MODULE.bazel (#3162) 2024-11-23 01:36:36 +01:00
Marc Alff 09c0616971
[BUILD] Fix missing dependency on protoc compiler (#3159) 2024-11-23 00:19:24 +01:00
Volodymyr Kolesnykov f1b5fbdedd
[TEST] add a test for ElasticSearchRecordable (#3154) 2024-11-22 23:33:45 +01:00
Volodymyr Kolesnykov 4341e1237e
[TEST] refactor UrlParser tests to use value-paramterized tests (#3153) 2024-11-22 22:50:10 +01:00
Marc Alff fe68d51efe
[EXPORTER] Upgrade to opentelemetry-proto 1.4.0 (#3157) 2024-11-21 08:43:52 +01:00
Volodymyr Kolesnykov 4d9cc288d5
[EXPORTER] fix clang-tidy warnings in UrlParser (#3146) 2024-11-19 22:13:08 +01:00
Tom Tan 8e7a192f3e
[BUILD] Fix error message (#3152) 2024-11-19 18:12:36 +00:00
Alex E. 8691248fdd
[CI] Add cppcheck in the build (#3151) 2024-11-19 01:37:22 +01:00
dependabot[bot] 169525328a
Bump codecov/codecov-action from 4 to 5 (#3143)
* Bump codecov/codecov-action from 4 to 5

Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4 to 5.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v4...v5)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update .github/workflows/ci.yml

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marc Alff <marc.alff@oracle.com>
2024-11-19 01:04:53 +01:00
WenTao Ou a5db7e5935
[EXPORTER] Allow to share gRPC clients between OTLP exporters (#3041) 2024-11-18 23:32:36 +01:00
Volodymyr Kolesnykov a388e87d72
[CI] speed up `clang-tidy` workflow (#3148) 2024-11-15 16:46:25 +01:00
Volodymyr Kolesnykov 149d29ca78
[EXPORTER] handling of invalid ports in UrlParser (#3142) 2024-11-14 19:06:39 +01:00
Marc Alff c81a3d4d20
[SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.28.0 (#3139) 2024-11-14 00:34:37 +01:00
Marc Alff f7a9aea063
[SEMANTIC CONVENTIONS] Migration to weaver (#3105) 2024-11-13 19:14:12 +01:00
Chris Ward a713947e59
[BUILD] Patches for building on AIX (#3127) 2024-11-12 08:43:36 +01:00
Pranav Sharma 1863fe723d
[TEST] Rename w3c_tracecontext_test to w3c_tracecontext_http_test_server (#3132) 2024-11-08 20:58:52 +01:00
Maxime Leblanc 24a523c0cc
[EXPORTER]: Elasticsearch exporter put log resource in root instead of under 'resources' (#3131) 2024-11-08 16:37:22 +01:00
Yash Tibrewal 95d039c08a
[BUILD] Fix -Wmissing-template-arg-list-after-template-kw warning (#3133) 2024-11-08 00:09:26 +01:00
Santiago ff2447df63
[BUILD] Improve how to handle yield() in ARM. (#3129) 2024-11-07 22:01:59 +00:00
Alex E. 84d4270708
[EXPORTER] Log SSL Connection Information (#3113) 2024-11-06 22:50:51 +01:00
Ehsan Saei b0e8d7a57f
[EXPORTER] bump prometheus to v1.3.0 (#3122) 2024-11-06 21:20:33 +01:00
Pranav Sharma be1f43ca00
[API] Comply with W3C Trace Context (#3115) 2024-11-06 18:35:40 +01:00
Marc Alff 6fdf797ace
[CI] Comment the arm64 CI (#3125) 2024-11-06 09:06:39 +01:00
Claus F. Strasburger d16f7815ef
[BUILD] allow building with -DWITH_OTLP_HTTP_COMPRESSION=OFF without zlib (#3120) 2024-11-05 00:54:32 +01:00
uuzay f30ab925c8
[API] Add synchronous gauge (#3029)
* Add synchronous gauge

* Add ABI Version macro, update tests

* Fix function description

* Fix formatting

* Remove ABI macros from SDK.

* Add error log for gauge delta temporality.

* Fix formatting

* Apply suggestions from code review

Move kGauge to the end, for better ABI compatibility.

---------

Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
Co-authored-by: Marc Alff <marc.alff@free.fr>
2024-10-30 22:34:25 +01:00
tobim 6292a6a74e
[INSTALL] Resolve dependencies in opentelemetry-cpp-config.cmake (#3094)
* Resolve dependencies in opentelemetry-cpp-config.cmake

Before this change, consumers of the exported CMake targets had to know
which dependencies are needed to get the transitive target dependencies
like `absl::*`, `gRPC::grpc++`, or `protobuf::libprotobuf`.

* Add find_dependency calls for remaining deps

Now we also resolve `OpenTracing`, and `prometheus-cpp`.

If necessary, `CURL` and `ZLIB` are also resolved.

---------

Co-authored-by: Marc Alff <marc.alff@oracle.com>
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
2024-10-30 18:27:15 +01:00
Maxime Leblanc 5e62859ffc
[EXPORTER] Elastic Search exporter follow ECS guidelines (#3107)
* [EXPORTERS]: elastic search log message within `message` key instead of
`body`

According to ECS logging reference
https://www.elastic.co/guide/en/ecs/8.11/ecs-base.html#field-message

Refs #3091

* [EXPORTERS]: elastic search set severity within `log.level` key instead of
    `severity`

According to ECS logging reference
https://www.elastic.co/guide/en/ecs/8.11/ecs-log.html#field-log-level

Refs #3091

* [EXPORTERS]: elastic search set timestamp within `@timestamp` instead of
`timestamp`

Also changes the format to be a Date string.

According to ECS logging reference
https://www.elastic.co/guide/en/ecs/8.11/ecs-base.html#field-timestamp

Refs #3091

* [EXPORTERS]: elastic search set instrumentation scope within `log.logger` instead of
`name`

According to ECS logging reference
https://www.elastic.co/guide/en/ecs/8.11/ecs-log.html#field-log-logger

Refs #3091

* EXPORTERS]: elastic search recorable constructor sets `ecs.version` field
to 8.11.0

According to ECS guidelines this field is mandatory
https://www.elastic.co/guide/en/ecs/8.11/ecs-guidelines.html

Refs #3091

* [EXPORTERS]: elastic search put attributes in json root instead of under
`attributes`

This allows user to set other fields that are part of the [ECS log documentation](https://www.elastic.co/guide/en/ecs/8.11/ecs-log.html).
For instance, it allows to have an attribute with key `log.file`, that
will, thanks to `nlohmann::json`, appear as :
```
{
  "log": {
    "file": "xxx"
  }
}
```

Closes #3091
2024-10-27 17:50:41 +01:00
ColoredCarrot 2c912d50a5
[BUILD] Remove aligned_storage from nostd (#3112)
std::aligned_storage was deprecated in C++23.
Abseil removed its aligned_storage in 42133464db
2024-10-26 01:16:10 +02:00
Santiago Gimeno 994761988e
[EXPORTER] Add logging for async gRPC errors (#3108) 2024-10-24 14:32:48 +02:00
Tom Tan 751ba5b48f
[EXPORTER] Remove out of date ETW exporter doc (#3103) 2024-10-22 14:11:55 -07:00
tobim 7402ed9bac
[BUILD] Add a CMake option to disable shared libs (#3095)
* Add a CMake option to disable shared libs

This option is useful to support platforms that do not support
dynamic libraries and `dlopen`.
2024-10-21 23:27:57 +02:00
Pranav Sharma b1488cd37c
[EXPORTER] Add config options to prometheus exporter (#3104) 2024-10-21 22:43:30 +02:00
WenTao Ou 1185405c46
[TEST] Fix linking order and gmock linking (#3106)
* Fix link order

* Fix gmock linking
2024-10-18 12:20:42 +02:00
WenTao Ou 63683c1596
[BUILD] Fix compiling problems for gcc 4.8 (#3100)
* Fix compiling problems for gcc 4.8

* Apply suggestions from code review

---------

Co-authored-by: Marc Alff <marc.alff@free.fr>
2024-10-17 09:57:10 +02:00
WenTao Ou 70ed9bcac0
[BUILD] Remove std::make_unique (#3098) 2024-10-16 11:21:59 +02:00
WenTao Ou f69963f587
Update bzlmod version (#3093) 2024-10-13 17:18:22 +02:00
Marc Alff 6445819fce
[API] Jaeger Propagator should not be deprecated (#3086) 2024-10-08 18:49:56 +02:00
Romain Geissler @ Amadeus 3d9c2b5382
[BUILD] Avoid buggy "should be explicitly initialized in the copy constructor" warning with gcc <= 8 (#3087)
gcc <= 8, when building with -Wextra (and -Werror) wrongly raises this:
/data/mwrep/res/mdw/SIOTF/internal/opentelemetry_cpp/trace/18-0-0-7/include/opentelemetry/trace/default_span.h: In copy constructor 'opentelemetry::v1::trace::DefaultSpan::DefaultSpan(const opentelemetry::v1::trace::DefaultSpan&)':
/data/mwrep/res/mdw/SIOTF/internal/opentelemetry_cpp/trace/18-0-0-7/include/opentelemetry/trace/default_span.h:70:3: error: base class 'class opentelemetry::v1::trace::Span' should be explicitly initialized in the copy constructor [-Werror=extra]
   DefaultSpan(const DefaultSpan &spn) noexcept : span_context_(spn.GetContext()) {}
   ^~~~~~~~~~~

See on Compiler Explorer here: https://godbolt.org/z/ed5rv74nT

I believe Jason Merrill fixed it in gcc for all gcc >= 9 with:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=f3f7cefecc833b4ab652215ceb8b408c21dca225;hp=777083bb806dbe31ab97002b7d445191d3ee7a2d

Workaround this by calling explicitly the empty Span constructor.
2024-10-08 17:28:30 +02:00
Maxime Leblanc 0ea1f2c644
[EXPORTER] Fix crash in ElasticsearchLogRecordExporter when (#3082)
using constructor with user given options (#3078)

 Closes #3078
2024-10-08 09:12:37 +02:00
Marc Alff fa0a5200dd
[RELEASE] Release opentelemetry-cpp 1.17.0 (#3076) 2024-10-07 23:57:27 +02:00
ShadowMaxLeb 35e8d17420
[EXPORTER] Add possibility to give custom HttpHeaders for (#3083) 2024-10-07 22:44:24 +02:00
WenTao Ou 3910b049c1
Fix URL in ES exporter, fix ipv6 supporting for http client. (#3081) 2024-10-07 09:03:21 +02:00
Punya Biswal 7b824738c3
[SDK] Update MetricProducer interface to match spec (#3044)
Following https://github.com/open-telemetry/opentelemetry-specification/blob/v1.36.0/specification/metrics/sdk.md#metricproducer.

Updates #1831
2024-10-01 22:29:22 +02:00
Fabrízio de Royes Mello 23818a7105
[CI] Update otel-collector version (#3067)
Looks like otel-collector equal or higher than 0.86.0 has the "debug"
exporter.

So updated the README.md with the latest version of the otel-collector
(v0.109.0) and also the CI script.
2024-09-20 15:49:22 +02:00
loong_hy 2314e061a5
[BUILD] add loongarch info (#3052) 2024-09-18 06:03:42 +02:00
Marc Alff c6d394547b
[Code Health] include-what-you-use cleanup, part 4 (#3040) 2024-09-11 21:05:32 +02:00
Punya Biswal c37df2318d
Implement in-memory metric exporter (#3043)
Fixes #1405
2024-09-10 07:27:48 -07:00
Tom Tan 4eb78a6a04
[EXPORTER] Fix the format of SpanLink for ETW (#3054) 2024-09-08 09:22:15 +02:00
Tom Tan d623bc57f6
[EXAMPLE] Clean the tracer initialization in OStream example (#3051) 2024-09-05 22:40:26 +02:00
Alex Boten 261a151829
[TEST] update references to logging exporter (#3053)
This exporter has been replaced by the debug exporter and will be removed soon

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2024-09-05 21:34:20 +02:00
Alex Boten 0d5a387b00
[EXAMPLE] update collector example with debug exporter (#3049)
The logging exporter was renamed debug in 2023, the logging exporter will be removed in the near future, updating the example accordingly.

Co-authored-by: Marc Alff <marc.alff@oracle.com>
2024-09-04 23:58:53 +02:00
Alex Boten 080356950e
[TEST] update collector example with debug exporter (#3050)
The logging exporter was renamed debug in 2023, the logging exporter will be removed in the near future, updating the example accordingly.
2024-09-04 21:45:12 +02:00
Punya Biswal 7f785b5d5c
[TEST] Add missing tests to Bazel build (#3045)
* Fix overflow in timeout logic

Also use steady clock consistently.

Prior to this change, the test would fail under ASAN:

bazel test --config=asan --test_output=errors //sdk/test/metrics:meter_provider_sdk_test
INFO: Analyzed target //sdk/test/metrics:meter_provider_sdk_test (0 packages loaded, 0 targets configured).
FAIL: //sdk/test/metrics:meter_provider_sdk_test (see /private/var/tmp/_bazel_punya/e3bd968ba61238cdeb1a5537fc3dbf7d/execroot/_main/bazel-out/darwin_arm64-fastbuild-asan/testlogs/sdk/test/metrics/meter_provider_sdk_test/test.log)
INFO: From Testing //sdk/test/metrics:meter_provider_sdk_test:
==================== Test output for //sdk/test/metrics:meter_provider_sdk_test:
Running main() from gmock_main.cc
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from MeterProvider
[ RUN      ] MeterProvider.GetMeter
[Warning] File: sdk/src/metrics/meter_provider.cc:65 [MeterProvider::GetMeter] Library name is empty.
[Warning] File: sdk/src/metrics/meter_provider.cc:65 [MeterProvider::GetMeter] Library name is empty.
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__chrono/duration.h:102:59: runtime error: signed integer overflow: 9221646818050376183 * 1000 cannot be represented in type '_Ct' (aka 'long long')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__chrono/duration.h:102:59 in 
================================================================================
INFO: Found 1 test target...
Target //sdk/test/metrics:meter_provider_sdk_test up-to-date:
  bazel-bin/sdk/test/metrics/meter_provider_sdk_test
INFO: Elapsed time: 2.251s, Critical Path: 2.13s
INFO: 5 processes: 5 darwin-sandbox.
INFO: Build completed, 1 test FAILED, 5 total actions
//sdk/test/metrics:meter_provider_sdk_test                               FAILED in 0.6s
  /private/var/tmp/_bazel_punya/e3bd968ba61238cdeb1a5537fc3dbf7d/execroot/_main/bazel-out/darwin_arm64-fastbuild-asan/testlogs/sdk/test/metrics/meter_provider_sdk_test/test.log

Executed 1 out of 1 test: 1 fails locally.

Fix overflow in periodic_exporting_metric_reader

* Add missing tests to Bazel build by globbing test files

Previously, we were missing
* instrument_metadata_validator_test
* observable_registry_test
* cardinality_limit_test
* periodic_exporting_metric_reader_test
And there were no checks in place to prevent things from getting worse.

Remove unnecessary exception checks in attributes_hashmap_test,
which simplifies the build and CI script.

Resolve symbol collision using anonymous namespaces.

---------

Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
2024-09-03 21:08:37 +02:00
Punya Biswal f02d70bdb8
Fix overflow in timeout logic (#3046) 2024-09-03 06:19:57 -07:00
Marc Alff a9208987c5
[Code Health] include-what-you-use cleanup, part 3 (#3004) 2024-08-26 12:59:17 -07:00
Siddhartha Malladi a71642fe67
[Code Health] Clang Tidy cleanup, Part 2 (#3038) 2024-08-25 19:58:32 +02:00
WenTao Ou 242d52ac67
[SDK] PeriodicExportingMetricReader: future is never set, blocks until timeout (#3030) 2024-08-21 15:36:53 -07:00
WenTao Ou b8909692c6
[TEST] Fix sync problems in OTLP File exporter tests. (#3031) 2024-08-16 15:30:29 +02:00
Lalit Kumar Bhasin 1203bcf264
[SDK] Support empty histogram buckets (#3027)
* support empty buckets

* Update histogram_test.cc

* Update histogram_test.cc

* test for negative values

* fix count
2024-08-14 17:47:59 +00:00
Marc Alff 9e062b5bdd
[SEMANTIC CONVENTIONS] Upgrade semantic conventions to 1.27.0 (#3023) 2024-08-13 10:51:39 +02:00
Troels Hoffmeyer 41538b0525
[BUILD] Version opentelemetry_proto/proto_grpc shared libraries (#2992) 2024-08-09 13:38:17 +02:00
Marc Alff cc60934199
[Code health] Expand iwyu coverage to include unit tests. (#3022) 2024-08-08 21:13:54 +02:00
Carbo Kuo 7c6b9dbcaf
[BUILD] Add abi_version_no bazel flag. (#3020) 2024-08-06 19:43:02 +02:00
Manuel Bergler 34ca855055
[BUILD] Fix build without vcpkg on Windows when gRPC is disabled (#3016) 2024-08-02 15:54:26 -07:00
Carbo Kuo eda6e93f47
[BUILD] Update MODULE.bazel (#3015) 2024-08-02 21:30:41 +02:00
WenTao Ou 84368cd761
[EXPORTER] Ignore exception when create thread in OTLP file exporter. (#3012) 2024-07-29 17:25:44 +02:00
Weipeng Hong deed1e3a0c
[SDK] Fix memory leak in TlsRandomNumberGenerator() constructor (#2661) 2024-07-19 20:13:04 +02:00
WenTao Ou 4520aa598b
[SDK] Fix crash in `PeriodicExportingMetricReader`. (#2983) 2024-07-19 12:12:48 +02:00
WenTao Ou f195b9e3da
[EXPORTER] ForceFlush before canceling the running requests on shutdown. (#2727) 2024-07-19 11:34:40 +02:00
Marc Alff 611906eeaf
[REMOVAL] Remove build option `WITH_DEPRECATED_SDK_FACTORY` (#2717) 2024-07-18 01:27:46 +02:00
Marc Alff 0a43c1f2b1
[BUILD] Upgrade to opentelemetry-proto 1.3.2 (#2991) 2024-07-18 00:48:26 +02:00
Siddhartha Malladi aac2b775af
[CI] Add a clang-tidy build (#3001) 2024-07-17 23:19:41 +02:00
Marc Alff baecbb95bd
[RELEASE] Release opentelemetry-cpp version 1.16.1 (#3007) 2024-07-17 22:04:10 +02:00
Lalit Kumar Bhasin d8ae09e53d
[Metrics SDK] Fix hash calculation for nostd::string (#2999)
* add test to validate cardinaity limit

* format

* warning

* Format

* maint mode CI

* modify test to reproduce the issue

* Format

* remove vscode settings

* remove redundant test

* remove unused code

* fix to calculate hash on string_view

* remove iostream

* template specialization for const char *, and varous string type tests

* unused variable warning

* more warnings

* format

* fix use-after-stack-scope

* format

* another try

* format

---------

Co-authored-by: Tom Tan <Tom.Tan@microsoft.com>
2024-07-17 07:00:20 -07:00
Keith Smiley 323a279ec5
[CI] Enable bzlmod (#2995) 2024-07-12 23:03:17 +02:00
Marc Alff 63fa4fde4e
[CI] Build failures with ABSEIL 20240116 and CMAKE 3.30 (#3002) 2024-07-12 12:17:04 +02:00
Siddhartha Malladi eb2b9753ea
[Code Health] clang-tidy cleanup, part 1 (#2990) 2024-07-11 11:45:17 +02:00
Marc Alff 6dbfdb52eb
[Code health] include-what-you-use cleanup, part 2 (#2704) 2024-07-06 17:16:02 +02:00
Mats Taraldsvik 0ff58e8334
[EXPORTER] Fix references in AttributeValueVisitor (#2985) 2024-07-05 19:16:32 +02:00
Marc Alff f6dca999b5
[TEST] Fix opentelemetry-collector bind address (#2989) 2024-07-03 18:04:05 +02:00
Marc Alff 42563e4160
[SECURITY] Remove OTLP HTTP support for TLS 1.0 and TLS 1.1, require TLS 1.2 (#2722) 2024-07-02 20:42:54 +02:00
Dylan Herman 5e21b8ac2d
[DOC] Remove comment for unused LoggerProvider initialization params (#2972) 2024-06-30 23:42:19 +02:00
Pravila ead2d1b606
[DOC] Update "Using triplets" section in building-with-vcpkg documentation. (#2726)
* Update triplet links in building-with-vcpkg documentation.

* Update docs/building-with-vcpkg.md

Co-authored-by: Tom Tan <lilotom@gmail.com>

---------

Co-authored-by: Marc Alff <marc.alff@free.fr>
Co-authored-by: Tom Tan <lilotom@gmail.com>
2024-06-30 14:47:06 +02:00
Siddhartha Malladi f0e0ef0bf3
[SDK] Added reserve for spans array in BatchSpanProcessor. (#2724)
* Added reserve for spans array in BatchSpanProcessor.

    Added reserve for spans array in BatchSpanProcessor.
    
    Helps to allocate the amount of memory needed for number of records so that dynamic memory allocation doesn't happen in the consume method.
    
    .push_back() reallocates memory each time the method is called.
    
    Using .reserve() would avoid memory reallocation as already the memory is allocated.
    
    References:
    https://cplusplus.com/reference/vector/vector/push_back/
    https://cplusplus.com/reference/vector/vector/reserve/

* Added reserve for spans array in BatchLogProcessor.

Added reserve for spans array in BatchLogProcessor. Same as previously done for BatchSpanProcessor

* Update batch_log_record_processor.cc

* Update batch_span_processor.cc

* Update sdk/src/logs/batch_log_record_processor.cc
2024-06-28 00:14:31 +02:00
Dat Le 77012391b2
[BUILD] Add bazel missing BUILD file (#2720) 2024-06-27 09:01:41 +02:00
Marc Alff fd57e7aa23
[RELEASE] Release opentelemetry-cpp version 1.16.0 (#2711) 2024-06-21 19:13:20 +02:00
WenTao Ou 4e86a86a5f
[EXPORTER] All 2xx return codes should be considered successful. (#2712) 2024-06-21 11:14:09 +02:00
WenTao Ou 086e94cdbd
[BUILD] Add option `WITH_OTLP_GRPC_SSL_MTLS_PREVIEW` (#2714) 2024-06-21 09:35:34 +02:00
Harish e1d96901fc
[Code health] Remove Unicode Text from Source files (#2707)
Signed-off-by: perhapsmaple <140232061+perhapsmaple@users.noreply.github.com>
2024-06-20 09:20:57 +02:00
Ehsan Saei aff26ac503
[CI] Enable ARM64 build in CI (#2699) 2024-06-19 09:25:08 +02:00
dependabot[bot] 595801bab9
Bump docker/build-push-action from 5 to 6 (#2705)
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v5...v6)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-18 13:11:37 +02:00
Yijie Ma 05bfb8a257
[DOC] Fix typo tace_id -> trace_id in logger.h (#2703) 2024-06-17 08:51:42 +02:00
Darren Bolduc 9af3c99cf0
[BUILD] Restore Bazel flag removed from public API (#2702) 2024-06-15 18:20:57 +02:00
Marc Alff f97dc061bc
[Code health] include-what-you-use cleanup (#2692) 2024-06-15 17:10:05 +02:00
zhanglei fad93f0727
[BUILD] Fix Import Abseil-cpp (#2701) 2024-06-15 13:50:04 +02:00
Keith Smiley 025f42f1ea
[BUILD] Add support for bzlmod (#2608)
* Add support for bzlmod

This adds support for bzlmod, which is bazel's new dependency resolution
system.

Theoretically we could now remove the previous dependency management
configuration which required flattening all the dependencies, but I left
it here for now for users using old versions of bazel.
2024-06-14 22:43:37 +02:00
Keith Smiley 508910529b
[bazel] Bump version and deps (#2679)
---------

Co-authored-by: Marc Alff <marc.alff@oracle.com>
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
Co-authored-by: Tom Tan <Tom.Tan@microsoft.com>
2024-06-11 21:47:23 +02:00
WenTao Ou 3efd3ce8f4
[EXPORTER] OTLP file: use `fopen`, `fwrite`, `fflush` and `fclose` which are thread-safe. (#2675)
* Use `fopen`, `fwrite`, `fflush` and `fclose` which are thread-safety.

* Add some macros to help to find problems.

Add `OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND` , `OPENTELEMETRY_SANITIZER_NO_MEMORY` , `OPENTELEMETRY_SANITIZER_NO_THREAD`, `OPENTELEMETRY_SANITIZER_NO_ADDRESS`, `OPENTELEMETRY_HAVE_BUILTIN`, `OPENTELEMETRY_HAVE_FEATURE`, `OPENTELEMETRY_HAVE_ATTRIBUTE`, `OPENTELEMETRY_HAVE_CPP_ATTRIBUTE`

* Append EOL before call Export of backend

---------

Co-authored-by: Marc Alff <marc.alff@oracle.com>
2024-06-08 14:38:00 +02:00
Thomas Braun 436a981d81
CMakeLists.txt: Enable CMAKE_MSVC_RUNTIME_LIBRARY support (#2652)
The documentation for CMAKE_MSVC_RUNTIME_LIBRARY states [1]:

> This variable has effect only when policy CMP0091 is set to NEW prior to
> the first project() or enable_language() command that enables a language
> using a compiler targeting the MSVC ABI.

so the current usage of CMAKE_MSVC_RUNTIME_LIBRARY for vcpkg does not work
at all.

Let's fix that by setting policy 91 to new if present.

[1]: https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html

Co-authored-by: Tom Tan <Tom.Tan@microsoft.com>
2024-06-06 19:34:47 +02:00
Tom Tan 1d8a7b5b25
[BUILD] Remove the incorrect set of CMAKE_MSVC_RUNTIME_LIBRARY for vcpkg (#2696) 2024-06-06 09:24:23 -07:00
Tom Tan bf8fa53ac1
[BUILD] Remove benchmark overlay for vcpkg (#2695) 2024-06-06 17:47:45 +02:00
Tom Tan cb9cd1d1d1
[ETW] Add table name mapping for Logs other than the default Log table (#2691) 2024-06-05 10:52:19 -07:00
Marc Alff 2535c70c4e
[API/SDK] Provider cleanup (#2664) 2024-06-03 22:46:08 +02:00
Marc Alff 4f37503105
[SEMANTIC CONVENTIONS] Upgrade to version 1.26.0 (#2687) 2024-05-31 20:48:54 +02:00
Lalit Kumar Bhasin c5269cd1d2
[CI] Fix CI failures on Ubuntu 24.04 (#2686) 2024-05-30 22:41:04 +02:00
Marc Alff c42dcca9f8
[CI] Upgrade to clang-format 18 (#2684) 2024-05-29 22:01:06 +02:00
Marc Alff 0dd64e0747
[CI] include-what-you-use (#2629) 2024-05-29 19:06:10 +02:00
WenTao Ou 277190d3f2
[BUILD] Read default proto version from `third_party_release` (#2677) 2024-05-28 11:04:00 +02:00
WenTao Ou 17c3bc66d4
[API] DO not allow unsafe `Logger::EmitLogRecord` (#2673) 2024-05-28 09:04:49 +02:00
WenTao Ou 605c3e8ea7
[SDK] Fix forceflush may wait for ever (#2584)
Co-authored-by: Marc Alff <marc.alff@oracle.com>
Co-authored-by: Tom Tan <Tom.Tan@microsoft.com>
2024-05-27 21:50:01 +02:00
Tom Tan 78d488ca44
[BUILD] Remove the hard-coded separator in tracestate (#2672) 2024-05-23 14:54:53 +02:00
Marc Alff 9c767df507
[API] Return NoopLogRecord from NoopLogger (#2668)
Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
2024-05-16 21:48:14 +02:00
Marc Alff 2db27ddfd3
[BUILD] Upgrade to opentelemetry-proto 1.3.1 (#2669) 2024-05-16 21:12:15 +02:00
Marc Alff 4edcebdbff
[CI] Upgrade Maintainers CI to ubuntu-24.04 (#2670)
* Upgrade Maintainers CI to ubuntu-24.04

* Disable IWYU
2024-05-16 19:29:04 +02:00
Marc Alff ce14bf6520
[EXPORTER] General cleanup for is_shutdown_ flags in exporters. (#2663) 2024-05-08 21:09:58 +02:00
Marc Alff 6de4ccd421
[BUILD] Build break in OLTP_FILE tests (#2659) 2024-05-08 17:59:49 +02:00
Rashid Kaleem 4f32bc6f29
[SDK] Avoid missing conditional variable update and simplify atomic bool (#2553)
Addresses two issues -
1. Fix the use of a conditional variable where a wait on the variable might not be in flight when a notify is called. This is fixed by ensuring that an associated lock is aquired before calling the notify.
2. Instead of relying on a lock an a boolean, replace the use wit a single atomic boolean.

---------

Co-authored-by: Ehsan Saei <71217171+esigo@users.noreply.github.com>
Co-authored-by: Marc Alff <marc.alff@oracle.com>
Co-authored-by: Marc Alff <marc.alff@free.fr>
2024-05-08 14:44:46 +02:00
WenTao Ou da8e377be5
[BUILD] Link CoreFoundation on apple systems because some dependency packages require it. (#2655) 2024-05-06 11:44:17 +02:00
Tom Tan 2d077f8ec5
Update ExemplarFilter and ExemplarReservoir for spec (#2372) 2024-04-29 13:14:06 -07:00
WenTao Ou 830651a4c7
Use `nostd::enable_if_t` instead of `std::enable_if_t` (#2648) 2024-04-29 21:19:31 +02:00
Marc Alff 0ca7d707a5
[BUILD] Upgrade bazel abseil from 20220623.1 to 20230802.2 (#2650) 2024-04-29 19:20:27 +02:00
Marc Alff 054b0dc207
[RELEASE] Release opentelemetry-cpp version 1.15.0 (#2639) 2024-04-21 22:11:48 +02:00
Xx 6c2a6abad3
[DOC] Update INSTALL.md (#2592)
Co-authored-by: Tom Tan <Tom.Tan@microsoft.com>
Co-authored-by: Marc Alff <marc.alff@free.fr>
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
Co-authored-by: Marc Alff <marc.alff@oracle.com>
2024-04-18 12:29:10 +02:00
Marc Alff 7aea1a6a94
[SEMANTIC CONVENTIONS] Rework on semantic conventions 1.25.0 (#2640) 2024-04-18 00:41:38 +02:00
WenTao Ou 950c336e3f
[DOC] Add readme and examples for OTLP FILE exporters. (#2638) 2024-04-17 09:10:24 +02:00
Ehsan Saei 8f15440b45
[SEMANTIC CONVENTIONS] Upgrade to semantic convention 1.25.0 (#2633) 2024-04-16 23:29:10 +02:00
Marc Alff 78947b2ab1
[SDK] DefaultLogHandler to print errors to std::cerr, add LogLevel::None (#2622) 2024-04-13 17:20:11 +02:00
Marc Alff cd22f0f8ac
[PROTO] Upgrade to opentelemetry-proto 1.2.0 (#2631) 2024-04-09 18:31:23 +02:00
Marc Alff 848db5722e
[CI] Use platform CMake (#2627) 2024-04-04 22:09:47 +02:00
WenTao Ou e86ceba79d
[EXPORTER] OTLP file exporter (#2540) 2024-04-03 20:45:07 +02:00
Marc Alff 13a4c45009
[CI] Benchmark, provide units with --benchmark_min_time (#2621) 2024-04-03 19:00:46 +02:00
Marc Alff fabd8cc2bc
[CI] Upgrade to abseil 20240116.1 (CMake only) (#2599) 2024-03-28 22:25:44 +01:00
John Bley 3adcc791e7
[CI] Add shellcheck --severity=error as a CI step (#2618) 2024-03-28 21:23:35 +01:00
John Bley a06fd25ae7
[MISC] Use set -e on all shell scripts and pass shellcheck --severity=error (#2616) 2024-03-28 18:43:46 +01:00
Tom Tan 8dacf7e65d
[METRICS SDK] Remove extra OfferMeasurement call in SyncMetricsStorage::RecordDouble (#2610) 2024-03-27 08:55:20 +01:00
Keith Smiley 611caa786e
Remove unused variable (#2609) 2024-03-25 19:09:36 -07:00
WenTao Ou 02e6ad25ad
[BUILD] Do not link `prometheus-cpp::util` when it doesn't exist (#2606) 2024-03-25 09:01:53 +01:00
Yijie Ma 9500c12046
fix typo (#2604) 2024-03-23 00:48:59 +00:00
Marc Alff f2f0738792
Upgrade to prometheus 1.2.4 (#2598) 2024-03-21 21:17:02 -07:00
Marc Alff d24839e318
Upgrade to benchmark 1.8.3 (#2597) 2024-03-21 20:08:15 -07:00
Keith Smiley 8605fe82c1
[bazel] Fix -std=c++14 warning on Windows (#2601) 2024-03-22 00:59:29 +01:00
Keith Smiley 3f8d954468
[bazel] Move -std=c++14 to .bazelrc (#2600)
This way it applies to local builds as well as CI builds
2024-03-21 20:33:11 +01:00
Marc Alff 0375cd4051
Upgrade to nlohmann_json 3.11.3 (#2595) 2024-03-21 19:07:07 +01:00
Marc Alff 788631d964
Upgrade to googletest 1.14.0 (#2596) 2024-03-21 10:26:04 -07:00
Tom Tan 4d4f8ed085
[etw] cleanup include path (#2594) 2024-03-20 11:09:44 -07:00
Harish 19f0dc7760
[EXPORTER] OTLP: Fix missing ResourceMetrics SchemaURL (#2587) 2024-03-12 10:34:24 -07:00
Marc Alff 25738f391b
[BUILD] Provide LIKELY / UNLIKELY macros (#2580)
* Contributes to #2572

* Restored support for __builtin_expect()

* Typo
2024-03-11 22:14:14 +01:00
Marc Alff 3e4b7d3c73
[BUILD] Bump cmake version to 3.9 (#2581) 2024-03-08 09:35:12 +01:00
Marc Alff ac7ee5f80a
[BUILD] CMake cleanup for message() (#2582) 2024-03-08 09:02:49 +01:00
Johannes Tax e5c2e25144
Support URL-encoded values for `OTEL_EXPORTER_OTLP_HEADERS` (#2579) 2024-03-07 07:16:16 -08:00
Willie Abrams 14f7542c18
[SDK] Support for OTEL_SERVICE_NAME (#2577) 2024-03-06 01:24:41 +01:00
Tom Tan c82306f431
[BUILD] update vcpkg submodule to 20240214 (#2575) 2024-03-04 19:34:30 +01:00
Harish 07f6cb54ec
[EXPORTER] Gzip compression support for OTLP/HTTP and OTLP/gRPC exporter (#2530) 2024-02-29 18:42:25 +01:00
Keith Smiley eaaf6cd602
Fix old style cast warning (#2567)
Fixes https://github.com/open-telemetry/opentelemetry-cpp/issues/2556
2024-02-28 23:01:19 +01:00
Alan West ba183049a5
[DOC] Fix OTLP documentation: Default endpoint is wrong for OTLP/HTTP (#2560) 2024-02-28 09:24:18 +01:00
Tom Tan d036d8227f
Reapply "Change OTLP HTTP content_type default to binary (#2558)" (#2564) 2024-02-27 14:16:03 -08:00
Lalit Kumar Bhasin a799f4aed9
Patch release v1.14.2 (#2563) 2024-02-27 12:32:08 -08:00
Lalit Kumar Bhasin 719c60fd8e
Revert "Change OTLP HTTP content_type default to binary (#2558)" (#2562)
This reverts commit a883dc7255.
2024-02-27 11:46:40 -08:00
WenTao Ou a883dc7255
Change OTLP HTTP content_type default to binary (#2558) 2024-02-27 10:04:13 -08:00
Lalit Kumar Bhasin 32196a51f0
Fix observable attributes drop (#2557) 2024-02-27 08:56:57 -08:00
karusher 84e38b215f
Provide span for opentracing shim inject (#2535)
The various propagation injectors will attempt to retrieve the
Span from the context that is provided in the api call:

  void Inject(context::propagation::TextMapCarrier &carrier,
              const context::Context &context) noexcept override

The shim will provide the RuntimeContext augmented with the baggage
to the Inject method. Unfortunately, the shim does not add the span
to the RuntimeContext. It does not instantiate a Scope.

This commit adds a Span to the context passed into Inject by
modifying the shim.
2024-02-26 22:31:09 +01:00
Marc Alff 563094b683
[RELEASE] Release opentelemetry-cpp version 1.14.1 (#2551) 2024-02-23 22:47:57 +01:00
Darren Bolduc 75f34e60a3
[SDK] Restore Recordable API compatibility with versions < 1.14.0 (#2547) 2024-02-23 21:35:22 +01:00
Marc Alff 89a3d9be45
[DOC] Add missing CHANGELOG. (#2549) 2024-02-23 20:54:30 +01:00
Markus Hennerbichler 9649ebeaaf
[EXPORTER] Error when grpc endpoint is empty (#2507) 2024-02-23 17:53:34 +00:00
Marc Alff 4eb99f9e05
[BUILD] Incorrect test on ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW (#2546) 2024-02-22 10:09:21 +01:00
Isaac David 2f3fbd48b7
[DOC] Fix typo in benchmarks.rst (#2542) 2024-02-20 10:43:50 +01:00
Tom Tan e1119ed781
[RELEASE] opentelemetry-cpp version 1.14.0 (#2537) 2024-02-17 08:38:30 -08:00
karusher c7a88c479f
[API] Propagation: fix for hex conversion to binary for odd hex strings (#2533) 2024-02-14 09:59:31 +01:00
Marc Alff 614b8db9bf
[DOC] Fix calendar link (#2532) 2024-02-12 23:44:30 +01:00
Tom Tan 8684a33fea
Remove namespace using in ETW exporter which affects global namespace (#2531) 2024-02-12 13:37:12 -08:00
Tom Tan 4700e483e0
Don't invoke vcpkg from this repo with CMAKE_TOOLCHAIN_FILE set (#2527) 2024-02-09 16:01:05 -08:00
WenTao Ou 6e8f7c44f3
[EXPORTER] Async exporting for otlp grpc (#2407) 2024-02-08 13:50:03 -08:00
Lalit Kumar Bhasin cf5cdaae86
Fix attribute filtering for synchronous instruments. (#2472) 2024-02-08 13:02:25 -08:00
dependabot[bot] d32f9609b9
Bump codecov/codecov-action from 3 to 4 (#2519)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3 to 4.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-01 11:07:30 +01:00
bcsgh 497eaf43e5
[BUILD] Better handling of OPENTELEMETRY_STL_VERSION under Bazel. (#2503) 2024-01-30 09:13:51 +01:00
Marc Alff 732f0b22fb
[DOC] Fixes CI markdown error MD055 - Table pipe style (#2517) 2024-01-30 00:20:50 +01:00
Emmanuel Courreges 7cc781e654
[API] Propagators: do not overwrite the active span with a default invalid span (#2511) 2024-01-29 22:59:29 +01:00
Tom Tan 23206365dc
Updated the recorded vcpkg submodule version (#2513) 2024-01-27 16:42:47 +01:00
dependabot[bot] f36fc0fc79
Bump peter-evans/create-or-update-comment from 3.1.0 to 4.0.0 (#2512) 2024-01-27 09:39:15 +00:00
Bogdan Drutu 8cbe7271a0
[BUILD] Remove unnecessary usage/includes of nostd/type_traits (#2509) 2024-01-27 01:17:20 -08:00
Marc Alff bbd6325f78
[SEMANTIC CONVENTIONS] Upgrade to version 1.24.0 (#2461) 2024-01-25 11:04:55 +01:00
Tom Tan 14b74b9fb4
[EXAMPLES] Improve readme of Metrics example (#2510) 2024-01-25 10:31:25 +01:00
Marc Alff 8da71b78ed
[BUILD] Clang-15 warning about `__has_trivial_destructor` (#2502)
* Upgrade compiler in CI

* Backport abseil fix for clang-15.

* More backport for clang-15

* Missed backport bits.

* Fixed a new warning.
2024-01-23 12:47:11 -08:00
Sai Harsha Kottapalli fe15d0a4d1
[BUILD] Fix multiple assignment operators for SpinLockMutex (#2501) 2024-01-23 09:08:56 -08:00
Mats Taraldsvik a2323281ad
[BUILD] Alternative way of exporting symbols (generating .def file) (#2476) 2024-01-22 14:27:48 -08:00
bcsgh 8f88553507
[CI] Make cmake.c++20*.test actualy use C++20 and add cmake.c++23*.test (#2496) 2024-01-22 13:27:33 -08:00
Sören Bohn 02b984abf5
[DOCUMENTATION] Add api reference documentation for logs (#2497)
* Remove superfluous slash and bring input in lexicographic order.

* Add logs to generated Doxygen documentation.

---------

Co-authored-by: Marc Alff <marc.alff@oracle.com>
2024-01-21 11:20:55 -08:00
WenTao Ou ff13fdd92d
[BUILD] Fix variable shadow (#2498) 2024-01-21 15:47:56 +01:00
Tom Tan 2b5c2b4044
[BUILD] Add DLL build CI pipeline with CXX20 (#2465) 2024-01-19 09:10:55 +01:00
bcsgh 589dd2ac6b
[BUILD] Fix checks on __cplusplus under MSVC, do not assume /Zc (#2493) 2024-01-18 14:47:24 -08:00
Tom Tan 1467d663a9
[EXAMPLES] Use logs API instead of logs bridge API in the example (#2494) 2024-01-18 22:52:12 +01:00
dependabot[bot] 0cd3e88bbb
Bump actions/cache from 3 to 4 (#2491)
Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-18 09:42:04 +01:00
Tom Tan f3132e5304
[EXPORTER] Fix forward protocol encoding for ETW exporter (#2473) 2024-01-17 09:11:06 +01:00
Marc Alff 423ecacdf6
[PROTO] Upgrade to opentelemetry-proto v1.1.0 (#2488) 2024-01-16 23:49:59 +01:00
WenTao Ou c4f39f2be8
[BUILD] Skip patch alias target (#2457) 2024-01-08 21:27:46 +01:00
Tim Wojtulewicz f084fbce22
[EXPORTER] Rename populate_otel_scope to without_otel_scope (#2479) 2024-01-08 21:02:18 +01:00
Shrey Amin 928a87ce57
[EXPORTER] Set is_monotonic flag for Observable Counters (#2478) 2024-01-08 20:07:56 +01:00
Mats Taraldsvik 74db5e6101
Remove duplicate install command in CMakeLists.txt for api (#2474) 2024-01-04 21:56:57 +00:00
Mats Taraldsvik 0134bbe0de
[EXPORTER and SDK] Additional fixes after NOMINMAX removal on Windows (#2475) 2024-01-03 13:05:37 -08:00
WenTao Ou ddfafff999
[EXPORTER] Do not use regex in `CleanUpString` because some implementations of STL may crash. (#2464) 2023-12-23 11:23:01 +01:00
Lalit Kumar Bhasin 0dd5eedf75
[EXPORTER] Fix Aggregation type detection in OTLP Exporter (#2467) 2023-12-22 18:09:48 +01:00
Tim Wojtulewicz e8afbb8eac
[EXPORTER] Add option to disable Prometheus otel_scope_name and otel_scope_version attributes (#2451) 2023-12-16 17:37:13 +01:00
dependabot[bot] e79a10f69a
Bump actions/upload-artifact from 3 to 4 (#2456)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-15 09:34:38 +01:00
Marc Alff ebb45c6a3b
[SEMANTIC CONVENTIONS] Code generation script fails on SELINUX (#2455) 2023-12-14 18:18:01 -08:00
Tom Tan 03f2a6916d
[BUILD] Introduce CXX 20 CI pipeline for MSVC/Windows (#2450) 2023-12-14 21:02:12 +01:00
dependabot[bot] ab440e4d4c
Bump github/codeql-action from 2 to 3 (#2452) 2023-12-13 22:20:31 -08:00
Marc Alff 51c2ee5679
[REMOVAL] Remove option WITH_OTLP_HTTP_SSL_PREVIEW (#2435) 2023-12-14 00:37:31 +01:00
Tom Tan 0b9371dcc5
[BUILD] Fix removing of NOMINMAX on Windows (#2449) 2023-12-13 21:37:55 +01:00
Tom Tan 96e5078cff
[BUILD] Accept path list in OPENTELEMETRY_EXTERNAL_COMPONENT_PATH (#2439) 2023-12-08 13:54:37 -08:00
dependabot[bot] cd626c2ae9
Bump actions/stale from 8 to 9 (#2441) 2023-12-07 22:46:12 -08:00
Tom Tan a8b11a3503
[BUILD] Remove gmock from GTEST_BOTH_LIBRARIES (#2437) 2023-12-07 09:04:59 +01:00
Marc Alff 4bd64c9a33
[RELEASE] Prepare release 1.13.0 (#2432) 2023-12-06 20:39:21 +01:00
Marc Alff 9f6d1453e7
[REMOVAL] Remove ZPAGES (#2433) 2023-12-06 01:25:11 +01:00
Lalit Kumar Bhasin 48e633e740
[API] Create root span with active span (#2427) 2023-12-06 00:26:16 +01:00
Bogdan Drutu d91e5bac17
[BUILD] Use fully qualified references to trace/common namespace (#2424) 2023-12-05 22:46:01 +01:00
Marc Alff 39ad238f55
[SEMANTIC CONVENTIONS] Upgrade to semconv version 1.23.1 (#2428) 2023-12-05 21:22:33 +01:00
Kyle L a86f8f094a
[BUILD] Improve the handling of OPENTELEMETRY_HAVE_WORKING_REGEX. (#2430) 2023-12-05 20:39:39 +01:00
Thomas-Barbier-1A d1143ab37e
[BUILD] 'uint8_t' not declared in this scope with gcc 13.2.1 (#2423) 2023-12-05 10:54:00 +01:00
Tom Tan abad83d03e
[BUILD] Remove defining NOMINMAX from api (#2420) 2023-12-02 03:46:18 -08:00
Bogdan Drutu 25343e6e3b
Bump third_party/googletest to same version as bazel (#2421) 2023-12-01 10:08:25 +01:00
Bogdan Drutu 27a58cdc25
[BUILD] Fix references to trace namespace to be fully qualified (#2422) 2023-12-01 09:25:25 +01:00
Tom Tan 064fef0d87
[Metrics] Make context optional for histogram instruments in Metrics SDK (#2416) 2023-11-29 09:45:09 -08:00
Ehsan Saei 71d0e50b12
[EXPORTER] Prometheus: Add unit to names, convert to word (#2213) 2023-11-22 17:26:14 +01:00
Lalit Kumar Bhasin 9b89843553
[SDK] Cardinality limits for metrics streams (Sync Instruments + Delta Temporality) (#2255) 2023-11-21 10:06:06 +01:00
Tom Tan 8cba762d0d
[BUILD] Update vcpkg to latest release (#2412) 2023-11-21 08:52:17 +01:00
dependabot[bot] cb603ad97f
Bump actions/github-script from 6 to 7 (#2403)
Bumps [actions/github-script](https://github.com/actions/github-script) from 6 to 7.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-16 21:53:05 -08:00
Marc Alff 3dfcf93c41
[EXPORTER] Rework OTLP/HTTP and OTLP/GRPC exporter options (#2388) 2023-11-13 14:27:29 -08:00
Tom Tan 5bd9c65c64
[BUILD] Check windows options are not passed to non-Windows build (#2399) 2023-11-12 21:07:11 +01:00
WenTao Ou 6322607520
[TEST] Fix compiling problem and removed -DENABLE_TEST (#2401) 2023-11-11 11:20:51 +01:00
Tom Tan 86ee88615b
[SDK] Fix GetLogger with empty library name (#2398) 2023-11-10 10:53:12 +01:00
Marc Alff 35a9362732
[ADMIN] Add file .github/repository-settings.md (#2392) 2023-11-06 14:27:16 -08:00
Harish Shan 5bf2f8007f
[BUILD] Add missing includes to runtime_context_test (#2395) 2023-11-06 11:42:59 -08:00
Harish Shan ca08c5a34a
[BUILD] Fix exported definitions when building DLL with STL (#2387) 2023-10-31 22:42:53 -07:00
Alex E 758687cde4
[opentracing-shim] Add check for sampled context (#2390) 2023-10-30 09:55:32 -07:00
Marc Alff 17da6d87c1
[API] Add a new AddLink() operation to Span (#2380) 2023-10-27 18:27:57 +02:00
jafonso d3a873a673
[BUILD] Fix cpack broken package version (#2386) 2023-10-25 20:33:21 +02:00
Marc Alff 0baf5015ea
[BUILD] enum CanonicalCode names too generic... conflict with old C defines (#2385) 2023-10-24 10:11:32 +02:00
Harish Shan 045be9c02b
[BUILD] DLL export interface for Metrics (#2344) 2023-10-23 23:42:28 +02:00
dependabot[bot] f16deb0740
Bump peter-evans/create-or-update-comment from 3.0.2 to 3.1.0 (#2381) 2023-10-19 23:01:38 -07:00
Marc Alff 91dd15fbdf
[API] Add InstrumentationScope attributes in TracerProvider::GetTracer() (#2371) 2023-10-19 23:34:58 +02:00
Lalit Kumar Bhasin d9ad76f6be
[SDK] Creating DoubleUpDownCounter with no matching view (#2379) 2023-10-19 11:28:12 +02:00
Marc Alff 0e6eae0466
[BUILD] Make WITH_OTLP_HTTP_SSL_PREVIEW mainstream (#2378) 2023-10-19 09:42:40 +02:00
Harish Shan 231ca4ade1
[SDK] Metrics ObservableRegistry Cleanup (#2376) 2023-10-18 20:50:54 +02:00
Marc Alff e918960e06
[BUILD] Remove WITH_REMOVE_METER_PREVIEW, use WITH_ABI_VERSION_2 instead (#2370) 2023-10-16 22:07:47 +02:00
Marc Alff 46e20a42ae
[RELEASE] Prepare release 1.12.0 (#2359) 2023-10-16 10:38:49 +02:00
Marc Alff f2cbf02ec1
[SEMANTIC CONVENTION] Upgrade to semconv 1.22.0 (#2368) 2023-10-16 09:38:30 +02:00
WenTao Ou cbee4de0ec
[BUILD] Support to use different cmake package CONFIG of dependencies. (#2263) 2023-10-16 09:00:24 +02:00
WenTao Ou 3ff4b4c1f7
Fix protoc searching with non-imported protobuf::protoc target. (#2362) 2023-10-14 13:35:10 +02:00
andremarianiello 2c4b2a910c
Fix behavior of opentracing-shim when added as subdirectory of a larger project (#2356) 2023-10-11 19:18:32 +02:00
Marc Alff df96b7429a
[BUILD] Upgrade libcurl to version 8.4.0 (#2358) 2023-10-11 11:17:26 +02:00
Marc Alff 18a27df365
Fixes #2352 (#2353) 2023-10-10 08:59:03 +02:00
Marc Alff 05b26cae87
[BUILD] error: read-only reference ‘value’ used as ‘asm’ output (#2354) 2023-10-10 01:30:27 +02:00
WenTao Ou 0eaa7944e1
Export resource for prometheus (#2301) 2023-10-03 21:47:27 +02:00
David Ashpole 0803e6a8f2
prometheus exporter: Add otel_scope_name and otel_scope_version labels (#2293) 2023-10-02 20:21:01 +02:00
Marc Alff bd11434940
[REMOVAL] Drop C++11 support (#2342) 2023-09-30 16:23:52 +02:00
Marc Alff c3c643a597
[API] Add InstrumentationScope attributes in MeterProvider::GetMeter() (#2224) 2023-09-30 10:08:02 +02:00
Marc Alff ad626cec45
[BUILD] Need fine-grained HAVE_CPP_STDLIB (#2304) 2023-09-28 10:25:51 +02:00
Matthijs Brobbel 5e96b80bc9
[Exporter] Group spans by resource and instrumentation scope in OTLP export requests (#2335) 2023-09-28 09:46:17 +02:00
WenTao Ou 368ee79210
Fix deadlock when shuting down http client. (#2337) 2023-09-28 09:02:55 +02:00
Punya Biswal a45081a83b
[exporters/prometheus] Sanitize labels according to Prometheus spec (#2330)
Fixes #2289
2023-09-27 09:04:27 +02:00
Reiley Yang a4961c421c
Simplify the project status section to better communicate the intention (#2332)
* Simplify the project status section to better communicate the intention

* cleanup
2023-09-25 17:25:24 -07:00
Tom Tan ab83f4f747
Fix minor inconsistent log message in Meter::RegisterSyncMetricStorage (#2325) 2023-09-26 00:57:16 +02:00
Punya Biswal d49ba52591
[exporters/prometheus] Get rid of friend test (#2329)
Instead, test using the TranslateToPrometheus public API.
2023-09-25 08:30:48 -07:00
Punya Biswal 61e7429d63
[exporters/prometheus] Handle attribute key collisions from sanitation (#2326)
Fixes #2290
2023-09-24 17:27:22 +02:00
Punya Biswal 41a7875ef8
[exporters/prometheus] Remove explicit timestamps from metric points (#2324)
Fixes #2316
2023-09-23 12:02:09 +02:00
Punya Biswal ca67af031b
Fix lifetime issues in test utils (#2322) 2023-09-21 23:37:58 -07:00
Tom Tan 13f01cae93
Add exemplar reservoir to async metric storage (#2319) 2023-09-21 22:41:18 +02:00
Lalit Kumar Bhasin 0563a71ce3
Fix Observable Counters/UpDownCounters (#2298) 2023-09-18 12:57:28 -07:00
Marc Alff 049f7e8a19
Revert "Bump codecov/codecov-action from 3 to 4 (#2314)" (#2315) 2023-09-16 08:07:30 -07:00
dependabot[bot] f5c00160c4
Bump codecov/codecov-action from 3 to 4 (#2314)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3 to 4.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-15 09:02:17 +02:00
Marc Alff 44096c8072
[SDK] Allow metric instrument names to contain / characters (#2310) 2023-09-14 18:44:01 +02:00
Marc Alff b9776d63d4
[API] Deliver ABI breaking changes (#2222) 2023-09-14 10:58:47 +02:00
dependabot[bot] f5f39343ac
Bump docker/setup-buildx-action from 2 to 3 (#2307)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2 to 3.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-13 09:34:13 +02:00
dependabot[bot] 7aee911985
Bump docker/build-push-action from 4 to 5 (#2308)
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4 to 5.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v4...v5)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-13 08:50:55 +02:00
dependabot[bot] e706b20503
Bump docker/setup-qemu-action from 2 to 3 (#2306) 2023-09-12 19:17:21 -07:00
Marc Alff cdbc90abf3
[DEPRECATION] Deprecate ZPAGES (#2291) 2023-09-05 10:51:58 +02:00
dependabot[bot] 6eb09faa7c
Bump actions/checkout from 3 to 4 (#2295)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-05 08:47:56 +02:00
Lalit Kumar Bhasin 5acaa14c21
[SDK] Remove unused variables from sync storage (#2294) 2023-09-03 17:00:51 +02:00
Marc Alff 01e65810b9
[SEMANTIC CONVENTION] Deprecated semconv (in the spec) not deprecated (in C++) (#2285) 2023-09-02 12:09:47 +02:00
Marc Alff f52ec6cade
[SDK] Increase metric name maximum length from 63 to 255 characters (#2284) 2023-08-31 17:17:26 +02:00
Marc Alff 7196ec3fda
[CI] Benchmark workflow fails, C++14 required to build grpc (#2278) 2023-08-25 15:23:36 +02:00
Marc Alff 628838af8a
[CI] Never close stale issues (#2277)
Fixes #2276
2023-08-24 23:06:53 +02:00
Darren Bolduc c0f17d99b0
Support `pkg-config` (#2269) 2023-08-22 13:28:18 -07:00
Tom Tan 11d5d9e0d8
Prepare for releasing 1.11.0 (#2272) 2023-08-22 08:49:00 -07:00
TomSvk88 36fb921fe0
Fix more cases for symbol name for 32-bit win32 DLL build (#2264) 2023-08-21 16:19:29 -07:00
Alexey Shakula 4bfddde7ad
added public link of `opentelemetry_proto_grpc` against gRPC lib [only if gRPC library is shared] (#2268) 2023-08-21 21:19:57 +00:00
Lalit Kumar Bhasin d3799a63ff
use ubuntu-latest for tsan CI (#2267) 2023-08-21 20:31:07 +00:00
jaelrod c0092c4c84
fixing an apparent logging macro bug (#2265) 2023-08-16 15:31:53 -07:00
WenTao Ou 0d1326a02e
Support protobuf 3.22 or upper (#2163) 2023-08-11 14:56:50 -07:00
Lalit Kumar Bhasin b7fd057185
remove extra includes (#2252) 2023-08-01 15:41:28 -07:00
Tom Tan 8c82d24c20
Mark logs signal as stable API/SDK (#2229) 2023-08-01 00:18:57 -07:00
Marc Alff 8f97cab686
[SEMANTIC CONVENTIONS] Upgrade to 1.21.0 (#2248) 2023-07-28 15:06:57 -07:00
Marc Alff 0c5f90dea5
[SDK] Valgrind errors on std::atomic variables (#2244) 2023-07-22 16:51:57 +02:00
WenTao Ou 92a8a54c6f
[BUILD] Fix compile with clang 16 and libc++ (#2242) 2023-07-21 09:54:24 +02:00
Lalit Kumar Bhasin a15a9b8101
[Metrics SDK] Add unit to Instrument selection criteria (#2236) 2023-07-20 20:53:32 +02:00
WenTao Ou 2974eb8eef
Add OStreamLogRecordExporterFactory (#2240) 2023-07-20 20:05:02 +02:00
Lalit Kumar Bhasin 038e65d7f2
Add support for LowMemory metrics temporality (#2234) 2023-07-13 22:59:43 +02:00
Marc Alff bc23e6a43f
[CI] Misc build scripts cleanup (#2232) 2023-07-12 15:13:08 -07:00
Cengizhan Pasaoglu b3d547c205
[CI] Upgrade GoogleTest version from 1.12.1 to 1.13.0 (#2114) 2023-07-12 21:18:18 +02:00
Darren Bolduc d99cbab06c
[BUILD] include <cstdint> (#2230) 2023-07-12 09:24:21 +02:00
Marc Alff ca8c23481a
Prepare release 1.10.0 (#2227) 2023-07-11 21:45:24 +02:00
dependabot[bot] 7b95f5b2af
Bump peter-evans/create-or-update-comment from 1.4.5 to 3.0.2 (#2226)
Bumps [peter-evans/create-or-update-comment](https://github.com/peter-evans/create-or-update-comment) from 1.4.5 to 3.0.2.
- [Release notes](https://github.com/peter-evans/create-or-update-comment/releases)
- [Commits](a35cf36e53...c6c9a1a660)

---
updated-dependencies:
- dependency-name: peter-evans/create-or-update-comment
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-11 12:28:40 +02:00
Marc Alff f5426ce8cf
[CI] Do not tag pull_request with the "need-triage" label. (#2228) 2023-07-11 11:37:26 +02:00
Ehsan Saei 556139396c
opentelemetry-cpp project CI (#2071) 2023-07-10 17:04:22 +02:00
Marc Alff 1111f3409f
[API] Remove Meters (#2205) 2023-07-10 10:48:57 +02:00
Marc Alff 8b613188a3
[SDK] TracerProvider should own TracerContext, not share it (#2221) 2023-07-08 16:07:38 +02:00
Tom Tan d6cebe1404
Include nostd/string_view which is used severity.h (#2219) 2023-07-07 08:39:37 +02:00
Marc Alff 6ecd201f95
[SDK] MeterProvider should own MeterContext, not share it (#2218) 2023-07-06 22:46:53 +02:00
Ehsan Saei 5466c5be26
Add Include what you use (#2214) 2023-07-05 18:30:43 +02:00
Marc Alff 60794ac79f
[BUILD] Upgrade opentelemetry-proto to 1.0.0 (#2216) 2023-07-05 17:08:31 +02:00
WenTao Ou 31f218c1e2
[BUILD] Add `OPENTELEMETRY_CPP_FOUND` into cmake CONFIG file. (#2215) 2023-07-05 08:53:59 +02:00
Marc Alff ebbcd48a88
[TEST] Expand api singleton test to cover explicit dlopen(). (#2164) 2023-07-03 09:00:02 +02:00
Marc Alff 42709f4575
[REMOVAL] Remove the jaeger exporter (#2031) 2023-07-02 20:16:10 +02:00
Kyle L 049ab63103
[EXPORTER] OTLP GRPC mTLS support (#2120) 2023-06-29 10:50:12 +02:00
Tom Tan 313b04d859
[BUILD] Fix if check on environment variable and add CMake variable (#2207) 2023-06-29 08:44:54 +02:00
Lalit Kumar Bhasin efde01033b
[BUILD] Enable building otel-cpp extensions from main repo (#1937) 2023-06-28 21:03:34 +02:00
Marc Alff d0452f829f
[SDK] Provide builders to avoid exposing Metrics SDK internals (#2189) 2023-06-28 19:08:42 +02:00
Cengizhan Pasaoglu cfcda5728e
[SDK] Header files cleanup, use forward declarations (#2182) 2023-06-21 00:11:31 +02:00
Marc Alff 2db5f29396
[EXPORTER] Prometheus: Error on ingesting samples with different value but same timestamp (#2200) 2023-06-20 18:03:54 +02:00
Reiley Yang 4cae6aae8c
move Reiley Yang to emeritus (#2198) 2023-06-16 17:52:08 +02:00
Ehsan Saei 763f11d65b
Prometheus exporter sanitizes invalid characters (#1934) 2023-06-16 14:08:18 +02:00
WenTao Ou fc8853e418
Fix OTLP HTTP exporting in sync mode. (#2193) 2023-06-13 23:08:05 +02:00
Marc Alff 4b20067c35
Upgrade to opentelemetry-proto 0.20.0 (#2195) 2023-06-13 21:20:53 +02:00
WenTao Ou 773a172ddb
Remove include_trace_context (#2194) 2023-06-12 19:16:06 +02:00
Tom Tan bd83aa367c
Fix the exported symbol name for 32-bit win32 DLL build (#2190) 2023-06-09 17:30:24 -07:00
Tom Tan c89a6fde66
Add ctime header to metrics_exporter.cc (#2187) 2023-06-09 08:56:38 +02:00
Ruslan Nigmatullin d233b9bc1a
[SDK] Add benchmark for base2 exponential histogram indexer (#2181) 2023-06-07 09:07:01 +02:00
Marc Alff d980e8b406
[SDK] Simplify SDK version 2023-06-06 12:25:57 +02:00
Marc Alff 600bd305fe
[BUILD] Avoid dependency on protobuf from the OTLP HTTP metrics exporter header 2023-06-06 10:16:24 +02:00
Marc Alff 500cf98f0b
[EXPORTER] Fixed HTTP CURL for 32bits platforms 2023-06-06 08:47:01 +02:00
Tom Tan 834c0c4d1b
[DLL Build] link to opentelemetry_logs even without OTLP (#2177) 2023-06-03 10:44:58 -07:00
Ruslan Nigmatullin 082bb93098
[SDK] Add base2 exponential histogram indexer (#2173) 2023-06-03 10:52:39 +02:00
jaelrod 41416ce21f
[EXPORTER] set is_monotonic only for instrument type kCounter (#2171) 2023-06-03 08:35:24 +02:00
Ruslan Nigmatullin f5fd9062de
[SDK] Add AdaptingCircularBufferCounter for exponential histograms (#2158) 2023-06-01 09:14:39 +02:00
Tom Tan 8ba95296e4
[BUILD] Remove option WITH_OTLP (#2161) 2023-05-31 21:06:18 +02:00
Matthijs Brobbel 0eca570bbf
[EXPORTER] Support empty arrays in `OtlpRecordable` attributes (#2166) 2023-05-31 18:47:41 +02:00
WenTao Ou 8b7f9b4209
Change OTLP Json field name to camelCase (#2162) 2023-05-27 10:17:44 +02:00
Marc Alff f55346262b
[CI] Add a C++11 build (#2152) 2023-05-26 20:01:50 +02:00
Bailey Chittle 3707bc04e0
[BUILD] Fixing CMake to build GTest on Windows (#1887) 2023-05-26 13:39:29 +02:00
Lalit Kumar Bhasin 5e290c909d
[DOC] Small fix for Histogram documentation. (#2156) 2023-05-26 11:42:54 +02:00
Marc Alff 770fce3c40
[RELEASE] Prepare release 1.9.1 (#2149) 2023-05-26 10:13:12 +02:00
Andrew Stitcher 32a823514c
[BUILD] Transitive dependency issue with the otlp http exporter (#2154) 2023-05-26 09:05:13 +02:00
Marc Alff 61e8741a70
[DEPRECATION] Drop C++11 support (#2146) 2023-05-23 09:52:38 +02:00
Andrew Stitcher cfa130bb92
Missed include (#2143) 2023-05-20 10:39:20 +02:00
WenTao Ou 23dfc20ac6
Allow build shared `opentelemetry_proto` on non-Windows platform. (#2097) 2023-05-17 21:13:07 +02:00
Cengizhan Pasaoglu c9f14e9bce
Single character wrapped by std::string to get rid of warning (#2137) 2023-05-11 16:46:20 +02:00
WenTao Ou 75d76a1cbb
Add unit test for log body implicit conversions. (#2136) 2023-05-11 03:08:31 -07:00
Tom Tan 8308fc6150
Add event id to logger benchmark method (#2133) 2023-05-07 17:15:55 -07:00
Cengizhan Pasaoglu 990da7dd0f
Fix inclusion header files and use forward declaration for API (#2124) 2023-05-07 16:02:40 -07:00
Tom Tan 80f301805d
SDK support for the new OTel log API (#2123) 2023-05-05 21:22:31 -07:00
Lalit Kumar Bhasin b4ff53ded2
Add missing target dependencies (#2128) 2023-05-03 13:44:06 -07:00
Cengizhan Pasaoglu 8c750414c5
Fix if JSON library already added another CMake target (#2126) 2023-05-03 11:23:56 -07:00
Cengizhan Pasaoglu 2fd3d35550
Upgrade Bazel and Bazelisk version (#2118) 2023-04-27 15:59:45 -07:00
WenTao Ou 6ca0d68ca1
Fix 2110 (#2111) 2023-04-27 10:11:19 -07:00
Cengizhan Pasaoglu 6c7f7c8100
Upgrade Google Benchmark version from 1.6.0 to 1.7.1 (#2116) 2023-04-27 06:16:10 +00:00
Cengizhan Pasaoglu fbcf3aac13
Upgrade Nlohmann JSON library version from 3.10.5 to 3.11.2 (#2115) 2023-04-26 22:19:05 -07:00
Tom Tan a39e8b51ea
Add user facing Logging API and Benchmarks (#2094) 2023-04-23 07:52:43 -07:00
Lalit Kumar Bhasin 22d0448ebc
Fix: #2100 Building shared libraries with version suffix, along with the symbolic link (#2109) 2023-04-22 10:09:00 +02:00
Tom Tan 71ba593b9b
Show warning message if WITH_OTLP is enabled (#2112) 2023-04-22 09:20:16 +02:00
WenTao Ou 7ee86a96b0
Add missing STL header. (#2107)
Signed-off-by: owent <admin@owent.net>
2023-04-20 23:27:08 +02:00
Marc Alff 82f2828ed0
[BUILD] Build break with old curl, macro CURL_VERSION_BITS unknown (#2102)
Fix #2101
2023-04-19 23:03:53 +02:00
Marc Alff 7cb7654552
Add Marc as maintainer. (#2027)
Add Marc as maintainer. (#2027)
2023-04-14 13:59:22 +02:00
WenTao Ou 6a3ee1632d
Delegate all API calls of gRPC into `opentelemetry_exporter_otlp_grpc_client`, and make it contains all symbols needed. (#2005)
Fix #1998

Delegate all API calls of gRPC into `opentelemetry_exporter_otlp_grpc_client`, and make it contains all symbols needed.
2023-04-14 10:50:19 +02:00
Marc Alff 7887d32da6
[RELEASE] Release version 1.9.0 (#2091)
Fix #2089

Prepare release 1.9.0
2023-04-13 08:55:54 +02:00
davidmandle e71e28c2d7
Use sdk_start_ts for MetricData start_ts for instruments having cumulative aggregation temporality. (#2086)
Co-authored-by: Marc Alff <marc.alff@oracle.com>
2023-04-12 16:32:38 +02:00
Marc Alff efb1a260fe
[SEMANTIC CONVENTIONS] Upgrade to version 1.20.0 (#2088)
Fix #2087
2023-04-12 09:02:17 +02:00
Marc Alff 0e52dfdb15
[EXPORTER] Add OTLP HTTP SSL support (#1793) 2023-04-05 09:59:15 -07:00
Cengizhan Pasaoglu 9bcfcb99ff
Make Windows build environment parallel (#2080)
* Make Windows build environment parallel with help of Ninja

* Add number of processors explicitly as an argument to CMake

---------

Co-authored-by: Marc Alff <marc.alff@oracle.com>
2023-04-01 18:17:40 +02:00
N0tell 0139cb4e27
make some hints (#2078) 2023-04-01 10:34:44 +02:00
Cengizhan Pasaoglu b793426b51
Make some targets parallel in CI pipeline (#2076) 2023-03-28 19:24:26 +02:00
Lalit Kumar Bhasin bd7a3c7b41
[Metrics SDK] Implement Forceflush for Periodic Metric Reader (#2064) 2023-03-27 15:14:27 -07:00
Marc Alff 380f0f2543
Upgraded semantic conventions to 1.19.0 (#2017) 2023-03-27 06:34:20 -07:00
dependabot[bot] 3305bd73fc
Bump actions/stale from 7 to 8 (#2070)
Bumps [actions/stale](https://github.com/actions/stale) from 7 to 8.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v7...v8)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-26 20:42:54 +02:00
Cengizhan Pasaoglu fb3bcb5b52
Include directory path added for Zipkin exporter example (#2069)
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
2023-03-23 19:03:19 +00:00
WenTao Ou 2b2fe449ac
Ignore more warning of generated protobuf files than not included in `-Wall` and `-Wextra` (#2067) 2023-03-23 11:05:51 -07:00
WenTao Ou 9b222f2af1
Add `ForceFlush` for all `LogRecordExporter`s and `SpanExporter`s. (#2000) 2023-03-19 22:29:21 -07:00
tyler92 3a09d53195
Remove unused 'alerting' section from prometheus.yml in examples (#2055) 2023-03-17 07:54:35 +00:00
Tom Tan e7589c0a7a
Clean warnings in ETW exporters (#2063) 2023-03-17 00:05:17 -07:00
WenTao Ou 5ccf493a9c
Fix default value of `OPENTELEMETRY_INSTALL_default`. (#2062) 2023-03-17 03:02:53 +00:00
Marc Alff 211d9c92d0
[EXPORTER] GRPC endpoint scheme should take precedence over OTEL_EXPORTER_OTLP_TRACES_INSECURE (#2060) 2023-03-16 08:20:35 -07:00
tyler92 e0a85f2b03
Fix view names in Prometheus example (#2034) 2023-03-16 06:27:42 +00:00
Chill.dude 2462f7c98c
Fix some docs typo (#2057) 2023-03-15 22:37:18 -07:00
Tom Tan 15ab9ed9ad
Checking indices before dereference (#2040) 2023-03-13 22:49:25 -07:00
Tom Tan b04676454d
Export factory class of log provider (#2041) 2023-03-13 16:12:40 -07:00
Johan Peltenburg 1ac9caf100
Pick old schema url when updating schema url is empty according to specification in Resource::Merge (#2036) 2023-03-10 15:44:14 -08:00
Tom Tan 504644380a
Remove separate run of metrics ostream example (#2030) 2023-03-09 09:38:20 -08:00
Patrice Chalin 7db57f9d2b
Update README.md (#2028) 2023-03-08 14:54:30 -08:00
Tom Tan f702676250
Prepare v1.8.3 release (#2018) 2023-03-07 15:12:39 -08:00
Tom Tan 04a0751f38
Fix syntax issue in pre-release script (#2021)
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
2023-03-07 12:08:47 -08:00
tyler92 f732872cc6
Fix compile error with GCC 11.3 (#2025)
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
2023-03-07 18:24:59 +00:00
WenTao Ou 2b08db2db4
Add `OPENTELEMETRY_INSTALL` to allow user to skip install targets. (#2022) 2023-03-07 09:24:03 -08:00
Lalit Kumar Bhasin 0b72b030bc
Remove ubuntu 18.04 runner image from CI (#2023) 2023-03-07 00:05:04 -08:00
Lalit Kumar Bhasin da333f8eba
[Metrics SDK] Performance improvement in measurement processing (#1993) 2023-03-04 04:59:42 +00:00
Marc Alff 649829fe96
Provide version major/minor/patch macros (#2014) 2023-03-04 00:34:03 +00:00
Alex E 4dff60af85
Opentracing shim (#1909) 2023-03-03 15:33:20 -08:00
Tom Tan 9a5bb8d1af
Change SDK version global variable name to lowercase (#2013)
* Change SDK version global variable name to lowercase

* Rename build_date in pre-commit
2023-03-03 13:00:20 -08:00
Tom Tan 76935bcde0
Rename the global SDK version variables to avoid naming clash (#2011)
* Rename the global SDK version variables to avoid name clashing

* Add changelog entry

* Update pre-commit script with new SDK version variables
2023-03-02 18:51:52 -08:00
Abhinab Saha 3ef579bca3
fix typo (#2010) 2023-03-02 17:13:42 +00:00
WenTao Ou fd06d84ea3
Add attributes for `InstrumentationScope` (#2004) 2023-03-02 02:03:44 +00:00
Ehsan Saei 075f45d251
fix Prometheus test iterator increment (#2006) 2023-03-01 20:28:37 +01:00
Lalit Kumar Bhasin 7c0826efe0
Add benchmark tests for Sum Aggregation #1949 (#1948) 2023-02-22 20:18:12 +00:00
Tom Tan 5c121cf04e
[ETW Exporter]Support serialize span/log attributes into JSON (#1991) 2023-02-21 20:03:55 -08:00
Ariel Machado eed657237e
Add example for Logs ostream exporter (#1992) 2023-02-19 22:17:08 -08:00
Tom Tan 95f6c66de2
[ETW Exporter]Do not overwrite ParentId when setting attribute on Span (#1989) 2023-02-18 01:36:56 +00:00
Lalit Kumar Bhasin 01eac4ca9c
fix variable names (#1987) 2023-02-17 02:32:53 +00:00
Marc Alff 392c3965ed
[EXPORTER] Boolean environment variables not parsed per the spec (#1982) 2023-02-16 17:30:36 -08:00
Lalit Kumar Bhasin a6211fa904
Fix Prometheus server crash on listening to already used port (#1986) 2023-02-15 16:10:05 -08:00
WenTao Ou e47dec5cfa
Fix missing ObservedTimestamp. (#1985) 2023-02-15 07:42:13 -08:00
Tom Tan 4daca390e9
Build OpenTelemetry C++ SDK and exporter into DLL (#1932) 2023-02-13 09:46:25 -08:00
WenTao Ou 6f0a30ee1c
Fix thread-safety when shutdown. (#1977) 2023-02-10 13:32:54 -08:00
Marc Alff 9d8efafc28
Upgraded semantic conventions to 1.18.0 (#1974) 2023-02-10 11:02:28 -08:00
Marc Alff 6d9c4cacc9
Fix #1970 (#1971)
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
2023-02-10 07:20:40 -08:00
Samuel Roberts d1fd49d372
Fix typo GENENV -> GETENV (#1972) 2023-02-09 19:44:03 -08:00
Marc Alff 2544803a37
Enforce copyright check in CI (#1965) 2023-02-08 15:04:21 -08:00
Tom Tan b364dce27b
Update copyright for the remaining repo (#1963) 2023-02-07 06:08:51 -08:00
Marc Alff 1d18614edb
Fixed copyright in examples. (#1964) 2023-02-07 05:59:12 +00:00
Marc Alff 7ed1b1db29
Fixed copyright for exporters (#1962) 2023-02-07 05:00:28 +00:00
Marc Alff 6925fc4751
Fixed copyright for every file under sdk. (#1961) 2023-02-06 20:14:19 -08:00
Marc Alff 1fc4cacf3e
Fixed copyright for every file under api/, (#1960) 2023-02-06 22:07:36 +00:00
Tom Tan 97f0751ba9
Update copyright headers in zipkin and Jaeger exporters for consistency (#1959) 2023-02-06 12:51:21 -08:00
Severin Neumann 2bae1c68da
Add alpine packages to INSTALL.md (#1957) 2023-02-06 11:19:04 -08:00
Lalit Kumar Bhasin c4c8ee053f
Convert Prometheus Exporter to Pull MetricReader (#1953) 2023-02-05 18:12:09 +00:00
Lalit Kumar Bhasin 9200d0c8fb
upgrade prometheus-cpp to v1.1.0 (#1954) 2023-02-04 20:32:33 -08:00
Marc Alff 32af3529ef
[BUILD] OTLP HTTP Exporter has build warnings in maintainer mode (#1943) 2023-02-02 21:22:19 -08:00
Ehsan Saei d56a5c702f
Prepare v1.8.2 release (#1947) 2023-01-31 19:26:41 +00:00
dependabot[bot] 5b0adc747b
Bump docker/build-push-action from 3 to 4 (#1946)
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 3 to 4.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-31 12:47:14 +01:00
Marc Alff 1ae2fe538c
[MAINTAINER DOC] Define and document a deprecation process (#1923) 2023-01-30 10:24:34 -08:00
WenTao Ou 65ebdb1e61
Update logs sdk and api to follow specification (#1884) 2023-01-28 09:29:36 -08:00
Tom Tan 7e7184d0a4
Remove redundant macro check in nostd::shared_ptr (#1939) 2023-01-27 01:26:06 +00:00
bretdusseault 52309ddc65
Fix typo in packages.cmake causing incorrect nuget package versions (#1936) 2023-01-23 22:35:40 +00:00
Lalit Kumar Bhasin 998badd466
Custom Aggregation support (#1899) 2023-01-23 07:56:35 +00:00
Lalit Kumar Bhasin e8fce84de8
fix (#1930) 2023-01-18 20:46:48 +00:00
Marc Alff 7406b4fb2d
[SEMANTIC CONVENTIONS] Upgrade to version 1.17.0 (#1927)
* Upgrade semantic convention to spec 1.17.0

* Add CHANGELOG.
2023-01-18 17:18:47 +00:00
Jan-Willem Buurlage c9e76b4a1a
Fix warning for misconfiguration of PeriodicExportingMetricReader (#1929)
The periodically exporting metric reader requires the timeout field to be strictly less than the interval field. However, the warning that is logged out gives the opposite requirement. The existing logic in the code is correct.
2023-01-18 16:05:33 +00:00
Tom Tan 59d0bc2055
Make macros.h available for all source files via version.h (#1918) 2023-01-17 13:45:17 -08:00
Marc Alff 0305ad8e4c
Cleanup CMake makefiles for CURL usage (#1916) 2023-01-17 07:05:59 -08:00
Lalit Kumar Bhasin 46b16ec3cf
Histogram Aggregation: Fix bucket detection logic, performance improvements, and benchmark tests (#1869) 2023-01-11 16:49:35 -08:00
Tom Tan 57d1a478bd
Remove unused namespace alias for nostd (#1914) 2023-01-10 22:47:39 +00:00
Marc Alff 65c22e94fa
Cleanup CMake makefiles for nlohmann_json. (#1912) 2023-01-10 13:46:04 -08:00
sanjaypujare 8a9d085f05
Update meter.h (#1907)
Fix typo: replace Counter with Gauge (most likely a copy-paste error)
2023-01-09 04:28:22 -08:00
Ehsan Saei 201b347588
sdk::resource::Resource::Merge should be const (#1905) 2023-01-07 13:46:52 -08:00
Lalit Kumar Bhasin d5571916e1
Collect and Export metric data before PeriodicMetricReader shutdown. (#1860) 2023-01-04 21:28:14 +00:00
Lalit Kumar Bhasin 61bc860a49
[ETW Exporter] Add Virtual destructor for TailSampler, Update Maintainer mode warnings for MSVC (#1897) 2023-01-04 09:33:02 -08:00
Marc Alff a343da043e
Fix #1867 Orderly shutdown in examples (#1868) 2023-01-04 06:33:40 -08:00
Alexey Shakula d5f0c484e3
minor metrics handling optimizations (#1890) 2023-01-03 12:22:08 -08:00
davidmandle 9197bf38f1
Migrate from @bazel_tools//platforms to https://github.com/bazelbuild/platforms (#1873)
* Migrate from @bazel_tools//platforms to https://github.com/bazelbuild/platforms.

* Bump grpc and googletest versions for Bazel 6.0.0 compatibility.
2022-12-23 18:45:23 +00:00
WenTao Ou 94a6783025
Fix resource and scope of new Logs SDK implementation. (#1881) 2022-12-23 08:31:44 +00:00
Johan Peltenburg c0deb4065e
Log a warning when the BatchSpanProcessor queue is full. (#1871) 2022-12-22 23:31:10 -08:00
Gabriel SCHWAB 8866c10f10
use _mm_pause instead of __builtin_ia_32_pause when __INTEL_COMPILER defined (#1885) 2022-12-22 14:37:31 -08:00
andyning 9dd19a2afb
Change BatchLogRecordProcessorFactory::Create to static method, Fixed a typo in a comment (#1876) 2022-12-20 19:24:44 -08:00
dependabot[bot] 066c2f3927
Bump actions/stale from 6 to 7 (#1878)
Bumps [actions/stale](https://github.com/actions/stale) from 6 to 7.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-20 18:20:29 -08:00
Lalit Kumar Bhasin e7579ed688
Enable generating deb, rpm, NuGet, tgz, zip package through cmake build (#1662) 2022-12-13 14:49:30 -08:00
WenTao Ou dfff6936ef
Fix compatibility when using clang and libc++ (#1852) 2022-12-13 00:10:14 -08:00
WenTao Ou 9f333ff4f6
Remove `EmitEvent` to follow https://github.com/open-telemetry/opentelemetry-specification/pull/2941 (#1766) 2022-12-13 02:57:39 +00:00
Paul Ohl 9712161b43
Updated clone command in INSTALL.md (#1818)
Since version 2.13 of git, the `--recursive` flag has been replaced by `--recurse-submodules`.

See [this issue](https://stackoverflow.com/questions/3796927/how-do-i-git-clone-a-repo-including-its-submodules) for details.
2022-12-12 18:25:07 +00:00
Lalit Kumar Bhasin f3daca092b
cleanup (#1855) 2022-12-12 09:24:30 -08:00
Marc Alff d30c14008c
[SEMANTIC CONVENTIONS] Upgrade to version 1.16.0 (#1853) (#1854)
* [SEMANTIC CONVENTIONS] Upgrade to version 1.16.0 (#1853)

* Add changelog.
2022-12-11 18:01:32 -08:00
Lalit Kumar Bhasin f1f6083c88
Fix #1856 (#1857)
Fixes https://github.com/open-telemetry/opentelemetry-cpp/issues/1856
2022-12-10 09:51:00 -08:00
Marc Alff 75f3900a83
Fix OTELCPP_MAINTAINER_MODE (#1844) 2022-12-09 10:51:18 -08:00
Lalit Kumar Bhasin 722ad4e771
Enable setting Span endtime for ETW exporter (#1846) 2022-12-08 20:59:14 +00:00
Marc Alff 7727620b6c
[Removal] Remove deprecated experimental semantic conventions (#1741) (#1743) 2022-12-08 10:28:27 -08:00
Marc Alff 41821d67cd
Fix console debug logs for otlp exporters. (#1848)
Fixes https://github.com/open-telemetry/opentelemetry-cpp/issues/1847
2022-12-07 14:29:29 -08:00
Ehsan Saei 57bf8c2b0e
Prepare v1.8.1 release (#1839) 2022-12-04 19:11:21 +01:00
Lalit Kumar Bhasin d74e02f1c3
[ETW Exporter] Tail based sampling support (#1780) 2022-12-02 13:20:01 -08:00
Alexey Shakula 02bca217db
fix silly typo [affecting otlp exported histogram metrics max<uint>] (#1827) 2022-12-02 18:12:26 +00:00
Flier Lu f23c4a2e89
fix enum-compare-switch warning (#1833) 2022-12-01 23:24:29 -08:00
Lalit Kumar Bhasin 2accc77af1
Change default temporality as "Cumulative" for OTLP metrics exporters (#1828) 2022-12-01 23:32:41 +00:00
Lalit Kumar Bhasin a24488f43b
Moved otlp_grpc_utils.cc to opentelemetry_exporter_otlp_grpc_client. (#1829) 2022-12-01 14:26:01 -08:00
Eguzki Astiz Lezaun 82d8cb49cd
Fix opentelemetry-proto file exists check (#1824) 2022-12-01 09:57:22 -08:00
WenTao Ou 7e26a7e84e
Fix type mismatch when move `nostd::shared_ptr` (#1815)
L
2022-11-29 12:15:57 -08:00
Lalit Kumar Bhasin 33d244a943
Fix Prometheus target name (#1820) 2022-11-29 07:47:21 +00:00
Ehsan Saei 308ec88b56
Clean unused docker files (#1817) 2022-11-28 19:51:58 +00:00
Ehsan Saei 368c8bfef7
[BUILD] Fix default bazel build (#1816) 2022-11-28 18:52:45 +00:00
Ehsan Saei ec90007e35
[BUILD] move client::nosend under test_common (#1811) 2022-11-28 17:03:21 +01:00
Ehsan Saei 6a99feed82
Prepare v1.8.0 release (#1813) 2022-11-27 23:01:30 +01:00
Ehsan Saei 0122b139f5
Upgrade abseil-cpp cmake CI (#1807) 2022-11-27 10:53:57 +01:00
Ehsan Saei 5642d1ce34
[BUILD] Fix benchmark CI (#1808) 2022-11-25 21:29:54 +00:00
Marc Alff e1b56117b4
Fix #1804 (#1805) 2022-11-25 04:45:38 -08:00
Tom Tan b13e3e2969
Add status code to OTLP grpc trace log (#1792) 2022-11-24 23:08:07 -08:00
rochaudhari 8bfb9a3f2d
[Exporter] add fix for prometheus exporter build (#1795) 2022-11-24 06:09:48 -08:00
Tom Tan 3f0eee6b91
Add option WITH_BENCHMARK to disable building benchmarks (#1794) 2022-11-23 17:01:33 -08:00
Marc Alff c1aa0b80fb
Fix CI benchmark (#1799) 2022-11-23 23:28:51 +01:00
Ehsan Saei 6ba1f73b04
bump to gRPC v1.48.1 for bazel CIs (#1786) 2022-11-23 17:50:11 +00:00
Marc Alff 0dc22681f2
Fix CI build (#1798) 2022-11-23 17:52:09 +01:00
Marc Alff a0e98fb506
Fix clang-format in CI (#1796) 2022-11-23 06:46:59 -08:00
WenTao Ou 6644ddd7f3
Fix session lock of `OtlpHttpClient` (#1760) 2022-11-21 19:09:52 -08:00
Lalit Kumar Bhasin 8f778b7412
Add MeterContext::ForEachMeter() method to process callbacks on Meter in thread-safe manner (#1783) 2022-11-17 10:12:51 -08:00
Marc Alff d0571d8ac7
Fixes #1781 (#1782) 2022-11-16 17:26:03 -08:00
Marc Alff 8da88df80d
[BUILD] Upgrade bazel build to use abseil-cpp-20220623.1 (#1779) 2022-11-16 15:11:03 -08:00
Marc Alff d7a388b154
[SEMANTIC CONVENTIONS] Upgrade to version 1.15.0 (#1761) 2022-11-16 13:46:14 -08:00
Lalit Kumar Bhasin a3e3a90ec6
Fix GlobalLogHandler singleton creation order (#1767) 2022-11-14 13:26:41 -08:00
Lalit Kumar Bhasin 389b84f430
[Metrics SDK] Change Prometheus CMake target name (#1765) 2022-11-12 22:24:28 +00:00
Tom Tan b157216274
Cleanup INSTALL.md (#1757) 2022-11-10 01:39:13 -08:00
Marc Alff 702a68c129
[Deprecation] Deprecate experimental semantic conventions (#1742) (#1744)
Fixes https://github.com/open-telemetry/opentelemetry-cpp/issues/1742
2022-11-09 13:27:42 -08:00
Tom Tan a220ac4c6f
Format config options in OTLP exporter readme (#1748) 2022-11-08 23:19:43 -08:00
Marc Alff b46ca963e8
[Build] Bring your own dependency: opentelemetry-proto (#1730) 2022-11-08 13:06:49 -08:00
Marc Alff b89f981e10
[Doc] Cleanup ENABLE_METRICS_PREVIEW (#1745) 2022-11-07 23:44:26 -08:00
Marc Alff 34b659743f
[Build] Multiple CURL packages leads to invalid build (#1738) (#1739) 2022-11-07 08:47:40 -08:00
Ehsan Saei b8b715faf9
[Metrics SDK] Cleanup ENABLE_METRICS_PREVIEW (#1735) 2022-11-06 21:03:08 +00:00
Ehsan Saei 7efeeabeea
[Logs SDK] LogProcessor, LogExporter class name (#1736) 2022-11-06 20:08:24 +00:00
Ehsan Saei ec8895bc98
[Metrics SDK] Cleanup of old _metric api/sdk (#1734) 2022-11-06 19:31:37 +01:00
Lalit Kumar Bhasin 99a9b4cc07
[Old Metrics Cleanup] Remove old metric from GitHub CI (#1733) 2022-11-05 10:24:30 +01:00
WenTao Ou 7634edf461
[Logs SDK] LogProcessor, LogExporter changes (#1727)
* + Rename `LogProcessor` to `LogRecordProcessor`
+ Rename `LogExporter` to `LogRecordExporter`
+ Move `*log_processor*` to `*log_record_processor*`
+ Move `*log_exporter*` to `*log_record_exporter*`

Signed-off-by: owent <admin@owent.net>

* Add changelog

Signed-off-by: owent <admin@owent.net>

Signed-off-by: owent <admin@owent.net>
Co-authored-by: Ehsan Saei <71217171+esigo@users.noreply.github.com>
2022-11-04 19:11:32 +01:00
Marc Alff 7812651354
Fix #1705 (#1731) 2022-11-03 23:13:14 -07:00
Lalit Kumar Bhasin ac179dd64a
[ETW Exporter] Fix span timestamp(s) precision to nanoseconds (#1726) 2022-11-01 11:09:31 -07:00
Lalit Kumar Bhasin e5590c5b70
Update Metrics status in README.md (#1722)
* update metrics status

* add project column
2022-10-30 21:01:50 -07:00
Ehsan Saei 9acde87b08
Prepare v1.7.0 release with Metrics API/SDK GA. (#1721) 2022-10-29 00:01:56 +02:00
Lalit Kumar Bhasin dd7e257b6d
Fix: 1712 - Validate Instrument meta data (name, unit, description) (#1713) 2022-10-27 15:29:09 -07:00
Tom Tan e785f5f636
Document libthrift 0.12.0 doesn't work with Jaeger exporter (#1714)
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
2022-10-26 16:48:56 -07:00
Lalit Kumar Bhasin f17043f2ec
Fix:1674, Add Monotonic Property to Sum Aggregation, and unit tests for Up Down Counter (#1675) 2022-10-25 17:40:09 -07:00
Lalit Kumar Bhasin 419e2d616a
[Metrics SDK] Move Metrics Exemplar processing behind feature flag (#1710) 2022-10-25 15:29:04 -07:00
Ehsan Saei 9b8a4dcdc7
[Metrics API/SDK] Change Meter API/SDK to return nostd::unique_ptr for Sync Instruments (#1707) 2022-10-25 19:02:05 +02:00
Ehsan Saei 7fd76eec7d
[Metrics] Switch to explicit 64 bit integers (#1686) 2022-10-25 16:57:49 +02:00
Ehsan Saei 2ed104c50d
Add metrics e2e test to asan & tsan CI (#1670) 2022-10-24 15:35:56 +00:00
Ehsan Saei 52585635bb
Add otlp-grpc example bazel (#1708) 2022-10-24 16:31:01 +02:00
Ehsan Saei 70777ef9fa
[Metrics SDK] Add support for Pull Metric Reader (#1701) 2022-10-21 23:21:18 +02:00
WenTao Ou 15a148e1ac
Fix debug log of OTLP HTTP exporter and ES log exporter (#1703) 2022-10-21 01:13:25 -07:00
Marc Alff ac105bf419
[SEMANTIC CONVENTIONS] Upgrade to version 1.14.0 (#1697) 2022-10-19 10:06:25 -07:00
Tom Tan d9f8bcec4b
Fix a potential precision loss on integer in ReservoirCellIndexFor (#1696) 2022-10-18 09:41:59 -07:00
Ehsan Saei 7f37bc3281
fix Histogram crash (#1685) 2022-10-17 17:58:34 +00:00
Lalit Kumar Bhasin 8061423fe9
Fix:1676 Segfault when short export period is used for metrics (#1682) 2022-10-15 04:01:24 -07:00
Tom Tan 47a897d197
Add timeout support to MeterContext::ForceFlush (#1673) 2022-10-14 23:15:27 -07:00
Marc Alff fa5f9fc105
Add CMake OTELCPP_MAINTAINER_MODE (#1650) 2022-10-14 20:52:10 -07:00
Lalit Kumar Bhasin 89eb1ec6bf
[DOCS] - Minor updates to OStream Metrics exporter documentation (#1679) 2022-10-14 15:53:55 -07:00
Lalit Kumar Bhasin 3ff2ed827d
Fix:#1575 API Documentation for Metrics SDK and API (#1678)
* add api/sdk API doc

* update doxyfile
2022-10-13 22:43:38 -07:00
Marc Alff f29703b21c
Fixes #249 (#1677)
Fixed many remaining compiler warnings.
2022-10-13 20:56:17 +02:00
Lalit Kumar Bhasin 99f2ba4e34
Fix #1663 Threading issue between Meter::RegisterSyncMetricStorage and Meter::Collect (#1666) 2022-10-11 10:58:07 -07:00
Ehsan Saei 7140166d62
fix data race on MeterContext::meters_ (#1668) 2022-10-09 19:01:03 +02:00
Lalit Kumar Bhasin 79a9471f5c
Fix observable Gauge metrics generation (#1651) 2022-10-06 17:31:14 +00:00
Marc Alff a64ac09d48
Detect ARCH=sparc in CMake (#1660) 2022-10-06 09:18:36 -07:00
WenTao Ou 787d9c1908
Add user agent for OTLP http/grpc client (#1657) 2022-10-05 15:15:21 -07:00
Marc Alff 1dc810d882
Fix #1649 (#1658)
Fixed some warnings reported by clang.

-Wnewline-eof
  no newline at end of file

-Wc++98-compat-extra-semi
  extra ';' outside of a function is incompatible with C++98

-Winconsistent-missing-destructor-override
  '~XXX' overrides a destructor but is not marked 'override'

-Wheader-hygiene
  using namespace directive in global context in header

-Wunused-parameter
  unused parameter

Fixed some warnings reported by gcc.

-Werror=missing-field-initializers
  missing initializer for member ‘opentelemetry::v1::sdk::trace::SamplingResult::trace_state’

-Werror=unused-variable
  unused variable

-Werror=unused-parameter
  unused parameter
2022-10-05 11:41:58 -07:00
Ehsan Saei 7724361917
[Metrics SDK] Add Metrics ExemplarFilter and ExemplarReservoir (#1584) 2022-10-05 18:35:39 +02:00
WenTao Ou 1bda597711
Rename `OnReceive` to `OnEmit` (#1652) 2022-10-04 10:18:33 -07:00
Lalit Kumar Bhasin f21b3a009a
Fix #1588 - Observable Gauge does not reflect updated values, and send the old value always (#1641) 2022-10-02 14:38:50 -07:00
Lalit Kumar Bhasin d127140564
[Metrics SDK] Change boundry type to `double` for Explicit Bucket Histogram Aggregation, and change default bucket range (#1626)
* fix bucket boundaries type for histogram aggregation

* update bucket range, and fix build
2022-10-02 11:39:06 -07:00
Lalit Kumar Bhasin 9e87a6eb59
Fix #1632 - Occasional Segfault with LongCounter instrument (#1638) 2022-09-28 18:05:58 -07:00
Ehsan Saei 30cc1bca25
bump vcpk to 2022.08.15 (#1633) 2022-09-28 13:15:50 +00:00
davidmandle 7278d83ef1
Fix typo in package name in documentation. (#1636)
This is a minor fix of a typo in the dependencies documentation.`@io_opentelemetry_cpp/api:with_abseil` is not a valid Bazel target name, it should instead be @io_opentelemetry_cpp//api:with_abseil.
2022-09-27 18:24:54 -07:00
Tom Tan c10d4a0d5d
Fix some typo in CHANGELOG (#1637) 2022-09-27 11:28:29 -07:00
Marc Alff 1626436613
Add Marc Alff in cpp-approvers (#1635)
* Add Marc Alff in cpp-approvers

Per discussion in C++ SIG Meeting, 2022-09-26.

* Order by name.

Co-authored-by: Tom Tan <Tom.Tan@microsoft.com>
2022-09-26 22:29:49 -07:00
Ehsan Saei 0bd57d650d
bump gRPC to v1.48.1 for CMake Linux CI (#1608) 2022-09-26 22:20:39 +02:00
Tom Tan 5c180a1688
Prepare v1.6.1 release (#1630) 2022-09-22 20:19:36 -07:00
dependabot[bot] 38012fab34
Bump actions/stale from 5 to 6 (#1627) 2022-09-22 10:08:57 -07:00
Marc Alff fe0c62fec8
[Semantic Conventions] Align on the specification 1.13.0 (#1625)
* Fix #1624

* Added changelog
2022-09-21 19:11:11 -07:00
Marc Alff 909c26d89d
Fixes issue #1612. (#1622) 2022-09-20 21:55:05 -07:00
Marc Alff 85b78784a5
Fix more build warnings (#1616) (#1620) 2022-09-20 11:43:08 -07:00
Lalit Kumar Bhasin a7c4bbc18d
update meeting time (#1621) 2022-09-20 17:16:55 +00:00
Lalit Kumar Bhasin 2142d007d0
[ETW Exporter] - Add Trace flags in SpanContext (#1618) 2022-09-19 13:51:57 -07:00
Dennis ed9f583c47
[gRPC]: Fix out-of-bounds access of string_view in GrpcClientCarrier in the example (#1619) 2022-09-19 09:43:35 -07:00
Akshath Kothari 82a81157a9
resource sdk: Update Resource::Merge function docs (#1615) 2022-09-14 19:34:15 -07:00
Marc Alff c7dfc0de26
Fix build warnings (#1613) 2022-09-14 16:32:56 +02:00
Marc Alff 74f0ac16b1
Fix header only api singletons (#1520) (#1604) 2022-09-13 07:01:40 -07:00
Lalit Kumar Bhasin cfaf8a1f6c
Example for OTLP gRPC exporter for Metrics. (#1598) 2022-09-12 23:44:35 -07:00
dependabot[bot] c44fd917d6
Bump actions/upload-artifact from 2 to 3 (#1610) 2022-09-12 21:49:54 -07:00
WenTao Ou 0b7d4ab57b
Add OTLP Metric Exporter Factory and `OtlpGrpcClient` (#1606) 2022-09-12 20:14:47 -07:00
Lalit Kumar Bhasin 951768a8b1
changes (#1597)
Co-authored-by: Ehsan Saei <71217171+esigo@users.noreply.github.com>
2022-09-11 22:07:31 -07:00
Ehsan Saei aedd61009b
codecov ignore paths (#1609) 2022-09-11 14:04:05 -07:00
WenTao Ou 13cb2ea88a
Fix default value of `OtlpHttpMetricExporterOptions::aggregation_temporality`. (#1601) 2022-09-09 10:09:53 -07:00
Tom Tan b8504d978d
Remove running CI on async-changes branch on PR (#1599) 2022-09-08 09:34:54 -07:00
Lalit Kumar Bhasin e4b04208c6
Fix 1585 - Multiple cumulative metric collections without measurement recording. (#1586) 2022-09-07 16:09:21 -07:00
dependabot[bot] e27fc88f19
Bump actions/checkout from 2 to 3 (#1596)
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-07 06:29:52 +02:00
WenTao Ou b520480b16
Fix `LoggerContext::Shutdown` and tsan of `OtlpHttpClient` (#1592) 2022-09-06 09:56:56 -07:00
Ehsan Saei 5788287d49
metrics warnings (#1583) 2022-08-28 21:03:36 +02:00
Ákos Hadnagy 1f37839651
Fix ObservableInstrument::RemoveCallback (#1582) 2022-08-26 07:55:01 -07:00
WenTao Ou cecfc19bfa
Add error log when getting a http error code (#1581) 2022-08-25 10:37:34 -07:00
Lalit Kumar Bhasin 453534726b
ETW Exporter - Add support for Sampler and ID Generator (#1547) 2022-08-24 00:53:16 +00:00
Lalit Kumar Bhasin 39d6a225c3
Upgrade opentelemetry-proto to v0.19.0 (#1579)
* changes

* add changelog

* update third_party_release
2022-08-22 18:51:11 -07:00
Lalit Kumar Bhasin ef4136e611
Update metrics status to Release Candidate (#1570) 2022-08-17 00:48:51 -07:00
Tom Tan 6e6e33c70f
Fix format in precommit script (#1569) 2022-08-16 10:47:39 -07:00
Tom Tan 22e64e21f3
Prepare for metrics release candidate v1.6.0 (#1568) 2022-08-16 08:05:53 -07:00
Lalit Kumar Bhasin ad23f20392
METRICS SDK - Calling Observable Instruments callback during metrics collection (#1554) 2022-08-15 16:19:34 -07:00
Ehsan Saei d04e1ce361
Add CI jobs for new and deprecated metrics (#1531) 2022-08-12 16:31:49 +00:00
Ehsan Saei 1b9aa31537
Fix metrics asan and tsan CI (#1562) 2022-08-12 00:14:00 +02:00
Ehsan Saei 6c240fdfbc
remove throw check from metrics with noexcept (#1560) 2022-08-11 18:24:01 +00:00
Ehsan Saei 8844771d30
fix metrics race condition (#1552) 2022-08-11 10:23:16 -07:00
Ehsan Saei 4cf41c4d6c
Fix metrics context circular reference (#1535) 2022-08-11 14:56:39 +00:00
Bryce Arden 86c9f2bc71
[NFC] Improve scope/instrument names in metrics ostream exporter (#1544) 2022-08-10 21:07:58 -07:00
Bryce Arden b4ed0471d0
build: fix IWYU error in instruments.h (#1555) 2022-08-10 20:25:36 -07:00
Ehsan Saei f0109eb989
Prometheus exporter support Gauge Type (#1553) 2022-08-10 21:28:54 +02:00
Ehsan Saei 45037ac2a8
Fix default Metric view name (#1515) 2022-08-10 09:41:39 -07:00
WenTao Ou ba1cd0d9f9
Fix infinitely waiting when shutdown with more than one running http sessions. (#1549)
Signed-off-by: owentou <owentou@tencent.com>
2022-08-09 19:28:22 -07:00
Lalit Kumar Bhasin 319d854365
[METRICS SDK] Fix OTLP gRPC Metrics env variables (#1543) 2022-08-08 10:52:21 -07:00
Lalit Kumar Bhasin 8b61c99368
[Metrics SDK] Metric aggregation temporality controls (#1541) 2022-08-08 08:57:19 -07:00
Ehsan Saei 124b198b35
[Metrics SDK] Histogram min/max support (#1540) 2022-08-05 20:18:31 -07:00
Bryce Arden 22f07a0c3a
fix(metrics): ostream exporter should print out resource attributes (#1523) 2022-08-05 16:43:14 -07:00
Lalit Kumar Bhasin 73a51cf633
Support multiple async callbacks (#1495) 2022-08-05 11:54:00 -07:00
Ehsan Saei d29934819f
Fix code scanning alert (#1530) 2022-08-03 18:36:23 +00:00
WenTao Ou b4d8245d65
Fix several compiling/linking errors (#1539)
Signed-off-by: owentou <owentou@tencent.com>
2022-08-02 21:26:24 -07:00
Ehsan Saei 90fd29183e
[dev] vscode debug launch.json (#1537) 2022-08-02 13:24:37 -07:00
Lalit Kumar Bhasin 78551fbb53
[Trace] Add SpanData getter for Span Recordable (#1508) 2022-08-02 12:09:34 -07:00
Marc Alff 70fd2dcb88
Fix log sdk builder (#1486) (#1524) 2022-08-02 00:17:49 -07:00
Ehsan Saei 3af512e0ed
Add configuration options for Aggregation creation (#1513) 2022-08-01 21:02:54 +00:00
Ehsan Saei d452e8e859
Fix metrics unit test memory leack (#1533) 2022-07-31 19:48:15 +02:00
Tom Tan 9e6fd1e0be
Prepare v1.5.0 release (#1528) 2022-07-30 10:53:30 -07:00
WenTao Ou 59e7496f94
Upgrade `instrumentation_library_metrics` to `scope_metrics` (#1507)
* Upgrade `instrumentation_library_metrics` to `scope_metrics`

Signed-off-by: owentou <owentou@tencent.com>

* Rename `InstrumentationLibrary` -> `InstrumentationScope`

Signed-off-by: owentou <owentou@tencent.com>

* Fix style

Signed-off-by: owentou <owentou@tencent.com>

* Fix compiling

Signed-off-by: owentou <owentou@tencent.com>

* Remove duplicated `ElasticSearchRecordable::SetInstrumentationLibrary`

Signed-off-by: owentou <owentou@tencent.com>

* Fix comments

Signed-off-by: owentou <owentou@tencent.com>

* Update the usage of `instrumentation_library` of prometheus exporter.

Signed-off-by: owentou <owentou@tencent.com>
2022-07-30 03:42:15 -07:00
Tom Tan 0015475adc
Add resources to dep list of prometheus exporter test (#1527) 2022-07-28 17:45:56 +00:00
Ehsan Saei e4f3a9c46f
Prometheus unit test (#1461) 2022-07-28 07:34:02 -07:00
Andrew Stitcher 3a8f913de5
Don't require applications using jaeger exporter to know about libcurl (#1518) 2022-07-26 21:03:46 +02:00
Ehsan Saei 30b4fcd701
fix compiler warnings (#1514) 2022-07-25 19:13:07 +02:00
Ákos Hadnagy e5cf017fa9
Inline print_value() in ostream exporter (#1512) 2022-07-24 10:03:18 +02:00
wangzhen2271 a77ec80312
fix: urlPaser will incorrect parsing url like http://abc.com/xxx@xxx/a/b (#1511)
Co-authored-by: Lalit Kumar Bhasin <labhas@microsoft.com>
2022-07-22 08:53:34 -07:00
Marc Alff 09480544c8
Add automatically semantic conventions from the spec (#873) (#1497) 2022-07-21 10:57:34 -07:00
WenTao Ou beba41485a
Try to build nlohmann-json only it's depended. (#1505)
Signed-off-by: owentou <owentou@tencent.com>
2022-07-20 18:57:26 +02:00
Tom Tan abf3312e1b
Link opentelemetry_api to ETW exporter test (#1503) 2022-07-19 08:04:02 -07:00
WenTao Ou 24d5100ada
[Metrics] Add OTLP http metric exporter (#1487)
* Add OTLP http metric exporter

Signed-off-by: owentou <owentou@tencent.com>

* Add changelog for OTLP HTTP metric exporter

Signed-off-by: owentou <owentou@tencent.com>

* Add unit test of `SumPointData` for `OtlpHttpMetricExporter`

Signed-off-by: owentou <owentou@tencent.com>

* Fix dependency of otlp recordable, add `Gauge` support for `OtlpMetricUtils::PopulateRequest`

Signed-off-by: owentou <owentou@tencent.com>

* Add unit test for `OtlpHttpMetricExporter`

Signed-off-by: owentou <owentou@tencent.com>

* Fix format

Signed-off-by: owentou <owentou@tencent.com>

* Fix unit test `OtlpMetricSerializationTest.ObservableGauge`

Signed-off-by: owentou <owentou@tencent.com>
2022-07-19 00:59:24 -07:00
Yan Xue 4062237e7c
Use template class for in-memory data. (#1496) 2022-07-18 10:16:57 -07:00
Ehsan Saei fba16c6c44
fix compiler warnings (#1499)
* fix compiler warnings

* format
2022-07-17 11:26:57 -07:00
Marc Alff e708de5565
Fix trace sdk builder 1393 (#1471) 2022-07-15 12:52:12 -07:00
Marc Alff c22463384d
Fixed file permissions on source code (#1490) (#1491) 2022-07-12 18:47:09 -07:00
Lalit Kumar Bhasin 801ebba8ef
Enable bazel build for metrics proto files (#1489)
* enable bazel build for metrics proto

* error
2022-07-11 18:51:15 -07:00
Lalit Kumar Bhasin 235c90eb7b
fix otlp grpc exporter naming (#1488) 2022-07-11 18:00:58 -07:00
WenTao Ou 8691a2d582
Remove `--config Debug` when installing. (#1480) 2022-07-09 11:25:40 -07:00
WenTao Ou 4762910eab
Merge branch 'merge_main_into_async-changes' into merge_async-changes_into_main (#1413) 2022-07-08 22:16:01 -07:00
lostwong 9efb7a1453
Fix endpoint in otlp grpc exporter (#1474) 2022-07-01 14:16:31 -07:00
James Peach e372ce5ee7
Update docs to use relative code links. (#1447) 2022-07-01 12:54:20 -07:00
luyor 4c08919aa1
Fix trace kIsSampled flag set incorrectly (#1465) 2022-07-01 10:58:56 -07:00
taekahn 7b0bb14837
Fix build warnings about missing aggregates. (#1368) 2022-07-01 10:18:40 -07:00
Tom Tan 45fdbf2b47
Remove reference to deprecated InstrumentationLibrary in OTLP (#1469) 2022-06-29 14:32:03 -07:00
Lalit Kumar Bhasin b285874cd8
OTLP gRPC Metrics Exporter (#1454) 2022-06-23 16:50:09 -07:00
Ehsan Saei 5ccca49318
fix prometheus exporter failure type (#1460) 2022-06-22 16:33:35 +02:00
Tom Tan 96534a7c23
Prepare v1.4.1 patch release (#1458) 2022-06-20 15:16:05 -07:00
Tom Tan 9f3a8eeb19
Don't close inactive issues by the stable bot (#1453) 2022-06-16 15:16:37 -07:00
univisionsrl 2d78a56baa
Fix variables inizialization (#1430) 2022-06-15 10:19:56 -07:00
Marc Alff 2f0a3d69cb
Fixed broken link to OpenTelemetry.io (#1445) (#1446) 2022-06-10 18:19:36 -07:00
Marc Alff 33567b9c95
Upgrade nlohmann_json to 3.10.5 (#1438) (#1441) 2022-06-10 15:30:00 -07:00
Lalit Kumar Bhasin 423a1a2260
fix histogram (#1440) 2022-06-10 13:46:23 -07:00
Marc Alff 6ee70a7360
Fix GettingStarted documentation for Jaeger HTTP exporter (#1347) (#1439) 2022-06-09 19:38:44 -07:00
Flier Lu 4c657a1fa4
install sdk-config.h (#1419) 2022-06-08 23:06:03 -07:00
Tom Tan 473c93163a
Log current timestamp instead of epoch time (#1434) 2022-06-07 15:42:54 -07:00
Lalit Kumar Bhasin 18991a6360
Add attributes/dimensions to metrics ostream exporter (#1400) 2022-06-07 11:11:44 -07:00
WenTao Ou 7e90dae3e4
Fix global log handle symbols when using dlopen (#1420) 2022-06-03 21:30:20 -07:00
Lalit Kumar Bhasin 62b65fab92
[Metrics SDK] Only record non-negative / finite / Non-NAN histogram values (#1427)
* validate histogram value

* handle Nan

* add changelog

* divide by 0 error on windows

* fix markdown lint
2022-06-02 20:30:15 -07:00
Lalit Kumar Bhasin 81df64b576
Fix ETW log exporter header inclusion (#1426) 2022-06-02 13:24:23 -07:00
Tom Tan 93ef013c70
Copy string_view passed to ETW exporter in PropertyVariant (#1425) 2022-06-02 19:24:18 +00:00
Lalit Kumar Bhasin 9df5c4fef1
[Metrics API/SDK] - Pass state to async callback function. (#1408) 2022-05-31 10:27:42 -07:00
Leo Di Donato 5c8f476459
[BUILD] fix nlohmann_json's (third party) include dir (#1415) 2022-05-24 09:26:40 -07:00
ztao 0ef9446f7a
fix: WaitOnSocket select error when sockfd above FD_SETSIZE (#1410) 2022-05-20 23:16:41 -07:00
Lalit Kumar Bhasin 63803d10c6
fix OTEL_INTERNAL_LOG_INFO (#1407) 2022-05-18 18:56:21 -07:00
Ehsan Saei a847d0ce42
Document Getting Started with Prometheus and Grafana (#1396)
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
2022-05-18 21:29:22 +00:00
Tom Tan ab084ecea5
Fix vcpkg package name in doc (#1392) 2022-05-18 10:52:59 -07:00
Tom Tan 09b92afd9d
Prepare v1.4.0 release (#1404) 2022-05-18 09:22:06 -07:00
WenTao Ou 280f546e17
Upgrade proto to v0.17.0, update log data model (#1383) 2022-05-16 20:46:39 -07:00
Ehsan Saei 1e25d58a11
Alpine image (#1382) 2022-05-16 20:59:15 +00:00
Hamed Mansouri e11cc62c47
get span_id from context when Logger::Log received invalid span_id (#1398) 2022-05-16 19:13:28 +00:00
Lalit Kumar Bhasin 45f0235dda
Connect async storage with async instruments (#1388) 2022-05-16 11:10:13 -07:00
Ehsan Saei 3fd5ca38a0
Getting started document using ostream exporter (#1394)
Co-authored-by: Reiley Yang <reyang@microsoft.com>
2022-05-16 16:53:40 +02:00
Leo Di Donato 4b69a107ae
fix: missing link to nlohmann_json (#1390) 2022-05-13 13:40:00 -07:00
Tom Tan 88e23ad469
Fix sharing resource in batched exported spans (#1386)
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
2022-05-11 13:03:11 -07:00
Ehsan Saei 95effbde67
Prometheus exporter meters and instrument name (#1378) 2022-05-10 17:55:05 +00:00
Lalit Kumar Bhasin 54abc2741b
reuse temporal metric storage for sync storage (#1369) 2022-05-10 04:17:08 +05:30
Lalit Kumar Bhasin 02630e0b6d
[Metrics SDK] Remove un-necessary files. (#1379) 2022-05-07 09:45:44 +02:00
dependabot[bot] 0d27a43a2f
Bump docker/setup-buildx-action from 1 to 2 (#1376) 2022-05-06 20:14:25 +00:00
dependabot[bot] a0d4a7215a
Bump docker/build-push-action from 2 to 3 (#1377) 2022-05-06 19:25:08 +00:00
Lalit Kumar Bhasin 99a72e1ae0
Add noexcept/const qualifier at missing places for Trace API. (#1374)
* fix noxcept

* fix etw
2022-05-06 07:21:22 -07:00
dependabot[bot] 5458dde947
Bump docker/setup-qemu-action from 1 to 2 (#1375) 2022-05-05 20:50:24 -07:00
Zsolt Bölöny d3c4200654
Fix empty tracestate header propagation (#1373) 2022-05-05 11:49:23 -07:00
Lalit Kumar Bhasin 59a48c1c99
fix baggage propagation for empty/invalid baggage context (#1367) 2022-05-03 17:26:43 -07:00
Lalit Kumar Bhasin 9c734b33ee
Enable metric collection for Async Instruments - Delta and Cumulative (#1334) 2022-05-03 15:37:32 -07:00
Tom Tan 13ac5c30b6
Disable test on prometheus-cpp which not need (#1363) 2022-05-02 19:28:51 +00:00
Ehsan Saei c1e6e16e7d
export opentelemetry_otlp_recordable (#1365) 2022-05-02 10:12:38 -07:00
Ehsan Saei c8bd431be2
codecov ignore (#1364) 2022-04-30 10:29:13 -07:00
Lalit Kumar Bhasin 8ef6764c2f
Fix class member initialization order (#1360) 2022-04-29 18:40:06 -07:00
Lalit Kumar Bhasin f31452286c
Simplify SDK Configuration: Use View with default aggregation if no matching View is configured (#1358) 2022-04-29 17:48:49 -07:00
Tom Tan 3a4a3a33ff
Fix output time in metrics OStream exporter (#1346) 2022-04-28 15:57:07 -07:00
Ehsan Saei a4bd3b0667
prometheus example (#1332) 2022-04-28 16:29:26 +00:00
Lalit Kumar Bhasin 4008da54fa
Use latest TraceLoggingDynamic.h (#1354) 2022-04-27 18:08:22 +05:30
Zsolt Bölöny 72360b49f6
Add missing include guard (#1357) 2022-04-27 16:48:26 +05:30
Lalit Kumar Bhasin 3b9bfd41e7
conditional include for codecvt header (#1355) 2022-04-27 14:20:24 +05:30
Tom Tan e2337912f0
Fix scalar delete against array (#1356) 2022-04-27 10:57:39 +05:30
Tom Tan c917beda3e
Add explicit type cast in baggage UrlDecode (#1353) 2022-04-26 21:42:26 +02:00
dependabot[bot] 33cb82714e
Bump github/codeql-action from 1 to 2 (#1351)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-26 10:55:34 -07:00
Lalit Kumar Bhasin 0c74e0b93d
remove exporter registration to meter provider (#1350) 2022-04-25 13:13:13 -07:00
Ehsan Saei e6fb935f75
prometheus exporter (#1331) 2022-04-25 16:48:11 +00:00
Ehsan Saei bf8f433cae
ostream metrics cmake (#1344) 2022-04-21 21:27:19 +00:00
WenTao Ou 7fde3bc792
Link `opentelemetry_ext` with `opentelemetry_api` (#1336) 2022-04-21 09:46:29 -07:00
Ehsan Saei b33dd0920a
metrics histogram example (#1330) 2022-04-18 16:37:01 +00:00
Ehsan Saei 1d2cd4225d
dependencies image as artifact (#1333)
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
2022-04-18 15:39:02 +00:00
Tom Tan 2e9b7a1867
Remove redundant tail / in CMake install (#1329) 2022-04-16 12:19:53 +05:30
Tom Tan defdfd2ca7
Replace deprecated googletest API (#1327) 2022-04-15 09:08:26 -07:00
Ehsan Saei e3304d7897
fix metrics compiler warnings (#1328) 2022-04-15 12:50:47 +05:30
Lalit Kumar Bhasin 29d68f1146
Implement Merge and Diff operation for Histogram Aggregation (#1303) 2022-04-14 09:53:09 -07:00
jmanjon e7f051edf7
Fix for #1292 (#1326) 2022-04-14 09:51:47 +05:30
Lalit Kumar Bhasin 75c2a8f7a6
Update yield logic for ARM processor (#1325) 2022-04-12 14:33:39 -07:00
Tom Tan da2911cf44
Prepare v1.3.0 release (#1324) 2022-04-12 12:46:07 -07:00
Ehsan Saei 755f109a0d
ostream metrics example (#1312) 2022-04-12 11:12:21 -07:00
dependabot[bot] e200c1f183
Bump actions/stale from 4 to 5 (#1323) 2022-04-11 07:55:15 -07:00
Lalit Kumar Bhasin d72dcb69b0
[ETW Exporter] - ETW provider handle cleanup (#1322) 2022-04-11 00:45:36 -07:00
Ben Landrum 3122254e82
Remove implicitly deleted default constructor (#1267)
Co-authored-by: Tom Tan <Tom.Tan@microsoft.com>
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
2022-04-07 10:02:11 -07:00
WenTao Ou 6b87300b5a
Add building test without RTTI (#1294) 2022-04-07 08:56:44 -07:00
WenTao Ou 74ec691e4a
Move public definitions into `opentelemetry_api`. (#1314)
Signed-off-by: owent <admin@owent.net>
2022-04-06 23:06:59 -07:00
dependabot[bot] fd338cc9f9
Bump codecov/codecov-action from 2.1.0 to 3 (#1318) 2022-04-05 23:05:14 -07:00
Tom Tan 237a0b2637
Excempt should be applied on issue instead of PR (#1316) 2022-04-04 20:41:02 -07:00
Lalit Kumar Bhasin be75bbc862
Add InstrumentationInfo and Resource to the metrics data to be exported. (#1299) 2022-04-04 22:09:02 +00:00
WenTao Ou 48a4060106
Add `async-changes` branch to pull_request of github action (#1309)
Signed-off-by: owent <admin@owent.net>
2022-04-04 13:09:48 -07:00
Lalit Kumar Bhasin 33d9c628f2
Implement periodic exporting metric reader (#1286) 2022-04-01 14:07:44 -07:00
Tom Tan 2034c9bcfa
Don't show coverage annotation for pull requests (#1304) 2022-04-01 19:57:31 +02:00
WenTao Ou 76c664a20b
Rename `http_client_curl` to `opentelemetry_http_client_curl` (#1301)
Signed-off-by: owent <admin@owent.net>
2022-03-31 11:51:26 -07:00
Lalit Kumar Bhasin a7e814a632
Synchronous Metric collection (Delta , Cumulative) (#1265) 2022-03-30 01:01:37 +00:00
Ehsan Saei c1b959079b
Fix span SetAttribute crash (#1283) 2022-03-26 08:25:42 +00:00
Ehsan Saei 91b05720ef
fix compilation error with protobuf 3.5 (#1289) 2022-03-25 17:40:21 +01:00
Lalit Kumar Bhasin 2c9ce393e0
[Metrics SDK] - fix spelling (AggregationTemporarily to AggregationTemporality) (#1288) 2022-03-24 16:47:49 -07:00
Ehsan Saei 3c7b44bf4f
metrics exemplar round 1 (#1264) 2022-03-24 22:31:41 +01:00
Ehsan Saei 0c9aecea7a
Disable benchmark action failure (#1284) 2022-03-24 16:45:38 +01:00
Lalit Kumar Bhasin b5155a5dea
Add owent as an Approver (#1276)
* add owent as reviewer

* fix order
2022-03-23 08:06:46 -07:00
dependabot[bot] 6ec1b596fd
Bump actions/cache from 2 to 3 (#1277) 2022-03-22 18:27:20 +01:00
Ehsan Saei e072daa229
install sdk config (#1273) 2022-03-21 07:02:15 -07:00
Lalit Kumar Bhasin 31d888a540
Enable metric collection from MetricReader (#1241) 2022-03-17 18:15:35 -07:00
Ehsan Saei 6bd2f96309
MetricStorage dtors (#1270) 2022-03-17 17:10:32 -07:00
Tom Tan 0b1a74c7ab
Enable line-length lint for markdown docs (#1268) 2022-03-16 07:17:12 -07:00
Lalit Kumar Bhasin 49648bd8f7
Remove nostd::span as dependency from Dependency document (#1260) 2022-03-13 13:19:09 -07:00
Ehsan Saei da94697c01
AttributesProcessor dtor (#1263) 2022-03-13 09:39:41 -07:00
Lalit Kumar Bhasin 28bd621552
Asynchronous Aggregation storage (#1232) 2022-03-11 22:36:10 +00:00
wxl374 4a7200b365
fix: use CURLOPT_TIMEOUT_MS to config OtlpHttpExporter's timeout instead of CURLOPT_TIMEOUT (#1261) 2022-03-11 19:43:43 +01:00
DJ Gregor fd5a6218bd
Add support for span links to Jaeger export. (#1251) 2022-03-09 09:35:09 -08:00
WenTao Ou c96a3e32f0
Reorder the destructor of members in LoggerProvider and TracerProvider (#1245) 2022-03-08 10:17:02 -08:00
dependabot[bot] cba0a2a657
Bump actions/checkout from 2 to 3 (#1248) 2022-03-07 17:03:30 +00:00
dependabot[bot] 32cd04774b
Bump codecov/codecov-action from 1 to 2.1.0 (#1247)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 1 to 2.1.0.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v1...v2.1.0)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ehsan Saei <71217171+esigo@users.noreply.github.com>
2022-03-07 17:16:50 +01:00
Reiley Yang b46cd6f580
Update Maintainers (#1249) 2022-03-06 20:35:50 -08:00
Ehsan Saei 50fabb5fa0
dependabot for GitHub actions (#1246) 2022-03-04 15:00:10 -08:00
Greg Miller 99c483c790
chore: update prometheus to 1.0 version (#1242) 2022-03-03 19:08:15 -08:00
Artiom Vaskov 84394fda87
Added s390x arch into CMake build. (#1216) 2022-03-02 07:52:37 -08:00
Ehsan Saei 1fe14b984a
centos image (#1240) 2022-03-02 02:29:47 -08:00
Ehsan Saei 11a219c80a
Jaeger bazel windows (#1227) 2022-02-28 20:22:13 -08:00
Lalit Kumar Bhasin c10bc36e7d
[Metric SDK] Synchronous Instruments - Aggregation Storage(s) creation for configured views (#1219) 2022-02-24 00:12:23 -08:00
Ehsan Saei 9157fd4748
Mock for http exporters (#1185) 2022-02-19 02:12:02 -08:00
Ehsan Saei 9502339a58
Ostream metric exporter (#1196) 2022-02-19 00:23:57 -08:00
Ehsan Saei 3508d7c11c
allow extension of the lifetime of ContextStorage. (#1214) 2022-02-18 23:44:56 -08:00
Tom Tan 1026ec3ffc
Run apt update before install thrift dependencies (#1225) 2022-02-18 18:56:06 -08:00
Ehsan Saei cf7f9e28ab
thrift boost deps (#1224) 2022-02-18 16:18:32 -08:00
Tom Tan 3a9d0870bc
Detect vs2022 as build environment (#1212) 2022-02-17 08:10:19 +00:00
Lalit Kumar Bhasin ef3a623a3b
Add Aggregation Storage (#1213) 2022-02-16 14:58:32 -08:00
WenTao Ou 15c6f33631
Update grpc to v1.43.2 to support VS2022/MSVC 19.30 and bazel 5.0 (#1207)
Signed-off-by: owent <admin@owent.net>
2022-02-14 20:24:58 -08:00
Ehsan Saei 9ed312b29c
fix ostream_log_test Mac (#1208) 2022-02-14 13:05:25 -08:00
Ehsan Saei e89e5b3dd6
Benchmark documentation (#1205) 2022-02-11 21:23:30 -08:00
Lalit Kumar Bhasin 7485102bfa
Change Monday's community meeting time (13:00 PT - 14:00 PT) (#1204) 2022-02-11 09:47:47 -08:00
Lalit Kumar Bhasin 04e3a68263
Sync and Async Instruments SDK (#1184) 2022-02-09 22:27:55 -08:00
Ehsan Saei e1c8557032
fix errors in SDK documentation (#1201) 2022-02-09 12:35:54 -08:00
Lalit Kumar Bhasin 44795b6d21
Add Aggregation as part of metrics SDK. (#1178) 2022-02-04 21:53:10 -08:00
Lalit Kumar Bhasin b6a28df5c4
Metrics SDK: Filtering metrics attributes (#1191) 2022-02-04 18:46:06 -08:00
Ehsan Saei e1b4a49f9b
disable failing test (#1193) 2022-02-04 11:52:45 -08:00
Deepika Upadhyay e9127fc49d
cmake: thrift requires boost headers, include them as Boost_INCLUDE_DIRS (#1100) 2022-02-04 10:43:33 -08:00
Hamed Mansouri a320739a46
Update GettingStarted.rst (#1189) 2022-02-02 13:58:45 -08:00
Tom Tan 033b16fe19
Prepare for 1.2.0 release (#1188) 2022-02-01 11:58:47 -08:00
Reiley Yang 43ad7b9fea
move non-active members to Emeritus (#1186) 2022-01-31 17:54:10 +00:00
Lalit Kumar Bhasin 16a9c53680
Add @esigo as approver (#1183) 2022-01-26 08:58:05 -08:00
Ehsan Saei a605fd9116
importing gsl::span if std::span is not available (#1167) 2022-01-24 19:14:20 -08:00
Ehsan Saei 2a821fdfa5
Continuous benchmark tests as part of the CI (#1174) 2022-01-21 10:12:39 -08:00
Tom Tan fed56cc346
Fix build test of Zipkin exporter on Windows (#1177) 2022-01-20 10:11:16 -08:00
WenTao Ou bc1b469c72
Waiting a longer time when run unit tests of http client, which may take a long time when run under valgrind. (#1171) 2022-01-15 21:07:01 -08:00
Ehsan Saei f380fcba45
Logger-Support-for-Instrumentation-library (#1149) 2022-01-14 19:39:27 -08:00
WenTao Ou b8fae39f81
Use custom abseil with bazel (#1172) 2022-01-14 16:53:15 -08:00
WenTao Ou d206b505e0
Logger: Propagating resources through LoggerProvider (#1154) 2022-01-12 10:11:43 -08:00
Ehsan Saei f20f72f3a9
ZipkinExporter unit-tests (#1155) 2022-01-06 10:13:06 -08:00
Ehsan Saei 1688c7c248
Synchronized calls to Exporter::Export & Shutdown (#1164) 2022-01-05 09:16:26 -08:00
WenTao Ou 1f0bf83b98
Using system installed grpc,curl,protobuf to enable otlp exporters by default (#1131) 2022-01-03 21:15:18 -08:00
WenTao Ou baab88ff21
Add log level for internal log of sdk (#1147) 2022-01-03 19:25:25 -08:00
Ehsan Saei 4bffa633c0
Jaeger: ThriftSender unit test (#1162) 2022-01-03 09:14:06 -08:00
Lalit Kumar Bhasin 09fb4e0a0d
Metrics SDK: View API (#1110) 2021-12-27 12:53:37 -08:00
Bjorn Svensson de276f5fa2
Fix leak in Jaeger exporter (#1160)
The jaeger_span was never destroyed after its release from the
JaegerRecordable. This change let a `std::unique_ptr` handle
the destruction when going out of scope, first allowing the
`thrift::Span` to be copied to the `span_buffer_`.
2021-12-23 14:52:31 -08:00
wxl374 dcea27bc1d
fix: otlp http exporter block thread (#1141) (#1163) 2021-12-23 11:26:47 -08:00
Ehsan Saei bb9d5de0b0
InMemorySpanExporter shutdown fix (#1161) 2021-12-22 23:13:05 -08:00
Tom Tan 1cf2422c29
Fix PR number in CHANGELOG (#1159) 2021-12-21 14:00:20 -08:00
Lalit Kumar Bhasin c842be7790
install json only if required (#1157) 2021-12-21 13:11:38 -08:00
Ehsan Saei 9a6c745781
Add unit-test for Jaeger exporter (#1151) 2021-12-20 20:02:50 -08:00
Tom Tan 48033107c8
Prepare for patch release v1.1.1 (#1156) 2021-12-20 14:59:31 -08:00
Lalit Kumar Bhasin 4f5505f9cb
sem ver (#1140) 2021-12-20 12:25:30 -08:00
Ehsan Saei 3701a6e4c7
ZipkinExporter shutdown (#1153) 2021-12-20 09:49:34 -08:00
Vasi Vasireddy 7b9132c9d2
docs-changes (#1152) 2021-12-19 00:41:12 -08:00
Ehsan Saei 85ea91f94a
Jaeger exporter shutdown (#1150) 2021-12-18 16:27:26 -08:00
Ehsan Saei f60eec26b3
etw logger test bazel (#1148) 2021-12-17 09:45:31 -08:00
Ehsan Saei b021bd6c79
C++20 not Building with VS2019 (#1144) 2021-12-15 20:00:19 -08:00
Ehsan Saei 5aa632741d
Mark tags to bazel targets round 2 (#1094) 2021-12-15 18:50:04 -08:00
Vasi Vasireddy 9dd3da33b0
Improve the instructions for Bazel build. (#1136) 2021-12-15 10:21:31 -08:00
Lalit Kumar Bhasin 7f5eb45900
Add note on DLL support (#1137) 2021-12-14 11:09:42 -08:00
Ehsan Saei f349053c09
Otlp http cmake build fail (#1133) 2021-12-13 11:19:25 -08:00
Ehsan Saei 836dda6f06
run_docker user (#1123) 2021-12-10 10:53:17 -08:00
Tom Tan 5e258b0c0c
Add explicit type conversion when assigning value_type to Jaeger tag (#1118) 2021-12-08 17:02:17 -08:00
Ehsan Saei 30d9bbc047
Document dependencies (#1119) 2021-12-08 14:51:30 -08:00
Ehsan Saei a9805719f6
`jaeger::TUDPTransport::write` crash when `getaddrinfo` returns error (#1116) 2021-12-07 09:08:23 -08:00
Ehsan Saei c50ed1c976
Jaeger exporter: extend supported attributes types (#1106) 2021-12-06 15:31:47 -08:00
Ehsan Saei 235112548a
Jaeger exporter: attributes of unsupported types (#1115) 2021-12-04 12:47:23 -08:00
Ehsan Saei baeee42f04
Fix otlp generates null span ids (#1113) 2021-12-04 01:01:58 -08:00
Ehsan Saei a92340db6d
fix in memory exporter test bazel (#1112) 2021-12-03 15:39:15 -08:00
Ehsan Saei 15155f76bd
fix data race in BM_ThreadYieldSpinLockThrashing (#1099) 2021-12-02 08:18:28 -08:00
Lalit Kumar Bhasin 93249de07a
Dockerfile for quick demo/troubleshooting purpose. (#905) 2021-12-01 12:16:31 -08:00
Lalit Kumar Bhasin b1b1f6409a
Add Meter and MeterProvider in the SDK (#1078) 2021-11-29 16:20:33 -08:00
Ehsan Saei 6b9ed3d864
Jaeger bazel (Linux only) (#1077) 2021-11-25 10:01:58 -08:00
WenTao Ou 1e1fb8b53b
Remove missing target in legacy prometheus (#1097) 2021-11-24 18:06:15 -08:00
Ehsan Saei 1867688f7c
Otlp gRPC log example (#1083) 2021-11-23 13:08:45 -08:00
WenTao Ou caade511bf
Fix #1081 (#1082) 2021-11-23 12:30:28 -08:00
Ehsan Saei 0a924fb490
Mark tags to bazel targets (#1075) 2021-11-22 14:10:03 -08:00
Tom Tan 426365c2c0
Prepare for releasing 1.1.0 (#1079) 2021-11-22 13:08:32 -08:00
Morgan McLean 9e8be676cb
Remove hardcoded Zoom link (#1085) 2021-11-22 10:57:09 -08:00
WenTao Ou 089b04d77f
Fix timeout of `OtlpHttpExporterTestPeer` and `OtlpHttpLogExporterTestPeer` when run under valgrind. (#1080) 2021-11-22 10:00:23 -08:00
Ehsan Saei 6e249fd560
build release tarball when nlohmann-json not installed (#1074) 2021-11-19 09:25:00 -08:00
Ehsan Saei 97fbdaa747
Otlp http log example (#1062) 2021-11-17 09:27:25 -08:00
Shuai Zhang 3db551f1b0
Bugfix: regex is neither working on GCC 4.9.x (#1069) 2021-11-16 08:26:54 -08:00
Shuai Zhang 69fdf67154
Improvement: span_id should not break strict aliasing. (#1068) 2021-11-15 22:44:54 -08:00
Paurush Garg 9772156789
fix: issue 368- consistent namespace scope resolution (#1008) 2021-11-15 19:53:34 -08:00
Ehsan Saei b2a0a560f6
otlp gRPC log export should fail after shutdown (#1064) 2021-11-15 10:17:09 -08:00
Ehsan Saei 4a49b1b09e
otlp grpc exporter (#1063) 2021-11-13 09:44:19 -08:00
Lalit Kumar Bhasin eca856df5c
Build opentelemetry-proto collector interface with cmake only if WITH_OTLP_GRPC is enabled. (#1061) 2021-11-12 22:27:35 -08:00
Tom Tan e21f033274
Remove stale bot to operate on PRs (#1059) 2021-11-10 23:35:04 -08:00
Tom Tan e7b5b9dcdc
Mark cURL as required dependence for building Zipkin exporter (#1060) 2021-11-10 22:46:18 -08:00
Tom Tan 4554be10d3
OTLP gRPC log exporter (#1048) 2021-11-10 21:19:53 -08:00
Lalit Kumar Bhasin 8ddf9d30a6
Metrics API : Provider , MeterProvider, Meter, SynchronousInstrument (#1033) 2021-11-10 19:03:13 -08:00
Tom Tan 3807726a3a
Add action to mark and close stale issues after timeout (#1058) 2021-11-09 18:03:09 -08:00
Ehsan Saei 435e37787d
Building otlp exporter from the release tarball (#1056) 2021-11-09 16:59:38 -08:00
Ehsan Saei 55aa7ead1a
checkout opentelemetry-proto v0.11.0 (#1055) 2021-11-09 16:20:12 -08:00
Ehsan Saei 994c08aefb
Add Prometheus Exporter (#1031) 2021-11-09 08:25:29 -08:00
Lalit Kumar Bhasin c3f3042a38
List otel-cpp ports for conan and vcpkg (#1057) 2021-11-08 11:13:23 -08:00
Lalit Kumar Bhasin e58524c49a
Move old metrics implementation to different directory, and rename targets to *_deprecated (#1053)
Co-authored-by: Tom Tan <Tom.Tan@microsoft.com>
2021-11-05 14:25:22 -07:00
wenyg 14ec78569c
fix: redefinition (#1052) 2021-11-04 09:45:02 -07:00
Ehsan Saei 8e8c50a0c1
otlp_grpc_exporter export after shutdown should fail (#1050) 2021-11-02 19:30:32 -07:00
Lalit Kumar Bhasin 52f61988d4
Update Install doc for bazel build (#1046) 2021-11-01 18:37:29 -07:00
Ehsan Saei bf176f35a7
fix compiler warnings (#1044) 2021-11-01 15:54:33 -07:00
Lalit Kumar Bhasin 64d736e207
fix namespace resolution for logger (#1047) 2021-11-01 14:44:03 -07:00
WenTao Ou 4110b56314
Implementation of `OtlpHttpLogExporter` (#1030) 2021-10-31 08:54:54 -07:00
Ehsan Saei af75379971
Extract foo library into a separate library (#1043) 2021-10-29 19:55:21 -07:00
Tom Tan 838d962efe
Fix the reference to tracer provider in ETW logger exporter (#1040) 2021-10-29 09:13:25 -07:00
Tom Tan 32cd66b623
Update example to latest otel-collector container (#1038) 2021-10-28 12:24:06 -07:00
WenTao Ou 6e8a169e79
Fix #1028 (#1029) 2021-10-23 21:18:33 -07:00
WenTao Ou 05d43d61ed
Export `ENABLE_LOGS_PREVIEW` and `ENABLE_METRICS_PREVIEW` (#1026) 2021-10-23 09:40:30 -07:00
1609 changed files with 145904 additions and 36390 deletions

View File

@ -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

View File

@ -1 +1 @@
4.2.0
7.1.1

View File

@ -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

42
.clang-tidy Normal file
View File

@ -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-*

View File

@ -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.

52
.copyright-ignore Normal file
View File

@ -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

View File

@ -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"]

View File

@ -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"]

38
.devcontainer/README.md Normal file
View File

@ -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"`

View File

@ -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."

View File

@ -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"
}

4
.gitattributes vendored
View File

@ -41,3 +41,7 @@ LICENSE* text
## git files
.gitignore text eol=lf
.gitattributes text eol=lf
## bazel files
WORKSPACE text eol=lf
BUILD text eol=lf

21
.github/.codecov.yaml vendored
View File

@ -12,11 +12,7 @@ coverage:
informational: true
target: auto
threshold: 10%
patch:
default:
informational: true
target: auto
threshold: 10%
patch: false
parsers:
gcov:
@ -37,3 +33,18 @@ comment:
# to coverage report file paths.
fixes:
- "/home/runner/::"
ignore:
- "docs/**/*"
- "docker/**/*"
- "examples/**/*"
- "bazel/**/*"
- "cmake/**/*"
- "buildscripts/**/*"
- "third_party/**/*"
- "test_common/**/*"
- "tools/**/*"
- ".vscode/**/*"
- ".github/**/*"
- "**/test/**/*"
- "**.md"

View File

@ -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>

View File

@ -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>

13
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
labels:
- "GHA"
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: daily

84
.github/workflows/benchmark.yml vendored Normal file
View File

@ -0,0 +1,84 @@
name: OpenTelemetry-cpp benchmarks
on:
push:
branches:
- main
permissions:
contents: read
jobs:
benchmark:
name: Run OpenTelemetry-cpp benchmarks
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
with:
submodules: 'recursive'
- name: Mount Bazel Cache
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
env:
cache-name: bazel_cache
with:
path: /home/runner/.cache/bazel
key: bazel_benchmark
- name: setup
run: |
sudo ./ci/setup_ci_environment.sh
sudo ./ci/install_bazelisk.sh
- name: Run benchmark
id: run_benchmarks
run: |
./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@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:
- 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
- name: Print json files
id: print_json
run: |
cat benchmarks/*
- name: Push benchmark result
uses: benchmark-action/github-action-benchmark@d48d326b4ca9ba73ca0cd0d59f108f9e02a381c7 # v1.20.4
with:
name: OpenTelemetry-cpp ${{ matrix.components }} Benchmark
tool: 'googlecpp'
output-file-path: benchmarks/${{ matrix.components }}-benchmark_result.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: false
gh-pages-branch: gh-pages
benchmark-data-dir-path: benchmarks

File diff suppressed because it is too large Load Diff

98
.github/workflows/clang-tidy.yaml vendored Normal file
View File

@ -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

318
.github/workflows/cmake_install.yml vendored Normal file
View File

@ -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

View File

@ -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@v2.3.4
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@v1
uses: github/codeql-action/init@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # v3.29.8
with:
languages: cpp
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # v3.29.8
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # v3.29.8

77
.github/workflows/cppcheck.yml vendored Normal file
View File

@ -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

View File

@ -0,0 +1,54 @@
name: 'OpenTelemetry-cpp dependencies image'
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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
-
name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
-
name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
-
name: Build Image
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
builder: ${{ steps.buildx.outputs.name }}
context: ci/
file: ./docker/Dockerfile
build-args: BASE_IMAGE=ubuntu:latest
platforms: linux/amd64
# platforms: linux/amd64,linux/arm64
push: false
tags: otel-cpp-deps
load: true
-
name: Save Image
run: |
docker images
docker save -o /opt/otel-cpp-deps-debian.tar otel-cpp-deps
-
name: Upload Image
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: otel-cpp-deps
path: /opt/otel-cpp-deps-debian.tar
retention-days: 14

25
.github/workflows/fossa.yml vendored Normal file
View File

@ -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

98
.github/workflows/iwyu.yml vendored Normal file
View File

@ -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

52
.github/workflows/ossf-scorecard.yml vendored Normal file
View File

@ -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

View File

@ -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:

View File

@ -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"]
})

21
.github/workflows/stale.yml vendored Normal file
View File

@ -0,0 +1,21 @@
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@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"

32
.gitignore vendored
View File

@ -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
@ -48,3 +53,30 @@
/bazel-*
/plugin
/build
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

47
.gitmodules vendored
View File

@ -1,34 +1,39 @@
[submodule "third_party/prometheus-cpp"]
path = third_party/prometheus-cpp
url = https://github.com/jupp0r/prometheus-cpp
branch = master
path = third_party/prometheus-cpp
url = https://github.com/jupp0r/prometheus-cpp
branch = master
[submodule "tools/vcpkg"]
path = tools/vcpkg
url = https://github.com/Microsoft/vcpkg
branch = master
path = tools/vcpkg
url = https://github.com/Microsoft/vcpkg
branch = master
[submodule "third_party/ms-gsl"]
path = third_party/ms-gsl
url = https://github.com/microsoft/GSL
branch = master
path = third_party/ms-gsl
url = https://github.com/microsoft/GSL
branch = main
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://github.com/google/googletest
branch = master
path = third_party/googletest
url = https://github.com/google/googletest
branch = main
[submodule "third_party/benchmark"]
path = third_party/benchmark
url = https://github.com/google/benchmark
branch = master
path = third_party/benchmark
url = https://github.com/google/benchmark
branch = main
[submodule "third_party/opentelemetry-proto"]
path = third_party/opentelemetry-proto
url = https://github.com/open-telemetry/opentelemetry-proto
branch = master
path = third_party/opentelemetry-proto
url = https://github.com/open-telemetry/opentelemetry-proto
branch = main
[submodule "third_party/nlohmann-json"]
path = third_party/nlohmann-json
url = https://github.com/nlohmann/json
branch = master
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

31
.iwyu.imp Normal file
View File

@ -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"] },
]

View File

@ -1,4 +1,8 @@
{
"default": true,
"line-length": false
"MD013":
{
"code_blocks": false,
"tables": false
}
}

33
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,33 @@
{
"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"
}
]
}

File diff suppressed because it is too large Load Diff

View File

@ -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,45 +41,31 @@ if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
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)
# 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()
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)
# 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()
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)
else()
message(
FATAL_ERROR
"opentelemetry-cpp: unrecognized target processor configuration!")
endif()
endforeach()
endif()
message(STATUS "Building for architecture ARCH=${ARCH}")
# Autodetect vcpkg toolchain
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
@ -67,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})
@ -92,55 +132,31 @@ else()
)
endif()
option(WITH_STL "Whether to use Standard Library for C++latest features" OFF)
message(STATUS "OPENTELEMETRY_VERSION=${OPENTELEMETRY_VERSION}")
option(WITH_ABSEIL "Whether to use Abseil for C++latest features" OFF)
option(WITH_NO_DEPRECATED_CODE "Do not include deprecated code" 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(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)
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_ABSEIL)
find_package(absl CONFIG REQUIRED)
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/tools.cmake")
set(CORE_RUNTIME_LIBS absl::bad_variant_access absl::any absl::base
absl::bits absl::city)
# target_link_libraries(main PRIVATE absl::any absl::base absl::bits
# absl::city)
endif()
if(WITH_STL)
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
# the global project build definitions.
add_definitions(-DHAVE_CPP_STDLIB)
add_definitions(-DHAVE_GSL)
# Guidelines Support Library path. Used if we are not on not get C++20.
#
# TODO: respect WITH_ABSEIL as alternate implementation of std::span
find_package(Microsoft.GSL QUIET)
if(TARGET Microsoft.GSL::GSL)
list(APPEND CORE_RUNTIME_LIBS Microsoft.GSL::GSL)
else()
set(GSL_DIR third_party/ms-gsl)
include_directories(${GSL_DIR}/include)
endif()
# Optimize for speed to reduce the hops
# the global project build definitions. Optimize for speed to reduce the hops
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
if(CMAKE_BUILD_TYPE MATCHES Debug)
# Turn off optimizations for DEBUG
@ -155,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"
@ -164,78 +205,92 @@ 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)
if(WITH_NO_GENENV)
add_definitions(-DNO_GETENV)
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)
add_definitions(-DNOMINMAX)
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)
if(WITH_ETW)
add_definitions(-DHAVE_MSGPACK)
endif(WITH_ETW)
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
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
add_compile_options(-Wno-error=deprecated-declarations)
endif()
option(
WITH_API_ONLY
"Only build the API (use as a header-only library). Overrides WITH_EXAMPLES"
"Only build the API (use as a header-only library). Overrides WITH_EXAMPLES and all options to enable exporters"
OFF)
option(WITH_EXAMPLES "Whether to build examples" ON)
option(WITH_METRICS_PREVIEW "Whether to build metrics preview" OFF)
# This requires CURL, OFF by default.
option(
WITH_EXAMPLES_HTTP
"Whether to build http client/server examples. Requires WITH_EXAMPLES and CURL"
OFF)
if(WITH_METRICS_PREVIEW)
add_definitions(-DENABLE_METRICS_PREVIEW)
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
"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()
option(WITH_LOGS_PREVIEW "Whether to build logs preview" OFF)
if(WITH_LOGS_PREVIEW)
add_definitions(-DENABLE_LOGS_PREVIEW)
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(NOT Thrift_FOUND)
# 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
@ -245,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
@ -258,178 +307,379 @@ endif()
# GNUInstallDirs.
include(GNUInstallDirs)
if((NOT WITH_API_ONLY)
#
# Do we need HTTP CLIENT CURL ?
#
if(WITH_OTLP_HTTP
OR WITH_ELASTICSEARCH
OR WITH_ZIPKIN
OR WITH_OTLP
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)
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/prometheus-cpp.cmake")
endif()
#
# Do we need protobuf and/or gRPC ?
#
if(WITH_OTLP_GRPC
OR WITH_OTLP_HTTP
OR WITH_ZPAGES
OR WITH_OTLP_FILE)
# 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()
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/protobuf.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_OTLP_FILE
OR BUILD_W3CTRACECONTEXT_TEST
OR WITH_ETW)
# nlohmann_json package is required for most SDK build configurations
find_package(nlohmann_json QUIET)
if(NOT nlohmann_json_FOUND)
if(EXISTS ${PROJECT_SOURCE_DIR}/.git)
message("Trying to use local nlohmann::json from submodule")
set(JSON_BuildTests
OFF
CACHE INTERNAL "")
set(JSON_Install
ON
CACHE INTERNAL "")
if(EXISTS ${PROJECT_SOURCE_DIR}/third_party/nlohmann-json/CMakeLists.txt)
# 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()
message(
FATAL_ERROR
"\nnlohmann_json 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()
# Let's fail with default find_package error
find_package(nlohmann_json REQUIRED)
endif()
else()
message("Using external nlohmann::json")
endif()
set(USE_NLOHMANN_JSON ON)
else()
set(USE_NLOHMANN_JSON OFF)
endif()
if(WITH_OTLP)
set(protobuf_MODULE_COMPATIBLE ON)
find_package(Protobuf)
find_package(gRPC)
if((NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND) OR (NOT gRPC_FOUND))
if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE))
install_windows_deps()
endif()
if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE))
message(STATUS_FATAL "Windows dependency installation failed!")
endif()
if(WIN32)
include(${CMAKE_TOOLCHAIN_FILE})
endif()
if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND)
find_package(Protobuf REQUIRED)
endif()
if(NOT gRPC_FOUND)
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()
message("PROTOBUF_PROTOC_EXECUTABLE=${PROTOBUF_PROTOC_EXECUTABLE}")
include(cmake/opentelemetry-proto.cmake)
include(CMakeDependentOption)
find_package(CURL)
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)
if((NOT WITH_API_ONLY) AND USE_NLOHMANN_JSON)
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(STATUS "Building with gcc in maintainer mode.")
add_compile_options(-Wall)
add_compile_options(-Werror)
add_compile_options(-Wextra)
# Tested with GCC 9.4 on github.
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.4)
message(STATUS "Building with additional warnings for gcc.")
# Relaxed warnings
# Enforced warnings
# C++ options only
add_compile_options($<$<STREQUAL:$<COMPILE_LANGUAGE>,CXX>:-Wextra-semi>)
add_compile_options(
$<$<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)
add_compile_options(-Wformat-security)
add_compile_options(-Wlogical-op)
add_compile_options(-Wmissing-include-dirs)
add_compile_options(-Wstringop-truncation)
add_compile_options(-Wundef)
add_compile_options(-Wvla)
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
message(STATUS "Building with clang in maintainer mode.")
add_compile_options(-Wall)
add_compile_options(-Werror)
add_compile_options(-Wextra)
# Tested with Clang 11.0 on github.
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0)
message(STATUS "Building with additional warnings for clang.")
# Relaxed warnings
add_compile_options(-Wno-error=unused-private-field)
# Enforced warnings
add_compile_options(-Wcast-qual)
add_compile_options(-Wconditional-uninitialized)
add_compile_options(-Wextra-semi)
add_compile_options(-Wformat-security)
add_compile_options(-Wheader-hygiene)
add_compile_options(-Winconsistent-missing-destructor-override)
add_compile_options(-Winconsistent-missing-override)
add_compile_options(-Wnewline-eof)
add_compile_options(-Wnon-virtual-dtor)
add_compile_options(-Woverloaded-virtual)
add_compile_options(-Wrange-loop-analysis)
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(STATUS "Building with msvc in maintainer mode.")
add_compile_options(/WX)
add_compile_options(/W4)
# Relaxed warnings
add_compile_options(/wd4100)
add_compile_options(/wd4125)
add_compile_options(/wd4566)
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()
endif(OTELCPP_MAINTAINER_MODE)
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}")
include(CTest)
if(BUILD_TESTING)
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)
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)
include_directories(sdk/include)
include_directories(sdk)
include_directories(ext/include)
set(BUILD_TESTING ${BUILD_TESTING})
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()

View File

@ -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 @@
]
}
]
}
}

View File

@ -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 youre 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)

65
DEPRECATED.md Normal file
View File

@ -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

View File

@ -3,40 +3,76 @@
[CMake](https://cmake.org/) and [Bazel](https://bazel.build) are the official
build systems for opentelemetry-cpp.
## Dependencies
You can link OpenTelemetry C++ SDK with libraries provided in
[dependencies.md](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/dependencies.md)
(complete list of libraries with versions used in our CI can be found
[here](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/third_party_release)).
## 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. We use GoogleTest version 1.10.0 in our build system. To
install GoogleTest, consult the [GoogleTest Build
the unittests. Refer to
[third_party_release](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/third_party_release#L5)
for version of GoogleTest used in CI. To install GoogleTest, consult the
[GoogleTest Build
Instructions](https://github.com/google/googletest/blob/master/googletest/README.md#generic-build-instructions).
- [Google Benchmark](https://github.com/google/benchmark) framework to build and
run benchmark tests. Refer to
[third_party_release](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/third_party_release#L4)
for version of Benchmark used in CI. To install Benchmark, consult the
[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 as Standalone CMake Project
### Building dependencies for the OTLP exporters
1. Getting the opentelementry-cpp source:
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 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.
@ -48,8 +84,7 @@ build systems for opentelemetry-cpp.
```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
...
@ -66,12 +101,17 @@ build systems for opentelemetry-cpp.
configuration, the code is compiled without `-fpic` option, so it is not
suitable for inclusion in shared libraries. To enable the code for
inclusion in shared libraries, this variable is used.
- `-DWITH_OTLP=ON` : To enable building Otlp exporter.
- `-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_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
@ -104,56 +144,159 @@ build systems for opentelemetry-cpp.
files for SDK at custom/default install location.
```console
$ cmake --install . --config Debug --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.
NOTE: Experimental, and not supported for all the components. Make sure the
[GoogleTest](https://github.com/google/googletest) installation may fail if
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 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.
- [Bazel](https://www.bazel.build/) for building opentelemetry-cpp API,
SDK with their unittests. We use 3.7.2 in our build system.
- 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++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.
- [Bazel](https://www.bazel.build/) for building opentelemetry-cpp API, SDK with
their unittests. We use 3.7.2 in our build system.
To install Bazel, consult the [Installing Bazel](https://docs.bazel.build/versions/3.7.0/install.html) guide.
To install Bazel, consult the [Installing
Bazel](https://docs.bazel.build/versions/3.7.0/install.html) guide.
### Building as Standalone Bazel Project
### 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
@ -166,9 +309,11 @@ To install Bazel, consult the [Installing Bazel](https://docs.bazel.build/versio
$
```
2. Download the dependencies and build the source code:
2. Navigate to the repository cloned above, download the dependencies and build
the source code:
```console
$ cd opentelemetry-cpp
$ bazel build //...
bazel build -- //... -//exporters/otlp/... -//exporters/prometheus/...
Extracting Bazel installation...
@ -189,3 +334,119 @@ To install Bazel, consult the [Installing Bazel](https://docs.bazel.build/versio
```
4. The build artifacts will be located under `bazel-bin`
### Incorporating into an existing Bazel Project
- WORKSPACE file:
```console
http_archive(
name = "io_opentelemetry_cpp",
sha256 = "<sha256>",
strip_prefix = "opentelemetry-cpp-1.0.1",
urls = [
"https://github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/v1.0.1.tar.gz"
],
)
# Load OpenTelemetry dependencies after load.
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")
grpc_deps()
# Load extra gRPC dependencies due to https://github.com/grpc/grpc/issues/20511
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
grpc_extra_deps()
```
- Component level BUILD file:
```console
cc_library(
name = "<name>"
...
deps = [
"@io_opentelemetry_cpp//api",
"@io_opentelemetry_cpp//exporters/otlp:otlp_exporter",
"@io_opentelemetry_cpp//sdk/src/trace",
...
],
...
)
```
## Building shared libs for Windows
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
If you are using [Conan](https://www.conan.io/) to manage your dependencies, add
[`opentelemetry-cpp/x.y.z`](https://conan.io/center/opentelemetry-cpp) to your
`conanfile`'s requires, where `x.y.z` is the release version you want to use.
Please file issues [here](https://github.com/conan-io/conan-center-index/issues)
if you experience problems with the packages.
If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project
for external dependencies, then you can install the [opentelemetry-cpp
package](https://github.com/microsoft/vcpkg/tree/master/ports/opentelemetry-cpp)
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.

25
MODULE.bazel Normal file
View File

@ -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")

107
README.md
View File

@ -5,37 +5,27 @@
[![Build
Status](https://github.com/open-telemetry/opentelemetry-cpp/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/open-telemetry/opentelemetry-cpp/actions)
[![Release](https://img.shields.io/github/v/release/open-telemetry/opentelemetry-cpp?include_prereleases&style=)](https://github.com/open-telemetry/opentelemetry-cpp/releases/)
[![FOSSA License Status](https://app.fossa.com/api/projects/custom%2B162%2Fgithub.com%2Fopen-telemetry%2Fopentelemetry-cpp.svg?type=shield&issueType=license)](https://app.fossa.com/projects/custom%2B162%2Fgithub.com%2Fopen-telemetry%2Fopentelemetry-cpp?ref=badge_shield&issueType=license)
[![FOSSA Security Status](https://app.fossa.com/api/projects/custom%2B162%2Fgithub.com%2Fopen-telemetry%2Fopentelemetry-cpp.svg?type=shield&issueType=security)](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 | Development paused [1] | N/A |
| Logs | Experimental [2] | N/A |
**Stable** across all 3 signals i.e. `Logs`, `Metrics`, and `Traces`.
* [1]: The development of the metrics API and SDK has paused due to limited development resources, prioritization of a stable Traces release, and waiting for availability of stable Metrics (API + SDK) design from the OpenTelemetry specification. The current implementation can be included in build by setting `ENABLE_METRICS_PREVIEW` preprocessor macro.
* [2]: 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.0.0 | 1.0.0-rc4 | N/A [1] |
| 1.0.0 | 1.0.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.
@ -50,23 +40,20 @@ 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).
## Dependencies
Please refer to [Dependencies.md](docs/dependencies.md) for OSS Dependencies and license requirements.
Please refer to [Dependencies.md](docs/dependencies.md) for OSS Dependencies and
license requirements.
## Installation
@ -74,7 +61,9 @@ Please refer to [INSTALL.md](./INSTALL.md).
## Getting Started
As an application owner or the library author, you can find the getting started guide and reference documentation on [opentelemetry-cpp.readthedocs.io](https://opentelemetry-cpp.readthedocs.io/en/latest/)
As an application owner or the library author, you can find the getting started
guide and reference documentation on
[opentelemetry-cpp.readthedocs.io](https://opentelemetry-cpp.readthedocs.io/en/latest/)
The `examples/simple` directory contains a minimal program demonstrating how to
instrument a small library using a simple `processor` and console `exporter`,
@ -84,50 +73,46 @@ along with build files for CMake and Bazel.
See [CONTRIBUTING.md](CONTRIBUTING.md)
We meet weekly, and the time of the meeting alternates between Monday at 15:00
PT and Wednesday at 10:00 PT. The meeting is subject to change depending on
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)
for specific dates.
Meetings take place via [Zoom video conference](https://zoom.us/j/6729396170).
The passcode is _77777_.
calendar](https://github.com/open-telemetry/community#calendar)
for specific dates and Zoom meeting links.
Meeting notes are available as a public [Google
doc](https://docs.google.com/document/d/1i1E4-_y4uJ083lCutKGDhkpi3n4_e774SBLi9hPLocw/edit?usp=sharing).
For edit access, get in touch on
[Slack](https://cloud-native.slack.com/archives/C01N3AT62SJ).
Approvers
([@open-telemetry/cpp-approvers](https://github.com/orgs/open-telemetry/teams/cpp-approvers)):
### Maintainers
* [Johannes Tax](https://github.com/pyohannes), Microsoft
* [Josh Suereth](https://github.com/jsuereth), Google
* [Max Golovanov](https://github.com/maxgolov), Microsoft
* [Ryan Burn](https://github.com/rnburn), Lightstep
*Find more about the approver role in [community
repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver).*
Maintainers
([@open-telemetry/cpp-maintainers](https://github.com/orgs/open-telemetry/teams/cpp-maintainers)):
* [Emil Mikulic](https://github.com/g-easy), Google
* [Ehsan Saei](https://github.com/esigo)
* [Lalit Kumar Bhasin](https://github.com/lalitb), Microsoft
* [Reiley Yang](https://github.com/reyang), Microsoft
* [Marc Alff](https://github.com/marcalff), Oracle
* [Tom Tan](https://github.com/ThomsonTan), Microsoft
*Find more about the maintainer role in [community
repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer).*
For more information about the maintainer role, see the [community repository](https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md#maintainer).
Triagers
([@open-telemetry/cpp-triagers](https://github.com/orgs/open-telemetry/teams/cpp-triagers)):
### Approvers
* [Alolita Sharma](https://github.com/alolita), Amazon
* [Jodee Varney](https://github.com/jodeev), New Relic
* [Doug Barker](https://github.com/dbarker)
* [Josh Suereth](https://github.com/jsuereth), Google
* [Pranav Sharma](https://github.com/psx95), Google
* [WenTao Ou](https://github.com/owent), Tencent
*Find more about the triager role in [community
repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#triager).*
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
@ -135,8 +120,6 @@ repository](https://github.com/open-telemetry/community/blob/main/community-memb
## 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.

View File

@ -2,24 +2,27 @@
## Pre Release
1: Make sure all relevant changes for this release are included under
1: Upgrade to latest [dependencies](docs/maintaining-dependencies.md)
if required.
2: Make sure all relevant changes for this release are included under
`Unreleased` section in `CHANGELOG.md` and are in language that non-contributors
to the project can understand.
2: Run the pre-release script. It creates a branch `pre_release_<new-tag>` and
3: Run the pre-release script. It creates a branch `pre_release_<new-tag>` and
updates `CHANGELOG.md` with the `<new-tag>`:
```sh
./buildscripts/pre_release.sh -t <new-tag>
```
3: Verify that CHANGELOG.md is updated properly:
4: Verify that CHANGELOG.md is updated properly:
```sh
git diff main
```
4: Push the changes to upstream and create a Pull Request on GitHub. Be sure to
5: Push the changes to upstream and create a Pull Request on GitHub. Be sure to
include the curated changes from the [Changelog](./CHANGELOG.md) in the
description.
@ -89,5 +92,5 @@ should include all the release notes from the Changelog for this release.
## Post Release
Update the OpenTelemetry.io document
[here](https://github.com/open-telemetry/opentelemetry.io/tree/main/content/en/docs/cpp)
[here](https://github.com/open-telemetry/opentelemetry.io/tree/main/content/en/docs/instrumentation/cpp)
by sending a Pull Request.

View File

@ -19,20 +19,20 @@ buy may not work in applications using `opentelemetry 2.0.0`.
Refer to the [ABI Policy](./docs/abi-policy.md) for more details. To summarise:
* The API is header only, and uses ABI compliant interfaces. However, ABI stability
is not guaranteed for SDK.
* In case of ABI breaking changes, a new `inline namespace` version will
be introduced, and the existing linked applications can continue using the older version
unless they relink with newer version.
* The API is header only, and uses ABI compliant interfaces. However, ABI
stability is not guaranteed for SDK.
* In case of ABI breaking changes, a new `inline namespace` version will be
introduced, and the existing linked applications can continue using the older
version unless they relink with newer version.
## Release Policy
* Release versions will follow [SemVer 2.0](https://semver.org/).
* Only a single source package containing the API, SDK, and exporters which are
required by the specification would be released. All these components are
always versioned and released together. For example, any changes in one of the exporter
would result in version update of the entire source package even though there is
no changes in API, SDK and other exporters.
always versioned and released together. For example, any changes in one of the
exporter would result in version update of the entire source package even
though there is no changes in API, SDK and other exporters.
* Experimental releases: New (unstable) telemetry signals and features will be
introduced behind feature flag protected by a preprocessor macro.
@ -52,7 +52,7 @@ Refer to the [ABI Policy](./docs/abi-policy.md) for more details. To summarise:
* Naming:
* `ENABLE_<SIGNAL>_PREVIEW` : For experimental release of signal api/sdks
eg, `METRICS_PREVIEW`, `LOGGING_PREVIEW`,
eg, `METRICS_PREVIEW`, `LOGS_PREVIEW`,
* `ENABLE_<SIGNAL>_<FEATURE_NAME>_PREVIEW` : For experimental release for
any feature within stable signal. For example, `TRACING_JAEGER_PREVIEW` to
release the experimental Jaeger exporter for tracing.
@ -65,16 +65,19 @@ Refer to the [ABI Policy](./docs/abi-policy.md) for more details. To summarise:
allowed to break existing stable interfaces. Feature flags will be removed
once we have a stable implementation for the signal.
* As an exception, small experimental features in otherwise stable signals/components
mayn't necessarily be released under feature flag. These would be flagged as experimental
by adding a `NOTE` in it's header file - either at the beginning of file, or as the comment for
the experimental API methods. Also, if the complete header is experimental, it would be prefixed
as `experimental_`. As an example, the semantic conventions for
trace signal is experimental at the time of the writing and is within `experimental_semantic_conventions.h`
* As an exception, small experimental features in otherwise stable
signals/components mayn't necessarily be released under feature flag. These
would be flagged as experimental by adding a `NOTE` in it's header file -
either at the beginning of file, or as the comment for the experimental API
methods. Also, if the complete header is experimental, it would be prefixed as
`experimental_`. As an example, the semantic conventions for trace signal is
experimental at the time of the writing and is within
`experimental_semantic_conventions.h`
* Code under the "*::detail" namespace implements internal details,
and NOT part of public interface. Also, any API not documented in the [public
documentation](https://opentelemetry-cpp.readthedocs.io/en/latest/) is NOT part of public interface.
* Code under the "*::detail" namespace implements internal details, and is NOT
part of public interface. Also, any API not documented in the [public
documentation](https://opentelemetry-cpp.readthedocs.io/en/latest/) is NOT
part of the public interface.
* GitHub releases will be made for all released versions.

View File

@ -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,6 +8,10 @@ load("//bazel:repository.bzl", "opentelemetry_cpp_deps")
opentelemetry_cpp_deps()
load("//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")
@ -28,13 +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 prometheus C++ dependencies.
load("@com_github_jupp0r_prometheus_cpp//bazel:repositories.bzl", "prometheus_cpp_repositories")
prometheus_cpp_repositories()

4
WORKSPACE.bzlmod Normal file
View File

@ -0,0 +1,4 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0
# Disables the default WORKSPACE when using bzlmod

View File

@ -1,21 +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", "int_flag", "string_flag")
package(default_visibility = ["//visibility:public"])
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({
":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 = [
"@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 = "abi_version_no_1",
flag_values = {":abi_version_no": "1"},
)
config_setting(
name = "abi_version_no_2",
flag_values = {":abi_version_no": "2"},
)

View File

@ -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

View File

@ -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,53 +9,130 @@ 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)
target_compile_definitions(opentelemetry_api INTERFACE HAVE_ABSEIL)
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
HAVE_GSL)
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(CORE_RUNTIME_LIBS)
target_link_libraries(opentelemetry_api INTERFACE ${CORE_RUNTIME_LIBS})
if(WITH_GSL)
target_compile_definitions(opentelemetry_api INTERFACE HAVE_GSL)
target_link_libraries(opentelemetry_api INTERFACE Microsoft.GSL::GSL)
list(APPEND TARGET_DEPS "gsl")
endif()
if(WITH_NO_GETENV)
target_compile_definitions(opentelemetry_api INTERFACE NO_GETENV)
endif()
if(WIN32)
if(WITH_ETW)
target_compile_definitions(opentelemetry_api INTERFACE HAVE_MSGPACK)
endif()
endif()
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()

View File

@ -1,4 +1,4 @@
// Copyright The OpenTelemetry Authors
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#pragma once
@ -6,6 +6,7 @@
#include <cctype>
#include "opentelemetry/common/kv_properties.h"
#include "opentelemetry/common/macros.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/version.h"
@ -15,7 +16,7 @@ OPENTELEMETRY_BEGIN_NAMESPACE
namespace baggage
{
class Baggage
class OPENTELEMETRY_EXPORT Baggage
{
public:
static constexpr size_t kMaxKeyValuePairs = 180;
@ -25,15 +26,15 @@ public:
static constexpr char kMembersSeparator = ',';
static constexpr char kMetadataSeparator = ';';
Baggage() : kv_properties_(new opentelemetry::common::KeyValueProperties()) {}
Baggage(size_t size) : 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)
: kv_properties_(new opentelemetry::common::KeyValueProperties(keys_and_values))
Baggage(const T &keys_and_values) noexcept
: kv_properties_(new common::KeyValueProperties(keys_and_values))
{}
static nostd::shared_ptr<Baggage> GetDefault()
OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr<Baggage> GetDefault()
{
static nostd::shared_ptr<Baggage> baggage{new Baggage()};
return baggage;
@ -42,7 +43,7 @@ public:
/* Get value for key in the baggage
@returns true if key is found, false otherwise
*/
bool GetValue(nostd::string_view key, std::string &value) const
bool GetValue(nostd::string_view key, std::string &value) const noexcept
{
return kv_properties_->GetValue(key, value);
}
@ -50,7 +51,8 @@ public:
/* Returns shared_ptr of new baggage object which contains new key-value pair. If key or value is
invalid, copy of current baggage is returned
*/
nostd::shared_ptr<Baggage> Set(const nostd::string_view &key, const nostd::string_view &value)
nostd::shared_ptr<Baggage> Set(const nostd::string_view &key,
const nostd::string_view &value) noexcept
{
nostd::shared_ptr<Baggage> baggage(new Baggage(kv_properties_->Size() + 1));
@ -89,7 +91,7 @@ public:
// if key does not exist, copy of current baggage is returned.
// Validity of key is not checked as invalid keys should never be populated in baggage in the
// first place.
nostd::shared_ptr<Baggage> Delete(nostd::string_view key)
nostd::shared_ptr<Baggage> Delete(nostd::string_view key) noexcept
{
// keeping size of baggage same as key might not be found in it
nostd::shared_ptr<Baggage> baggage(new Baggage(kv_properties_->Size()));
@ -103,7 +105,7 @@ public:
}
// Returns shared_ptr of baggage after extracting key-value pairs from header
static nostd::shared_ptr<Baggage> FromHeader(nostd::string_view header)
static nostd::shared_ptr<Baggage> FromHeader(nostd::string_view header) noexcept
{
if (header.size() > kMaxSize)
{
@ -158,7 +160,7 @@ public:
}
// Creates string from baggage object.
std::string ToHeader() const
std::string ToHeader() const noexcept
{
std::string header_s;
bool first = true;
@ -249,7 +251,9 @@ private:
};
auto from_hex = [](char c) -> char {
return std::isdigit(c) ? c - '0' : std::toupper(c) - 'A' + 10;
// c - '0' produces integer type which could trigger error/warning when casting to char,
// but the cast is safe here.
return static_cast<char>(std::isdigit(c) ? c - '0' : std::toupper(c) - 'A' + 10);
};
std::string ret;
@ -287,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

View File

@ -15,21 +15,19 @@ namespace baggage
static const std::string kBaggageHeader = "baggage";
inline nostd::shared_ptr<opentelemetry::baggage::Baggage> GetBaggage(
const opentelemetry::context::Context &context)
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)
inline context::Context SetBaggage(context::Context &context,
const nostd::shared_ptr<Baggage> &baggage) noexcept
{
return context.SetValue(kBaggageHeader, baggage);
}

View File

@ -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,22 +20,34 @@ 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);
carrier.Set(kBaggageHeader, baggage->ToHeader());
auto baggage = baggage::GetBaggage(context);
auto header = baggage->ToHeader();
if (header.size())
{
carrier.Set(kBaggageHeader, header);
}
}
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);
return opentelemetry::baggage::SetBaggage(context, baggage);
nostd::string_view baggage_str = carrier.Get(baggage::kBaggageHeader);
auto baggage = baggage::Baggage::FromHeader(baggage_str);
if (baggage->ToHeader().size())
{
return baggage::SetBaggage(context, baggage);
}
else
{
return context;
}
}
bool Fields(nostd::function_ref<bool(nostd::string_view)> callback) const noexcept override

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"
@ -33,7 +32,7 @@ class KeyValueStringTokenizer
public:
KeyValueStringTokenizer(
nostd::string_view str,
const KeyValueStringTokenizerOptions &opts = KeyValueStringTokenizerOptions())
const KeyValueStringTokenizerOptions &opts = KeyValueStringTokenizerOptions()) noexcept
: str_(str), opts_(opts), index_(0)
{}
@ -48,7 +47,7 @@ public:
// @param key : key in kv pair
// @param key : value in kv pair
// @returns true if next kv pair was found, false otherwise.
bool next(bool &valid_kv, nostd::string_view &key, nostd::string_view &value)
bool next(bool &valid_kv, nostd::string_view &key, nostd::string_view &value) noexcept
{
valid_kv = true;
while (index_ < str_.size())
@ -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.
@ -170,13 +169,13 @@ public:
}
// Gets the key associated with this entry.
nostd::string_view GetKey() const { return key_.get(); }
nostd::string_view GetKey() const noexcept { return key_.get(); }
// Gets the value associated with this entry.
nostd::string_view GetValue() const { return value_.get(); }
nostd::string_view GetValue() const noexcept { return value_.get(); }
// Sets the value for this entry. This overrides the previous value.
void SetValue(nostd::string_view value) { value_ = CopyStringToPointer(value); }
void SetValue(nostd::string_view value) noexcept { value_ = CopyStringToPointer(value); }
private:
// Store key and value as raw char pointers to avoid using std::string.
@ -206,15 +205,15 @@ public:
public:
// Create Key-value list of given size
// @param size : Size of list.
KeyValueProperties(size_t size)
KeyValueProperties(size_t size) noexcept
: num_entries_(0), max_num_entries_(size), entries_(new Entry[size])
{}
// Create Empty Key-Value list
KeyValueProperties() : num_entries_(0), max_num_entries_(0), entries_(nullptr) {}
KeyValueProperties() noexcept : num_entries_(0), max_num_entries_(0), entries_(nullptr) {}
template <class T, class = typename std::enable_if<detail::is_key_value_iterable<T>::value>::type>
KeyValueProperties(const T &keys_and_values)
KeyValueProperties(const T &keys_and_values) noexcept
: num_entries_(0),
max_num_entries_(keys_and_values.size()),
entries_(new Entry[max_num_entries_])
@ -227,7 +226,7 @@ public:
}
// Adds new kv pair into kv properties
void AddEntry(nostd::string_view key, nostd::string_view value)
void AddEntry(nostd::string_view key, nostd::string_view value) noexcept
{
if (num_entries_ < max_num_entries_)
{
@ -238,7 +237,7 @@ public:
// Returns all kv pair entries
bool GetAllEntries(
nostd::function_ref<bool(nostd::string_view, nostd::string_view)> callback) const
nostd::function_ref<bool(nostd::string_view, nostd::string_view)> callback) const noexcept
{
for (size_t i = 0; i < num_entries_; i++)
{
@ -252,7 +251,7 @@ public:
}
// Return value for key if exists, return false otherwise
bool GetValue(nostd::string_view key, std::string &value) const
bool GetValue(nostd::string_view key, std::string &value) const noexcept
{
for (size_t i = 0; i < num_entries_; i++)
{
@ -270,4 +269,4 @@ public:
size_t Size() const noexcept { return num_entries_; }
};
} // namespace common
OPENTELEMETRY_END_NAMESPACE
OPENTELEMETRY_END_NAMESPACE

View File

@ -0,0 +1,523 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#pragma once
/*
OPENTELEMETRY_HAVE_BUILTIN&OPENTELEMETRY_HAVE_FEATURE
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
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_CONDITION(C) (C) [[likely]]
# endif
# endif
# endif
#endif
#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_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
/// usage:
/// OPENTELEMETRY_MAYBE_UNUSED int a;
/// class OPENTELEMETRY_MAYBE_UNUSED a;
/// OPENTELEMETRY_MAYBE_UNUSED int a();
///
#if defined(__cplusplus) && __cplusplus >= 201703L
# define OPENTELEMETRY_MAYBE_UNUSED [[maybe_unused]]
#elif defined(__clang__)
# define OPENTELEMETRY_MAYBE_UNUSED __attribute__((unused))
#elif defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
# define OPENTELEMETRY_MAYBE_UNUSED __attribute__((unused))
#elif (defined(_MSC_VER) && _MSC_VER >= 1910) && (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
# define OPENTELEMETRY_MAYBE_UNUSED [[maybe_unused]]
#else
# define OPENTELEMETRY_MAYBE_UNUSED
#endif
#ifndef OPENTELEMETRY_RTTI_ENABLED
# if defined(__clang__)
# if __has_feature(cxx_rtti)
# define OPENTELEMETRY_RTTI_ENABLED
# endif
# elif defined(__GNUG__)
# if defined(__GXX_RTTI)
# define OPENTELEMETRY_RTTI_ENABLED
# endif
# elif defined(_MSC_VER)
# if defined(_CPPRTTI)
# define OPENTELEMETRY_RTTI_ENABLED
# endif
# endif
#endif
#if defined(__cplusplus) && __cplusplus >= 201402L
# define OPENTELEMETRY_DEPRECATED [[deprecated]]
#elif defined(__clang__)
# define OPENTELEMETRY_DEPRECATED __attribute__((deprecated))
#elif defined(__GNUC__)
# define OPENTELEMETRY_DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER)
# if _MSC_VER >= 1910 && defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
# define OPENTELEMETRY_DEPRECATED [[deprecated]]
# else
# define OPENTELEMETRY_DEPRECATED __declspec(deprecated)
# endif
#else
# define OPENTELEMETRY_DEPRECATED
#endif
#if defined(__cplusplus) && __cplusplus >= 201402L
# define OPENTELEMETRY_DEPRECATED_MESSAGE(msg) [[deprecated(msg)]]
#elif defined(__clang__)
# define OPENTELEMETRY_DEPRECATED_MESSAGE(msg) __attribute__((deprecated(msg)))
#elif defined(__GNUC__)
# define OPENTELEMETRY_DEPRECATED_MESSAGE(msg) __attribute__((deprecated(msg)))
#elif defined(_MSC_VER)
# if _MSC_VER >= 1910 && defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
# define OPENTELEMETRY_DEPRECATED_MESSAGE(msg) [[deprecated(msg)]]
# else
# define OPENTELEMETRY_DEPRECATED_MESSAGE(msg) __declspec(deprecated(msg))
# endif
#else
# define OPENTELEMETRY_DEPRECATED_MESSAGE(msg)
#endif
// Regex support
#if (__GNUC__ == 4 && (__GNUC_MINOR__ == 8 || __GNUC_MINOR__ == 9))
# define OPENTELEMETRY_HAVE_WORKING_REGEX 0
#else
# define OPENTELEMETRY_HAVE_WORKING_REGEX 1
#endif
/* clang-format off */
/**
@page HEADER_ONLY_SINGLETON Header only singleton.
@section ELF_SINGLETON
For clang and gcc, the desired coding pattern is as follows.
@verbatim
class Foo
{
// (a)
__attribute__((visibility("default")))
// (b)
T& get_singleton()
{
// (c)
static T singleton;
return singleton;
}
};
@endverbatim
(a) is needed when the code is build with
@code -fvisibility="hidden" @endcode
to ensure that all instances of (b) are visible to the linker.
What is duplicated in the binary is @em code, in (b).
The linker will make sure only one instance
of all the (b) methods is used.
(c) is a singleton implemented inside a method.
This is very desirable, because:
- the C++ compiler guarantees that construction
of the variable (c) is thread safe.
- constructors for (c) singletons are executed in code path order,
or not at all if the singleton is never used.
@section OTHER_SINGLETON
For other platforms, header only singletons are not supported at this
point.
@section CODING_PATTERN
The coding pattern to use in the source code is as follows
@verbatim
class Foo
{
OPENTELEMETRY_API_SINGLETON
T& get_singleton()
{
static T singleton;
return singleton;
}
};
@endverbatim
*/
/* clang-format on */
#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

View File

@ -10,13 +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
@ -53,10 +53,29 @@ 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
{
// Issue a Pause/Yield instruction while spinning.
#if defined(_MSC_VER)
YieldProcessor();
#elif defined(__i386__) || defined(__x86_64__)
# if defined(__clang__) || defined(__INTEL_COMPILER)
_mm_pause();
# else
__builtin_ia32_pause();
# endif
#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
}
/**
* Attempts to lock the mutex. Return immediately with `true` (success) or `false` (failure).
@ -90,22 +109,7 @@ public:
{
return;
}
// Issue a Pause/Yield instruction while spinning.
#if defined(_MSC_VER)
YieldProcessor();
#elif defined(__i386__) || defined(__x86_64__)
# if defined(__clang__)
_mm_pause();
# else
__builtin_ia32_pause();
# endif
#elif defined(__arm__)
// This intrinsic should fail to be found if YIELD is not supported on the current
// processor.
__yield();
#else
// TODO: Issue PAGE/YIELD on other architectures.
#endif
fast_yield();
}
// Yield then try again (goal ~100ns)
std::this_thread::yield();

View File

@ -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
@ -26,20 +13,20 @@ namespace common
class StringUtil
{
public:
static nostd::string_view Trim(nostd::string_view str, size_t left, size_t right)
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--;
}
return str.substr(left, 1 + right - left);
}
static nostd::string_view Trim(nostd::string_view str)
static nostd::string_view Trim(nostd::string_view str) noexcept
{
if (str.empty())
{

View File

@ -3,7 +3,6 @@
#pragma once
#include <algorithm>
#include <chrono>
#include <cstdint>
@ -169,5 +168,39 @@ public:
private:
int64_t nanos_since_epoch_;
};
class DurationUtil
{
public:
template <class Rep, class Period>
static std::chrono::duration<Rep, Period> AdjustWaitForTimeout(
std::chrono::duration<Rep, Period> timeout,
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)())
{
return indefinite_value;
}
// 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());
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());
if (timeout >= max_timeout)
{
return indefinite_value;
}
return timeout;
}
};
} // namespace common
OPENTELEMETRY_END_NAMESPACE

View File

@ -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

View File

@ -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
@ -24,17 +28,15 @@ public:
// Creates a context object from a map of keys and identifiers, this will
// hold a shared_ptr to the head of the DataList linked list
template <class T>
Context(const T &keys_and_values)
{
head_ = nostd::shared_ptr<DataList>{new DataList(keys_and_values)};
}
Context(const T &keys_and_values) noexcept
: 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)
{
head_ = nostd::shared_ptr<DataList>{new DataList(key, value)};
}
Context(nostd::string_view key, ContextValue value) noexcept
: 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

View File

@ -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,

View File

@ -1,10 +1,13 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#include <initializer_list>
#pragma once
#include <memory>
#include <vector>
#include "opentelemetry/context/propagation/text_map_propagator.h"
#include "opentelemetry/version.h"
OPENTELEMETRY_BEGIN_NAMESPACE
namespace context
@ -87,4 +90,4 @@ private:
};
} // namespace propagation
} // namespace context
OPENTELEMETRY_END_NAMESPACE;
OPENTELEMETRY_END_NAMESPACE

View File

@ -6,8 +6,8 @@
#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"
#include "opentelemetry/nostd/shared_ptr.h"
@ -19,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
@ -30,20 +32,20 @@ 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;
}
private:
static nostd::shared_ptr<TextMapPropagator> &GetPropagator() noexcept
OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr<TextMapPropagator> &GetPropagator() noexcept
{
static nostd::shared_ptr<TextMapPropagator> propagator(new NoOpPropagator());
return propagator;
}
static common::SpinLockMutex &GetLock() noexcept
OPENTELEMETRY_API_SINGLETON static common::SpinLockMutex &GetLock() noexcept
{
static common::SpinLockMutex lock;
return lock;
@ -52,4 +54,4 @@ private:
} // namespace propagation
} // namespace context
OPENTELEMETRY_END_NAMESPACE
OPENTELEMETRY_END_NAMESPACE

View File

@ -26,13 +26,15 @@ public:
}
/** Noop inject function does nothing */
void Inject(TextMapCarrier & /*carrier*/, const context::Context &context) noexcept override {}
void Inject(TextMapCarrier & /*carrier*/,
const context::Context & /* context */) noexcept override
{}
bool Fields(nostd::function_ref<bool(nostd::string_view)> callback) const noexcept override
bool Fields(nostd::function_ref<bool(nostd::string_view)> /* callback */) const noexcept override
{
return true;
}
};
} // namespace propagation
} // namespace context
OPENTELEMETRY_END_NAMESPACE
OPENTELEMETRY_END_NAMESPACE

View File

@ -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"
@ -26,7 +26,7 @@ public:
/* list of all the keys in the carrier.
By default, it returns true without invoking callback */
virtual bool Keys(nostd::function_ref<bool(nostd::string_view)> callback) const noexcept
virtual bool Keys(nostd::function_ref<bool(nostd::string_view)> /* callback */) const noexcept
{
return true;
}

View File

@ -1,9 +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
@ -17,13 +26,11 @@ class Token
public:
bool operator==(const Context &other) const noexcept { return context_ == other; }
~Token();
~Token() noexcept;
private:
friend class RuntimeContextStorage;
Token() noexcept = default;
// A constructor that sets the token's Context object to the
// one that was passed in.
Token(const Context &context) : context_(context) {}
@ -38,7 +45,7 @@ private:
* this class and passing an initialized RuntimeContextStorage object to
* RuntimeContext::SetRuntimeContextStorage.
*/
class RuntimeContextStorage
class OPENTELEMETRY_EXPORT RuntimeContextStorage
{
public:
/**
@ -49,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;
@ -61,7 +68,7 @@ public:
*/
virtual bool Detach(Token &token) noexcept = 0;
virtual ~RuntimeContextStorage(){};
virtual ~RuntimeContextStorage() {}
protected:
nostd::unique_ptr<Token> CreateToken(const Context &context) noexcept
@ -79,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.
@ -145,25 +152,38 @@ 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;
}
/**
* Provide a pointer to const runtime context storage.
*
* The returned pointer can only be used for extending the lifetime of the runtime context
* storage.
*
*/
static nostd::shared_ptr<const RuntimeContextStorage> GetConstRuntimeContextStorage() noexcept
{
return GetRuntimeContextStorage();
}
private:
static nostd::shared_ptr<RuntimeContextStorage> GetRuntimeContextStorage() noexcept
{
return GetStorage();
}
static nostd::shared_ptr<RuntimeContextStorage> &GetStorage() noexcept
OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr<RuntimeContextStorage> &GetStorage() noexcept
{
static nostd::shared_ptr<RuntimeContextStorage> context(GetDefaultStorage());
return context;
}
};
inline Token::~Token()
inline Token::~Token() noexcept
{
context::RuntimeContext::Detach(*this);
}
@ -221,7 +241,7 @@ private:
{
friend class ThreadLocalContextStorage;
Stack() noexcept : size_(0), capacity_(0), base_(nullptr){};
Stack() noexcept : size_(0), capacity_(0), base_(nullptr) {}
// Pops the top Context off the stack.
void Pop() noexcept
@ -305,7 +325,7 @@ private:
Context *base_;
};
Stack &GetStack()
OPENTELEMETRY_API_SINGLETON Stack &GetStack()
{
static thread_local Stack stack_ = Stack();
return stack_;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -2,29 +2,25 @@
// SPDX-License-Identifier: Apache-2.0
#pragma once
#ifdef ENABLE_LOGS_PREVIEW
# include <chrono>
# include <map>
# include <vector>
# include "opentelemetry/common/attribute_value.h"
# include "opentelemetry/common/key_value_iterable.h"
# include "opentelemetry/common/key_value_iterable_view.h"
# include "opentelemetry/common/timestamp.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/type_traits.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/logs/logger_type_traits.h"
#include "opentelemetry/logs/severity.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
{
class EventId;
class LogRecord;
/**
* Handles log record creation.
**/
@ -37,553 +33,460 @@ public:
virtual const nostd::string_view GetName() noexcept = 0;
/**
* Each of the following overloaded Log(...) methods
* creates a log message with the specific parameters passed.
* Create a Log Record object
*
* @param severity the severity level of the log event.
* @param name the name of the log event.
* @param message the string message of the log (perhaps support std::fmt or fmt-lib format).
* @param resource the resources, stored as a 2D list of key/value pairs, that are associated
* with the log event.
* @param attributes the attributes, stored as a 2D list of key/value pairs, that are associated
* with the log event.
* @param trace_id the trace id associated with the log event.
* @param span_id the span id associate with the log event.
* @param trace_flags the trace flags associated with the log event.
* @param timestamp the timestamp the log record was created.
* @throws No exceptions under any circumstances.
* @return nostd::unique_ptr<LogRecord>
*/
virtual nostd::unique_ptr<LogRecord> CreateLogRecord() noexcept = 0;
/**
* The base Log(...) method that all other Log(...) overloaded methods will eventually call,
* in order to create a log record.
* Emit a Log Record object
*
* Note this takes in a KeyValueIterable for the resource and attributes fields.
* @param log_record Log record
*/
virtual void EmitLogRecord(nostd::unique_ptr<LogRecord> &&log_record) noexcept = 0;
/**
* Emit a Log Record object with arguments
*
* @param log_record Log record
* @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,trace_id and trace_flags
* SpanId -> span_id
* TraceId -> trace_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 EmitLogRecord(nostd::unique_ptr<LogRecord> &&log_record, ArgumentType &&...args)
{
if (!log_record)
{
return;
}
//
// Keep the parameter pack unpacking order from left to right because left
// ones are usually more important like severity and event_id than the
// attributes. The left to right unpack order could pass the more important
// data to processors to avoid caching and memory allocating.
//
#if __cplusplus <= 201402L
// C++14 does not support fold expressions for parameter pack expansion.
int dummy[] = {(detail::LogRecordSetterTrait<typename std::decay<ArgumentType>::type>::Set(
log_record.get(), std::forward<ArgumentType>(args)),
0)...};
IgnoreTraitResult(dummy);
#else
IgnoreTraitResult((detail::LogRecordSetterTrait<typename std::decay<ArgumentType>::type>::Set(
log_record.get(), std::forward<ArgumentType>(args)),
...));
#endif
EmitLogRecord(std::move(log_record));
}
/**
* Emit a Log Record object with arguments
*
* @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,trace_id and trace_flags
* SpanId -> span_id
* TraceId -> trace_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 EmitLogRecord(ArgumentType &&...args)
{
nostd::unique_ptr<LogRecord> log_record = CreateLogRecord();
EmitLogRecord(std::move(log_record), std::forward<ArgumentType>(args)...);
}
/**
* Writes a log with a severity of trace.
* @param args Arguments which can be used to set data of log record by type.
* string_view -> body
* AttributeValue -> body
* SpanContext -> span_id,trace_id and trace_flags
* SpanId -> span_id
* TraceId -> trace_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 Trace(ArgumentType &&...args) noexcept
{
static_assert(
!detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value,
"Severity is already set.");
this->EmitLogRecord(Severity::kTrace, std::forward<ArgumentType>(args)...);
}
/**
* Writes a log with a severity of debug.
* @param args Arguments which can be used to set data of log record by type.
* string_view -> body
* AttributeValue -> body
* SpanContext -> span_id,trace_id and trace_flags
* SpanId -> span_id
* TraceId -> trace_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 Debug(ArgumentType &&...args) noexcept
{
static_assert(
!detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value,
"Severity is already set.");
this->EmitLogRecord(Severity::kDebug, std::forward<ArgumentType>(args)...);
}
/**
* Writes a log with a severity of info.
* @param args Arguments which can be used to set data of log record by type.
* string_view -> body
* AttributeValue -> body
* SpanContext -> span_id,trace_id and trace_flags
* SpanId -> span_id
* TraceId -> trace_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 Info(ArgumentType &&...args) noexcept
{
static_assert(
!detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value,
"Severity is already set.");
this->EmitLogRecord(Severity::kInfo, std::forward<ArgumentType>(args)...);
}
/**
* Writes a log with a severity of warn.
* @param args Arguments which can be used to set data of log record by type.
* string_view -> body
* AttributeValue -> body
* SpanContext -> span_id,trace_id and trace_flags
* SpanId -> span_id
* TraceId -> trace_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 Warn(ArgumentType &&...args) noexcept
{
static_assert(
!detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value,
"Severity is already set.");
this->EmitLogRecord(Severity::kWarn, std::forward<ArgumentType>(args)...);
}
/**
* Writes a log with a severity of error.
* @param args Arguments which can be used to set data of log record by type.
* string_view -> body
* AttributeValue -> body
* SpanContext -> span_id,trace_id and trace_flags
* SpanId -> span_id
* TraceId -> trace_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 Error(ArgumentType &&...args) noexcept
{
static_assert(
!detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value,
"Severity is already set.");
this->EmitLogRecord(Severity::kError, std::forward<ArgumentType>(args)...);
}
/**
* Writes a log with a severity of fatal.
* @param args Arguments which can be used to set data of log record by type.
* string_view -> body
* AttributeValue -> body
* SpanContext -> span_id,trace_id and trace_flags
* SpanId -> span_id
* TraceId -> trace_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 Fatal(ArgumentType &&...args) noexcept
{
static_assert(
!detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value,
"Severity is already set.");
this->EmitLogRecord(Severity::kFatal, std::forward<ArgumentType>(args)...);
}
//
// OpenTelemetry C++ user-facing Logs API
//
inline bool Enabled(Severity severity, const EventId &event_id) const noexcept
{
if OPENTELEMETRY_LIKELY_CONDITION (!Enabled(severity))
{
return false;
}
return EnabledImplementation(severity, event_id);
}
inline bool Enabled(Severity severity, int64_t event_id) const noexcept
{
if OPENTELEMETRY_LIKELY_CONDITION (!Enabled(severity))
{
return false;
}
return EnabledImplementation(severity, event_id);
}
inline bool Enabled(Severity severity) const noexcept
{
return static_cast<uint8_t>(severity) >= OPENTELEMETRY_ATOMIC_READ_8(&minimum_severity_);
}
/**
* Log an event
*
* @severity severity of the log
* @event_id event identifier of the log
* @format an utf-8 string following https://messagetemplates.org/
* @attributes key value pairs of the log
*/
virtual void Log(Severity severity,
nostd::string_view name,
nostd::string_view body,
const common::KeyValueIterable &resource,
const common::KeyValueIterable &attributes,
trace::TraceId trace_id,
trace::SpanId span_id,
trace::TraceFlags trace_flags,
common::SystemTimestamp timestamp) noexcept = 0;
/*** Overloaded methods for KeyValueIterables ***/
/**
* The secondary base Log(...) method that all other Log(...) overloaded methods except the one
* above will eventually call, in order to create a log record.
*
* Note this takes in template types for the resource and attributes fields.
*/
template <class T,
class U,
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr,
nostd::enable_if_t<common::detail::is_key_value_iterable<U>::value> * = nullptr>
void Log(Severity severity,
nostd::string_view name,
nostd::string_view body,
const T &resource,
const U &attributes,
trace::TraceId trace_id,
trace::SpanId span_id,
trace::TraceFlags trace_flags,
common::SystemTimestamp timestamp) noexcept
const EventId &event_id,
nostd::string_view format,
const common::KeyValueIterable &attributes) noexcept
{
Log(severity, name, body, common::KeyValueIterableView<T>(resource),
common::KeyValueIterableView<U>(attributes), trace_id, span_id, trace_flags, timestamp);
this->EmitLogRecord(severity, event_id, format, attributes);
}
void Log(Severity severity,
nostd::string_view name,
nostd::string_view body,
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>> resource,
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>> attributes,
trace::TraceId trace_id,
trace::SpanId span_id,
trace::TraceFlags trace_flags,
common::SystemTimestamp timestamp) noexcept
virtual void Log(Severity severity,
int64_t event_id,
nostd::string_view format,
const common::KeyValueIterable &attributes) noexcept
{
return this->Log(severity, name, body,
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
resource.begin(), resource.end()},
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
attributes.begin(), attributes.end()},
trace_id, span_id, trace_flags, timestamp);
this->EmitLogRecord(severity, EventId{event_id}, format, attributes);
}
/** Wrapper methods that the user could call for convenience when logging **/
/**
* Writes a log.
* @param severity The severity of the log
* @param message The message to log
*/
void Log(Severity severity, nostd::string_view message) noexcept
virtual void Log(Severity severity,
nostd::string_view format,
const common::KeyValueIterable &attributes) noexcept
{
this->Log(severity, "", message, {}, {}, {}, {}, {}, std::chrono::system_clock::now());
this->EmitLogRecord(severity, format, attributes);
}
/**
* Writes a log.
* @param severity The severity of the log
* @param name The name of the log
* @param message The message to log
*/
void Log(Severity severity, nostd::string_view name, nostd::string_view message) noexcept
virtual void Log(Severity severity, nostd::string_view message) noexcept
{
this->Log(severity, name, message, {}, {}, {}, {}, {}, std::chrono::system_clock::now());
this->EmitLogRecord(severity, message);
}
/**
* Writes a log.
* @param severity The severity of the log
* @param attributes The attributes of the log as a key/value object
*/
template <class T,
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
void Log(Severity severity, const T &attributes) noexcept
// Convenient wrappers based on virtual methods Log().
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-severitynumber
inline void Trace(const EventId &event_id,
nostd::string_view format,
const common::KeyValueIterable &attributes) noexcept
{
this->Log(severity, "", "", std::map<std::string, std::string>{}, attributes, {}, {}, {},
std::chrono::system_clock::now());
this->Log(Severity::kTrace, event_id, format, attributes);
}
/**
* Writes a log.
* @param severity The severity of the log
* @param name The name of the log
* @param attributes The attributes of the log as a key/value object
*/
template <class T,
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
void Log(Severity severity, nostd::string_view name, const T &attributes) noexcept
inline void Trace(int64_t event_id,
nostd::string_view format,
const common::KeyValueIterable &attributes) noexcept
{
this->Log(severity, name, "", std::map<std::string, std::string>{}, attributes, {}, {}, {},
std::chrono::system_clock::now());
this->Log(Severity::kTrace, EventId{event_id}, format, attributes);
}
/**
* Writes a log.
* @param severity The severity of the log
* @param attributes The attributes of the log as an initializer list
*/
void Log(Severity severity,
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
inline void Trace(nostd::string_view format, const common::KeyValueIterable &attributes) noexcept
{
this->Log(severity, "", "", {}, attributes, {}, {}, {}, std::chrono::system_clock::now());
this->Log(Severity::kTrace, format, attributes);
}
/**
* Writes a log.
* @param severity The severity of the log
* @param name The name of the log
* @param attributes The attributes of the log as an initializer list
*/
void Log(Severity severity,
nostd::string_view name,
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
inline void Trace(nostd::string_view message) noexcept { this->Log(Severity::kTrace, message); }
inline void Debug(const EventId &event_id,
nostd::string_view format,
const common::KeyValueIterable &attributes) noexcept
{
this->Log(severity, name, "", {}, attributes, {}, {}, {}, std::chrono::system_clock::now());
this->Log(Severity::kDebug, event_id, format, attributes);
}
/**
* Writes a log.
* @param severity The severity of the log
* @param name The name of the log
* @param attributes The attributes, stored as a 2D list of key/value pairs, that are associated
* with the log event
*/
void Log(Severity severity,
nostd::string_view name,
common::KeyValueIterable &attributes) noexcept
inline void Debug(int64_t event_id,
nostd::string_view format,
const common::KeyValueIterable &attributes) noexcept
{
this->Log(severity, name, {},
common::KeyValueIterableView<
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>>({}),
attributes, {}, {}, {}, std::chrono::system_clock::now());
this->Log(Severity::kDebug, EventId{event_id}, format, attributes);
}
/** Trace severity overloads **/
/**
* Writes a log with a severity of trace.
* @param message The message to log
*/
void Trace(nostd::string_view message) noexcept { this->Log(Severity::kTrace, message); }
/**
* Writes a log with a severity of trace.
* @param name The name of the log
* @param message The message to log
*/
void Trace(nostd::string_view name, nostd::string_view message) noexcept
inline void Debug(nostd::string_view format, const common::KeyValueIterable &attributes) noexcept
{
this->Log(Severity::kTrace, name, message);
this->Log(Severity::kDebug, format, attributes);
}
/**
* Writes a log with a severity of trace.
* @param attributes The attributes of the log as a key/value object
*/
template <class T,
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
void Trace(const T &attributes) noexcept
inline void Debug(nostd::string_view message) noexcept { this->Log(Severity::kDebug, message); }
inline void Info(const EventId &event_id,
nostd::string_view format,
const common::KeyValueIterable &attributes) noexcept
{
this->Log(Severity::kTrace, attributes);
this->Log(Severity::kInfo, event_id, format, attributes);
}
/**
* Writes a log with a severity of trace.
* @param name The name of the log
* @param attributes The attributes of the log as a key/value object
*/
template <class T,
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
void Trace(nostd::string_view name, const T &attributes) noexcept
inline void Info(int64_t event_id,
nostd::string_view format,
const common::KeyValueIterable &attributes) noexcept
{
this->Log(Severity::kTrace, name, attributes);
this->Log(Severity::kInfo, EventId{event_id}, format, attributes);
}
/**
* Writes a log with a severity of trace.
* @param attributes The attributes of the log as an initializer list
*/
void Trace(std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
inline void Info(nostd::string_view format, const common::KeyValueIterable &attributes) noexcept
{
this->Log(Severity::kTrace, attributes);
this->Log(Severity::kInfo, format, attributes);
}
/**
* Writes a log with a severity of trace.
* @param name The name of the log
* @param attributes The attributes of the log as an initializer list
*/
void Trace(nostd::string_view name,
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
inline void Info(nostd::string_view message) noexcept { this->Log(Severity::kInfo, message); }
inline void Warn(const EventId &event_id,
nostd::string_view format,
const common::KeyValueIterable &attributes) noexcept
{
this->Log(Severity::kTrace, name, attributes);
this->Log(Severity::kWarn, event_id, format, attributes);
}
/** Debug severity overloads **/
/**
* Writes a log with a severity of debug.
* @param message The message to log
*/
void Debug(nostd::string_view message) noexcept { this->Log(Severity::kDebug, message); }
/**
* Writes a log with a severity of debug.
* @param name The name of the log
* @param message The message to log
*/
void Debug(nostd::string_view name, nostd::string_view message) noexcept
inline void Warn(int64_t event_id,
nostd::string_view format,
const common::KeyValueIterable &attributes) noexcept
{
this->Log(Severity::kDebug, name, message);
this->Log(Severity::kWarn, EventId{event_id}, format, attributes);
}
/**
* Writes a log with a severity of debug.
* @param attributes The attributes of the log as a key/value object
*/
template <class T,
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
void Debug(const T &attributes) noexcept
inline void Warn(nostd::string_view format, const common::KeyValueIterable &attributes) noexcept
{
this->Log(Severity::kDebug, attributes);
this->Log(Severity::kWarn, format, attributes);
}
/**
* Writes a log with a severity of debug.
* @param name The name of the log
* @param attributes The attributes of the log as a key/value object
*/
template <class T,
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
void Debug(nostd::string_view name, const T &attributes) noexcept
inline void Warn(nostd::string_view message) noexcept { this->Log(Severity::kWarn, message); }
inline void Error(const EventId &event_id,
nostd::string_view format,
const common::KeyValueIterable &attributes) noexcept
{
this->Log(Severity::kDebug, name, attributes);
this->Log(Severity::kError, event_id, format, attributes);
}
/**
* Writes a log with a severity of debug.
* @param attributes The attributes of the log as an initializer list
*/
void Debug(std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
inline void Error(int64_t event_id,
nostd::string_view format,
const common::KeyValueIterable &attributes) noexcept
{
this->Log(Severity::kDebug, attributes);
this->Log(Severity::kError, EventId{event_id}, format, attributes);
}
/**
* Writes a log with a severity of debug.
* @param name The name of the log
* @param attributes The attributes of the log as an initializer list
*/
void Debug(nostd::string_view name,
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
inline void Error(nostd::string_view format, const common::KeyValueIterable &attributes) noexcept
{
this->Log(Severity::kDebug, name, attributes);
this->Log(Severity::kError, format, attributes);
}
/** Info severity overloads **/
inline void Error(nostd::string_view message) noexcept { this->Log(Severity::kError, message); }
/**
* Writes a log with a severity of info.
* @param message The message to log
*/
void Info(nostd::string_view message) noexcept { this->Log(Severity::kInfo, message); }
/**
* Writes a log with a severity of info.
* @param name The name of the log
* @param message The message to log
*/
void Info(nostd::string_view name, nostd::string_view message) noexcept
inline void Fatal(const EventId &event_id,
nostd::string_view format,
const common::KeyValueIterable &attributes) noexcept
{
this->Log(Severity::kInfo, name, message);
this->Log(Severity::kFatal, event_id, format, attributes);
}
/**
* Writes a log with a severity of info.
* @param attributes The attributes of the log as a key/value object
*/
template <class T,
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
void Info(const T &attributes) noexcept
inline void Fatal(int64_t event_id,
nostd::string_view format,
const common::KeyValueIterable &attributes) noexcept
{
this->Log(Severity::kInfo, attributes);
this->Log(Severity::kFatal, EventId{event_id}, format, attributes);
}
/**
* Writes a log with a severity of info.
* @param name The name of the log
* @param attributes The attributes of the log as a key/value object
*/
template <class T,
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
void Info(nostd::string_view name, const T &attributes) noexcept
inline void Fatal(nostd::string_view format, const common::KeyValueIterable &attributes) noexcept
{
this->Log(Severity::kInfo, name, attributes);
this->Log(Severity::kFatal, format, attributes);
}
/**
* Writes a log with a severity of info.
* @param attributes The attributes of the log as an initializer list
*/
void Info(std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
inline void Fatal(nostd::string_view message) noexcept { this->Log(Severity::kFatal, message); }
//
// End of OpenTelemetry C++ user-facing Log API.
//
protected:
// TODO: discuss with community about naming for internal methods.
virtual bool EnabledImplementation(Severity /*severity*/,
const EventId & /*event_id*/) const noexcept
{
this->Log(Severity::kInfo, attributes);
return false;
}
/**
* Writes a log with a severity of info.
* @param name The name of the log
* @param attributes The attributes of the log as an initializer list
*/
void Info(nostd::string_view name,
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
virtual bool EnabledImplementation(Severity /*severity*/, int64_t /*event_id*/) const noexcept
{
this->Log(Severity::kInfo, name, attributes);
return false;
}
/** Warn severity overloads **/
/**
* Writes a log with a severity of warn.
* @param message The message to log
*/
void Warn(nostd::string_view message) noexcept { this->Log(Severity::kWarn, message); }
/**
* Writes a log with a severity of warn.
* @param name The name of the log
* @param message The message to log
*/
void Warn(nostd::string_view name, nostd::string_view message) noexcept
void SetMinimumSeverity(uint8_t severity_or_max) noexcept
{
this->Log(Severity::kWarn, name, message);
OPENTELEMETRY_ATOMIC_WRITE_8(&minimum_severity_, severity_or_max);
}
/**
* Writes a log with a severity of warn.
* @param attributes The attributes of the log as a key/value object
*/
template <class T,
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
void Warn(const T &attributes) noexcept
{
this->Log(Severity::kWarn, attributes);
}
private:
template <class... ValueType>
void IgnoreTraitResult(ValueType &&...)
{}
/**
* Writes a log with a severity of warn.
* @param name The name of the log
* @param attributes The attributes of the log as a key/value object
*/
template <class T,
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
void Warn(nostd::string_view name, const T &attributes) noexcept
{
this->Log(Severity::kWarn, name, attributes);
}
/**
* Writes a log with a severity of warn.
* @param attributes The attributes of the log as an initializer list
*/
void Warn(std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
{
this->Log(Severity::kWarn, attributes);
}
/**
* Writes a log with a severity of warn.
* @param name The name of the log
* @param attributes The attributes of the log as an initializer list
*/
void Warn(nostd::string_view name,
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
{
this->Log(Severity::kWarn, name, attributes);
}
/** Error severity overloads **/
/**
* Writes a log with a severity of error.
* @param message The message to log
*/
void Error(nostd::string_view message) noexcept { this->Log(Severity::kError, message); }
/**
* Writes a log with a severity of error.
* @param name The name of the log
* @param message The message to log
*/
void Error(nostd::string_view name, nostd::string_view message) noexcept
{
this->Log(Severity::kError, name, message);
}
/**
* Writes a log with a severity of error.
* @param attributes The attributes of the log as a key/value object
*/
template <class T,
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
void Error(const T &attributes) noexcept
{
this->Log(Severity::kError, attributes);
}
/**
* Writes a log with a severity of error.
* @param name The name of the log
* @param attributes The attributes of the log as a key/value object
*/
template <class T,
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
void Error(nostd::string_view name, const T &attributes) noexcept
{
this->Log(Severity::kError, name, attributes);
}
/**
* Writes a log with a severity of error.
* @param attributes The attributes of the log as an initializer list
*/
void Error(std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
{
this->Log(Severity::kError, attributes);
}
/**
* Writes a log with a severity of error.
* @param name The name of the log
* @param attributes The attributes of the log as an initializer list
*/
void Error(nostd::string_view name,
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
{
this->Log(Severity::kError, name, attributes);
}
/** Fatal severity overloads **/
/**
* Writes a log with a severity of fatal.
* @param message The message to log
*/
void Fatal(nostd::string_view message) noexcept { this->Log(Severity::kFatal, message); }
/**
* Writes a log with a severity of fatal.
* @param name The name of the log
* @param message The message to log
*/
void Fatal(nostd::string_view name, nostd::string_view message) noexcept
{
this->Log(Severity::kFatal, name, message);
}
/**
* Writes a log with a severity of fatal.
* @param attributes The attributes of the log as a key/value object
*/
template <class T,
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
void Fatal(const T &attributes) noexcept
{
this->Log(Severity::kFatal, attributes);
}
/**
* Writes a log with a severity of fatal.
* @param name The name of the log
* @param attributes The attributes of the log as a key/value object
*/
template <class T,
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
void Fatal(nostd::string_view name, const T &attributes) noexcept
{
this->Log(Severity::kFatal, name, attributes);
}
/**
* Writes a log with a severity of fatal.
* @param attributes The attributes of the log as an initializer list
*/
void Fatal(std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
{
this->Log(Severity::kFatal, attributes);
}
/**
* Writes a log with a severity of fatal.
* @param name The name of the log
* @param attributes The attributes of the log as an initializer list
*/
void Fatal(nostd::string_view name,
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
{
this->Log(Severity::kFatal, name, attributes);
}
//
// minimum_severity_ can be updated concurrently by multiple threads/cores, so race condition on
// read/write should be handled. And std::atomic can not be used here because it is not ABI
// compatible for OpenTelemetry C++ API.
//
mutable uint8_t minimum_severity_{kMaxSeverity};
};
} // namespace logs
OPENTELEMETRY_END_NAMESPACE
#endif

View File

@ -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,12 +36,36 @@ public:
*
*/
virtual nostd::shared_ptr<Logger> GetLogger(nostd::string_view logger_name,
nostd::string_view options = "") = 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) = 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

View File

@ -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

View File

@ -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,44 +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 name,
nostd::string_view body,
const common::KeyValueIterable &resource,
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());
}
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) override
{
return logger_;
}
nostd::shared_ptr<Logger> GetLogger(nostd::string_view logger_name,
nostd::span<nostd::string_view> args) override
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 */) 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

View File

@ -2,22 +2,28 @@
// SPDX-License-Identifier: Apache-2.0
#pragma once
#ifdef ENABLE_LOGS_PREVIEW
# include <mutex>
#include <mutex>
# 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:
/**
@ -35,20 +41,55 @@ 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:
static nostd::shared_ptr<LoggerProvider> &GetProvider() noexcept
OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr<LoggerProvider> &GetProvider() noexcept
{
static nostd::shared_ptr<LoggerProvider> provider(new NoopLoggerProvider);
return provider;
}
static common::SpinLockMutex &GetLock() noexcept
#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;
return lock;
@ -57,4 +98,3 @@ private:
} // namespace logs
OPENTELEMETRY_END_NAMESPACE
#endif

View File

@ -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

View File

@ -2,87 +2,32 @@
// SPDX-License-Identifier: Apache-2.0
#pragma once
#ifdef ENABLE_METRICS_PREVIEW
# include "instrument.h"
# include "observer_result.h"
#include "opentelemetry/metrics/observer_result.h"
#include "opentelemetry/version.h"
OPENTELEMETRY_BEGIN_NAMESPACE
namespace metrics
{
template <class T>
class ValueObserver : virtual public AsynchronousInstrument<T>
using ObservableCallbackPtr = void (*)(ObserverResult, void *);
class ObservableInstrument
{
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;
ObservableInstrument() = default;
virtual ~ObservableInstrument() = default;
/**
* 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
* Sets up a function that will be called whenever a metric collection is initiated.
*/
virtual void run() override = 0;
};
virtual void AddCallback(ObservableCallbackPtr, void *state) noexcept = 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;
/**
* Remove a function that was configured to be called whenever a metric collection is initiated.
*/
virtual void RemoveCallback(ObservableCallbackPtr, void *state) noexcept = 0;
};
} // namespace metrics
OPENTELEMETRY_END_NAMESPACE
#endif

View File

@ -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

View File

@ -2,19 +2,30 @@
// 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"
#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.
*
@ -29,260 +40,135 @@ public:
virtual ~Meter() = default;
/**
* Creates a Counter with the passed characteristics and returns a shared_ptr to that Counter.
* Creates a Counter with the passed characteristics and returns a unique_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::unique_ptr<Counter<uint64_t>> CreateUInt64Counter(
nostd::string_view name,
nostd::string_view description = "",
nostd::string_view unit = "") noexcept = 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;
virtual nostd::unique_ptr<Counter<double>> CreateDoubleCounter(
nostd::string_view name,
nostd::string_view description = "",
nostd::string_view unit = "") noexcept = 0;
/**
* Creates an UpDownCounter with the passed characteristics and returns a shared_ptr to that
* Creates a Asynchronous (Observable) counter with the passed characteristics and returns a
* shared_ptr to that Observable Counter
*
* @param name the name of the new Observable Counter.
* @param description a brief description of what the Observable Counter is used for.
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
*/
virtual nostd::shared_ptr<ObservableInstrument> CreateInt64ObservableCounter(
nostd::string_view name,
nostd::string_view description = "",
nostd::string_view unit = "") noexcept = 0;
virtual nostd::shared_ptr<ObservableInstrument> CreateDoubleObservableCounter(
nostd::string_view name,
nostd::string_view description = "",
nostd::string_view unit = "") noexcept = 0;
/**
* Creates a Histogram with the passed characteristics and returns a unique_ptr to that Histogram.
*
* @param name the name of the new Histogram.
* @param description a brief description of what the Histogram is used for.
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
* @return a shared pointer to the created Histogram.
*/
virtual nostd::unique_ptr<Histogram<uint64_t>> CreateUInt64Histogram(
nostd::string_view name,
nostd::string_view description = "",
nostd::string_view unit = "") noexcept = 0;
virtual nostd::unique_ptr<Histogram<double>> CreateDoubleHistogram(
nostd::string_view name,
nostd::string_view description = "",
nostd::string_view unit = "") noexcept = 0;
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
/**
* 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.
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
*/
virtual nostd::shared_ptr<ObservableInstrument> CreateInt64ObservableGauge(
nostd::string_view name,
nostd::string_view description = "",
nostd::string_view unit = "") noexcept = 0;
virtual nostd::shared_ptr<ObservableInstrument> CreateDoubleObservableGauge(
nostd::string_view name,
nostd::string_view description = "",
nostd::string_view unit = "") noexcept = 0;
/**
* Creates an UpDownCounter with the passed characteristics and returns a unique_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(
virtual nostd::unique_ptr<UpDownCounter<int64_t>> CreateInt64UpDownCounter(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) = 0;
nostd::string_view description = "",
nostd::string_view unit = "") noexcept = 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(
virtual nostd::unique_ptr<UpDownCounter<double>> CreateDoubleUpDownCounter(
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;
nostd::string_view description = "",
nostd::string_view unit = "") noexcept = 0;
/**
* Creates a ValueRecorder with the passed characteristics and returns a shared_ptr to that
* ValueRecorder.
* 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 ValueRecorder.
* @param description a brief description of what the ValueRecorder is used for.
* @param name the name of the new Observable UpDownCounter.
* @param description a brief description of what the Observable 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 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(
virtual nostd::shared_ptr<ObservableInstrument> CreateInt64ObservableUpDownCounter(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) = 0;
nostd::string_view description = "",
nostd::string_view unit = "") noexcept = 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(
virtual nostd::shared_ptr<ObservableInstrument> CreateDoubleObservableUpDownCounter(
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;
nostd::string_view description = "",
nostd::string_view unit = "") noexcept = 0;
};
} // namespace metrics
OPENTELEMETRY_END_NAMESPACE
#endif

View File

@ -2,15 +2,20 @@
// 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"
#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,15 +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 = "") = 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

View File

@ -2,653 +2,270 @@
// 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
#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
{
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*/)
NoopCounter(nostd::string_view /* name */,
nostd::string_view /* description */,
nostd::string_view /* unit */) noexcept
{}
void Add(T /* value */) 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 context::Context & /* context */) noexcept override
{}
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>
class NoopHistogram : public Histogram<T>
{
public:
BoundNoopUpDownCounter() = default;
BoundNoopUpDownCounter(nostd::string_view /*name*/,
nostd::string_view /*description*/,
nostd::string_view /*unit*/,
bool /*enabled*/)
NoopHistogram(nostd::string_view /* name */,
nostd::string_view /* description */,
nostd::string_view /* unit */) noexcept
{}
void Record(T /* value */, const context::Context & /* context */) noexcept override {}
void Record(T /* value */,
const common::KeyValueIterable & /* attributes */,
const context::Context & /* context */) noexcept override
{}
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
void Record(T /*value*/,
const opentelemetry::common::KeyValueIterable & /*attributes*/) noexcept override
{}
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; }
void Record(T /*value*/) noexcept override {}
#endif
};
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*/)
NoopUpDownCounter(nostd::string_view /* name */,
nostd::string_view /* description */,
nostd::string_view /* unit */) noexcept
{}
~NoopUpDownCounter() override = default;
void Add(T /* value */) 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 context::Context & /* context */) noexcept override
{}
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; }
};
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
template <class T>
class BoundNoopValueRecorder : public BoundValueRecorder<T>
class NoopGauge : public Gauge<T>
{
public:
BoundNoopValueRecorder() = default;
BoundNoopValueRecorder(nostd::string_view /*name*/,
nostd::string_view /*description*/,
nostd::string_view /*unit*/,
bool /*enabled*/)
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
{}
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; }
};
#endif
template <class T>
class NoopValueRecorder : public ValueRecorder<T>
class NoopObservableInstrument : public ObservableInstrument
{
public:
NoopValueRecorder() = default;
NoopValueRecorder(nostd::string_view /*name*/,
nostd::string_view /*description*/,
nostd::string_view /*unit*/,
bool /*enabled*/)
NoopObservableInstrument(nostd::string_view /* name */,
nostd::string_view /* description */,
nostd::string_view /* unit */) noexcept
{}
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; }
void AddCallback(ObservableCallbackPtr, void * /* state */) noexcept override {}
void RemoveCallback(ObservableCallbackPtr, void * /* state */) noexcept override {}
};
/**
* No-op implementation of Meter. This class should not be used directly.
* No-op implementation of Meter.
*/
class NoopMeter : public Meter
class NoopMeter final : 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::unique_ptr<Counter<uint64_t>> CreateUInt64Counter(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<short>)) override
nostd::string_view description = "",
nostd::string_view unit = "") noexcept override
{
return nostd::shared_ptr<SumObserver<short>>{
new NoopSumObserver<short>(name, description, unit, enabled, callback)};
return nostd::unique_ptr<Counter<uint64_t>>{new NoopCounter<uint64_t>(name, description, unit)};
}
nostd::shared_ptr<SumObserver<int>> NewIntSumObserver(
nostd::unique_ptr<Counter<double>> CreateDoubleCounter(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<int>)) override
nostd::string_view description = "",
nostd::string_view unit = "") noexcept override
{
return nostd::shared_ptr<SumObserver<int>>{
new NoopSumObserver<int>(name, description, unit, enabled, callback)};
return nostd::unique_ptr<Counter<double>>{new NoopCounter<double>(name, description, unit)};
}
nostd::shared_ptr<SumObserver<float>> NewFloatSumObserver(
nostd::shared_ptr<ObservableInstrument> CreateInt64ObservableCounter(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<float>)) override
nostd::string_view description = "",
nostd::string_view unit = "") noexcept override
{
return nostd::shared_ptr<SumObserver<float>>{
new NoopSumObserver<float>(name, description, unit, enabled, callback)};
return nostd::shared_ptr<ObservableInstrument>(
new NoopObservableInstrument(name, description, unit));
}
nostd::shared_ptr<SumObserver<double>> NewDoubleSumObserver(
nostd::shared_ptr<ObservableInstrument> CreateDoubleObservableCounter(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<double>)) override
nostd::string_view description = "",
nostd::string_view unit = "") noexcept override
{
return nostd::shared_ptr<SumObserver<double>>{
new NoopSumObserver<double>(name, description, unit, enabled, callback)};
return nostd::shared_ptr<ObservableInstrument>(
new NoopObservableInstrument(name, description, unit));
}
/**
*
* 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::unique_ptr<Histogram<uint64_t>> CreateUInt64Histogram(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<short>)) override
nostd::string_view description = "",
nostd::string_view unit = "") noexcept override
{
return nostd::shared_ptr<UpDownSumObserver<short>>{
new NoopUpDownSumObserver<short>(name, description, unit, enabled, callback)};
return nostd::unique_ptr<Histogram<uint64_t>>{
new NoopHistogram<uint64_t>(name, description, unit)};
}
nostd::shared_ptr<UpDownSumObserver<int>> NewIntUpDownSumObserver(
nostd::unique_ptr<Histogram<double>> CreateDoubleHistogram(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<int>)) override
nostd::string_view description = "",
nostd::string_view unit = "") noexcept override
{
return nostd::shared_ptr<UpDownSumObserver<int>>{
new NoopUpDownSumObserver<int>(name, description, unit, enabled, callback)};
return nostd::unique_ptr<Histogram<double>>{new NoopHistogram<double>(name, description, unit)};
}
nostd::shared_ptr<UpDownSumObserver<float>> NewFloatUpDownSumObserver(
#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,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<float>)) override
nostd::string_view description = "",
nostd::string_view unit = "") noexcept override
{
return nostd::shared_ptr<UpDownSumObserver<float>>{
new NoopUpDownSumObserver<float>(name, description, unit, enabled, callback)};
return nostd::shared_ptr<ObservableInstrument>(
new NoopObservableInstrument(name, description, unit));
}
nostd::shared_ptr<UpDownSumObserver<double>> NewDoubleUpDownSumObserver(
nostd::shared_ptr<ObservableInstrument> CreateDoubleObservableGauge(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<double>)) override
nostd::string_view description = "",
nostd::string_view unit = "") noexcept override
{
return nostd::shared_ptr<UpDownSumObserver<double>>{
new NoopUpDownSumObserver<double>(name, description, unit, enabled, callback)};
return nostd::shared_ptr<ObservableInstrument>(
new NoopObservableInstrument(name, description, unit));
}
/**
*
* 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::unique_ptr<UpDownCounter<int64_t>> CreateInt64UpDownCounter(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<short>)) override
nostd::string_view description = "",
nostd::string_view unit = "") noexcept override
{
return nostd::shared_ptr<ValueObserver<short>>{
new NoopValueObserver<short>(name, description, unit, enabled, callback)};
return nostd::unique_ptr<UpDownCounter<int64_t>>{
new NoopUpDownCounter<int64_t>(name, description, unit)};
}
nostd::shared_ptr<ValueObserver<int>> NewIntValueObserver(
nostd::unique_ptr<UpDownCounter<double>> CreateDoubleUpDownCounter(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<int>)) override
nostd::string_view description = "",
nostd::string_view unit = "") noexcept override
{
return nostd::shared_ptr<ValueObserver<int>>{
new NoopValueObserver<int>(name, description, unit, enabled, callback)};
return nostd::unique_ptr<UpDownCounter<double>>{
new NoopUpDownCounter<double>(name, description, unit)};
}
nostd::shared_ptr<ValueObserver<float>> NewFloatValueObserver(
nostd::shared_ptr<ObservableInstrument> CreateInt64ObservableUpDownCounter(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<float>)) override
nostd::string_view description = "",
nostd::string_view unit = "") noexcept override
{
return nostd::shared_ptr<ValueObserver<float>>{
new NoopValueObserver<float>(name, description, unit, enabled, callback)};
return nostd::shared_ptr<ObservableInstrument>(
new NoopObservableInstrument(name, description, unit));
}
nostd::shared_ptr<ValueObserver<double>> NewDoubleValueObserver(
nostd::shared_ptr<ObservableInstrument> CreateDoubleObservableUpDownCounter(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<double>)) override
nostd::string_view description = "",
nostd::string_view unit = "") noexcept 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
return nostd::shared_ptr<ObservableInstrument>(
new NoopObservableInstrument(name, description, unit));
}
};
class NoopMeterProvider final : public opentelemetry::metrics::MeterProvider
/**
* No-op implementation of a MeterProvider.
*/
class NoopMeterProvider final : public MeterProvider
{
public:
NoopMeterProvider()
: meter_{nostd::shared_ptr<opentelemetry::metrics::NoopMeter>(
new opentelemetry::metrics::NoopMeter)}
{}
NoopMeterProvider() : meter_{nostd::shared_ptr<Meter>(new NoopMeter)} {}
nostd::shared_ptr<opentelemetry::metrics::Meter> GetMeter(
nostd::string_view library_name,
nostd::string_view library_version) override
#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<opentelemetry::metrics::Meter> meter_;
nostd::shared_ptr<Meter> meter_;
};
} // namespace metrics
OPENTELEMETRY_END_NAMESPACE
#endif

View File

@ -2,40 +2,53 @@
// SPDX-License-Identifier: Apache-2.0
#pragma once
#ifdef ENABLE_METRICS_PREVIEW
# include "instrument.h"
# include "opentelemetry/nostd/shared_ptr.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
{
/**
* 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.
* ObserverResultT class is necessary for the callback recording asynchronous
* instrument use.
*/
template <class T>
class ObserverResult
class ObserverResultT
{
public:
ObserverResult() = default;
virtual ~ObserverResultT() = default;
ObserverResult(AsynchronousInstrument<T> *instrument) : instrument_(instrument) {}
virtual void Observe(T value) noexcept = 0;
virtual void observe(T value, const common::KeyValueIterable &labels)
virtual void Observe(T value, const common::KeyValueIterable &attributes) noexcept = 0;
template <class U,
nostd::enable_if_t<common::detail::is_key_value_iterable<U>::value> * = nullptr>
void Observe(T value, const U &attributes) noexcept
{
instrument_->observe(value, labels);
this->Observe(value, common::KeyValueIterableView<U>{attributes});
}
private:
AsynchronousInstrument<T> *instrument_;
void Observe(T value,
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
{
this->Observe(value, nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
attributes.begin(), attributes.end()});
}
};
using ObserverResult = nostd::variant<nostd::shared_ptr<ObserverResultT<int64_t>>,
nostd::shared_ptr<ObserverResultT<double>>>;
} // namespace metrics
OPENTELEMETRY_END_NAMESPACE
#endif

View File

@ -2,17 +2,19 @@
// SPDX-License-Identifier: Apache-2.0
#pragma once
#ifdef ENABLE_METRICS_PREVIEW
# include <mutex>
# 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 <mutex>
#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.
*/
@ -34,20 +36,20 @@ 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;
}
private:
static nostd::shared_ptr<MeterProvider> &GetProvider() noexcept
OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr<MeterProvider> &GetProvider() noexcept
{
static nostd::shared_ptr<MeterProvider> provider(new NoopMeterProvider);
return provider;
}
static common::SpinLockMutex &GetLock() noexcept
OPENTELEMETRY_API_SINGLETON static common::SpinLockMutex &GetLock() noexcept
{
static common::SpinLockMutex lock;
return lock;
@ -56,4 +58,3 @@ private:
} // namespace metrics
OPENTELEMETRY_END_NAMESPACE
#endif

View File

@ -2,180 +2,327 @@
// SPDX-License-Identifier: Apache-2.0
#pragma once
#ifdef ENABLE_METRICS_PREVIEW
# include "instrument.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
{
template <class T>
class BoundCounter : virtual public BoundSynchronousInstrument<T>
class SynchronousInstrument
{
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;
SynchronousInstrument() = default;
virtual ~SynchronousInstrument() = default;
};
/* A Counter instrument that adds values. */
template <class T>
class Counter : virtual public SynchronousInstrument<T>
class Counter : public SynchronousInstrument
{
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.
/**
* Record a value
*
* @param labels the set of labels, as key-value pairs.
* @return a BoundIntCounter tied to the specified labels
* @param value The increment amount. MUST be non-negative.
*/
virtual nostd::shared_ptr<BoundCounter<T>> bindCounter(const common::KeyValueIterable &labels)
virtual void Add(T value) noexcept = 0;
/**
* Record a value
*
* @param value The increment amount. MUST be non-negative.
* @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 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
{
return nostd::shared_ptr<BoundCounter<T>>();
this->Add(value, common::KeyValueIterableView<U>{attributes});
}
/*
* 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)
template <class U,
nostd::enable_if_t<common::detail::is_key_value_iterable<U>::value> * = nullptr>
void Add(T value, const U &attributes, const context::Context &context) noexcept
{
return nostd::shared_ptr<BoundUpDownCounter<T>>();
this->Add(value, common::KeyValueIterableView<U>{attributes}, context);
}
/*
* 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)
void Add(T value,
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
{
return nostd::shared_ptr<BoundValueRecorder<T>>();
this->Add(value, nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
attributes.begin(), attributes.end()});
}
/*
* 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;
void Add(T value,
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>> attributes,
const context::Context &context) noexcept
{
this->Add(value,
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
attributes.begin(), attributes.end()},
context);
}
};
/** A histogram instrument that records values. */
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 measurement value. MUST be non-negative.
* @param context The explicit context to associate with this measurement.
*/
virtual void Record(T value, const context::Context &context) noexcept = 0;
/**
* Records a value with a set of attributes.
*
* @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 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 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,
const context::Context &context) noexcept
{
this->Record(value,
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
attributes.begin(), attributes.end()},
context);
}
};
/** An up-down-counter instrument that adds or reduce values. */
template <class T>
class UpDownCounter : public SynchronousInstrument
{
public:
/**
* Record a value.
*
* @param value The increment amount. May be positive, negative or zero.
*/
virtual void Add(T value) 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;
/**
* 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 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
{
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 context::Context &context) noexcept
{
this->Add(value, common::KeyValueIterableView<U>{attributes}, context);
}
void Add(T value,
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
{
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 context::Context &context) noexcept
{
this->Add(value,
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
attributes.begin(), attributes.end()},
context);
}
};
#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

View File

@ -1,4 +0,0 @@
# Notes on Abseil Variant implementation
This is a snapshot of Abseil Variant `absl::variant` from Abseil
`v2020-03-03#8`.

View File

@ -1,3 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <type_traits>

View File

@ -1,3 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <type_traits>

View File

@ -1,3 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <type_traits>

View File

@ -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

View File

@ -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,43 +82,45 @@ 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
} // namespace detail
/* clang-format off */
template <typename F, typename... Args>
inline constexpr auto invoke(F &&f, Args &&... args)
OPENTELEMETRY_RETURN(detail::invoke_impl(std::forward<F>(f), std::forward<Args>(args)...));
OPENTELEMETRY_RETURN(detail::invoke_impl(std::forward<F>(f), std::forward<Args>(args)...))
namespace detail
/* clang-format on */
{
template <typename Void, typename, typename...>
struct invoke_result
{};
template <typename Void, typename, typename...>
struct invoke_result
{};
template <typename F, typename... Args>
struct invoke_result<void_t<decltype(nostd::invoke(std::declval<F>(), std::declval<Args>()...))>,
F,
Args...>
{
using type = decltype(nostd::invoke(std::declval<F>(), std::declval<Args>()...));
};
template <typename F, typename... Args>
struct invoke_result<void_t<decltype(nostd::invoke(std::declval<F>(), std::declval<Args>()...))>,
F, Args...>
{
using type = decltype(nostd::invoke(std::declval<F>(), std::declval<Args>()...));
};
} // namespace detail

View File

@ -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)

View File

@ -1,3 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <cstddef>

View File

@ -1,3 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "opentelemetry/version.h"

View File

@ -1,3 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <type_traits>

View File

@ -1,3 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "opentelemetry/version.h"

View File

@ -1,3 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <type_traits>

View File

@ -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