Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ObservabilityDevServicesConfigBuildItem usage - can be multiple, fix dup logging output #43945

Merged
merged 5 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import java.util.Map;

import io.quarkus.builder.item.SimpleBuildItem;
import io.quarkus.builder.item.MultiBuildItem;

/**
* Build item used to carry running DevService values to Dev UI.
*/
public final class ObservabilityDevServicesConfigBuildItem extends SimpleBuildItem {
public final class ObservabilityDevServicesConfigBuildItem extends MultiBuildItem {

private final Map<String, String> config;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.quarkus.observability.deployment.devui;

import java.util.List;
import java.util.Map;
import java.util.Optional;

import org.apache.commons.lang3.StringUtils;

Expand All @@ -26,45 +26,46 @@ public class ObservabilityDevUIProcessor {
@BuildStep(onlyIf = IsDevelopment.class)
void createVersion(BuildProducer<CardPageBuildItem> cardPageBuildItemBuildProducer,
BuildProducer<FooterPageBuildItem> footerProducer,
Optional<ObservabilityDevServicesConfigBuildItem> configProps) {
List<ObservabilityDevServicesConfigBuildItem> configProps) {

// LGTM
if (configProps.isPresent()) {
Map<String, String> runtimeConfig = configProps.get().getConfig();
String grafanaUrl = runtimeConfig.getOrDefault("grafana.endpoint", "");
if (configProps != null) {
configProps.forEach(cp -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change it here but we should really avoid using lambdas when they have no value. In this case a for loop would have been better.

Also configProps should never be null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Map<String, String> runtimeConfig = cp.getConfig();

if (StringUtils.isNotEmpty(grafanaUrl)) {
final CardPageBuildItem card = new CardPageBuildItem();
// LGTM
String grafanaUrl = runtimeConfig.getOrDefault("grafana.endpoint", "");
if (StringUtils.isNotEmpty(grafanaUrl)) {
final CardPageBuildItem card = new CardPageBuildItem();

// Grafana
grafanaUrl = StringUtils.prependIfMissing(grafanaUrl, "http://");
card.addPage(Page.externalPageBuilder("Grafana UI")
.url(grafanaUrl, grafanaUrl)
.doNotEmbed()
.isHtmlContent()
.icon("font-awesome-solid:chart-line"));
// Grafana
grafanaUrl = StringUtils.prependIfMissing(grafanaUrl, "http://");
card.addPage(Page.externalPageBuilder("Grafana UI")
.url(grafanaUrl, grafanaUrl)
.doNotEmbed()
.isHtmlContent()
.icon("font-awesome-solid:chart-line"));

// Open Telemetry
final ExternalPageBuilder otelPage = Page.externalPageBuilder("OpenTelemetry Port")
.icon("font-awesome-solid:binoculars")
.doNotEmbed()
.url("https://opentelemetry.io/")
.staticLabel(StringUtils
.substringAfterLast(runtimeConfig.getOrDefault("otel-collector.url", "0"), ":"));
card.addPage(otelPage);
// Open Telemetry
final ExternalPageBuilder otelPage = Page.externalPageBuilder("OpenTelemetry Port")
.icon("font-awesome-solid:binoculars")
.doNotEmbed()
.url("https://opentelemetry.io/")
.staticLabel(StringUtils
.substringAfterLast(runtimeConfig.getOrDefault("otel-collector.url", "0"), ":"));
card.addPage(otelPage);

card.setCustomCard("qwc-lgtm-card.js");
cardPageBuildItemBuildProducer.produce(card);
card.setCustomCard("qwc-lgtm-card.js");
cardPageBuildItemBuildProducer.produce(card);

// LGTM Container Log Console
WebComponentPageBuilder mailLogPageBuilder = Page.webComponentPageBuilder()
.icon("font-awesome-solid:chart-line")
.title("LGTM")
.componentLink("qwc-lgtm-log.js");
// LGTM Container Log Console
WebComponentPageBuilder mailLogPageBuilder = Page.webComponentPageBuilder()
.icon("font-awesome-solid:chart-line")
.title("LGTM")
.componentLink("qwc-lgtm-log.js");

footerProducer.produce(new FooterPageBuildItem(mailLogPageBuilder));
}
footerProducer.produce(new FooterPageBuildItem(mailLogPageBuilder));
}
});
}

}
}