Skip to content

Commit

Permalink
feat: Otel TracingHook implementation and repo skeleton (#1)
Browse files Browse the repository at this point in the history
**Requirements**

- [x] I have added test coverage for new or changed functionality
- [x] I have followed the repository's [pull request submission
guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests)
- [x] I have validated my changes against all supported platform
versions

**Related issues**

236794

**Describe the solution you've provided**

Implementation of SDK Hook interface that records spans and events for
feature flag evaluations using the OpenTelemetry API.
  • Loading branch information
tanderson-ld authored Apr 22, 2024
1 parent 17bf47d commit c808f7c
Show file tree
Hide file tree
Showing 30 changed files with 1,155 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Support request
url: https://support.launchdarkly.com/hc/en-us/requests/new
about: File your support requests with LaunchDarkly's support team
36 changes: 36 additions & 0 deletions .github/ISSUE_TEMPLATE/package-ldotel--bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: 'Bug report for the java-server-sdk-otel package'
about: Create a report to help us improve
title: ''
labels: 'package: java-server-sdk-otel, bug'
assignees: ''
---

**Is this a support request?**
This issue tracker is maintained by LaunchDarkly SDK developers and is intended for feedback on the code in this library. If you're not sure whether the problem you are having is specifically related to this library, or to the LaunchDarkly service overall, it may be more appropriate to contact the LaunchDarkly support team; they can help to investigate the problem and will consult the SDK team if necessary. You can submit a support request by going [here](https://support.launchdarkly.com/) and clicking "submit a request", or by emailing [email protected].

Note that issues filed on this issue tracker are publicly accessible. Do not provide any private account information on your issues. If your problem is specific to your account, you should submit a support request as described above.

**Describe the bug**
A clear and concise description of what the bug is.

**To reproduce**
Steps to reproduce the behavior.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Logs**
If applicable, add any log output related to your problem.

**SDK version**
The version of this SDK that you are using.

**Language version, developer tools**
For instance, Go 1.11 or Ruby 2.5.3. If you are using a language that requires a separate compiler, such as C, please include the name and version of the compiler too.

