Skip to content

Commit

Permalink
Merge branch 'main' into mattr/rsb/include-build-id-on-metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-richardson authored Dec 1, 2024
2 parents a0c0282 + 673c501 commit d7eba3b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@
import com.octopus.teamcity.opentelemetry.server.endpoints.custom.CustomOTELEndpointHandler;
import com.octopus.teamcity.opentelemetry.server.endpoints.honeycomb.HoneycombOTELEndpointHandler;
import com.octopus.teamcity.opentelemetry.server.endpoints.zipkin.ZipKinOTELEndpointHandler;
import jetbrains.buildServer.serverSide.TeamCityNodes;
import jetbrains.buildServer.web.openapi.PluginDescriptor;
import org.jetbrains.annotations.NotNull;

public class OTELEndpointFactory {

@NotNull
private final PluginDescriptor pluginDescriptor;
@NotNull
private final TeamCityNodes teamcityNodesService;

public OTELEndpointFactory(
@NotNull PluginDescriptor pluginDescriptor)
@NotNull PluginDescriptor pluginDescriptor,
@NotNull TeamCityNodes teamcityNodesService)
{
this.pluginDescriptor = pluginDescriptor;
this.teamcityNodesService = teamcityNodesService;
}

public IOTELEndpointHandler getOTELEndpointHandler(String otelService)
Expand All @@ -28,7 +33,7 @@ public IOTELEndpointHandler getOTELEndpointHandler(OTELService otelService)
switch (otelService)
{
case HONEYCOMB:
return new HoneycombOTELEndpointHandler(pluginDescriptor);
return new HoneycombOTELEndpointHandler(pluginDescriptor, teamcityNodesService);
case ZIPKIN:
return new ZipKinOTELEndpointHandler(pluginDescriptor);
case CUSTOM:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ private SpanProcessor buildGrpcSpanProcessor(Map<String, String> headers, String
spanExporterBuilder.setEndpoint(exporterEndpoint);
SpanExporter spanExporter = spanExporterBuilder.build();

LOG.debug("OTEL_PLUGIN: Opentelemetry export headers: " + LogMasker.mask(headers.toString()));
LOG.debug("OTEL_PLUGIN: Opentelemetry export endpoint: " + exporterEndpoint);

return BatchSpanProcessor.builder(spanExporter)
.setMaxQueueSize(BATCH_SPAN_PROCESSOR_MAX_QUEUE_SIZE)
.setScheduleDelay(BATCH_SPAN_PROCESSOR_MAX_SCHEDULE_DELAY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.opentelemetry.semconv.ServiceAttributes;
import jetbrains.buildServer.serverSide.BuildPromotion;
import jetbrains.buildServer.serverSide.SBuild;
import jetbrains.buildServer.serverSide.TeamCityNodes;
import jetbrains.buildServer.serverSide.crypt.EncryptUtil;
import jetbrains.buildServer.serverSide.crypt.RSACipher;
import jetbrains.buildServer.web.openapi.PluginDescriptor;
Expand All @@ -33,10 +34,12 @@
public class HoneycombOTELEndpointHandler implements IOTELEndpointHandler {

private final PluginDescriptor pluginDescriptor;
private final TeamCityNodes nodesService;
static Logger LOG = Logger.getLogger(HoneycombOTELEndpointHandler.class.getName());

public HoneycombOTELEndpointHandler(PluginDescriptor pluginDescriptor) {
public HoneycombOTELEndpointHandler(PluginDescriptor pluginDescriptor, TeamCityNodes nodesService) {
this.pluginDescriptor = pluginDescriptor;
this.nodesService = nodesService;
}

@NotNull
Expand Down Expand Up @@ -93,7 +96,8 @@ private SpanProcessor buildGrpcSpanProcessor(
var serviceNameResource = Resource
.create(Attributes.of(
ServiceAttributes.SERVICE_NAME, PluginConstants.SERVICE_NAME,
AttributeKey.stringKey("teamcity.build_promotion.id"), Long.toString(buildPromotion.getId())
AttributeKey.stringKey("teamcity.build_promotion.id"), Long.toString(buildPromotion.getId()),
AttributeKey.stringKey("teamcity.node.id"), nodesService.getCurrentNode().getId()
));

var meterProvider = OTELMetrics.getOTELMeterProvider(metricsExporter, serviceNameResource);
Expand Down

0 comments on commit d7eba3b

Please sign in to comment.