Merge exporter auto config into javaagent-tooling. (#1120)
* Merge exporter auto config into javaagent-tooling. * Update javadoc
This commit is contained in:
parent
e20cba57c2
commit
770502eed9
|
@ -36,7 +36,6 @@ ext {
|
|||
opentelemetryAutoAnnotations: dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-extension-auto-annotations', version: versions.opentelemetryOther),
|
||||
opentelemetryTraceProps : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-extension-trace-propagators', version: versions.opentelemetryOther),
|
||||
opentelemetrySdk : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-sdk', version: versions.opentelemetryOther),
|
||||
opentelemetrySdkAutoConfig : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-sdk-extension-auto-config', version: versions.opentelemetryOther),
|
||||
opentelemetryJaeger : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporters-jaeger', version: versions.opentelemetry),
|
||||
opentelemetryOtlp : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporters-otlp', version: versions.opentelemetry),
|
||||
opentelemetryZipkin : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporters-zipkin', version: versions.opentelemetryOther),
|
||||
|
|
|
@ -8,10 +8,15 @@ apply from: "$rootDir/gradle/publish.gradle"
|
|||
archivesBaseName = 'javaagent-exporters-jaeger'
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":javaagent-tooling"))
|
||||
compileOnly deps.opentelemetrySdk
|
||||
|
||||
annotationProcessor deps.autoservice
|
||||
compileOnly deps.autoservice
|
||||
|
||||
implementation(deps.opentelemetryJaeger) {
|
||||
exclude group: 'io.opentelemetry', module: 'opentelemetry-sdk'
|
||||
}
|
||||
compileOnly deps.opentelemetrySdkAutoConfig
|
||||
implementation group: 'io.grpc', name: 'grpc-api', version: '1.24.0'
|
||||
implementation group: 'io.grpc', name: 'grpc-netty-shaded', version: '1.24.0'
|
||||
}
|
||||
|
|
|
@ -16,15 +16,17 @@
|
|||
|
||||
package io.opentelemetry.javaagent.exporters.jaeger;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import io.opentelemetry.exporters.jaeger.JaegerGrpcSpanExporter;
|
||||
import io.opentelemetry.sdk.extensions.auto.config.Config;
|
||||
import io.opentelemetry.sdk.extensions.auto.config.SpanExporterFactory;
|
||||
import io.opentelemetry.javaagent.tooling.exporter.ExporterConfig;
|
||||
import io.opentelemetry.javaagent.tooling.exporter.SpanExporterFactory;
|
||||
import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||
|
||||
@AutoService(SpanExporterFactory.class)
|
||||
public class JaegerExporterFactory implements SpanExporterFactory {
|
||||
|
||||
@Override
|
||||
public SpanExporter fromConfig(Config config) {
|
||||
public SpanExporter fromConfig(ExporterConfig config) {
|
||||
return JaegerGrpcSpanExporter.newBuilder()
|
||||
.readEnvironmentVariables()
|
||||
.readSystemProperties()
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
io.opentelemetry.javaagent.exporters.jaeger.JaegerExporterFactory
|
|
@ -7,7 +7,6 @@ apply from: "$rootDir/gradle/java.gradle"
|
|||
dependencies {
|
||||
testImplementation project(':javaagent-tooling')
|
||||
|
||||
testImplementation deps.opentelemetrySdkAutoConfig
|
||||
testImplementation project(':javaagent-exporters:otlp')
|
||||
testImplementation project(':javaagent-exporters:jaeger')
|
||||
testImplementation project(':javaagent-exporters:logging')
|
||||
|
|
|
@ -8,9 +8,13 @@ apply from: "$rootDir/gradle/publish.gradle"
|
|||
archivesBaseName = 'javaagent-exporters-logging'
|
||||
|
||||
dependencies {
|
||||
compileOnly project(':javaagent-tooling')
|
||||
|
||||
annotationProcessor deps.autoservice
|
||||
compileOnly deps.autoservice
|
||||
|
||||
compileOnly deps.opentelemetrySdk
|
||||
compileOnly deps.opentelemetryApi
|
||||
compileOnly deps.opentelemetrySdkAutoConfig
|
||||
}
|
||||
|
||||
jar.enabled = false
|
||||
|
|
|
@ -16,13 +16,15 @@
|
|||
|
||||
package io.opentelemetry.javaagent.exporters.logging;
|
||||
|
||||
import io.opentelemetry.sdk.extensions.auto.config.Config;
|
||||
import io.opentelemetry.sdk.extensions.auto.config.SpanExporterFactory;
|
||||
import com.google.auto.service.AutoService;
|
||||
import io.opentelemetry.javaagent.tooling.exporter.ExporterConfig;
|
||||
import io.opentelemetry.javaagent.tooling.exporter.SpanExporterFactory;
|
||||
import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||
|
||||
@AutoService(SpanExporterFactory.class)
|
||||
public class LoggingExporterFactory implements SpanExporterFactory {
|
||||
@Override
|
||||
public SpanExporter fromConfig(Config config) {
|
||||
public SpanExporter fromConfig(ExporterConfig config) {
|
||||
return new LoggingExporter(config.getString("logging.prefix", "Logging Exporter:"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
io.opentelemetry.javaagent.exporters.logging.LoggingExporterFactory
|
|
@ -8,10 +8,15 @@ apply from: "$rootDir/gradle/publish.gradle"
|
|||
archivesBaseName = 'javaagent-exporters-otlp'
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(':javaagent-tooling'))
|
||||
compileOnly(deps.opentelemetrySdk)
|
||||
|
||||
annotationProcessor deps.autoservice
|
||||
compileOnly deps.autoservice
|
||||
|
||||
implementation(deps.opentelemetryOtlp) {
|
||||
exclude group: 'io.opentelemetry', module: 'opentelemetry-sdk'
|
||||
}
|
||||
compileOnly deps.opentelemetrySdkAutoConfig
|
||||
implementation group: 'io.grpc', name: 'grpc-api', version: '1.24.0'
|
||||
implementation group: 'io.grpc', name: 'grpc-netty-shaded', version: '1.24.0'
|
||||
}
|
||||
|
|
|
@ -16,15 +16,17 @@
|
|||
|
||||
package io.opentelemetry.javaagent.exporters.otlp;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import io.opentelemetry.exporters.otlp.OtlpGrpcMetricExporter;
|
||||
import io.opentelemetry.sdk.extensions.auto.config.Config;
|
||||
import io.opentelemetry.sdk.extensions.auto.config.MetricExporterFactory;
|
||||
import io.opentelemetry.javaagent.tooling.exporter.ExporterConfig;
|
||||
import io.opentelemetry.javaagent.tooling.exporter.MetricExporterFactory;
|
||||
import io.opentelemetry.sdk.metrics.export.MetricExporter;
|
||||
|
||||
@AutoService(MetricExporterFactory.class)
|
||||
public class OtlpMetricExporterFactory implements MetricExporterFactory {
|
||||
|
||||
@Override
|
||||
public MetricExporter fromConfig(Config config) {
|
||||
public MetricExporter fromConfig(ExporterConfig config) {
|
||||
return OtlpGrpcMetricExporter.newBuilder()
|
||||
.readEnvironmentVariables()
|
||||
.readSystemProperties()
|
||||
|
|
|
@ -16,15 +16,17 @@
|
|||
|
||||
package io.opentelemetry.javaagent.exporters.otlp;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import io.opentelemetry.exporters.otlp.OtlpGrpcSpanExporter;
|
||||
import io.opentelemetry.sdk.extensions.auto.config.Config;
|
||||
import io.opentelemetry.sdk.extensions.auto.config.SpanExporterFactory;
|
||||
import io.opentelemetry.javaagent.tooling.exporter.ExporterConfig;
|
||||
import io.opentelemetry.javaagent.tooling.exporter.SpanExporterFactory;
|
||||
import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||
|
||||
@AutoService(SpanExporterFactory.class)
|
||||
public class OtlpSpanExporterFactory implements SpanExporterFactory {
|
||||
|
||||
@Override
|
||||
public SpanExporter fromConfig(Config config) {
|
||||
public SpanExporter fromConfig(ExporterConfig config) {
|
||||
return OtlpGrpcSpanExporter.newBuilder()
|
||||
.readEnvironmentVariables()
|
||||
.readSystemProperties()
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
io.opentelemetry.javaagent.exporters.otlp.OtlpMetricExporterFactory
|
|
@ -1 +0,0 @@
|
|||
io.opentelemetry.javaagent.exporters.otlp.OtlpSpanExporterFactory
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
|
||||
import io.opentelemetry.javaagent.tooling.ExporterClassLoader
|
||||
import io.opentelemetry.sdk.extensions.auto.config.SpanExporterFactory
|
||||
import io.opentelemetry.javaagent.tooling.exporter.SpanExporterFactory
|
||||
import spock.lang.Shared
|
||||
import spock.lang.Specification
|
||||
|
||||
|
|
|
@ -16,15 +16,17 @@
|
|||
|
||||
package io.opentelemetry.javaagent.exporters.zipkin;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import io.opentelemetry.exporters.zipkin.ZipkinSpanExporter;
|
||||
import io.opentelemetry.sdk.extensions.auto.config.Config;
|
||||
import io.opentelemetry.sdk.extensions.auto.config.SpanExporterFactory;
|
||||
import io.opentelemetry.javaagent.tooling.exporter.ExporterConfig;
|
||||
import io.opentelemetry.javaagent.tooling.exporter.SpanExporterFactory;
|
||||
import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||
|
||||
@AutoService(SpanExporterFactory.class)
|
||||
public class ZipkinExporterFactory implements SpanExporterFactory {
|
||||
|
||||
@Override
|
||||
public SpanExporter fromConfig(Config config) {
|
||||
public SpanExporter fromConfig(ExporterConfig config) {
|
||||
return ZipkinSpanExporter.newBuilder()
|
||||
.readEnvironmentVariables()
|
||||
.readSystemProperties()
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
io.opentelemetry.javaagent.exporters.zipkin.ZipkinExporterFactory
|
|
@ -8,10 +8,15 @@ apply from: "$rootDir/gradle/publish.gradle"
|
|||
archivesBaseName = 'javaagent-exporters-zipkin'
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(':javaagent-tooling'))
|
||||
compileOnly(deps.opentelemetrySdk)
|
||||
|
||||
annotationProcessor deps.autoservice
|
||||
compileOnly deps.autoservice
|
||||
|
||||
implementation(deps.opentelemetryZipkin) {
|
||||
exclude group: 'io.opentelemetry', module: 'opentelemetry-sdk'
|
||||
}
|
||||
compileOnly deps.opentelemetrySdkAutoConfig
|
||||
}
|
||||
|
||||
jar.enabled = false
|
||||
|
|
|
@ -20,7 +20,6 @@ dependencies {
|
|||
implementation deps.opentelemetryApi
|
||||
implementation deps.opentelemetryContextProp
|
||||
implementation deps.opentelemetrySdk
|
||||
implementation deps.opentelemetrySdkAutoConfig
|
||||
implementation deps.opentelemetryTraceProps
|
||||
|
||||
implementation group: 'com.blogspot.mydailyjava', name: 'weak-lock-free', version: '0.15'
|
||||
|
|
|
@ -76,9 +76,9 @@ public class ExporterClassLoader extends URLClassLoader {
|
|||
// A small hack to prevent other exporters from being loaded by this classloader if they
|
||||
// should happen to appear on the classpath.
|
||||
if (name.equals(
|
||||
"META-INF/services/io.opentelemetry.sdk.extensions.auto.config.SpanExporterFactory")
|
||||
"META-INF/services/io.opentelemetry.javaagent.tooling.exporter.SpanExporterFactory")
|
||||
|| name.equals(
|
||||
"META-INF/services/io.opentelemetry.sdk.extensions.auto.config.MetricExporterFactory")) {
|
||||
"META-INF/services/io.opentelemetry.javaagent.tooling.exporter.MetricExporterFactory")) {
|
||||
return findResources(name);
|
||||
}
|
||||
return super.getResources(name);
|
||||
|
|
|
@ -18,9 +18,10 @@ package io.opentelemetry.javaagent.tooling;
|
|||
|
||||
import io.opentelemetry.instrumentation.api.config.Config;
|
||||
import io.opentelemetry.javaagent.bootstrap.spi.TracerCustomizer;
|
||||
import io.opentelemetry.javaagent.tooling.exporter.DefaultExporterConfig;
|
||||
import io.opentelemetry.javaagent.tooling.exporter.MetricExporterFactory;
|
||||
import io.opentelemetry.javaagent.tooling.exporter.SpanExporterFactory;
|
||||
import io.opentelemetry.sdk.OpenTelemetrySdk;
|
||||
import io.opentelemetry.sdk.extensions.auto.config.MetricExporterFactory;
|
||||
import io.opentelemetry.sdk.extensions.auto.config.SpanExporterFactory;
|
||||
import io.opentelemetry.sdk.metrics.export.IntervalMetricReader;
|
||||
import io.opentelemetry.sdk.metrics.export.MetricExporter;
|
||||
import io.opentelemetry.sdk.trace.TracerSdkProvider;
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.opentelemetry.javaagent.tooling;
|
||||
package io.opentelemetry.javaagent.tooling.exporter;
|
||||
|
||||
import io.opentelemetry.instrumentation.api.config.Config;
|
||||
|
||||
public class DefaultExporterConfig implements io.opentelemetry.sdk.extensions.auto.config.Config {
|
||||
public class DefaultExporterConfig implements ExporterConfig {
|
||||
private final String prefix;
|
||||
|
||||
public DefaultExporterConfig(String prefix) {
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Copyright The 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.javaagent.tooling.exporter;
|
||||
|
||||
/**
|
||||
* An interface used to provide configuration information to {@link SpanExporterFactory} and {@link
|
||||
* MetricExporterFactory} implementations.
|
||||
*
|
||||
* <p>This interface is intentionally kept very simple since the underlying implementations may only
|
||||
* have access to very basic configuration mechanisms such as system properties and environment
|
||||
* variables.
|
||||
*/
|
||||
public interface ExporterConfig {
|
||||
/**
|
||||
* Returns the string configuration property corresponding to a key. If the underlying
|
||||
* implementation cannot find a property for the key, {@code defaultValue} is returned.
|
||||
*
|
||||
* @param key The config key
|
||||
* @param defaultValue The value to use if no configuration property couldn't be found
|
||||
* @return The value of the configuration parameter
|
||||
*/
|
||||
String getString(String key, String defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the {@code int} configuration property corresponding to a key. If the underlying
|
||||
* implementation cannot find a property for the key, {@code defaultValue} is returned.
|
||||
*
|
||||
* @param key The config key
|
||||
* @param defaultValue The value to use if no configuration property couldn't be found
|
||||
* @return The value of the configuration parameter
|
||||
*/
|
||||
int getInt(String key, int defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the {@code long} configuration property corresponding to a key. If the underlying
|
||||
* implementation cannot find a property for the key, {@code defaultValue} is returned.
|
||||
*
|
||||
* @param key The config key
|
||||
* @param defaultValue The value to use if no configuration property couldn't be found
|
||||
* @return The value of the configuration parameter
|
||||
*/
|
||||
long getLong(String key, long defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the {@code boolean} configuration property corresponding to a key. If the underlying
|
||||
* implementation cannot find a property for the key, {@code defaultValue} is returned.
|
||||
*
|
||||
* @param key The config key
|
||||
* @param defaultValue The value to use if no configuration property couldn't be found
|
||||
* @return The value of the configuration parameter
|
||||
*/
|
||||
boolean getBoolean(String key, boolean defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the {@code double} configuration property corresponding to a key. If the underlying
|
||||
* implementation cannot find a property for the key, {@code defaultValue} is returned.
|
||||
*
|
||||
* @param key The config key
|
||||
* @param defaultValue The value to use if no configuration property couldn't be found
|
||||
* @return The value of the configuration parameter
|
||||
*/
|
||||
double getDouble(String key, double defaultValue);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright The 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.javaagent.tooling.exporter;
|
||||
|
||||
import io.opentelemetry.sdk.metrics.export.MetricExporter;
|
||||
|
||||
/**
|
||||
* A {@link MetricExporterFactory} acts as the bootstrap for a {@link MetricExporter}
|
||||
* implementation. An exporter must register its implementation of a {@link MetricExporterFactory}
|
||||
* through the Java SPI framework.
|
||||
*/
|
||||
public interface MetricExporterFactory {
|
||||
/**
|
||||
* Creates an instance of a {@link MetricExporter} based on the provided configuration.
|
||||
*
|
||||
* @param config The configuration
|
||||
* @return An implementation of a {@link MetricExporter}
|
||||
*/
|
||||
MetricExporter fromConfig(ExporterConfig config);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright The 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.javaagent.tooling.exporter;
|
||||
|
||||
import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||
|
||||
/**
|
||||
* A {@link SpanExporterFactory} acts as the bootstrap for a {@link SpanExporter} implementation. An
|
||||
* exporter must register its implementation of a {@link SpanExporterFactory} through the Java SPI
|
||||
* framework.
|
||||
*/
|
||||
public interface SpanExporterFactory {
|
||||
/**
|
||||
* Creates an instance of a {@link SpanExporter} based on the provided configuration.
|
||||
*
|
||||
* @param config The configuration
|
||||
* @return An implementation of a {@link SpanExporter}
|
||||
*/
|
||||
SpanExporter fromConfig(ExporterConfig config);
|
||||
}
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
package io.opentelemetry.javaagent.tooling
|
||||
|
||||
import io.opentelemetry.sdk.extensions.auto.config.Config
|
||||
import io.opentelemetry.sdk.extensions.auto.config.MetricExporterFactory
|
||||
import io.opentelemetry.sdk.extensions.auto.config.SpanExporterFactory
|
||||
import io.opentelemetry.javaagent.tooling.exporter.ExporterConfig
|
||||
import io.opentelemetry.javaagent.tooling.exporter.MetricExporterFactory
|
||||
import io.opentelemetry.javaagent.tooling.exporter.SpanExporterFactory
|
||||
import io.opentelemetry.sdk.metrics.export.MetricExporter
|
||||
import io.opentelemetry.sdk.trace.export.SpanExporter
|
||||
import java.nio.charset.StandardCharsets
|
||||
|
@ -56,7 +56,7 @@ class ExporterClassLoaderTest extends Specification {
|
|||
static class MetricExporterFactoryParent implements MetricExporterFactory {
|
||||
|
||||
@Override
|
||||
MetricExporter fromConfig(Config config) {
|
||||
MetricExporter fromConfig(ExporterConfig config) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class ExporterClassLoaderTest extends Specification {
|
|||
static class MetricExporterFactoryChild implements MetricExporterFactory {
|
||||
|
||||
@Override
|
||||
MetricExporter fromConfig(Config config) {
|
||||
MetricExporter fromConfig(ExporterConfig config) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ class ExporterClassLoaderTest extends Specification {
|
|||
static class SpanExporterFactoryParent implements SpanExporterFactory {
|
||||
|
||||
@Override
|
||||
SpanExporter fromConfig(Config config) {
|
||||
SpanExporter fromConfig(ExporterConfig config) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ class ExporterClassLoaderTest extends Specification {
|
|||
static class SpanExporterFactoryChild implements SpanExporterFactory {
|
||||
|
||||
@Override
|
||||
SpanExporter fromConfig(Config config) {
|
||||
SpanExporter fromConfig(ExporterConfig config) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue