Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Observe /vscode/unpkg and /vscode/asset requests #1105

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package org.eclipse.openvsx.adapter;

import com.google.common.collect.Lists;
import io.micrometer.observation.annotation.Observed;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.openvsx.cache.CacheService;
import org.eclipse.openvsx.entities.Extension;
Expand Down Expand Up @@ -273,6 +274,7 @@ private String getSortOrder(int sortOrder) {
}
}

@Observed
@Override
public ResponseEntity<StreamingResponseBody> getAsset(
String namespace, String extensionName, String version, String assetType, String targetPlatform,
Expand Down Expand Up @@ -392,6 +394,7 @@ public String download(String namespaceName, String extensionName, String versio
}
}

@Observed
@Override
public ResponseEntity<StreamingResponseBody> browse(String namespaceName, String extensionName, String version, String path) {
if(BuiltInExtensionUtil.isBuiltIn(namespaceName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
********************************************************************************/
package org.eclipse.openvsx.adapter;

import io.micrometer.observation.annotation.Observed;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.headers.Header;
Expand Down Expand Up @@ -87,6 +88,7 @@ public ExtensionQueryResult extensionQuery(@RequestBody @Parameter(description =
return extensionQueryRequestHandler.getResult(param, size, DEFAULT_PAGE_SIZE);
}

@Observed
@GetMapping("/vscode/asset/{namespaceName}/{extensionName}/{version}/{assetType}/**")
@CrossOrigin
@Operation(summary = "Access an extension asset")
Expand Down Expand Up @@ -258,6 +260,7 @@ public ModelAndView download(
return new ModelAndView(null, HttpStatus.NOT_FOUND);
}

@Observed
@GetMapping("/vscode/unpkg/{namespaceName}/{extensionName}/{version}/**")
@CrossOrigin
@Operation(summary = "Browse an extension package")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package org.eclipse.openvsx.adapter;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.micrometer.observation.annotation.Observed;
import org.eclipse.openvsx.cache.CacheService;
import org.eclipse.openvsx.cache.FilesCacheKeyGenerator;
import org.eclipse.openvsx.entities.FileResource;
Expand Down Expand Up @@ -56,6 +57,7 @@ public WebResourceService(
this.filesCacheKeyGenerator = filesCacheKeyGenerator;
}

@Observed
@Cacheable(value = CACHE_WEB_RESOURCE_FILES, keyGenerator = GENERATOR_FILES)
public Path getWebResource(String namespace, String extension, String targetPlatform, String version, String name, boolean browse) {
var download = repositories.findFileByType(namespace, extension, targetPlatform, version, FileResource.DOWNLOAD);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* ****************************************************************************** */
package org.eclipse.openvsx.cache;

import io.micrometer.observation.annotation.Observed;
import org.eclipse.openvsx.entities.*;
import org.eclipse.openvsx.repositories.RepositoryService;
import org.eclipse.openvsx.util.TargetPlatform;
Expand Down Expand Up @@ -176,6 +177,7 @@ public void evictExtensionFile(FileResource download) {
cache.evict(filesCacheKeyGenerator.generate(download));
}

@Observed
public void evictWebResourceFile(String namespaceName, String extensionName, String targetPlatform, String version, String path) {
var cache = cacheManager.getCache(CACHE_WEB_RESOURCE_FILES);
if(cache == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@Configuration
@Profile("!test")
public class MetricsConfiguration {
//@Bean
@Bean
public ObservedAspect observedAspect(ObservationRegistry observationRegistry) {
return new ObservedAspect(observationRegistry, new RegistryObservationConvention());
}
Expand Down