**OS/platform**
For instance, Ubuntu 16.04, Windows 10, or Android 4.0.3. If your code is running in a browser, please also include the browser type and version.

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/package-ldotel--feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request for the java-server-sdk-otel package
about: Suggest an idea for this project
title: ''
labels: 'package: java-server-sdk-otel, enhancement'
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I would love to see the SDK [...does something new...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context about the feature request here.
43 changes: 43 additions & 0 deletions .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This is a composite to allow sharing these steps into other workflows.
# It isn't a shared workflow, because then it isn't convenient to add
# additional package specific steps.
name: Shared CI Workflow
inputs:
workspace_path:
description: 'Path to the package.'
required: true
run_tests:
description: 'If true, run unit tests, otherwise skip them.'
required: false
default: 'true'
java_version:
description: 'The Java version to use.'
required: true
java_distribution:
description: 'The Java distribution to use.'
required: false
default: 'temurin'

runs:
using: composite
steps:
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: ${{ inputs.java_distribution }}
java-version: ${{ inputs.java_version }}

- name: Restore dependencies
shell: bash
id: restore
run: ${{ inputs.workspace_path }}/gradlew dependencies -p ${{ inputs.workspace_path }}

- name: Build
shell: bash
id: build
run: ${{ inputs.workspace_path }}/gradlew jar -p ${{ inputs.workspace_path }}

- name: Run Tests
if: steps.build.outcome == 'success' && inputs.run_tests == 'true'
shell: bash
run: ${{ inputs.workspace_path }}/gradlew test -p ${{ inputs.workspace_path }}
43 changes: 43 additions & 0 deletions .github/actions/publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Publish Package
description: 'Publish the package to Sonatype'
inputs:
workspace_path:
description: 'Path to the workspace.'
required: true
dry_run:
description: 'Is this a dry run. If so no package will be published.'
required: true
prerelease:
description: 'Is this a prerelease. If so then it will be published to the staging repository only.'
required: true
signing_key_id:
description: 'Signing key ID'
required: true
signing_key_passphrase:
description: 'Signing key passphrase'
required: true
code_signing_keyring:
description: 'The path of the code signing keyring.'
required: true
sonatype_username:
description: 'Sonatype repo username.'
required: true
sonatype_password:
description: 'Sonatype repo password.'
required: true

runs:
using: composite
steps:
- name: Publish Library
shell: bash
env:
WORKSPACE_PATH: ${{ inputs.workspace_path }}
LD_RELEASE_IS_PRERELEASE: ${{ inputs.prerelease }}
LD_RELEASE_IS_DRYRUN: ${{ inputs.dry_run }}
SIGNING_KEY_ID: ${{ inputs.signing_key_id }}
SIGNING_KEY_PASSPHRASE: ${{ inputs.signing_key_passphrase }}
SIGNING_SECRET_KEY_RING_FILE: ${{ inputs.code_signing_keyring }}
SONATYPE_USER_NAME: ${{ inputs.sonatype_username }}
SONATYPE_PASSWORD: ${{ inputs.sonatype_password }}
run: source $GITHUB_ACTION_PATH/publish.sh
22 changes: 22 additions & 0 deletions .github/actions/publish/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -ue

if $LD_RELEASE_IS_DRYRUN ; then
echo "Doing a dry run of publishing."
else
echo "Publishing to Sonatype"
if [ "${LD_RELEASE_IS_PRERELEASE}" == "true" ]; then
echo "PRERELEASE"
${WORKSPACE_PATH}/gradlew publishToSonatype -p ${WORKSPACE_PATH} -Psigning.keyId="${SIGNING_KEY_ID}" -Psigning.password="${SIGNING_KEY_PASSPHRASE}" -Psigning.secretKeyRingFile="${SIGNING_SECRET_KEY_RING_FILE}" -PsonatypeUsername="${SONATYPE_USER_NAME}" -PsonatypePassword="${SONATYPE_PASSWORD}" || {
echo "Gradle publish/release failed" >&2
exit 1
}
else
echo "RELEASE"
${WORKSPACE_PATH}/gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -p ${WORKSPACE_PATH} -Psigning.keyId="${SIGNING_KEY_ID}" -Psigning.password="${SIGNING_KEY_PASSPHRASE}" -Psigning.secretKeyRingFile="${SIGNING_SECRET_KEY_RING_FILE}" -PsonatypeUsername="${SONATYPE_USER_NAME}" -PsonatypePassword="${SONATYPE_PASSWORD}" || {
echo "Gradle publish/release failed" >&2
exit 1
}
fi
fi
21 changes: 21 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
**Requirements**

- [ ] I have added test coverage for new or changed functionality
- [ ] I have followed the repository's [pull request submission guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests)
- [ ] I have validated my changes against all supported platform versions

**Related issues**

Provide links to any issues in this repository or elsewhere relating to this pull request.

**Describe the solution you've provided**

Provide a clear and concise description of what you expect to happen.

**Describe alternatives you've considered**

Provide a clear and concise description of any alternative solutions or features you've considered.

**Additional context**

Add any other context about the pull request here.
23 changes: 23 additions & 0 deletions .github/workflows/java-server-sdk-otel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: java-server-sdk-otel

on:
push:
branches: [main, 'feat/**']
paths-ignore:
- '**.md' #Do not need to run CI for markdown changes.
pull_request:
branches: [main, 'feat/**']
paths-ignore:
- '**.md'

jobs:
build-test-java-server-sdk-otel:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Shared CI Steps
uses: ./.github/actions/ci
with:
workspace_path: 'lib/java-server-sdk-otel'
java_version: 8
17 changes: 17 additions & 0 deletions .github/workflows/lint-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Lint PR title

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
name: Verify the PR title matches conventional commit spec.
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55 changes: 55 additions & 0 deletions .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Publish Package
on:
workflow_dispatch:
inputs:
workspace_path:
description: 'The workspace to publish'
required: true
type: choice
options:
- lib/libotel
prerelease:
description: 'Is this a prerelease.'
type: boolean
required: true
dry_run:
description: 'Is this a dry run. If so no package will be published.'
type: boolean
required: true
run_tests:
description: 'If true, run unit tests, otherwise skip them.'
type: boolean
default: true

jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3

- name: Shared CI Steps
uses: ./.github/actions/ci
with:
workspace_path: ${{ inputs.workspace_path }}
java_version: 8

- uses: launchdarkly/gh-actions/actions/[email protected]
name: Get secrets
with:
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
ssm_parameter_pairs: '/production/common/releasing/sonatype/username = SONATYPE_USER_NAME,
/production/common/releasing/sonatype/password = SONATYPE_PASSWORD,
/production/common/releasing/android_code_signing/private_key_id = SIGNING_KEY_ID,
/production/common/releasing/android_code_signing/private_key_passphrase = SIGNING_KEY_PASSPHRASE'
s3_path_pairs: 'launchdarkly-releaser/android/code-signing-keyring.gpg = code-signing-keyring.gpg'

- name: Publish
uses: ./.github/actions/publish
with:
workspace_path: ${{ inputs.workspace_path }}
dry_run: ${{ inputs.dry_run }}
prerelease: ${{ inputs.prerelease }}
code_signing_keyring: 'code-signing-keyring.gpg'
14 changes: 14 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 1 * * *'

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v7
with:
stale-issue-message: 'This issue is stale because it has been open for 90 days without activity. Remove the stale label or comment, or this will be closed in 14 days.'
days-before-stale: 90
days-before-close: 14
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/*
.vscode
2 changes: 2 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Repository Maintainers
* @launchdarkly/team-sdk-java
41 changes: 41 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Contributing to the LaunchDarkly monorepo for Java SDKs

LaunchDarkly has published an [SDK contributor's guide](https://docs.launchdarkly.com/sdk/concepts/contributors-guide) that provides a detailed explanation of how our SDKs work. See below for additional information on how to contribute to this SDK.

## Submitting bug reports and feature requests

The LaunchDarkly SDK team monitors the [issue tracker](https://github.com/launchdarkly/java-core/issues) in the SDK repository. Bug reports and feature requests specific to this repository's packages should be filed in this issue tracker. The SDK team will make best effort to respond to all newly filed issues within two business days.

## Submitting pull requests

We encourage pull requests and other contributions from the community. Before submitting pull requests, ensure that all temporary or unintended code is removed. Don't worry about adding reviewers to the pull request; the LaunchDarkly SDK team will add themselves. The SDK team will acknowledge all pull requests within two business days.

## Build instructions

### Prerequisites

The majority of packages in this repo are built with [Gradle](https://gradle.org/) and should be built against Java 8.

### Building

To build a package without running any tests:
```
<package_path>/gradlew jar -p <package_path>
```

If you wish to clean your working directory between builds, you can clean it by running:
```
<package_path>/gradlew clean -p <package_path>
```

If you wish to use your generated package artifact by another Maven/Gradle project, you will likely want to publish the artifact to your local Maven repository so that your other project can access it.
```
<package_path>/gradlew publishToMavenLocal -p <package_path> -PskipSigning=true
```

### Testing

To build the package and run all unit tests:
```
<package_path>/gradlew test -p <package_path>
```
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2024 Catamorphic, Co.

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

0 comments on commit c808f7c

Please sign in to comment.