-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
115 changed files
with
1,775 additions
and
775 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.m3.octoparts | ||
|
||
import java.net.InetAddress | ||
|
||
import com.beachape.zipkin.services.{ BraveZipkinService, NoopZipkinService, ZipkinServiceLike } | ||
import com.github.kristofa.brave.zipkin.ZipkinSpanCollector | ||
import play.api.{ Logger, Play } | ||
|
||
object ZipkinServiceHolder { | ||
|
||
private implicit val app = play.api.Play.current | ||
private implicit val ex = play.api.libs.concurrent.Execution.Implicits.defaultContext | ||
|
||
val ZipkinService: ZipkinServiceLike = if (Play.isTest) { | ||
NoopZipkinService | ||
} else { | ||
val maybeService = for { | ||
zipkinHost <- Play.configuration.getString("zipkin.host") | ||
zipkinPort <- Play.configuration.getInt("zipkin.port") | ||
env <- Play.configuration.getString("application.env") | ||
} yield { | ||
val zipkinSpanCollector = new ZipkinSpanCollector(zipkinHost, zipkinPort) | ||
sys.addShutdownHook(zipkinSpanCollector.close()) | ||
val currentHostName = InetAddress.getLocalHost.getHostName | ||
val currentRunningPort = Play.configuration.getInt("http.port").getOrElse(9000) | ||
new BraveZipkinService( | ||
currentHostName, | ||
currentRunningPort, s"Octoparts - $env", | ||
zipkinSpanCollector, | ||
Seq( | ||
!_.startsWith("OPTION"), | ||
!_.startsWith("GET - /assets") | ||
) | ||
) | ||
} | ||
maybeService.getOrElse { | ||
Logger.warn("Zipkin configs are missing in the current environment, falling back to NoopZipkinService") | ||
NoopZipkinService | ||
} | ||
} | ||
|
||
} |
3 changes: 2 additions & 1 deletion
3
app/com/m3/octoparts/aggregator/handler/AggregatorHandlersModule.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
package com.m3.octoparts.aggregator.handler | ||
|
||
import com.beachape.zipkin.services.ZipkinServiceLike | ||
import com.m3.octoparts.http.HttpClientPool | ||
import scaldi.Module | ||
|
||
class AggregatorHandlersModule extends Module { | ||
|
||
implicit val glueContext = play.api.libs.concurrent.Execution.Implicits.defaultContext | ||
|
||
bind[HttpHandlerFactory] to new SimpleHttpHandlerFactory(inject[HttpClientPool]) | ||
bind[HttpHandlerFactory] to new SimpleHttpHandlerFactory(inject[HttpClientPool], inject[ZipkinServiceLike]) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
app/com/m3/octoparts/aggregator/handler/HttpHandlerFactory.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 11 additions & 10 deletions
21
app/com/m3/octoparts/aggregator/handler/SimpleHttpHandlerFactory.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.