@@ -49,6 +49,20 @@ public abstract class SimpleMetrics implements Metrics {
4949 private final URI url ;
5050 private final boolean debug ;
5151
52+ private final String SDK_NAME ;
53+ private final String SDK_VERSION ;
54+
55+ {
56+ final var properties = new Properties ();
57+ try (final var stream = getClass ().getResourceAsStream ("/META-INF/faststats.properties" )) {
58+ if (stream != null ) properties .load (stream );
59+ } catch (final IOException ignored ) {
60+ }
61+ this .SDK_NAME = properties .getProperty ("name" , "unknown" );
62+ this .SDK_VERSION = properties .getProperty ("version" , "unknown" );
63+ System .out .println (SDK_NAME + "/" + SDK_VERSION );
64+ }
65+
5266 @ Contract (mutates = "io" )
5367 @ SuppressWarnings ("PatternValidation" )
5468 protected SimpleMetrics (final Factory <?, ?> factory , final Config config ) throws IllegalStateException {
@@ -191,7 +205,7 @@ private boolean submitNow() throws IOException {
191205 .header ("Content-Encoding" , "gzip" )
192206 .header ("Content-Type" , "application/octet-stream" )
193207 .header ("Authorization" , "Bearer " + getToken ())
194- .header ("User-Agent" , "FastStats Metrics" )
208+ .header ("User-Agent" , "FastStats Metrics " + getSdkName () + "/" + getSdkVersion () )
195209 .timeout (Duration .ofSeconds (3 ))
196210 .uri (url )
197211 .build ();
@@ -227,6 +241,14 @@ private boolean submitNow() throws IOException {
227241 }
228242 }
229243
244+ private String getSdkName () {
245+ return SDK_NAME ;
246+ }
247+
248+ private String getSdkVersion () {
249+ return SDK_VERSION ;
250+ }
251+
230252 private final String javaVersion = System .getProperty ("java.version" );
231253 private final String osArch = System .getProperty ("os.arch" );
232254 private final String osName = System .getProperty ("os.name" );
0 commit comments