Skip to content

Commit 0406e38

Browse files
committed
feat: Add tracing hook.
1 parent 03e2a59 commit 0406e38

15 files changed

Lines changed: 1278 additions & 6 deletions

File tree

.github/workflows/release-please.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414
package-server-tag: ${{ steps.release.outputs['libs/server-sdk--tag_name'] }}
1515
package-server-redis-released: ${{ steps.release.outputs['libs/server-sdk-redis-source--release_created'] }}
1616
package-server-redis-tag: ${{ steps.release.outputs['libs/server-sdk-redis-source--tag_name'] }}
17+
package-server-otel-released: ${{ steps.release.outputs['libs/server-sdk-otel--release_created'] }}
18+
package-server-otel-tag: ${{ steps.release.outputs['libs/server-sdk-otel--tag_name'] }}
1719
steps:
1820
- uses: googleapis/release-please-action@v4
1921
id: release
@@ -142,3 +144,45 @@ jobs:
142144
upload-assets: true
143145
upload-tag-name: ${{ needs.release-please.outputs.package-server-redis-tag }}
144146
provenance-name: ${{ format('{0}-server-redis-multiple-provenance.intoto.jsonl', matrix.os) }}
147+
148+
release-server-otel:
149+
strategy:
150+
matrix:
151+
# Each of the platforms for which release-artifacts need generated.
152+
os: [ ubuntu-22.04, windows-2022, macos-13 ]
153+
runs-on: ${{ matrix.os }}
154+
needs: [ 'release-please' ]
155+
if: ${{ needs.release-please.outputs.package-server-otel-released == 'true'}}
156+
outputs:
157+
hashes-linux: ${{ steps.release-server-otel.outputs.hashes-linux }}
158+
hashes-windows: ${{ steps.release-server-otel.outputs.hashes-windows }}
159+
hashes-macos: ${{ steps.release-server-otel.outputs.hashes-macos }}
160+
steps:
161+
- uses: actions/checkout@v4
162+
- id: release-server-otel
163+
name: Full release of libs/server-sdk-otel
164+
uses: ./.github/actions/sdk-release
165+
with:
166+
# The tag of the release to upload artifacts to.
167+
tag_name: ${{ needs.release-please.outputs.package-server-otel-tag }}
168+
github_token: ${{secrets.GITHUB_TOKEN}}
169+
sdk_path: 'libs/server-sdk-otel'
170+
sdk_cmake_target: 'launchdarkly-cpp-server-otel'
171+
cmake_extra_options: '-DLD_BUILD_OTEL_SUPPORT=ON'
172+
173+
release-server-otel-provenance:
174+
needs: [ 'release-please', 'release-server-otel' ]
175+
strategy:
176+
matrix:
177+
# Generates a combined attestation for each platform
178+
os: [ linux, windows, macos ]
179+
permissions:
180+
actions: read
181+
id-token: write
182+
contents: write
183+
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.1.0
184+
with:
185+
base64-subjects: "${{ needs.release-server-otel.outputs[format('hashes-{0}', matrix.os)] }}"
186+
upload-assets: true
187+
upload-tag-name: ${{ needs.release-please.outputs.package-server-otel-tag }}
188+
provenance-name: ${{ format('{0}-server-otel-multiple-provenance.intoto.jsonl', matrix.os) }}

.github/workflows/server-otel.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: libs/server-sdk-otel
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths-ignore:
7+
- '**.md' # Do not need to run CI for markdown changes.
8+
pull_request:
9+
branches: [ "main", "feat/**" ]
10+
paths-ignore:
11+
- '**.md'
12+
schedule:
13+
# Run daily at midnight PST
14+
- cron: '0 8 * * *'
15+
16+
jobs:
17+
build-test-otel:
18+
runs-on: ubuntu-22.04
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: ./.github/actions/ci
22+
with:
23+
cmake_target: launchdarkly-cpp-server-otel
24+
cmake_extra_options: '-DLD_BUILD_OTEL_SUPPORT=ON'
25+
simulate_release: true
26+
build-otel-mac:
27+
runs-on: macos-13
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: ./.github/actions/ci
31+
with:
32+
cmake_target: launchdarkly-cpp-server-otel
33+
cmake_extra_options: '-DLD_BUILD_OTEL_SUPPORT=ON'
34+
platform_version: 12
35+
simulate_release: true
36+
build-test-otel-windows:
37+
runs-on: windows-2022
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: ilammy/msvc-dev-cmd@v1
41+
- uses: ./.github/actions/ci
42+
env:
43+
BOOST_LIBRARY_DIR: 'C:\local\boost_1_87_0\lib64-msvc-14.3'
44+
BOOST_LIBRARYDIR: 'C:\local\boost_1_87_0\lib64-msvc-14.3'
45+
Boost_DIR: 'C:\local\boost_1_87_0\lib64-msvc-14.3\cmake\Boost-1.87.0'
46+
with:
47+
cmake_target: launchdarkly-cpp-server-otel
48+
cmake_extra_options: '-DLD_BUILD_OTEL_SUPPORT=ON'
49+
platform_version: 2022
50+
toolset: msvc
51+
simulate_windows_release: true

