diff --git a/server/src/main/java/org/eclipse/openvsx/LocalRegistryService.java b/server/src/main/java/org/eclipse/openvsx/LocalRegistryService.java index 5db35190c..fcf4d9957 100644 --- a/server/src/main/java/org/eclipse/openvsx/LocalRegistryService.java +++ b/server/src/main/java/org/eclipse/openvsx/LocalRegistryService.java @@ -10,6 +10,8 @@ package org.eclipse.openvsx; import com.google.common.collect.Maps; +import io.micrometer.core.instrument.Metrics; +import io.micrometer.core.instrument.Tag; import jakarta.persistence.EntityManager; import jakarta.transaction.Transactional; import org.apache.commons.lang3.StringUtils; @@ -216,6 +218,16 @@ public ResponseEntity getFile(String namespace, String extensionName, St if (resource.getType().equals(DOWNLOAD)) storageUtil.increaseDownloadCount(resource); + var extVersion = resource.getExtension(); + var extension = extVersion.getExtension(); + Metrics.counter("ovsx.file", List.of( + Tag.of("namespace", extension.getNamespace().getName()), + Tag.of("extension", extension.getName()), + Tag.of("target", extVersion.getTargetPlatform()), + Tag.of("version", extVersion.getVersion()), + Tag.of("filename", resource.getName()), + Tag.of("type", resource.getType()) + )).increment(); return storageUtil.getFileResponse(resource); } diff --git a/server/src/main/java/org/eclipse/openvsx/adapter/LocalVSCodeService.java b/server/src/main/java/org/eclipse/openvsx/adapter/LocalVSCodeService.java index 8356c4cf1..f40dc9a35 100644 --- a/server/src/main/java/org/eclipse/openvsx/adapter/LocalVSCodeService.java +++ b/server/src/main/java/org/eclipse/openvsx/adapter/LocalVSCodeService.java @@ -12,6 +12,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Lists; +import io.micrometer.core.instrument.*; import org.apache.commons.lang3.StringUtils; import org.eclipse.openvsx.entities.Extension; import org.eclipse.openvsx.entities.ExtensionVersion; @@ -290,11 +291,19 @@ public ResponseEntity getAsset( throw new NotFoundException(); } + var tags = new ArrayList<>(List.of( + Tag.of("namespace", namespace.toLowerCase()), + Tag.of("extension", extensionName.toLowerCase()), + Tag.of("target", targetPlatform.toLowerCase()), + Tag.of("version", version.toLowerCase()) + )); if(asset.equals(FILE_PUBLIC_KEY)) { var publicId = repositories.findSignatureKeyPairPublicId(namespace, extensionName, targetPlatform, version); if(publicId == null) { throw new NotFoundException(); } else { + tags.add(Tag.of("type", "publicKey")); + Metrics.counter("vscode.assets", tags).increment(); return ResponseEntity .status(HttpStatus.FOUND) .location(URI.create(UrlUtil.getPublicKeyUrl(publicId))) @@ -333,6 +342,10 @@ public ResponseEntity getAsset( storageUtil.increaseDownloadCount(resource); } + tags.add(Tag.of("type", resource.getType())); + tags.add(Tag.of("filename", resource.getName())); + Metrics.counter("vscode.assets", tags).increment(); + return storageUtil.getFileResponse(resource); }