diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2015-07-21 14:23:54 +0200 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2015-07-21 14:23:54 +0200 |
commit | a9dc9a9879dc04b39911ce4d7971775403e05695 (patch) | |
tree | 71453fc02d5ee2c4f927b7fce94b670712ddcb1c /kamon-core/src/main/scala/kamon/trace/TraceSettings.scala | |
parent | c85c28d8c1b12b3d35cfc6dca628e72115db49f3 (diff) | |
parent | 02e18a1186f9b0dd9a7133ff30aa73774822db13 (diff) | |
download | Kamon-a9dc9a9879dc04b39911ce4d7971775403e05695.tar.gz Kamon-a9dc9a9879dc04b39911ce4d7971775403e05695.tar.bz2 Kamon-a9dc9a9879dc04b39911ce4d7971775403e05695.zip |
Merge branch 'samplers' of https://github.com/Elyrixia/Kamon into pr/elyrixia-samplers-206
Diffstat (limited to 'kamon-core/src/main/scala/kamon/trace/TraceSettings.scala')
-rw-r--r-- | kamon-core/src/main/scala/kamon/trace/TraceSettings.scala | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/kamon-core/src/main/scala/kamon/trace/TraceSettings.scala b/kamon-core/src/main/scala/kamon/trace/TraceSettings.scala new file mode 100644 index 00000000..06677314 --- /dev/null +++ b/kamon-core/src/main/scala/kamon/trace/TraceSettings.scala @@ -0,0 +1,49 @@ +/* + * ========================================================================================= + * Copyright © 2013-2015 the kamon project <http://kamon.io/> + * + * 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 kamon.trace + +import kamon.util.ConfigTools.Syntax +import com.typesafe.config.Config +import kamon.util.NanoInterval + +case class TraceSettings(levelOfDetail: LevelOfDetail, sampler: Sampler, tokenGeneratorFQN: String) + +object TraceSettings { + def apply(config: Config): TraceSettings = { + val tracerConfig = config.getConfig("kamon.trace") + + val detailLevel: LevelOfDetail = tracerConfig.getString("level-of-detail") match { + case "metrics-only" ⇒ LevelOfDetail.MetricsOnly + case "simple-trace" ⇒ LevelOfDetail.SimpleTrace + case other ⇒ sys.error(s"Unknown tracer level of detail [$other] present in the configuration file.") + } + + val sampler: Sampler = + if (detailLevel == LevelOfDetail.MetricsOnly) NoSampling + else tracerConfig.getString("sampling") match { + case "all" ⇒ SampleAll + case "random" ⇒ new RandomSampler(tracerConfig.getInt("random-sampler.chance")) + case "ordered" ⇒ new OrderedSampler(tracerConfig.getInt("ordered-sampler.sample-interval")) + case "threshold" ⇒ new ThresholdSampler(new NanoInterval(tracerConfig.getFiniteDuration("threshold-sampler.minimum-elapsed-time").toNanos)) + case "clock" ⇒ new ClockSampler(new NanoInterval(tracerConfig.getFiniteDuration("clock-sampler.pause").toNanos)) + } + + val tokenGeneratorFQN = tracerConfig.getString("token-generator") + + TraceSettings(detailLevel, sampler, tokenGeneratorFQN) + } +}
\ No newline at end of file |