Skip to content

Commit

Permalink
Add version metric (#533)
Browse files Browse the repository at this point in the history
* Add version metric.

* Update documentation. Metric's name style fix.
  • Loading branch information
ekharkunov authored Oct 26, 2024
1 parent 0ed9e13 commit 1e1af70
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion server/README_METRICS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ Below is the table with metrics description that collected inside application. T
|extender.service.sdk.get.download|Counter|Unit|How many times Defold sdk was downloaded|
|extender.service.sdk.get.duration|Timer|Milliseconds|How long Defold sdk was downloading|
|extender.service.gradle.unpack|Timer|Milliseconds|How long Gradle was unpacking dependencies|
|extender.service.gradle.get|Timer|Milliseconds|How long Gradle dependencies step was going|
|extender.service.gradle.get|Timer|Milliseconds|How long Gradle dependencies step was going|
|extender.versionInfo|Gauge|Unit|Always return 1. Labels contains git tag and git commit sha with current version|
4 changes: 3 additions & 1 deletion server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,18 @@ task createVersionFile() {
}
}
def build_time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date ())
def app_version = project.ext.extenderVersion
def text = """
// Auto generated by gradle
package com.defold.extender;
public class Version {
public static final String gitVersion = "${sha}";
public static final String buildTime = "${build_time}";
public static final String appVersion = "${app_version}";
}
"""
def binding = ["sha" : sha, "build_time" : build_time]
def binding = []

def engine = new groovy.text.SimpleTemplateEngine()
def template = engine.createTemplate(text).make(binding)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.MeterRegistry;

import jakarta.servlet.http.HttpServletRequest;
Expand All @@ -44,6 +46,7 @@
import java.nio.file.StandardCopyOption;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -123,7 +126,10 @@ public ExtenderController(DefoldSdkService defoldSdkService,
this.jobResultLocation = new File(jobResultLocation);
this.jobResultLocation.mkdirs();

this.asyncBuilder = asyncBuilder;
this.asyncBuilder = asyncBuilder;

Supplier<Number> staticValue = () -> 1;
Gauge.builder("extender.versionInfo", staticValue).tags("version", Version.appVersion, "commit_sha", Version.gitVersion).register(meterRegistry);
}

@ExceptionHandler({ExtenderException.class})
Expand Down

0 comments on commit 1e1af70

Please sign in to comment.