Skip to content

Commit

Permalink
TW-86258: Lens plugin S3 event names are not aligned with OTEL conven…
Browse files Browse the repository at this point in the history
…tion

fix: test

fix: TW-86258 Len plugin S3 event names are not aligned with OTEL convention


Merge-request: TC-MR-9240
Merged-by: Andrei Efimov <Andrei.Efimov@jetbrains.com>
  • Loading branch information
wayfarer-rus authored and qodana-bot committed Feb 29, 2024
1 parent e22770d commit 00bca75
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ allprojects {
}
}
maven { url "https://repo.labs.intellij.net/teamcity" }
mavenLocal()
maven { url "https://download.jetbrains.com/teamcity-repository" }
maven { url "https://repo.labs.intellij.net/teamcity" }
maven {
Expand All @@ -47,6 +46,7 @@ allprojects {
password = spacePassword as String
}
}
mavenLocal()
mavenCentral()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private static CompletableFuture[] sendFileEvents(@NotNull Collection<UploadStat
stat.getChunkSize(),
stat.getDuration().toMillis(),
stat.getErrors().size(),
stat.isSuccessful()
stat.isSuccessful() ? "success" : "failure"
))
// and then we need to send them to the lens
.map(event -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import org.jetbrains.annotations.NotNull;

public class LowLevelLensClient {
private static final String S3_UPLOAD_SUCCESS_EVENT = "s3UploadFileEvent";
private static final String S3_UPLOAD_INFO_EVENT = "s3UploadInfoEvent";
private static final String S3_UPLOAD_OBJECT_EVENT = "artifact_object_upload";
private static final String S3_UPLOAD_INFO_EVENT = "artifacts_upload";
private static final String LENS_CUSTOM_EVENTS_ENDPOINT = "/lens/customBuildEvent?buildId=%d&eventName=%s";
private final String myLensEndpointUrl;
private final String myLensProbingEndpointUrl;
Expand All @@ -32,7 +32,7 @@ public LowLevelLensClient(TeamCityConnectionConfiguration teamCityConnectionConf

public CompletableFuture<HttpResponseAdapter> publishUploadFileEvent(final long buildId, @NotNull final UploadFileEvent event)
throws URISyntaxException, JsonProcessingException {
return publishEvent(buildId, event, S3_UPLOAD_SUCCESS_EVENT);
return publishEvent(buildId, event, S3_UPLOAD_OBJECT_EVENT);
}

public CompletableFuture<HttpResponseAdapter> publishUploadInfoEvent(final long buildId, @NotNull final UploadInfoEvent event)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
package jetbrains.buildServer.artifacts.s3.lens.integration.dto;

public class UploadFileEvent {
private boolean successful;
import com.fasterxml.jackson.annotation.JsonProperty;

public class UploadFileEvent {
@JsonProperty("build.artifacts.object.upload.result")
private String uploadResult;
@JsonProperty("build.artifacts.object.key")
private String objectKey;

@JsonProperty("build.artifacts.object.size")
private long fileSize;
@JsonProperty("build.artifacts.object.chunk_count")
private int numberOfParts;
@JsonProperty("build.artifacts.object.chunk_size")
private long chunkSize;
@JsonProperty("build.artifacts.object.upload.duration")
private long duration;
@JsonProperty("build.artifacts.object.upload_retry_count")
private int restartCount;

public UploadFileEvent() {
}

public UploadFileEvent(String objectKey, long fileSize, int numberOfParts, long chunkSize, long duration, int restartCount, boolean isSuccessful) {
public UploadFileEvent(String objectKey, long fileSize, int numberOfParts, long chunkSize, long duration, int restartCount, String uploadResult) {
this.objectKey = objectKey;
this.fileSize = fileSize;
this.numberOfParts = numberOfParts > 0 ? numberOfParts : 1;
this.chunkSize = numberOfParts > 0 ? chunkSize : fileSize;
this.duration = duration;
this.restartCount = restartCount;
successful = isSuccessful;
this.uploadResult = uploadResult;
}

public boolean isSuccessful() {
return successful;
public String getUploadResult() {
return uploadResult;
}

public void setObjectKey(String objectKey) {
Expand Down Expand Up @@ -76,8 +83,8 @@ public int getRestartCount() {
return restartCount;
}

public void setSuccessful(boolean successful) {
this.successful = successful;
public void setUploadResult(String uploadResult) {
this.uploadResult = uploadResult;
}

@Override
Expand All @@ -89,7 +96,7 @@ public String toString() {
", chunkSize=" + chunkSize +
", duration=" + duration +
", restartCount=" + restartCount +
", successful=" + successful +
", uploadResult=" + uploadResult +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package jetbrains.buildServer.artifacts.s3.lens.integration.dto;

import com.fasterxml.jackson.annotation.JsonProperty;

public class UploadInfoEvent {
@JsonProperty("build.artifacts.upload.duration")
private long duration;
@JsonProperty("build.artifacts.count")
private long numberOfFiles;
@JsonProperty("build.artifacts.size")
private long totalSize;

public UploadInfoEvent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@Test
public class TestJsonGeneration {
private static final String TEST_JSON_STRING =
"{\"successful\":false,\"objectKey\":\"file.zip\",\"fileSize\":123456789,\"numberOfParts\":1,\"chunkSize\":123456789,\"duration\":123456789,\"restartCount\":0}";
"{\"build.artifacts.object.upload.result\":\"successful\",\"build.artifacts.object.key\":\"file.zip\",\"build.artifacts.object.size\":123456789,\"build.artifacts.object.chunk_count\":1,\"build.artifacts.object.chunk_size\":123456789,\"build.artifacts.object.upload.duration\":123456789,\"build.artifacts.object.upload_retry_count\":0}";

@Test
public void testDtoToJson() throws JsonProcessingException {
Expand All @@ -20,6 +20,7 @@ public void testDtoToJson() throws JsonProcessingException {
event.setNumberOfParts(1);
event.setChunkSize(123456789L);
event.setRestartCount(0);
event.setUploadResult("successful");

ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(event);
Expand Down
1 change: 1 addition & 0 deletions s3-artifact-storage-agent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {

teamcity {
version = teamcityVersion
allowSnapshotVersions = true
agent {
descriptor = project.file('teamcity-plugin.xml')
}
Expand Down
1 change: 1 addition & 0 deletions s3-artifact-storage-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {

teamcity {
version = teamcityVersion
allowSnapshotVersions = true
server {
descriptor = project.file('teamcity-plugin.xml')
tokens = [Version: project.version]
Expand Down

0 comments on commit 00bca75

Please sign in to comment.