
zipkin2.storage.mysql.v1.HasRemoteServiceName Maven / Gradle / Ivy
/*
* Copyright 2015-2019 The OpenZipkin Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin2.storage.mysql.v1;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sql.DataSource;
import org.jooq.DSLContext;
import org.jooq.exception.DataAccessException;
import static zipkin2.storage.mysql.v1.internal.generated.tables.ZipkinSpans.ZIPKIN_SPANS;
final class HasRemoteServiceName {
static final Logger LOG = Logger.getLogger(HasRemoteServiceName.class.getName());
static final String MESSAGE =
"zipkin_spans.remote_service_name doesn't exist, so queries for remote service names will return empty.\n"
+ "Execute: ALTER TABLE zipkin_spans ADD `remote_service_name` VARCHAR(255);\n"
+ "ALTER TABLE zipkin_spans ADD INDEX `remote_service_name`;";
static boolean test(DataSource datasource, DSLContexts context) {
try (Connection conn = datasource.getConnection()) {
DSLContext dsl = context.get(conn);
dsl.select(ZIPKIN_SPANS.REMOTE_SERVICE_NAME).from(ZIPKIN_SPANS).limit(1).fetchAny();
return true;
} catch (DataAccessException e) {
if (e.sqlState().equals("42S22")) {
LOG.warning(MESSAGE);
return false;
}
problemReading(e);
} catch (SQLException | RuntimeException e) {
problemReading(e);
}
return false;
}
static void problemReading(Exception e) {
LOG.log(Level.WARNING, "problem reading zipkin_spans.remote_service_name", e);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy