1 /*
2  *  Make.org Core API
3  *  Copyright (C) 2020 Make.org
4  *
5  * This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU Affero General Public License as
7  *  published by the Free Software Foundation, either version 3 of the
8  *  License, or (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU Affero General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Affero General Public License
16  *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  *
18  */
19 
20 package org.make.api.technical.tracing
21 
22 import kamon.Kamon
23 import kamon.context.Context
24 
25 object Tracing {
26 
27   private val EntrypointKey: Context.Key[Option[String]] = Context.key(EntrypointPatternConverter.name, None)
28 
29   def entrypoint: Option[String] = Kamon.currentContext().get(EntrypointKey)
30 
31   def entrypoint(name: String): Unit = {
32     Kamon.storeContext(Kamon.currentContext().withEntry(EntrypointKey, Some(name)))
33     ()
34   }
35 
36   def clearEntrypoint(): Unit = {
37     Kamon.storeContext(Kamon.currentContext().withoutEntry(EntrypointKey))
38     ()
39   }
40 
41 }
Line Stmt Id Pos Tree Symbol Tests Code
27 178 911 - 961 Apply kamon.context.Context.key org.make.api.user.adminuserapitest kamon.context.Context.key[Option[String]]("entrypoint", scala.None)
27 91 923 - 954 Literal <nosymbol> org.make.api.user.adminuserapitest "entrypoint"
27 305 956 - 960 Select scala.None org.make.api.user.adminuserapitest scala.None
29 53 1025 - 1038 Select org.make.api.technical.tracing.Tracing.EntrypointKey org.make.api.technical.makeclientoperationnamegeneratortest Tracing.this.EntrypointKey
29 318 998 - 1039 Apply kamon.context.Context.get org.make.api.technical.makeclientoperationnamegeneratortest kamon.Kamon.currentContext().get[Option[String]](Tracing.this.EntrypointKey)
32 220 1086 - 1165 Apply kamon.ContextStorage.storeContext org.make.api.user.adminuserapitest kamon.Kamon.storeContext(kamon.Kamon.currentContext().withEntry[Option[String]](Tracing.this.EntrypointKey, scala.Some.apply[String](name)))
32 196 1138 - 1151 Select org.make.api.technical.tracing.Tracing.EntrypointKey org.make.api.user.adminuserapitest Tracing.this.EntrypointKey
32 78 1153 - 1163 Apply scala.Some.apply org.make.api.user.adminuserapitest scala.Some.apply[String](name)
32 284 1105 - 1164 Apply kamon.context.Context.withEntry org.make.api.user.adminuserapitest kamon.Kamon.currentContext().withEntry[Option[String]](Tracing.this.EntrypointKey, scala.Some.apply[String](name))
33 92 1170 - 1172 Literal <nosymbol> org.make.api.user.adminuserapitest ()
37 306 1271 - 1284 Select org.make.api.technical.tracing.Tracing.EntrypointKey org.make.api.technical.makeclientoperationnamegeneratortest Tracing.this.EntrypointKey
37 54 1216 - 1286 Apply kamon.ContextStorage.storeContext org.make.api.technical.makeclientoperationnamegeneratortest kamon.Kamon.storeContext(kamon.Kamon.currentContext().withoutEntry[Option[String]](Tracing.this.EntrypointKey))
37 171 1235 - 1285 Apply kamon.context.Context.withoutEntry org.make.api.technical.makeclientoperationnamegeneratortest kamon.Kamon.currentContext().withoutEntry[Option[String]](Tracing.this.EntrypointKey)
38 324 1291 - 1293 Literal <nosymbol> org.make.api.technical.makeclientoperationnamegeneratortest ()