Use sdk_contrib exporter glue (#285)

This commit is contained in:
Pontus Rydin 2020-03-27 14:23:14 -04:00 committed by GitHub
parent 2a738506a9
commit ff47bf04cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 31 additions and 90 deletions

View File

@ -21,9 +21,8 @@ dependencies {
compile deps.opentelemetryApi
compile deps.opentelemetrySdk
compile deps.opentelemetrySdkAutoConfig
// TODO: This might have to live in opentelemetry-java
compile project(':exporter-support')
compile group: 'com.blogspot.mydailyjava', name: 'weak-lock-free', version: '0.15'
compile deps.bytebuddy

View File

@ -16,12 +16,11 @@
package io.opentelemetry.auto.tooling;
import io.opentelemetry.auto.config.Config;
import io.opentelemetry.auto.exportersupport.ConfigProvider;
public class DefaultConfigProvider implements ConfigProvider {
public class DefaultExporterConfig implements io.opentelemetry.sdk.contrib.auto.config.Config {
private final String prefix;
public DefaultConfigProvider(final String prefix) {
public DefaultExporterConfig(final String prefix) {
this.prefix = prefix;
}

View File

@ -62,7 +62,7 @@ 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.auto.exportersupport.SpanExporterFactory")) {
"META-INF/services/io.opentelemetry.sdk.contrib.auto.config.SpanExporterFactory")) {
return findResources(name);
}
return super.getResources(name);

View File

@ -17,8 +17,8 @@ package io.opentelemetry.auto.tooling;
import com.google.common.annotations.VisibleForTesting;
import io.opentelemetry.auto.config.Config;
import io.opentelemetry.auto.exportersupport.SpanExporterFactory;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.contrib.auto.config.SpanExporterFactory;
import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import java.io.File;
@ -74,7 +74,7 @@ public class TracerInstaller {
log.warn(
"Exporter JAR defines more than one factory. Only the first one found will be used");
}
return f.fromConfig(new DefaultConfigProvider("exporter"));
return f.fromConfig(new DefaultExporterConfig("exporter"));
}
log.warn("No matching providers in jar " + exporterJar);
return null;

View File

@ -6,6 +6,6 @@ apply from: "${rootDir}/gradle/java.gradle"
dependencies {
compile deps.opentelemetryJaeger
compile project(':exporter-support')
compileOnly deps.opentelemetrySdkAutoConfig
compile group: 'io.grpc', name: 'grpc-api', version: '1.24.0'
}

View File

@ -17,9 +17,9 @@ package io.opentelemetry.auto.exporters.jaeger;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.opentelemetry.auto.exportersupport.ConfigProvider;
import io.opentelemetry.auto.exportersupport.SpanExporterFactory;
import io.opentelemetry.exporters.jaeger.JaegerGrpcSpanExporter;
import io.opentelemetry.sdk.contrib.auto.config.Config;
import io.opentelemetry.sdk.contrib.auto.config.SpanExporterFactory;
import io.opentelemetry.sdk.trace.export.SpanExporter;
public class JaegerExporterFactory implements SpanExporterFactory {
@ -34,7 +34,7 @@ public class JaegerExporterFactory implements SpanExporterFactory {
private static final String DEFAULT_SERVICE = "(unknown service)";
@Override
public SpanExporter fromConfig(final ConfigProvider config) {
public SpanExporter fromConfig(final Config config) {
final String host = config.getString(HOST_CONFIG, null);
if (host == null) {
throw new IllegalArgumentException(HOST_CONFIG + " must be specified");

View File

@ -7,6 +7,6 @@ apply from: "${rootDir}/gradle/java.gradle"
dependencies {
compileOnly deps.opentelemetrySdk
compileOnly deps.opentelemetryApi
compile project(":exporter-support")
compileOnly deps.opentelemetrySdkAutoConfig
}

View File

@ -15,13 +15,13 @@
*/
package io.opentelemetry.auto.exporters.loggingexporter;
import io.opentelemetry.auto.exportersupport.ConfigProvider;
import io.opentelemetry.auto.exportersupport.SpanExporterFactory;
import io.opentelemetry.sdk.contrib.auto.config.Config;
import io.opentelemetry.sdk.contrib.auto.config.SpanExporterFactory;
import io.opentelemetry.sdk.trace.export.SpanExporter;
public class LoggingExporterFactory implements SpanExporterFactory {
@Override
public SpanExporter fromConfig(final ConfigProvider config) {
public SpanExporter fromConfig(final Config config) {
return new LoggingExporter(config.getString("logging.prefix", "no-prefix"));
}
}

View File

@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import io.opentelemetry.auto.exportersupport.SpanExporterFactory
import io.opentelemetry.auto.tooling.ExporterClassLoader
import io.opentelemetry.sdk.contrib.auto.config.SpanExporterFactory
import spock.lang.Shared
import spock.lang.Specification

View File

@ -1,5 +0,0 @@
apply from: "${rootDir}/gradle/java.gradle"
dependencies {
compileOnly deps.opentelemetrySdk
}

View File

@ -1,28 +0,0 @@
/*
* Copyright 2020, 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.auto.exportersupport;
public interface ConfigProvider {
String getString(String key, String defaultValue);
int getInt(String key, int defaultValue);
long getLong(String key, long defaultValue);
boolean getBoolean(String key, boolean defaultValue);
double getDouble(String key, double defaultValue);
}

View File

@ -1,22 +0,0 @@
/*
* Copyright 2020, 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.auto.exportersupport;
import io.opentelemetry.sdk.trace.export.SpanExporter;
public interface SpanExporterFactory {
SpanExporter fromConfig(ConfigProvider config);
}

View File

@ -22,6 +22,7 @@ ext {
// OpenTelemetry
opentelemetryApi : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-api', version: versions.opentelemetry),
opentelemetrySdk : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-sdk', version: versions.opentelemetry),
opentelemetrySdkAutoConfig: dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-sdk-contrib-auto-config', version: versions.opentelemetry),
opentelemetryJaeger : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporters-jaeger', version: versions.opentelemetry),
// General

View File

@ -27,9 +27,6 @@ include ':agent-bootstrap'
include ':agent-tooling'
include ':load-generator'
// exporter support
include ':exporter-support'
// misc
include ':testing'
include ':utils:test-utils'