Skip to content

Commit

Permalink
Slight logging tweaks (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-richardson authored Dec 1, 2024
1 parent 631f147 commit ee3aa63
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
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 @@ -76,26 +77,29 @@ protected ModelAndView doHandle(@NotNull HttpServletRequest request, @NotNull Ht
: 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

0 comments on commit ee3aa63

Please sign in to comment.