Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ configuration YAML file.

Find more information in the [routing rules documentation](routing-rules.md).

### Configure logging

Path to `log.properties` must be set via `log.levels-file` JVM options
like `-Dlog.levels-file=etc/log.properties`.

Use the `log.*` properties from the [Trino logging properties
documentation](https://trino.io/docs/current/admin/properties-logging.html) for further configuration.

### Proxying additional paths

By default, Trino Gateway only proxies requests to paths starting with
Expand Down
1 change: 1 addition & 0 deletions gateway-ha/etc/log.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.trino=INFO
13 changes: 1 addition & 12 deletions gateway-ha/gateway-ha-config-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,5 @@ managedApps:
- io.trino.gateway.ha.GatewayManagedApp
- io.trino.gateway.ha.clustermonitor.ActiveClusterMonitor

# Logging settings.
logging:
# The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
level: INFO

# Logger-specific levels.
loggers:
io.trino: DEBUG

appenders:
- type: console
filterFactories:
- type: Log-filter-factory
type: external
13 changes: 1 addition & 12 deletions gateway-ha/gateway-ha-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,5 @@ managedApps:
- io.trino.gateway.ha.GatewayManagedApp
- io.trino.gateway.ha.clustermonitor.ActiveClusterMonitor

# Logging settings.
logging:
# The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
level: INFO

# Logger-specific levels.
loggers:
io.trino: DEBUG

appenders:
- type: console
filterFactories:
- type: Log-filter-factory
type: external
59 changes: 41 additions & 18 deletions gateway-ha/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@

<dependencies>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${dep.logback.version}</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${dep.logback.version}</version>
</dependency>

<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
Expand Down Expand Up @@ -98,6 +86,11 @@
</exclusions>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>configuration</artifactId>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>http-client</artifactId>
Expand All @@ -108,6 +101,16 @@
<artifactId>json</artifactId>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>log</artifactId>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>log-manager</artifactId>
</dependency>

<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-assets</artifactId>
Expand Down Expand Up @@ -205,7 +208,7 @@

<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-logging</artifactId>
<artifactId>dropwizard-request-logging</artifactId>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to get rid of this and just use jetty directly .. but for now it might have to stay

</dependency>

<dependency>
Expand Down Expand Up @@ -235,6 +238,11 @@
<version>2.1.1</version>
</dependency>

<dependency>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is the suggested use from airlift/trino for the servlet api

<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
</dependency>

<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
Expand Down Expand Up @@ -299,6 +307,12 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-jakarta-servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand All @@ -311,11 +325,6 @@
<artifactId>jetty-util</artifactId>
</dependency>

<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-jakarta-servlet-api</artifactId>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
Expand Down Expand Up @@ -533,6 +542,20 @@
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<configuration>
<ignoredDependencies>
<ignoredDependency>joda-time:joda-time</ignoredDependency>
</ignoredDependencies>
</configuration>
</execution>
</executions>
</plugin>

<!-- maven shade plugin -->
<plugin>
<artifactId>maven-shade-plugin</artifactId>
Expand Down
37 changes: 21 additions & 16 deletions gateway-ha/src/main/java/io/trino/gateway/baseapp/BaseApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import io.airlift.log.Logger;
import io.dropwizard.auth.AuthDynamicFeature;
import io.dropwizard.auth.AuthFilter;
import io.dropwizard.core.Application;
import io.dropwizard.core.Configuration;
import io.dropwizard.core.server.DefaultServerFactory;
import io.dropwizard.core.setup.Bootstrap;
import io.dropwizard.core.setup.Environment;
import io.dropwizard.lifecycle.Managed;
import io.dropwizard.lifecycle.setup.LifecycleEnvironment;
import io.dropwizard.servlets.tasks.Task;
import io.trino.gateway.ha.log.GatewayRequestLogFactory;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.ext.Provider;
import org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature;
Expand All @@ -36,8 +39,6 @@
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import org.reflections.util.FilterBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -60,7 +61,7 @@
public abstract class BaseApp<T extends AppConfiguration>
extends Application<T>
{
private static final Logger logger = LoggerFactory.getLogger(BaseApp.class);
private static final Logger logger = Logger.get(BaseApp.class);

private final Reflections reflections;
private final ImmutableList.Builder<Module> appModules = ImmutableList.builder();
Expand All @@ -75,7 +76,7 @@ protected BaseApp(String... basePackages)
basePackages = new String[] {};
}

logger.info("op=create auto_scan_packages={}", basePackages);
logger.info("op=create auto_scan_packages=%s", basePackages);

for (String basePkg : basePackages) {
confBuilder.addUrls(ClasspathHelper.forPackage(basePkg));
Expand All @@ -89,6 +90,9 @@ protected BaseApp(String... basePackages)
this.reflections = new Reflections(confBuilder);
}

@Override // Using Airlift logger
protected void bootstrapLogging() {}

/**
* Initializes the application bootstrap.
*
Expand All @@ -115,8 +119,9 @@ public void initialize(Bootstrap<T> bootstrap)
public void run(T configuration, Environment environment)
throws Exception
{
((DefaultServerFactory) configuration.getServerFactory()).setRequestLogFactory(new GatewayRequestLogFactory());
Comment thread
ebyhr marked this conversation as resolved.
this.injector = configureGuice(configuration, environment);
logger.info("op=configure_guice injector={}", injector);
logger.info("op=configure_guice injector=%s", injector);
applicationAtRun(configuration, environment, injector);
logger.info("op=configure_app_custom completed");
}
Expand Down Expand Up @@ -147,14 +152,14 @@ private Injector configureGuice(T configuration, Environment environment)

private void registerWithInjector(T configuration, Environment environment, Injector injector)
{
logger.info("op=register_start configuration={}", configuration.toString());
logger.info("op=register_start configuration=%s", configuration.toString());
registerAuthFilters(environment, injector);
registerHealthChecks(environment, injector);
registerProviders(environment, injector);
registerTasks(environment, injector);
addManagedApps(configuration, environment, injector);
registerResources(environment, injector);
logger.info("op=register_end configuration={}", configuration.toString());
logger.info("op=register_end configuration=%s", configuration.toString());
}

/**
Expand All @@ -172,15 +177,15 @@ protected List<AppModule> addModules(T configuration, Environment environment)
}
for (String clazz : configuration.getModules()) {
try {
logger.info("Trying to load module [{}]", clazz);
logger.info("Trying to load module [%s]", clazz);
Object ob =
Class.forName(clazz)
.getConstructor(configuration.getClass(), Environment.class)
.newInstance(configuration, environment);
modules.add((AppModule) ob);
}
catch (Exception e) {
logger.error("Could not instantiate module [" + clazz + "]", e);
logger.error(e, "Could not instantiate module [%s]", clazz);
}
}
return modules;
Expand All @@ -205,10 +210,10 @@ protected List<Managed> addManagedApps(
Class c = Class.forName(clazz);
LifecycleEnvironment lifecycle = environment.lifecycle();
lifecycle.manage((Managed) injector.getInstance(c));
logger.info("op=register type=managed item={}", c);
logger.info("op=register type=managed item=%s", c);
}
catch (Exception e) {
logger.error("Error loading managed app", e);
logger.error(e, "Error loading managed app");
}
});
return managedApps;
Expand All @@ -220,7 +225,7 @@ private void registerTasks(Environment environment, Injector injector)
classes.forEach(
c -> {
environment.admin().addTask(injector.getInstance(c));
logger.info("op=register type=task item={}", c);
logger.info("op=register type=task item=%s", c);
});
}

Expand All @@ -230,7 +235,7 @@ private void registerHealthChecks(Environment environment, Injector injector)
classes.forEach(
c -> {
environment.healthChecks().register(c.getSimpleName(), injector.getInstance(c));
logger.info("op=register type=healthcheck item={}", c);
logger.info("op=register type=healthcheck item=%s", c);
});
}

Expand All @@ -240,7 +245,7 @@ private void registerProviders(Environment environment, Injector injector)
classes.forEach(
c -> {
environment.jersey().register(injector.getInstance(c));
logger.info("op=register type=provider item={}", c);
logger.info("op=register type=provider item=%s", c);
});
}

Expand All @@ -250,7 +255,7 @@ private void registerResources(Environment environment, Injector injector)
classes.forEach(
c -> {
environment.jersey().register(injector.getInstance(c));
logger.info("op=register type=resource item={}", c);
logger.info("op=register type=resource item=%s", c);
});
}

Expand All @@ -259,7 +264,7 @@ private void registerAuthFilters(Environment environment, Injector injector)
environment
.jersey()
.register(new AuthDynamicFeature(injector.getInstance(AuthFilter.class)));
logger.info("op=register type=auth filter item={}", AuthFilter.class);
logger.info("op=register type=auth filter item=%s", AuthFilter.class);
environment.jersey().register(RolesAllowedDynamicFeature.class);
}
}

This file was deleted.

Loading