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

Slight logging tweaks #349

Merged
merged 3 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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 @@ -8,6 +8,7 @@
import jetbrains.buildServer.serverSide.SProject;
import jetbrains.buildServer.web.openapi.*;
import jetbrains.buildServer.web.util.WebUtil;
import org.apache.logging.log4j.CloseableThreadContext;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.web.servlet.ModelAndView;
Expand Down Expand Up @@ -73,29 +74,32 @@ protected ModelAndView doHandle(@NotNull HttpServletRequest request, @NotNull Ht

Long buildId = WebUtil.sakuraUIOpened(request)
? PluginUIContext.getFromRequest(request).getBuildId()
: Long.parseLong(request.getParameter("buildId"));
: Long.valueOf(Long.parseLong(request.getParameter("buildId")));

if (buildId != null) {
final SBuild build = sBuildServer.findBuildInstanceById(buildId);
if (build == null) //if it's queued, we won't get it
return getEmptyState();
try (var ignored1 = CloseableThreadContext.put("teamcity.build.id", String.valueOf(buildId))) {

final SProject project = projectManager.findProjectByExternalId(build.getProjectExternalId());
final SBuild build = sBuildServer.findBuildInstanceById(buildId);
if (build == null) //if it's queued, we won't get it
return getEmptyState();

var features = project.getAvailableFeaturesOfType(PLUGIN_NAME);
if (!features.isEmpty()) {
var feature = features.stream().findFirst().get();
var params = feature.getParameters();
final SProject project = projectManager.findProjectByExternalId(build.getProjectExternalId());

if (!params.get(PROPERTY_KEY_ENABLED).equals("true"))
return getEmptyState();
var features = project.getAvailableFeaturesOfType(PLUGIN_NAME);
if (!features.isEmpty()) {
var feature = features.stream().findFirst().get();
var params = feature.getParameters();

var traceId = buildStorageManager.getTraceId(build);
if (traceId == null)
return getEmptyState();
if (!params.get(PROPERTY_KEY_ENABLED).equals("true"))
return getEmptyState();

var traceId = buildStorageManager.getTraceId(build);
if (traceId == null)
return getEmptyState();

var service = otelEndpointFactory.getOTELEndpointHandler(params.get(PROPERTY_KEY_SERVICE));
return service.getBuildOverviewModelAndView(build, params, traceId);
var service = otelEndpointFactory.getOTELEndpointHandler(params.get(PROPERTY_KEY_SERVICE));
return service.getBuildOverviewModelAndView(build, params, traceId);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public String getTraceId(SBuild build) {
File artifactsDir = build.getArtifactsDirectory();
File pluginFile = new File(artifactsDir, jetbrains.buildServer.ArtifactsConstants.TEAMCITY_ARTIFACTS_DIR + File.separatorChar + OTEL_TRACE_ID_FILENAME);

LOG.debug(String.format("Reading trace id or build %d.", build.getBuildId()));
LOG.debug(String.format("Reading trace id for build %d.", build.getBuildId()));

if (!pluginFile.exists()) {
LOG.info(String.format("Unable to find build artifact %s for build %d.", OTEL_TRACE_ID_FILENAME, build.getBuildId()));
Expand Down