-
Notifications
You must be signed in to change notification settings - Fork 848
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* A rough idea of how named tracers might look in the API. * update to require at least a name for the tracer * Introduce another layer of factory for the provider * remove convenience tracer methods from the OpenTelemetry class. * Update api/src/main/java/io/opentelemetry/trace/spi/TracerFactoryProvider.java Co-Authored-By: Armin Ruech <armin.ruech@gmail.com> * Update api/src/main/java/io/opentelemetry/trace/TracerFactory.java Co-Authored-By: Armin Ruech <armin.ruech@gmail.com> * Add clarifying javadoc, per PR review * reverse who calls whom
- Loading branch information
1 parent
a10e918
commit 60ba3b7
Showing
14 changed files
with
283 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
api/src/main/java/io/opentelemetry/trace/DefaultTracerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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.trace; | ||
|
||
public class DefaultTracerFactory implements TracerFactory { | ||
|
||
private static final TracerFactory instance = new DefaultTracerFactory(); | ||
|
||
public static TracerFactory getInstance() { | ||
return instance; | ||
} | ||
|
||
@Override | ||
public Tracer get(String instrumentationName) { | ||
return get(instrumentationName, null); | ||
} | ||
|
||
@Override | ||
public Tracer get(String instrumentationName, String instrumentationVersion) { | ||
return DefaultTracer.getInstance(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
api/src/main/java/io/opentelemetry/trace/DefaultTracerFactoryProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* 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.trace; | ||
|
||
import io.opentelemetry.trace.spi.TracerFactoryProvider; | ||
|
||
public class DefaultTracerFactoryProvider implements TracerFactoryProvider { | ||
private static final TracerFactoryProvider instance = new DefaultTracerFactoryProvider(); | ||
|
||
public static TracerFactoryProvider getInstance() { | ||
return instance; | ||
} | ||
|
||
@Override | ||
public TracerFactory create() { | ||
return DefaultTracerFactory.getInstance(); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
api/src/main/java/io/opentelemetry/trace/TracerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* 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.trace; | ||
|
||
import javax.annotation.concurrent.ThreadSafe; | ||
|
||
/** | ||
* A factory for creating named {@link Tracer}s. | ||
* | ||
* @see io.opentelemetry.OpenTelemetry | ||
* @see io.opentelemetry.trace.Tracer | ||
* @since 0.1.0 | ||
*/ | ||
@ThreadSafe | ||
public interface TracerFactory { | ||
|
||
/** | ||
* Gets or creates a named tracer instance. | ||
* | ||
* @param instrumentationName The name of the instrumentation library, not the name of the | ||
* instrument*ed* library. | ||
* @return a tracer instance. | ||
* @since 0.1.0 | ||
*/ | ||
Tracer get(String instrumentationName); | ||
|
||
/** | ||
* Gets or creates a named and versioned tracer instance. | ||
* | ||
* @param instrumentationName The name of the instrumentation library, not the name of the | ||
* instrument*ed* library. | ||
* @param instrumentationVersion The version of the instrumentation library. | ||
* @return a tracer instance. | ||
* @since 0.1.0 | ||
*/ | ||
Tracer get(String instrumentationName, String instrumentationVersion); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.