opik-backend
1
总安装量
1
周安装量
#77838
全站排名
安装命令
npx skills add https://github.com/comet-ml/opik --skill opik-backend
Agent 安装分布
amp
1
cline
1
opencode
1
cursor
1
continue
1
kimi-cli
1
Skill 文档
Opik Backend
Architecture
- Layered: Resource â Service â DAO (never skip layers)
- DI: Guice modules, constructor injection with
@Inject - Databases: MySQL (metadata, transactional) + ClickHouse (analytics, append-only)
Critical Gotchas
StringTemplate Memory Leak
// â
GOOD
var template = TemplateUtils.newST(QUERY);
// â BAD - causes memory leak via STGroup singleton
var template = new ST(QUERY);
List Access
// â
GOOD
users.getFirst()
users.getLast()
// â BAD
users.get(0)
users.get(users.size() - 1)
SQL Text Blocks
// â
GOOD - text blocks for multi-line SQL
@SqlQuery("""
SELECT * FROM datasets
WHERE workspace_id = :workspace_id
<if(name)> AND name like concat('%', :name, '%') <endif>
""")
// â BAD - string concatenation
@SqlQuery("SELECT * FROM datasets " +
"WHERE workspace_id = :workspace_id " +
"<if(name)> AND name like concat('%', :name, '%') <endif> ")
Immutable Collections
// â
GOOD
Set.of("A", "B", "C")
List.of(1, 2, 3)
Map.of("key", "value")
// â BAD
Arrays.asList("A", "B", "C")
Error Handling
Use Jakarta Exceptions
throw new BadRequestException("Invalid input");
throw new NotFoundException("User not found: '%s'".formatted(id));
throw new ConflictException("Already exists");
throw new InternalServerErrorException("System error", cause);
Error Response Classes
- Simple:
io.dropwizard.jersey.errors.ErrorMessage - Complex:
com.comet.opik.api.error.ErrorMessage - Never create new error message classes
Logging
Format Convention
// â
GOOD - values in single quotes
log.info("Created user: '{}'", userId);
log.error("Failed for workspace: '{}'", workspaceId, exception);
// â BAD - no quotes
log.info("Created user: {}", userId);
Never Log
- Emails, passwords, tokens, API keys
- PII, personal identifiers
- Database credentials
Reference Files
- clickhouse.md – ClickHouse query patterns
- mysql.md – TransactionTemplate patterns
- testing.md – PODAM, naming, assertion patterns
- migrations.md – Liquibase format for MySQL/ClickHouse