File tree Expand file tree Collapse file tree
api/src/main/java/marquez Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3636import marquez .db .DbMigration ;
3737import marquez .jobs .DbRetentionJob ;
3838import marquez .logging .LoggingMdcFilter ;
39+ import marquez .logging .SmarterNameStrategy ;
3940import marquez .tracing .SentryConfig ;
4041import marquez .tracing .TracingContainerResponseFilter ;
4142import marquez .tracing .TracingSQLLogger ;
@@ -162,7 +163,7 @@ private Jdbi newJdbi(
162163 .installPlugin (new SqlObjectPlugin ())
163164 .installPlugin (new PostgresPlugin ())
164165 .installPlugin (new Jackson2Plugin ());
165- SqlLogger sqlLogger = new InstrumentedSqlLogger (env .metrics ());
166+ SqlLogger sqlLogger = new InstrumentedSqlLogger (env .metrics (), new SmarterNameStrategy () );
166167 if (isSentryEnabled (config )) {
167168 sqlLogger = new TracingSQLLogger (sqlLogger );
168169 }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2018-2023 contributors to the Marquez project
3+ * SPDX-License-Identifier: Apache-2.0
4+ */
5+
6+ package marquez .logging ;
7+
8+ import com .codahale .metrics .MetricRegistry ;
9+ import com .codahale .metrics .jdbi3 .strategies .StatementNameStrategy ;
10+ import org .jdbi .v3 .core .extension .ExtensionMethod ;
11+ import org .jdbi .v3 .core .statement .StatementContext ;
12+ import org .slf4j .MDC ;
13+
14+ public class EndpointNameStrategy implements StatementNameStrategy {
15+
16+ @ Override
17+ public String getStatementName (StatementContext statementContext ) {
18+ ExtensionMethod extensionMethod = statementContext .getExtensionMethod ();
19+ if (extensionMethod != null ) {
20+ if (MDC .get ("method" ) != null && MDC .get ("path" ) != null ) {
21+ StringBuilder builder =
22+ new StringBuilder ()
23+ .append (extensionMethod .getMethod ().getName ())
24+ .append ("." )
25+ .append (MDC .get ("method" ))
26+ .append ("." )
27+ .append (MDC .get ("path" ));
28+ return MetricRegistry .name (extensionMethod .getType (), builder .toString ());
29+ }
30+ }
31+ return null ;
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2018-2023 contributors to the Marquez project
3+ * SPDX-License-Identifier: Apache-2.0
4+ */
5+
6+ package marquez .logging ;
7+
8+ import com .codahale .metrics .jdbi3 .strategies .DefaultNameStrategy ;
9+ import com .codahale .metrics .jdbi3 .strategies .DelegatingStatementNameStrategy ;
10+
11+ public class SmarterNameStrategy extends DelegatingStatementNameStrategy {
12+
13+ public SmarterNameStrategy () {
14+ super (
15+ DefaultNameStrategy .CHECK_EMPTY ,
16+ new EndpointNameStrategy (),
17+ DefaultNameStrategy .SQL_OBJECT ,
18+ DefaultNameStrategy .CONSTANT_SQL_RAW );
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments