Skip to content

Instantly share code, notes, and snippets.

<dependency>
<groupId>com.datorama.oss</groupId>
<artifactId>timbermill-client</artifactId>
<version>2.0.4</version>
</dependency>
<dependency>
<groupId>com.datorama.oss</groupId>
<artifactId>timbermill-client</artifactId>
<version>2.0.4</version>
</dependency>
@edengal
edengal / T.java
Last active August 6, 2019 12:18
@TimberLog(name = "main_application")
public static void main(String[] args) {
TimberLogger.logContext("userId", userId);
isUserAuthorized(userId);
String sql = getSqlQuery(args);
List<String> result = runSql(sql);
}
@TimberLog(name = "is_user_authorized")
private static void isUserAuthorized(String userId){
@TimberLog(name = "main_application")
public static void main(String[] args) {
isUserAuthorized(userId);
String sql = getSqlQuery(args);
List<String> result = runSql(sql);
}
@TimberLog(name = "is_user_authorized")
private static void isUserAuthorized(String userId){
...
public boolean auth(String token, String timbermillParentId){
TimberLogger.start("authenticate", timbermillParentId, LogParams.create().string("token", token));
try {
...
TimberLogger.logString("isAuthorized", isAuthorized);
return isAuthorized;
} catch (Throwable t){
TimberLogger.error(t);
throw t;
}
public List<String> query(String query, String timbermillParentId) throws InterruptedException {
String id = TimberLogger.start("query", timbermillParentId, LogParams.create().text("sql", query));
try {
authorize(id);
List<String> list = runSql(query);
TimberLogger.success();
return list;
} catch (Throwable t){
public boolean transformAndPersist(List<String> result, String outputDir, String timbermillParentId) {
String id = TimberLogger.start("transform_and_persist", timbermillParentId);
try{
authorize(id);
runTransformation(result);
boolean isSuccess = persistToDisk(outputDir);
TimberLogger.success();
return isSuccess;
public List<String> query(String query, String timbermillParentId) throws InterruptedException {
String id = TimberLogger.start("query", timbermillParentId, LogParams.create().text("sql", query));
try {
authorized(id);
List<String> list = runSql(query);
TimberLogger.success();
return list;
} catch (Throwable t){
@TimberLog(name = "etl_invocation")
public boolean runEtl(String userId, String query, String outputDir) {
TimberLogger.logContext("userId", userId);
String timbermillId = TimberLogger.getCurrentTaskId();
List<String> result = callQueryService(query, timbermillId);
boolean isSuccess = callTransformationService(result, outputDir, timbermillId);
return isSuccess;
}
public boolean transform(String outputDir, String timbermillParentId) throws InterruptedException {
String id = TimberLogger.start("transform", timbermillParentId, LogParams.create().text("outputhDir", outputDir));
boolean isAuthorized = authorized(id);
runTransformation();
boolean isSuccess = persistToDisk(outputDir);
TimberLogger.success();
return isSuccess;
}