Skip to content

Commit

Permalink
Merge pull request #1009 from amvanbaren/remove-file-metrics
Browse files Browse the repository at this point in the history
Remove file metrics
  • Loading branch information
amvanbaren authored Oct 3, 2024
2 parents 459a8ad + 7b6b06d commit 1a5f05e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 29 deletions.
12 changes: 0 additions & 12 deletions server/src/main/java/org/eclipse/openvsx/LocalRegistryService.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
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;
Expand Down Expand Up @@ -218,16 +216,6 @@ public ResponseEntity<byte[]> 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
import io.micrometer.core.instrument.*;
import io.micrometer.core.instrument.Metrics;
import io.micrometer.core.instrument.Tag;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.openvsx.entities.Extension;
import org.eclipse.openvsx.entities.ExtensionVersion;
import org.eclipse.openvsx.entities.FileResource;
import org.eclipse.openvsx.entities.Namespace;
import org.eclipse.openvsx.publish.ExtensionVersionIntegrityService;
import org.eclipse.openvsx.repositories.RepositoryService;
import org.eclipse.openvsx.search.SearchUtilService;
Expand Down Expand Up @@ -291,19 +291,11 @@ public ResponseEntity<byte[]> 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)))
Expand Down Expand Up @@ -342,10 +334,6 @@ public ResponseEntity<byte[]> 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);
}

Expand Down Expand Up @@ -415,9 +403,7 @@ public ResponseEntity<byte[]> browse(String namespaceName, String extensionName,
var namespace = extension.getNamespace();

Metrics.counter("vscode.unpkg", List.of(
Tag.of("namespace", namespace.getName()),
Tag.of("extension", extension.getName()),
Tag.of("version", extVersion.getVersion()),
Tag.of("extension", NamingUtil.toLogFormat(extVersion)),
Tag.of("file", String.valueOf(exactMatch != null)),
Tag.of("path", path)
)).increment();
Expand Down

0 comments on commit 1a5f05e

Please sign in to comment.