Logging emitter to publish query and other metric events as valid json objects (#8359)

* LoggingEmitter: print event as json

* use DefaultRequestLogEventBuilderFactory in emitting request logger by default

* print context in query metric as json

* removed unused jsonMapper from DefaultQueryMetrics

* add comment

* remove change to DefaultRequestLogEventBuilderFactory.java
This commit is contained in:
Himanshu 2019-08-27 15:00:23 -07:00 committed by GitHub
parent 44dd5b5f0d
commit 4d87a19547
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 42 additions and 152 deletions

View File

@ -95,28 +95,27 @@ public class LoggingEmitter implements Emitter
} }
} }
try { try {
final String message = "Event [%s]";
switch (level) { switch (level) {
case TRACE: case TRACE:
if (log.isTraceEnabled()) { if (log.isTraceEnabled()) {
log.trace(message, jsonMapper.writeValueAsString(event)); log.trace(jsonMapper.writeValueAsString(event));
} }
break; break;
case DEBUG: case DEBUG:
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug(message, jsonMapper.writeValueAsString(event)); log.debug(jsonMapper.writeValueAsString(event));
} }
break; break;
case INFO: case INFO:
if (log.isInfoEnabled()) { if (log.isInfoEnabled()) {
log.info(message, jsonMapper.writeValueAsString(event)); log.info(jsonMapper.writeValueAsString(event));
} }
break; break;
case WARN: case WARN:
log.warn(message, jsonMapper.writeValueAsString(event)); log.warn(jsonMapper.writeValueAsString(event));
break; break;
case ERROR: case ERROR:
log.error(message, jsonMapper.writeValueAsString(event)); log.error(jsonMapper.writeValueAsString(event));
break; break;
} }
} }

View File