.release-please-manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"libs/common": "1.10.0",
55
"libs/internal": "0.12.1",
66
"libs/server-sdk": "3.9.1",
7-
"libs/server-sdk-redis-source": "2.2.0"
7+
"libs/server-sdk-redis-source": "2.2.0",
8+
"libs/server-sdk-otel": "0.0.0"
89
}

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ option(LD_BUILD_EXAMPLES "Build hello-world examples." ON)
101101

102102
option(LD_BUILD_REDIS_SUPPORT "Build redis support." OFF)
103103

104+
option(LD_BUILD_OTEL_SUPPORT "Build OpenTelemetry integration." OFF)
105+
104106
# If using 'make' as the build system, CMake causes the 'install' target to have a dependency on 'all', meaning
105107
# it will cause a full build. This disables that, allowing us to build piecemeal instead. This is useful
106108
# so that we only need to build the client or server for a given release (if only the client or server were affected.)
@@ -195,6 +197,11 @@ if (LD_BUILD_REDIS_SUPPORT)
195197
add_subdirectory(libs/server-sdk-redis-source)
196198
endif ()
197199

200+
if (LD_BUILD_OTEL_SUPPORT)
201+
message("LaunchDarkly: building OpenTelemetry integration")
202+
add_subdirectory(libs/server-sdk-otel)
203+
endif ()
204+
198205
# Built as static or shared depending on LD_BUILD_SHARED_LIBS variable.
199206
# This target "links" in common, internal, and sse as object libraries.
200207
add_subdirectory(libs/client-sdk)

libs/server-sdk-otel/CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Changelog
2+
3+
All notable changes to the LaunchDarkly C++ Server SDK OpenTelemetry Integration will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
- Initial implementation of OpenTelemetry tracing hook
12+
- Automatic span event creation for feature flag evaluations
13+
- Optional dedicated span creation for flag evaluations
14+
- Configurable value inclusion in telemetry
15+
- Support for explicit parent span passing via HookContext
16+
- Builder pattern for configuration options
17+
- Comprehensive API documentation
18+
- Basic unit tests
19+
20+
### Features
21+
- `TracingHook` class implementing the Hook interface
22+
- `TracingHookOptions` for configuration
23+
- `TracingHookOptionsBuilder` for fluent configuration
24+
- `MakeHookContextWithSpan` helper function
25+
- Support for all OpenTelemetry semantic convention attributes:
26+
- `feature_flag.key`
27+
- `feature_flag.provider.name`
28+
- `feature_flag.context.id`
29+
- `feature_flag.set.id`
30+
- `feature_flag.result.value`
31+
- `feature_flag.result.variationIndex`
32+
- `feature_flag.result.reason.inExperiment`
33+
34+
### Dependencies
35+
- OpenTelemetry C++ API 1.23.0 or later (peer dependency)
36+
- LaunchDarkly C++ Server SDK 3.5.0 or later
37+
38+
## [0.1.0] - YYYY-MM-DD
39+
40+
Initial pre-release version.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This project aims to follow modern cmake guidelines, e.g.
2+
# https://cliutils.gitlab.io/modern-cmake
3+
4+
# Required for Apple Silicon support.
5+
cmake_minimum_required(VERSION 3.19)
6+
7+
project(
8+
LaunchDarklyCPPServerOtel
9+
VERSION 0.1.0
10+
DESCRIPTION "LaunchDarkly C++ Server SDK OpenTelemetry Integration"
11+
LANGUAGES CXX
12+
)
13+
14+
set(LIBNAME "launchdarkly-cpp-server-otel")
15+
16+
# If this project is the main CMake project (as opposed to being included via add_subdirectory)
17+
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
18+
# Disable C++ extensions for portability.
19+
set(CMAKE_CXX_EXTENSIONS OFF)
20+
# Enable folder support in IDEs.
21+
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
22+
endif ()
23+
24+
# Needed to fetch external dependencies.
25+
include(FetchContent)
26+
27+
# Find or fetch OpenTelemetry
28+
# For now, always fetch to ensure we have the right version
29+
FetchContent_Declare(
30+
opentelemetry-cpp
31+
GIT_REPOSITORY https://github.com/open-telemetry/opentelemetry-cpp.git
32+
GIT_TAG ea1f0d61ce5baa5584b097266bf133d1f31e3607 # v1.23.0
33+
)
34+
35+
# Configure OpenTelemetry build
36+
set(WITH_OTLP_HTTP OFF CACHE BOOL "Build with OTLP HTTP exporter" FORCE)
37+
set(WITH_EXAMPLES OFF CACHE BOOL "Build examples" FORCE)
38+
set(WITH_ABSEIL ON CACHE BOOL "Build with Abseil" FORCE)
39+
set(BUILD_TESTING OFF CACHE BOOL "Build tests" FORCE)
40+
41+
FetchContent_MakeAvailable(opentelemetry-cpp)
42+
43+
add_subdirectory(src)
44+
45+
if (LD_BUILD_UNIT_TESTS)
46+
add_subdirectory(tests)
47+
endif ()

0 commit comments

Comments
 (0)