Skip to content

Commit

Permalink
Add MP Telemetry (#66)
Browse files Browse the repository at this point in the history
Add microprofile telemetry tracing feature.
---------

Co-authored-by: Koki Kosaka <[email protected]>
  • Loading branch information
kosakak and Koki Kosaka authored Jun 5, 2023
1 parent 486511a commit ad103de
Show file tree
Hide file tree
Showing 35 changed files with 2,097 additions and 488 deletions.
10 changes: 2 additions & 8 deletions launcher-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@
</dependency>
<dependency>
<groupId>com.fujitsu.launcher</groupId>
<artifactId>microprofile-opentracing</artifactId>
<artifactId>microprofile-rest-client</artifactId>
</dependency>
<dependency>
<groupId>com.fujitsu.launcher</groupId>
<artifactId>microprofile-rest-client</artifactId>
<artifactId>microprofile-telemetry-tracing</artifactId>
</dependency>
<dependency>
<groupId>com.fujitsu.launcher</groupId>
Expand Down Expand Up @@ -138,12 +138,6 @@
<exclude>org/glassfish/web/embed/default-web.xml</exclude>
</excludes>
</filter>
<filter>
<artifact>io.smallrye:smallrye-opentracing</artifact>
<excludes>
<exclude>META-INF/services/org.eclipse.microprofile.rest.client.spi.RestClientListener</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.jersey.server;

import java.util.Comparator;
import java.util.logging.Logger;

import org.glassfish.jersey.internal.BootstrapBag;
import org.glassfish.jersey.internal.BootstrapConfigurator;
import org.glassfish.jersey.internal.inject.InjectionManager;
import org.glassfish.jersey.server.model.Resource;

/**
* Configurator which initializes and register {@link ResourceBag} instance into {@link BootstrapBag}.
*
* @author Petr Bouda
*/
class ResourceBagConfigurator implements BootstrapConfigurator {

private static final Logger LOGGER = Logger.getLogger(ResourceBagConfigurator.class.getName());

@Override
public void init(InjectionManager injectionManager, BootstrapBag bootstrapBag) {
ServerBootstrapBag serverBag = (ServerBootstrapBag) bootstrapBag;
ResourceConfig runtimeConfig = serverBag.getRuntimeConfig();

final boolean disableValidation = ServerProperties.getValue(runtimeConfig.getProperties(),
ServerProperties.RESOURCE_VALIDATION_DISABLE,
Boolean.FALSE,
Boolean.class);

final ResourceBag.Builder resourceBagBuilder = new ResourceBag.Builder();

// Adding programmatic resource models
for (final Resource programmaticResource : runtimeConfig.getResources()) {
resourceBagBuilder.registerProgrammaticResource(programmaticResource);
}

// Introspecting classes & instances
if (Boolean.getBoolean(ServerProperties.RESOURCE_VALIDATION_IGNORE_ERRORS)) {
runtimeConfig.getClasses().stream().sorted(new Comparator<Class<?>>() {
@Override
public int compare(Class<?> o1, Class<?> o2) {
if (o1.isInterface() && !o2.isInterface()) {
return 1;
} else if (!o1.isInterface() && o2.isInterface()) {
return -1;
} else {
return 0;
}
}
}).forEach( c -> {
try {
final Resource resource = Resource.from(c, disableValidation);
if (resource != null) {
resourceBagBuilder.registerResource(c, resource);
}
} catch (final IllegalArgumentException ex) {
LOGGER.warning(ex.getMessage());
}
});
} else {
for (final Class<?> c : runtimeConfig.getClasses()) {
try {
final Resource resource = Resource.from(c, disableValidation);
if (resource != null) {
resourceBagBuilder.registerResource(c, resource);
}
} catch (final IllegalArgumentException ex) {
LOGGER.warning(ex.getMessage());
}
}
}

for (final Object o : runtimeConfig.getSingletons()) {
try {
final Resource resource = Resource.from(o.getClass(), disableValidation);
if (resource != null) {
resourceBagBuilder.registerResource(o, resource);
}
} catch (final IllegalArgumentException ex) {
LOGGER.warning(ex.getMessage());
}
}

serverBag.setResourceBag(resourceBagBuilder.build());
}
}
43 changes: 0 additions & 43 deletions launcher-impl/microprofile/opentracing/pom.xml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit ad103de

Please sign in to comment.