@ -146,7 +146,7 @@ public class ServiceMetricEvent implements Event
return this; return this;
} }
public Builder setDimension(String dim, String value) public Builder setDimension(String dim, Object value)
{ {
userDims.put(dim, value); userDims.put(dim, value);
return this; return this;

View File

@ -19,19 +19,12 @@
package org.apache.druid.query.movingaverage; package org.apache.druid.query.movingaverage;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.druid.query.DefaultQueryMetrics; import org.apache.druid.query.DefaultQueryMetrics;
import org.apache.druid.query.DruidMetrics; import org.apache.druid.query.DruidMetrics;
public class DefaultMovingAverageQueryMetrics extends DefaultQueryMetrics<MovingAverageQuery> implements public class DefaultMovingAverageQueryMetrics extends DefaultQueryMetrics<MovingAverageQuery> implements
MovingAverageQueryMetrics MovingAverageQueryMetrics
{ {
public DefaultMovingAverageQueryMetrics(ObjectMapper jsonMapper)
{
super(jsonMapper);
}
@Override @Override
public void query(MovingAverageQuery query) public void query(MovingAverageQuery query)
{ {

View File

@ -19,19 +19,15 @@
package org.apache.druid.query.movingaverage; package org.apache.druid.query.movingaverage;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.inject.Inject;
import org.apache.druid.guice.LazySingleton; import org.apache.druid.guice.LazySingleton;
import org.apache.druid.guice.annotations.Json;
import org.apache.druid.jackson.DefaultObjectMapper;
@LazySingleton @LazySingleton
public class DefaultMovingAverageQueryMetricsFactory implements MovingAverageQueryMetricsFactory public class DefaultMovingAverageQueryMetricsFactory implements MovingAverageQueryMetricsFactory
{ {
private static final MovingAverageQueryMetricsFactory INSTANCE = private static final MovingAverageQueryMetricsFactory INSTANCE =
new DefaultMovingAverageQueryMetricsFactory(new DefaultObjectMapper()); new DefaultMovingAverageQueryMetricsFactory();
/** /**
* Should be used only in tests, directly or indirectly (via {@link * Should be used only in tests, directly or indirectly (via {@link
@ -43,17 +39,9 @@ public class DefaultMovingAverageQueryMetricsFactory implements MovingAverageQue
return INSTANCE; return INSTANCE;
} }
private final ObjectMapper jsonMapper;
@Inject
public DefaultMovingAverageQueryMetricsFactory(@Json ObjectMapper jsonMapper)
{
this.jsonMapper = jsonMapper;
}
@Override @Override
public MovingAverageQueryMetrics makeMetrics() public MovingAverageQueryMetrics makeMetrics()
{ {
return new DefaultMovingAverageQueryMetrics(jsonMapper); return new DefaultMovingAverageQueryMetrics();
} }
} }

View File

@ -135,7 +135,6 @@ import org.apache.druid.query.timeseries.TimeseriesResultValue;
import org.apache.druid.segment.DimensionHandlerUtils; import org.apache.druid.segment.DimensionHandlerUtils;
import org.apache.druid.segment.IndexIO; import org.apache.druid.segment.IndexIO;
import org.apache.druid.segment.QueryableIndex; import org.apache.druid.segment.QueryableIndex;
import org.apache.druid.segment.TestHelper;
import org.apache.druid.segment.column.DictionaryEncodedColumn; import org.apache.druid.segment.column.DictionaryEncodedColumn;
import org.apache.druid.segment.indexing.DataSchema; import org.apache.druid.segment.indexing.DataSchema;
import org.apache.druid.segment.indexing.granularity.UniformGranularitySpec; import org.apache.druid.segment.indexing.granularity.UniformGranularitySpec;
@ -2578,7 +2577,7 @@ public class KafkaIndexTaskTest
new ScanQueryRunnerFactory( new ScanQueryRunnerFactory(
new ScanQueryQueryToolChest( new ScanQueryQueryToolChest(
new ScanQueryConfig(), new ScanQueryConfig(),
new DefaultGenericQueryMetricsFactory(TestHelper.makeJsonMapper()) new DefaultGenericQueryMetricsFactory()
), ),
new ScanQueryEngine(), new ScanQueryEngine(),
new ScanQueryConfig() new ScanQueryConfig()

View File

@ -19,18 +19,14 @@
package org.apache.druid.query; package org.apache.druid.query;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.inject.Inject;
import org.apache.druid.guice.LazySingleton; import org.apache.druid.guice.LazySingleton;
import org.apache.druid.guice.annotations.Json;
import org.apache.druid.jackson.DefaultObjectMapper;
@LazySingleton @LazySingleton
public class DefaultGenericQueryMetricsFactory implements GenericQueryMetricsFactory public class DefaultGenericQueryMetricsFactory implements GenericQueryMetricsFactory
{ {
private static final GenericQueryMetricsFactory INSTANCE = private static final GenericQueryMetricsFactory INSTANCE =
new DefaultGenericQueryMetricsFactory(new DefaultObjectMapper()); new DefaultGenericQueryMetricsFactory();
/** /**
* Should be used only in tests, directly or indirectly (e. g. in {@link * Should be used only in tests, directly or indirectly (e. g. in {@link
@ -42,18 +38,10 @@ public class DefaultGenericQueryMetricsFactory implements GenericQueryMetricsFac
return INSTANCE; return INSTANCE;
} }
private final ObjectMapper jsonMapper;
@Inject
public DefaultGenericQueryMetricsFactory(@Json ObjectMapper jsonMapper)
{
this.jsonMapper = jsonMapper;
}
@Override @Override
public QueryMetrics<Query<?>> makeMetrics(Query<?> query) public QueryMetrics<Query<?>> makeMetrics(Query<?> query)
{ {
DefaultQueryMetrics<Query<?>> queryMetrics = new DefaultQueryMetrics<>(jsonMapper); DefaultQueryMetrics<Query<?>> queryMetrics = new DefaultQueryMetrics<>();
queryMetrics.query(query); queryMetrics.query(query);
return queryMetrics; return queryMetrics;
} }

View File

@ -19,8 +19,6 @@
package org.apache.druid.query; package org.apache.druid.query;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import org.apache.druid.collections.bitmap.BitmapFactory; import org.apache.druid.collections.bitmap.BitmapFactory;
import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.StringUtils;
@ -41,18 +39,12 @@ import java.util.concurrent.TimeUnit;
*/ */
public class DefaultQueryMetrics<QueryType extends Query<?>> implements QueryMetrics<QueryType> public class DefaultQueryMetrics<QueryType extends Query<?>> implements QueryMetrics<QueryType>
{ {
protected final ObjectMapper jsonMapper;
protected final ServiceMetricEvent.Builder builder = new ServiceMetricEvent.Builder(); protected final ServiceMetricEvent.Builder builder = new ServiceMetricEvent.Builder();
protected final Map<String, Number> metrics = new HashMap<>(); protected final Map<String, Number> metrics = new HashMap<>();
/** Non final to give subclasses ability to reassign it. */ /** Non final to give subclasses ability to reassign it. */
protected Thread ownerThread = Thread.currentThread(); protected Thread ownerThread = Thread.currentThread();
public DefaultQueryMetrics(ObjectMapper jsonMapper)
{
this.jsonMapper = jsonMapper;
}
protected void checkModifiedFromOwnerThread() protected void checkModifiedFromOwnerThread()
{ {
if (Thread.currentThread() != ownerThread) { if (Thread.currentThread() != ownerThread) {
@ -64,7 +56,7 @@ public class DefaultQueryMetrics<QueryType extends Query<?>> implements QueryMet
} }
} }
protected void setDimension(String dimension, String value) protected void setDimension(String dimension, Object value)
{ {
checkModifiedFromOwnerThread(); checkModifiedFromOwnerThread();
builder.setDimension(dimension, value); builder.setDimension(dimension, value);
@ -131,15 +123,7 @@ public class DefaultQueryMetrics<QueryType extends Query<?>> implements QueryMet
@Override @Override
public void context(QueryType query) public void context(QueryType query)
{ {
try { setDimension("context", query.getContext() == null ? ImmutableMap.of() : query.getContext());
setDimension(
"context",
jsonMapper.writeValueAsString(query.getContext() == null ? ImmutableMap.of() : query.getContext())
);
}
catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
} }
@Override @Override

View File

@ -19,18 +19,11 @@
package org.apache.druid.query.groupby; package org.apache.druid.query.groupby;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.druid.query.DefaultQueryMetrics; import org.apache.druid.query.DefaultQueryMetrics;
import org.apache.druid.query.DruidMetrics; import org.apache.druid.query.DruidMetrics;
public class DefaultGroupByQueryMetrics extends DefaultQueryMetrics<GroupByQuery> implements GroupByQueryMetrics public class DefaultGroupByQueryMetrics extends DefaultQueryMetrics<GroupByQuery> implements GroupByQueryMetrics
{ {
public DefaultGroupByQueryMetrics(ObjectMapper jsonMapper)
{
super(jsonMapper);
}
@Override @Override
public void query(GroupByQuery query) public void query(GroupByQuery query)
{ {

View File

@ -19,18 +19,14 @@
package org.apache.druid.query.groupby; package org.apache.druid.query.groupby;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.inject.Inject;
import org.apache.druid.guice.LazySingleton; import org.apache.druid.guice.LazySingleton;
import org.apache.druid.guice.annotations.Json;
import org.apache.druid.jackson.DefaultObjectMapper;
@LazySingleton @LazySingleton
public class DefaultGroupByQueryMetricsFactory implements GroupByQueryMetricsFactory public class DefaultGroupByQueryMetricsFactory implements GroupByQueryMetricsFactory
{ {
private static final GroupByQueryMetricsFactory INSTANCE = private static final GroupByQueryMetricsFactory INSTANCE =
new DefaultGroupByQueryMetricsFactory(new DefaultObjectMapper()); new DefaultGroupByQueryMetricsFactory();
/** /**
* Should be used only in tests, directly or indirectly (via {@link * Should be used only in tests, directly or indirectly (via {@link
@ -42,17 +38,9 @@ public class DefaultGroupByQueryMetricsFactory implements GroupByQueryMetricsFac
return INSTANCE; return INSTANCE;
} }
private final ObjectMapper jsonMapper;
@Inject
public DefaultGroupByQueryMetricsFactory(@Json ObjectMapper jsonMapper)
{
this.jsonMapper = jsonMapper;
}
@Override @Override
public GroupByQueryMetrics makeMetrics() public GroupByQueryMetrics makeMetrics()
{ {
return new DefaultGroupByQueryMetrics(jsonMapper); return new DefaultGroupByQueryMetrics();
} }
} }

View File

@ -19,18 +19,12 @@
package org.apache.druid.query.timeseries; package org.apache.druid.query.timeseries;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.druid.query.DefaultQueryMetrics; import org.apache.druid.query.DefaultQueryMetrics;
import org.apache.druid.query.DruidMetrics; import org.apache.druid.query.DruidMetrics;
public class DefaultTimeseriesQueryMetrics extends DefaultQueryMetrics<TimeseriesQuery> public class DefaultTimeseriesQueryMetrics extends DefaultQueryMetrics<TimeseriesQuery>
implements TimeseriesQueryMetrics implements TimeseriesQueryMetrics
{ {
public DefaultTimeseriesQueryMetrics(ObjectMapper jsonMapper)
{
super(jsonMapper);
}
@Override @Override
public void query(TimeseriesQuery query) public void query(TimeseriesQuery query)
{ {

View File

@ -19,18 +19,14 @@
package org.apache.druid.query.timeseries; package org.apache.druid.query.timeseries;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.inject.Inject;
import org.apache.druid.guice.LazySingleton; import org.apache.druid.guice.LazySingleton;
import org.apache.druid.guice.annotations.Json;
import org.apache.druid.jackson.DefaultObjectMapper;
@LazySingleton @LazySingleton
public class DefaultTimeseriesQueryMetricsFactory implements TimeseriesQueryMetricsFactory public class DefaultTimeseriesQueryMetricsFactory implements TimeseriesQueryMetricsFactory
{ {
private static final TimeseriesQueryMetricsFactory INSTANCE = private static final TimeseriesQueryMetricsFactory INSTANCE =
new DefaultTimeseriesQueryMetricsFactory(new DefaultObjectMapper()); new DefaultTimeseriesQueryMetricsFactory();
/** /**
* Should be used only in tests, directly or indirectly (via {@link * Should be used only in tests, directly or indirectly (via {@link
@ -42,17 +38,9 @@ public class DefaultTimeseriesQueryMetricsFactory implements TimeseriesQueryMetr
return INSTANCE; return INSTANCE;
} }
private final ObjectMapper jsonMapper;
@Inject
public DefaultTimeseriesQueryMetricsFactory(@Json ObjectMapper jsonMapper)
{
this.jsonMapper = jsonMapper;
}
@Override @Override
public TimeseriesQueryMetrics makeMetrics() public TimeseriesQueryMetrics makeMetrics()
{ {
return new DefaultTimeseriesQueryMetrics(jsonMapper); return new DefaultTimeseriesQueryMetrics();
} }
} }

View File

@ -19,7 +19,6 @@
package org.apache.druid.query.topn; package org.apache.druid.query.topn;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.druid.query.DefaultQueryMetrics; import org.apache.druid.query.DefaultQueryMetrics;
import org.apache.druid.query.DruidMetrics; import org.apache.druid.query.DruidMetrics;
import org.apache.druid.segment.ColumnValueSelector; import org.apache.druid.segment.ColumnValueSelector;
@ -27,12 +26,6 @@ import org.apache.druid.segment.Cursor;
public class DefaultTopNQueryMetrics extends DefaultQueryMetrics<TopNQuery> implements TopNQueryMetrics public class DefaultTopNQueryMetrics extends DefaultQueryMetrics<TopNQuery> implements TopNQueryMetrics
{ {
public DefaultTopNQueryMetrics(ObjectMapper jsonMapper)
{
super(jsonMapper);
}
@Override @Override
public void query(TopNQuery query) public void query(TopNQuery query)
{ {

View File

@ -19,17 +19,13 @@
package org.apache.druid.query.topn; package org.apache.druid.query.topn;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.inject.Inject;
import org.apache.druid.guice.LazySingleton; import org.apache.druid.guice.LazySingleton;
import org.apache.druid.guice.annotations.Json;
import org.apache.druid.jackson.DefaultObjectMapper;
@LazySingleton @LazySingleton
public class DefaultTopNQueryMetricsFactory implements TopNQueryMetricsFactory public class DefaultTopNQueryMetricsFactory implements TopNQueryMetricsFactory
{ {
private static final TopNQueryMetricsFactory INSTANCE = new DefaultTopNQueryMetricsFactory(new DefaultObjectMapper()); private static final TopNQueryMetricsFactory INSTANCE = new DefaultTopNQueryMetricsFactory();
/** /**
* Should be used only in tests, directly or indirectly (via {@link TopNQueryQueryToolChest#TopNQueryQueryToolChest}). * Should be used only in tests, directly or indirectly (via {@link TopNQueryQueryToolChest#TopNQueryQueryToolChest}).
@ -40,17 +36,9 @@ public class DefaultTopNQueryMetricsFactory implements TopNQueryMetricsFactory
return INSTANCE; return INSTANCE;
} }
private final ObjectMapper jsonMapper;
@Inject
public DefaultTopNQueryMetricsFactory(@Json ObjectMapper jsonMapper)
{
this.jsonMapper = jsonMapper;
}
@Override @Override
public TopNQueryMetrics makeMetrics() public TopNQueryMetrics makeMetrics()
{ {
return new DefaultTopNQueryMetrics(jsonMapper); return new DefaultTopNQueryMetrics();
} }
} }

View File

@ -28,7 +28,6 @@ import org.apache.druid.query.dimension.ListFilteredDimensionSpec;
import org.apache.druid.query.filter.SelectorDimFilter; import org.apache.druid.query.filter.SelectorDimFilter;
import org.apache.druid.query.topn.TopNQuery; import org.apache.druid.query.topn.TopNQuery;
import org.apache.druid.query.topn.TopNQueryBuilder; import org.apache.druid.query.topn.TopNQueryBuilder;
import org.apache.druid.segment.TestHelper;
import org.joda.time.Interval; import org.joda.time.Interval;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@ -49,7 +48,7 @@ public class DefaultQueryMetricsTest
{ {
CachingEmitter cachingEmitter = new CachingEmitter(); CachingEmitter cachingEmitter = new CachingEmitter();
ServiceEmitter serviceEmitter = new ServiceEmitter("", "", cachingEmitter); ServiceEmitter serviceEmitter = new ServiceEmitter("", "", cachingEmitter);
DefaultQueryMetrics<Query<?>> queryMetrics = new DefaultQueryMetrics<>(TestHelper.makeJsonMapper()); DefaultQueryMetrics<Query<?>> queryMetrics = new DefaultQueryMetrics<>();
TopNQuery query = new TopNQueryBuilder() TopNQuery query = new TopNQueryBuilder()
.dataSource("xx") .dataSource("xx")
.granularity(Granularities.ALL) .granularity(Granularities.ALL)
@ -90,7 +89,7 @@ public class DefaultQueryMetricsTest
{ {
CachingEmitter cachingEmitter = new CachingEmitter(); CachingEmitter cachingEmitter = new CachingEmitter();
ServiceEmitter serviceEmitter = new ServiceEmitter("", "", cachingEmitter); ServiceEmitter serviceEmitter = new ServiceEmitter("", "", cachingEmitter);
DefaultQueryMetrics<Query<?>> queryMetrics = new DefaultQueryMetrics<>(TestHelper.makeJsonMapper()); DefaultQueryMetrics<Query<?>> queryMetrics = new DefaultQueryMetrics<>();
testQueryMetricsDefaultMetricNamesAndUnits(cachingEmitter, serviceEmitter, queryMetrics); testQueryMetricsDefaultMetricNamesAndUnits(cachingEmitter, serviceEmitter, queryMetrics);
} }

View File

@ -32,7 +32,6 @@ import org.apache.druid.query.dimension.ExtractionDimensionSpec;
import org.apache.druid.query.extraction.MapLookupExtractor; import org.apache.druid.query.extraction.MapLookupExtractor;
import org.apache.druid.query.filter.SelectorDimFilter; import org.apache.druid.query.filter.SelectorDimFilter;
import org.apache.druid.query.lookup.LookupExtractionFn; import org.apache.druid.query.lookup.LookupExtractionFn;
import org.apache.druid.segment.TestHelper;
import org.joda.time.Interval; import org.joda.time.Interval;
import org.joda.time.Period; import org.joda.time.Period;
import org.junit.Assert; import org.junit.Assert;
@ -53,7 +52,7 @@ public class DefaultGroupByQueryMetricsTest
{ {
CachingEmitter cachingEmitter = new CachingEmitter(); CachingEmitter cachingEmitter = new CachingEmitter();
ServiceEmitter serviceEmitter = new ServiceEmitter("", "", cachingEmitter); ServiceEmitter serviceEmitter = new ServiceEmitter("", "", cachingEmitter);
DefaultGroupByQueryMetrics queryMetrics = new DefaultGroupByQueryMetrics(TestHelper.makeJsonMapper()); DefaultGroupByQueryMetrics queryMetrics = new DefaultGroupByQueryMetrics();
GroupByQuery.Builder builder = GroupByQuery GroupByQuery.Builder builder = GroupByQuery
.builder() .builder()
.setDataSource(QueryRunnerTestHelper.DATA_SOURCE) .setDataSource(QueryRunnerTestHelper.DATA_SOURCE)
@ -104,7 +103,7 @@ public class DefaultGroupByQueryMetricsTest
{ {
CachingEmitter cachingEmitter = new CachingEmitter(); CachingEmitter cachingEmitter = new CachingEmitter();
ServiceEmitter serviceEmitter = new ServiceEmitter("", "", cachingEmitter); ServiceEmitter serviceEmitter = new ServiceEmitter("", "", cachingEmitter);
DefaultGroupByQueryMetrics queryMetrics = new DefaultGroupByQueryMetrics(TestHelper.makeJsonMapper()); DefaultGroupByQueryMetrics queryMetrics = new DefaultGroupByQueryMetrics();
DefaultQueryMetricsTest.testQueryMetricsDefaultMetricNamesAndUnits(cachingEmitter, serviceEmitter, queryMetrics); DefaultQueryMetricsTest.testQueryMetricsDefaultMetricNamesAndUnits(cachingEmitter, serviceEmitter, queryMetrics);
} }
} }

View File

@ -25,7 +25,6 @@ import org.apache.druid.query.DefaultQueryMetricsTest;
import org.apache.druid.query.DruidMetrics; import org.apache.druid.query.DruidMetrics;
import org.apache.druid.query.Druids; import org.apache.druid.query.Druids;
import org.apache.druid.query.QueryRunnerTestHelper; import org.apache.druid.query.QueryRunnerTestHelper;
import org.apache.druid.segment.TestHelper;
import org.joda.time.Interval; import org.joda.time.Interval;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@ -46,7 +45,7 @@ public class DefaultTimeseriesQueryMetricsTest
{ {
CachingEmitter cachingEmitter = new CachingEmitter(); CachingEmitter cachingEmitter = new CachingEmitter();
ServiceEmitter serviceEmitter = new ServiceEmitter("", "", cachingEmitter); ServiceEmitter serviceEmitter = new ServiceEmitter("", "", cachingEmitter);
DefaultTimeseriesQueryMetrics queryMetrics = new DefaultTimeseriesQueryMetrics(TestHelper.makeJsonMapper()); DefaultTimeseriesQueryMetrics queryMetrics = new DefaultTimeseriesQueryMetrics();
TimeseriesQuery query = Druids TimeseriesQuery query = Druids
.newTimeseriesQueryBuilder() .newTimeseriesQueryBuilder()
.dataSource(QueryRunnerTestHelper.DATA_SOURCE) .dataSource(QueryRunnerTestHelper.DATA_SOURCE)
@ -89,7 +88,7 @@ public class DefaultTimeseriesQueryMetricsTest
{ {
CachingEmitter cachingEmitter = new CachingEmitter(); CachingEmitter cachingEmitter = new CachingEmitter();
ServiceEmitter serviceEmitter = new ServiceEmitter("", "", cachingEmitter); ServiceEmitter serviceEmitter = new ServiceEmitter("", "", cachingEmitter);
DefaultTimeseriesQueryMetrics queryMetrics = new DefaultTimeseriesQueryMetrics(TestHelper.makeJsonMapper()); DefaultTimeseriesQueryMetrics queryMetrics = new DefaultTimeseriesQueryMetrics();
DefaultQueryMetricsTest.testQueryMetricsDefaultMetricNamesAndUnits(cachingEmitter, serviceEmitter, queryMetrics); DefaultQueryMetricsTest.testQueryMetricsDefaultMetricNamesAndUnits(cachingEmitter, serviceEmitter, queryMetrics);
} }
} }

View File

@ -30,7 +30,6 @@ import org.apache.druid.query.aggregation.CountAggregatorFactory;
import org.apache.druid.query.dimension.DefaultDimensionSpec; import org.apache.druid.query.dimension.DefaultDimensionSpec;
import org.apache.druid.query.dimension.ListFilteredDimensionSpec; import org.apache.druid.query.dimension.ListFilteredDimensionSpec;
import org.apache.druid.query.filter.SelectorDimFilter; import org.apache.druid.query.filter.SelectorDimFilter;
import org.apache.druid.segment.TestHelper;
import org.joda.time.Interval; import org.joda.time.Interval;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@ -51,7 +50,7 @@ public class DefaultTopNQueryMetricsTest
{ {
CachingEmitter cachingEmitter = new CachingEmitter(); CachingEmitter cachingEmitter = new CachingEmitter();
ServiceEmitter serviceEmitter = new ServiceEmitter("", "", cachingEmitter); ServiceEmitter serviceEmitter = new ServiceEmitter("", "", cachingEmitter);
DefaultTopNQueryMetrics queryMetrics = new DefaultTopNQueryMetrics(TestHelper.makeJsonMapper()); DefaultTopNQueryMetrics queryMetrics = new DefaultTopNQueryMetrics();
TopNQuery query = new TopNQueryBuilder() TopNQuery query = new TopNQueryBuilder()
.dataSource("xx") .dataSource("xx")
.granularity(Granularities.ALL) .granularity(Granularities.ALL)
@ -101,7 +100,7 @@ public class DefaultTopNQueryMetricsTest
{ {
CachingEmitter cachingEmitter = new CachingEmitter(); CachingEmitter cachingEmitter = new CachingEmitter();
ServiceEmitter serviceEmitter = new ServiceEmitter("", "", cachingEmitter); ServiceEmitter serviceEmitter = new ServiceEmitter("", "", cachingEmitter);
DefaultTopNQueryMetrics queryMetrics = new DefaultTopNQueryMetrics(TestHelper.makeJsonMapper()); DefaultTopNQueryMetrics queryMetrics = new DefaultTopNQueryMetrics();
DefaultQueryMetricsTest.testQueryMetricsDefaultMetricNamesAndUnits(cachingEmitter, serviceEmitter, queryMetrics); DefaultQueryMetricsTest.testQueryMetricsDefaultMetricNamesAndUnits(cachingEmitter, serviceEmitter, queryMetrics);
} }
} }

View File

@ -42,7 +42,7 @@ public class EmittingRequestLoggerProvider implements RequestLoggerProvider
@JsonProperty @JsonProperty
@NotNull @NotNull
private RequestLogEventBuilderFactory requestLogEventBuilderFactory = null; private RequestLogEventBuilderFactory requestLogEventBuilderFactory = DefaultRequestLogEventBuilderFactory.instance();
@JacksonInject @JacksonInject
@NotNull @NotNull

View File

@ -54,7 +54,6 @@ import org.apache.druid.query.timeseries.TimeseriesQueryRunnerFactory;
import org.apache.druid.segment.IndexIO; import org.apache.druid.segment.IndexIO;
import org.apache.druid.segment.IndexMerger; import org.apache.druid.segment.IndexMerger;
import org.apache.druid.segment.IndexMergerV9; import org.apache.druid.segment.IndexMergerV9;
import org.apache.druid.segment.TestHelper;
import org.apache.druid.segment.column.ColumnConfig; import org.apache.druid.segment.column.ColumnConfig;
import org.apache.druid.segment.indexing.DataSchema; import org.apache.druid.segment.indexing.DataSchema;
import org.apache.druid.segment.indexing.RealtimeTuningConfig; import org.apache.druid.segment.indexing.RealtimeTuningConfig;
@ -253,7 +252,7 @@ public class AppenderatorTester implements AutoCloseable
ScanQuery.class, new ScanQueryRunnerFactory( ScanQuery.class, new ScanQueryRunnerFactory(
new ScanQueryQueryToolChest( new ScanQueryQueryToolChest(
new ScanQueryConfig(), new ScanQueryConfig(),
new DefaultGenericQueryMetricsFactory(TestHelper.makeJsonMapper()) new DefaultGenericQueryMetricsFactory()
), ),
new ScanQueryEngine(), new ScanQueryEngine(),
new ScanQueryConfig() new ScanQueryConfig()

View File

@ -255,7 +255,7 @@ public class AsyncQueryForwardingServletTest extends BaseJettyTest
null, null,
new NoopServiceEmitter(), new NoopServiceEmitter(),
new NoopRequestLogger(), new NoopRequestLogger(),
new DefaultGenericQueryMetricsFactory(jsonMapper), new DefaultGenericQueryMetricsFactory(),
new AuthenticatorMapper(ImmutableMap.of()) new AuthenticatorMapper(ImmutableMap.of())
) )
{ {
@ -347,7 +347,7 @@ public class AsyncQueryForwardingServletTest extends BaseJettyTest
injector.getInstance(DruidHttpClientConfig.class), injector.getInstance(DruidHttpClientConfig.class),
new NoopServiceEmitter(), new NoopServiceEmitter(),
new NoopRequestLogger(), new NoopRequestLogger(),
new DefaultGenericQueryMetricsFactory(jsonMapper), new DefaultGenericQueryMetricsFactory(),
new AuthenticatorMapper(ImmutableMap.of()) new AuthenticatorMapper(ImmutableMap.of())
) )
{ {

View File

@ -131,7 +131,7 @@ public class QueryResourceTest
new QueryLifecycleFactory( new QueryLifecycleFactory(
WAREHOUSE, WAREHOUSE,
TEST_SEGMENT_WALKER, TEST_SEGMENT_WALKER,
new DefaultGenericQueryMetricsFactory(JSON_MAPPER), new DefaultGenericQueryMetricsFactory(),
new NoopServiceEmitter(), new NoopServiceEmitter(),
testRequestLogger, testRequestLogger,
new AuthConfig(), new AuthConfig(),
@ -142,7 +142,7 @@ public class QueryResourceTest
queryManager, queryManager,
new AuthConfig(), new AuthConfig(),
null, null,
new DefaultGenericQueryMetricsFactory(JSON_MAPPER) new DefaultGenericQueryMetricsFactory()
); );
} }
@ -353,7 +353,7 @@ public class QueryResourceTest
new QueryLifecycleFactory( new QueryLifecycleFactory(
WAREHOUSE, WAREHOUSE,
TEST_SEGMENT_WALKER, TEST_SEGMENT_WALKER,
new DefaultGenericQueryMetricsFactory(JSON_MAPPER), new DefaultGenericQueryMetricsFactory(),
new NoopServiceEmitter(), new NoopServiceEmitter(),
testRequestLogger, testRequestLogger,
new AuthConfig(), new AuthConfig(),
@ -364,7 +364,7 @@ public class QueryResourceTest
queryManager, queryManager,
new AuthConfig(), new AuthConfig(),
authMapper, authMapper,
new DefaultGenericQueryMetricsFactory(JSON_MAPPER) new DefaultGenericQueryMetricsFactory()
); );
@ -467,7 +467,7 @@ public class QueryResourceTest
new QueryLifecycleFactory( new QueryLifecycleFactory(
WAREHOUSE, WAREHOUSE,
TEST_SEGMENT_WALKER, TEST_SEGMENT_WALKER,
new DefaultGenericQueryMetricsFactory(JSON_MAPPER), new DefaultGenericQueryMetricsFactory(),
new NoopServiceEmitter(), new NoopServiceEmitter(),
testRequestLogger, testRequestLogger,
new AuthConfig(), new AuthConfig(),
@ -478,7 +478,7 @@ public class QueryResourceTest
queryManager, queryManager,
new AuthConfig(), new AuthConfig(),
authMapper, authMapper,
new DefaultGenericQueryMetricsFactory(JSON_MAPPER) new DefaultGenericQueryMetricsFactory()
); );
final String queryString = "{\"queryType\":\"timeBoundary\", \"dataSource\":\"allow\"," final String queryString = "{\"queryType\":\"timeBoundary\", \"dataSource\":\"allow\","
@ -589,7 +589,7 @@ public class QueryResourceTest
new QueryLifecycleFactory( new QueryLifecycleFactory(
WAREHOUSE, WAREHOUSE,
TEST_SEGMENT_WALKER, TEST_SEGMENT_WALKER,
new DefaultGenericQueryMetricsFactory(JSON_MAPPER), new DefaultGenericQueryMetricsFactory(),
new NoopServiceEmitter(), new NoopServiceEmitter(),
testRequestLogger, testRequestLogger,
new AuthConfig(), new AuthConfig(),
@ -600,7 +600,7 @@ public class QueryResourceTest
queryManager, queryManager,
new AuthConfig(), new AuthConfig(),
authMapper, authMapper,
new DefaultGenericQueryMetricsFactory(JSON_MAPPER) new DefaultGenericQueryMetricsFactory()
); );
final String queryString = "{\"queryType\":\"timeBoundary\", \"dataSource\":\"allow\"," final String queryString = "{\"queryType\":\"timeBoundary\", \"dataSource\":\"allow\","

View File

@ -579,7 +579,7 @@ public class ServerManagerTest
@Override @Override
public QueryMetrics<Query<?>> makeMetrics(QueryType query) public QueryMetrics<Query<?>> makeMetrics(QueryType query)
{ {
return new DefaultQueryMetrics<>(new DefaultObjectMapper()); return new DefaultQueryMetrics<>();
} }
@Override @Override

View File

@ -531,7 +531,7 @@ public class CalciteTests
new ScanQueryRunnerFactory( new ScanQueryRunnerFactory(
new ScanQueryQueryToolChest( new ScanQueryQueryToolChest(
new ScanQueryConfig(), new ScanQueryConfig(),
new DefaultGenericQueryMetricsFactory(TestHelper.makeJsonMapper()) new DefaultGenericQueryMetricsFactory()
), ),
new ScanQueryEngine(), new ScanQueryEngine(),
new ScanQueryConfig() new ScanQueryConfig()
@ -588,7 +588,7 @@ public class CalciteTests
} }
}, },
walker, walker,
new DefaultGenericQueryMetricsFactory(INJECTOR.getInstance(Key.get(ObjectMapper.class, Json.class))), new DefaultGenericQueryMetricsFactory(),
new ServiceEmitter("dummy", "dummy", new NoopEmitter()), new ServiceEmitter("dummy", "dummy", new NoopEmitter()),
new NoopRequestLogger(), new NoopRequestLogger(),
new AuthConfig(), new AuthConfig(),