-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support using
ReconfigurableOpenTelemetry
instance through @Inject
- Loading branch information
1 parent
83ee9ac
commit 85785bc
Showing
4 changed files
with
114 additions
and
34 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
29 changes: 29 additions & 0 deletions
29
src/main/java/io/jenkins/plugins/opentelemetry/api/OpenTelemetryApiGuiceModule.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,29 @@ | ||
package io.jenkins.plugins.opentelemetry.api; | ||
|
||
import com.google.inject.AbstractModule; | ||
import hudson.Extension; | ||
import io.opentelemetry.api.OpenTelemetry; | ||
|
||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
/** | ||
* Support using @{@link javax.inject.Inject} to inject the OpenTelemetry instance in Jenkins @{@link Extension}. | ||
*/ | ||
@Extension | ||
public class OpenTelemetryApiGuiceModule extends AbstractModule { | ||
static final Logger logger = Logger.getLogger(OpenTelemetryApiGuiceModule.class.getName()); | ||
|
||
public OpenTelemetryApiGuiceModule() { | ||
logger.log(Level.FINE, "Creating OpenTelemetryApiGuiceModule"); | ||
} | ||
|
||
@Override | ||
public void configure() { | ||
logger.log(Level.FINE, "Configuring OpenTelemetryApiGuiceModule"); | ||
ReconfigurableOpenTelemetry reconfigurableOpenTelemetry = ReconfigurableOpenTelemetry.get(); | ||
bind(OpenTelemetry.class).toInstance(reconfigurableOpenTelemetry); | ||
bind(ExtendedOpenTelemetry.class).toInstance(reconfigurableOpenTelemetry); | ||
bind(ReconfigurableOpenTelemetry.class).toInstance(reconfigurableOpenTelemetry); | ||
} | ||
} |
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
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