Skip to content

Commit

Permalink
Separate the SDK into separate publishable artifacts (#1525)
Browse files Browse the repository at this point in the history
* Split single "sdk" module into separate pieces for common, correlationcontext, metrics, tracing, and the combination of them all

* Modify comment to not reference implementation class

* Moved JMH code to /sdk/all

* Move new files to adjusted location

* Move new files from rebase
  • Loading branch information
kenfinnigan authored Aug 18, 2020
1 parent 94eaef4 commit 2659726
Show file tree
Hide file tree
Showing 183 changed files with 308 additions and 73 deletions.
4 changes: 4 additions & 0 deletions all/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def subprojects = [
project(':opentelemetry-exporters-zipkin'),
project(':opentelemetry-integration-tests'),
project(':opentelemetry-opentracing-shim'),
project(':opentelemetry-sdk-common'),
project(':opentelemetry-sdk-correlation-context'),
project(':opentelemetry-sdk-metrics'),
project(':opentelemetry-sdk-tracing'),
project(':opentelemetry-sdk'),
project(':opentelemetry-sdk-extension-async-processor'),
project(':opentelemetry-sdk-extension-auto-config'),
Expand Down
File renamed without changes.
6 changes: 5 additions & 1 deletion sdk/build.gradle → sdk/all/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ ext.moduleName = "io.opentelemetry.sdk"
ext.propertiesDir = "build/generated/properties/io/opentelemetry/sdk"

dependencies {
api project(':opentelemetry-api')
api project(':opentelemetry-api'),
project(':opentelemetry-sdk-common'),
project(':opentelemetry-sdk-correlation-context'),
project(':opentelemetry-sdk-metrics'),
project(':opentelemetry-sdk-tracing')

implementation libraries.guava

Expand Down
65 changes: 65 additions & 0 deletions sdk/common/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
plugins {
id "java"
id "maven-publish"

id "ru.vyarus.animalsniffer"
}

description = 'OpenTelemetry SDK Common'
ext.moduleName = "io.opentelemetry.sdk.common"
ext.propertiesDir = "build/generated/properties/io/opentelemetry/sdk/common"

dependencies {
api project(':opentelemetry-api')

implementation libraries.guava

annotationProcessor libraries.auto_value

testAnnotationProcessor libraries.auto_value
testCompileOnly libraries.auto_value_annotation

testImplementation project(':opentelemetry-testing-internal')
testImplementation libraries.junit_pioneer

signature "org.codehaus.mojo.signature:java17:1.0@signature"
signature "net.sf.androidscents.signature:android-api-level-24:7.0_r2@signature"
}

sourceSets {
main {
output.dir("build/generated/properties", builtBy: 'generateVersionResource')
}
}

animalsniffer {
// Don't check sourceSets.jmh and sourceSets.test
sourceSets = [
sourceSets.main
]
}

configurations {
testClasses {
extendsFrom(testRuntime)
}
}

task testJar(type: Jar) {
archiveClassifier.set("test")
from sourceSets.test.output
}

// add the jar generated by the testJar task to the testClasses dependency
artifacts {
testClasses testJar
}

task generateVersionResource {
doLast {
def folder = file(propertiesDir)
folder.mkdirs()
def propertiesFile = new File(folder.getAbsolutePath(), "version.properties")
propertiesFile.write("sdk.version=${project.version}")
}
}
Original file line number Diff line number Diff line change
@@ -1,72 +1,71 @@
/*
* 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.
*/

package io.opentelemetry.sdk.common;

import com.google.auto.value.AutoValue;
import io.opentelemetry.sdk.trace.TracerSdkProvider;
import io.opentelemetry.trace.Tracer;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

/**
* Holds information about the instrumentation library specified when creating an instance of {@link
* Tracer} using {@link TracerSdkProvider}.
*/
@AutoValue
@Immutable
public abstract class InstrumentationLibraryInfo {
private static final InstrumentationLibraryInfo EMPTY = create("", null);

/**
* Creates a new instance of {@link InstrumentationLibraryInfo}.
*
* @param name name of the instrumentation library (e.g., "io.opentelemetry.contrib.mongodb"),
* must not be null
* @param version version of the instrumentation library (e.g., "semver:1.0.0"), might be null
* @return the new instance
*/
public static InstrumentationLibraryInfo create(String name, @Nullable String version) {
return new AutoValue_InstrumentationLibraryInfo(name, version);
}

/**
* Returns an "empty" {@code InstrumentationLibraryInfo}.
*
* @return an "empty" {@code InstrumentationLibraryInfo}.
*/
public static InstrumentationLibraryInfo getEmpty() {
return EMPTY;
}

/**
* Returns the name of the instrumentation library.
*
* @return the name of the instrumentation library.
*/
public abstract String getName();

/**
* Returns the version of the instrumentation library, or {@code null} if not available.
*
* @return the version of the instrumentation library, or {@code null} if not available.
*/
@Nullable
public abstract String getVersion();

// Package protected ctor to avoid others to extend this class.
InstrumentationLibraryInfo() {}
}
/*
* 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.
*/

package io.opentelemetry.sdk.common;

import com.google.auto.value.AutoValue;
import io.opentelemetry.trace.Tracer;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

/**
* Holds information about the instrumentation library specified when creating an instance of {@link
* Tracer} using the Tracer Provider.
*/
@AutoValue
@Immutable
public abstract class InstrumentationLibraryInfo {
private static final InstrumentationLibraryInfo EMPTY = create("", null);

/**
* Creates a new instance of {@link InstrumentationLibraryInfo}.
*
* @param name name of the instrumentation library (e.g., "io.opentelemetry.contrib.mongodb"),
* must not be null
* @param version version of the instrumentation library (e.g., "semver:1.0.0"), might be null
* @return the new instance
*/
public static InstrumentationLibraryInfo create(String name, @Nullable String version) {
return new AutoValue_InstrumentationLibraryInfo(name, version);
}

/**
* Returns an "empty" {@code InstrumentationLibraryInfo}.
*
* @return an "empty" {@code InstrumentationLibraryInfo}.
*/
public static InstrumentationLibraryInfo getEmpty() {
return EMPTY;
}

/**
* Returns the name of the instrumentation library.
*
* @return the name of the instrumentation library.
*/
public abstract String getName();

/**
* Returns the version of the instrumentation library, or {@code null} if not available.
*
* @return the version of the instrumentation library, or {@code null} if not available.
*/
@Nullable
public abstract String getVersion();

// Package protected ctor to avoid others to extend this class.
InstrumentationLibraryInfo() {}
}
50 changes: 50 additions & 0 deletions sdk/correlation_context/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
plugins {
id "java"
id "maven-publish"

id "ru.vyarus.animalsniffer"
}

description = 'OpenTelemetry SDK Correlation Context'
ext.moduleName = "io.opentelemetry.sdk.correlationcontext"
ext.propertiesDir = "build/generated/properties/io/opentelemetry/sdk/correlationcontext"

dependencies {
api project(':opentelemetry-api'),
project(':opentelemetry-sdk-common')

implementation libraries.guava

annotationProcessor libraries.auto_value

testAnnotationProcessor libraries.auto_value
testCompileOnly libraries.auto_value_annotation

testImplementation project(':opentelemetry-testing-internal')
testImplementation libraries.junit_pioneer

signature "org.codehaus.mojo.signature:java17:1.0@signature"
signature "net.sf.androidscents.signature:android-api-level-24:7.0_r2@signature"
}

sourceSets {
main {
output.dir("build/generated/properties", builtBy: 'generateVersionResource')
}
}

animalsniffer {
// Don't check sourceSets.jmh and sourceSets.test
sourceSets = [
sourceSets.main
]
}

task generateVersionResource {
doLast {
def folder = file(propertiesDir)
folder.mkdirs()
def propertiesFile = new File(folder.getAbsolutePath(), "version.properties")
propertiesFile.write("sdk.version=${project.version}")
}
}
53 changes: 53 additions & 0 deletions sdk/metrics/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
plugins {
id "java"
id "maven-publish"

id "me.champeau.gradle.jmh"
id "ru.vyarus.animalsniffer"
}

description = 'OpenTelemetry SDK Metrics'
ext.moduleName = "io.opentelemetry.sdk.metrics"
ext.propertiesDir = "build/generated/properties/io/opentelemetry/sdk/metrics"

dependencies {
api project(':opentelemetry-api'),
project(':opentelemetry-sdk-common')

implementation libraries.guava

annotationProcessor libraries.auto_value

testAnnotationProcessor libraries.auto_value
testCompileOnly libraries.auto_value_annotation

testCompile project(path: ':opentelemetry-sdk-common', configuration: 'testClasses')

testImplementation project(':opentelemetry-testing-internal')
testImplementation libraries.junit_pioneer

signature "org.codehaus.mojo.signature:java17:1.0@signature"
signature "net.sf.androidscents.signature:android-api-level-24:7.0_r2@signature"
}

sourceSets {
main {
output.dir("build/generated/properties", builtBy: 'generateVersionResource')
}
}

animalsniffer {
// Don't check sourceSets.jmh and sourceSets.test
sourceSets = [
sourceSets.main
]
}

task generateVersionResource {
doLast {
def folder = file(propertiesDir)
folder.mkdirs()
def propertiesFile = new File(folder.getAbsolutePath(), "version.properties")
propertiesFile.write("sdk.version=${project.version}")
}
}
53 changes: 53 additions & 0 deletions sdk/tracing/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
plugins {
id "java"
id "maven-publish"

id "me.champeau.gradle.jmh"
id "ru.vyarus.animalsniffer"
}

description = 'OpenTelemetry SDK Tracing'
ext.moduleName = "io.opentelemetry.sdk.tracing"
ext.propertiesDir = "build/generated/properties/io/opentelemetry/sdk/tracing"

dependencies {
api project(':opentelemetry-api'),
project(':opentelemetry-sdk-common')

implementation libraries.guava

annotationProcessor libraries.auto_value

testAnnotationProcessor libraries.auto_value
testCompileOnly libraries.auto_value_annotation

testCompile project(path: ':opentelemetry-sdk-common', configuration: 'testClasses')

testImplementation project(':opentelemetry-testing-internal')
testImplementation libraries.junit_pioneer

signature "org.codehaus.mojo.signature:java17:1.0@signature"
signature "net.sf.androidscents.signature:android-api-level-24:7.0_r2@signature"
}

sourceSets {
main {
output.dir("build/generated/properties", builtBy: 'generateVersionResource')
}
}

animalsniffer {
// Don't check sourceSets.jmh and sourceSets.test
sourceSets = [
sourceSets.main
]
}

task generateVersionResource {
doLast {
def folder = file(propertiesDir)
folder.mkdirs()
def propertiesFile = new File(folder.getAbsolutePath(), "version.properties")
propertiesFile.write("sdk.version=${project.version}")
}
}
Loading

0 comments on commit 2659726

Please sign in to comment.