Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMB-3907 Android side for tracer provider #36

Draft
wants to merge 30 commits into
base: feature-react-native-tracer-provider
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
24583da
EMB-3907 tracer provider package with android implementation
jpmunz Jun 17, 2024
ed35345
EMBR-3907 android build and test setup
jpmunz Jun 27, 2024
da9e062
EMBR-3907 review comments, kotlin lint
jpmunz Jun 28, 2024
a867da7
EMBR-3907 pass schemaUrl correctly, remove web-trace package dependency
jpmunz Jun 28, 2024
4d616d5
EBMR-3907 embrace sdk dependency
jpmunz Jun 28, 2024
1ae3190
EMBR-3907 linting
jpmunz Jun 28, 2024
6f12ff8
EMBR-3907 pushd not on build server
jpmunz Jun 28, 2024
3b1a088
EMBR-3907 setup Java in CI
jpmunz Jul 3, 2024
3f6ba0e
Merge branch 'feature-react-native-tracer-provider' into jpmunz/EMBR-…
jpmunz Jul 8, 2024
b9acad8
Merge branch 'feature-react-native-tracer-provider' into jpmunz/EMBR-…
jpmunz Jul 8, 2024
48d2569
Merge branch 'feature-react-native-tracer-provider' into jpmunz/EMBR-…
jpmunz Jul 8, 2024
eb883b8
EBMR-4247 JS layer for tracer provider
jpmunz Jul 8, 2024
d747459
Merge branch 'jpmunz/EMBR-4247-rn-tracer-provider-js-layer' into jpmu…
jpmunz Jul 8, 2024
5c02c5b
EMBR-3907 renaming
jpmunz Jul 8, 2024
d1112ad
EMBR-4247 rename module
jpmunz Jul 8, 2024
ff273ef
Merge branch 'jpmunz/EMBR-4247-rn-tracer-provider-js-layer' into jpmu…
jpmunz Jul 8, 2024
fbe0dc8
EMBR-4247 linting updates
jpmunz Jul 8, 2024
812c675
Merge branch 'feature-react-native-tracer-provider' into jpmunz/EMBR-…
jpmunz Jul 8, 2024
550c79e
EMBR-4247 typo on mock
jpmunz Jul 8, 2024
3ef8ceb
Merge branch 'jpmunz/EMBR-4247-rn-tracer-provider-js-layer' into jpmu…
jpmunz Jul 8, 2024
7bc73a7
EMBR-3907 fix scripts constraint
jpmunz Jul 8, 2024
1175f53
EMBR-3907 yarn update
jpmunz Jul 8, 2024
fea24ae
EMBR-3907 tests passing with Embracer tracer provider
jpmunz Jul 9, 2024
be45048
Merge branch 'feature-react-native-tracer-provider' into jpmunz/EMBR-…
jpmunz Jul 9, 2024
4cbb2c8
Merge branch 'jpmunz/EMBR-4247-rn-tracer-provider-js-layer' into jpmu…
jpmunz Jul 9, 2024
0c5258b
Merge branch 'feature-react-native-tracer-provider' into jpmunz/EMBR-…
jpmunz Jul 9, 2024
e26e52f
Merge branch 'jpmunz/EMBR-4247-rn-tracer-provider-js-layer' into jpmu…
jpmunz Jul 9, 2024
efd4e59
EMBR-4247 update how package is built
jpmunz Jul 9, 2024
1e109a0
Merge branch 'jpmunz/EMBR-4247-rn-tracer-provider-js-layer' into jpmu…
jpmunz Jul 9, 2024
d67d409
Merge branch 'feature-react-native-tracer-provider' into jpmunz/EMBR-…
jpmunz Jul 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
jdk-version: ["17"]

steps:
- uses: actions/checkout@v4
Expand All @@ -24,10 +25,16 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- name: Install JDK ${{ matrix.jdk-version }}
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: ${{ matrix.jdk-version }}
- run: corepack enable
- run: yarn
- run: yarn lint
- run: yarn test --watchAll=false --coverage
- run: yarn android-test
- run: yarn build
- uses: codecov/codecov-action@v4
with:
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"publish-modules": "npx lerna run build && npx lerna publish",
"build": "npx lerna run build",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx --fix && prettier --write \"**/*.{js,jsx,ts,tsx,json}\" && yarn constraints --fix",
"test": "jest"
"test": "jest",
"android-test": "npx lerna run android-test"
},
"lint-staged": {
"**/*.{js,jsx,ts,tsx}": [
Expand Down
23 changes: 23 additions & 0 deletions packages/react-native-tracer-provider/DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Package structure

Native modules can't be built outside the context of a React Application, this makes it difficult to run unit tests
on the native side functionality. To get around this limitation the actual Android and iOS native source files for this
module are in native-src/ structured as if they were plugins within an example app.

The source files are then copied over to the android/ and ios/ directories at build time following the structure RN
expects them to have when being packaged as libraries. To avoid editing the wrong spot the source files under those
directories are git ignored and only generated as needed during build.

## Testing

### Testing Android

Tests can be run from Android Studio by adding native-src/android as a Project or from the CLI with `yarn android-test`

### Testing iOS

TODO

## Building

`yarn build` will copy the needed files to android/ and ios/ and then compile the package as normal
4 changes: 4 additions & 0 deletions packages/react-native-tracer-provider/android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ local.properties

# Bundle artifacts
*.jsbundle

# See ../DEVELOPING.md
src/main/java/
dependencies.gradle
8 changes: 2 additions & 6 deletions packages/react-native-tracer-provider/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,7 @@ dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

// OTEL dependencies
implementation(platform("io.opentelemetry:opentelemetry-bom:1.38.0"));
implementation("io.opentelemetry:opentelemetry-api");
implementation("io.opentelemetry:opentelemetry-sdk");
implementation("io.opentelemetry:opentelemetry-exporter-logging");
}

// Copied from ../native-src/android/app/ as part of `yarn build`
apply from: 'dependencies.gradle'
7 changes: 7 additions & 0 deletions packages/react-native-tracer-provider/copy-native-src.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# See DEVELOPING.md

rm -r android/src/main/java
cp -r native-src/android/app/src/main/java android/src/main/java
cp native-src/android/app/dependencies.gradle android/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.yarn/*
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,19 @@ dependencies {
implementation jscFlavor
}

testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1'
testImplementation 'junit:junit:4.12'
testImplementation "org.mockito.kotlin:mockito-kotlin:5.3.1"
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1'
testImplementation 'junit:junit:4.12'
testImplementation "org.mockito.kotlin:mockito-kotlin:5.3.1"
testImplementation("io.mockk:mockk:1.13.11")
}

android {
useLibrary 'android.test.mock'

// OTEL dependencies
implementation(platform("io.opentelemetry:opentelemetry-bom:1.38.0"));
implementation("io.opentelemetry:opentelemetry-api");
implementation("io.opentelemetry:opentelemetry-sdk");
implementation("io.opentelemetry:opentelemetry-exporter-logging");
testOptions {
unitTests.returnDefaultValues = true
}
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: file("dependencies.gradle")
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
dependencies {
// TODO keep this in sync with the version from the core/ package
api "io.embrace:embrace-android-sdk:6.9.0"

// TODO remove once using the Embrace provider
implementation(platform("io.opentelemetry:opentelemetry-bom:1.38.0"))
implementation("io.opentelemetry:opentelemetry-api")
implementation("io.opentelemetry:opentelemetry-sdk")
implementation("io.opentelemetry:opentelemetry-exporter-logging")
}
Loading