-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Protobuf scala span creation (#2069)
* Added tracing context in Scala SDK and using sttp in the Scala sample * simpler sync example * added async calling endpoint * using core sttp and some cleaning * refactoring * added readme * removing sync * implementing interface for ScalaActionContextAdapter * Cleaned and created docs * Clean up scala-protobuf-traicing sample and adding NoOps tracer for a better DX * docs and new implementation for the java-protobuf-tracing example * avoid validating local urls and validate back * Update docs/src/modules/java-protobuf/pages/actions.adoc Co-authored-by: Renato Cavalcanti <[email protected]> * Update samples/scala-protobuf-tracing/project/plugins.sbt Co-authored-by: Renato Cavalcanti <[email protected]> * Update sdk/java-sdk-protobuf/src/main/java/kalix/javasdk/action/ActionCreationContext.java Co-authored-by: Renato Cavalcanti <[email protected]> * addressing comments * simplifying request/response types --------- Co-authored-by: Renato Cavalcanti <[email protected]>
- Loading branch information
1 parent
8aceaa8
commit 05f78a5
Showing
36 changed files
with
637 additions
and
97 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# this is the port where the kalix runtime container will be exposed | ||
# when running multiple services on your local machine, make sure that this port is unique | ||
ADVERTISED_HTTP_PORT=9000 | ||
|
||
# this is the port where the user services (your application) will open | ||
# when running multiple services on your local machine, make sure that this port is unique | ||
USER_SERVICE_PORT=8080 | ||
|
||
# this variable defines the host where the kalix runtime (running in docker) | ||
# will reach the user service in local development | ||
USER_SERVICE_HOST=host.docker.internal |
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,33 @@ | ||
boot/ | ||
lib_managed/ | ||
src_managed/ | ||
.bsp | ||
|
||
# intellij | ||
/src/intellij*/*.iml | ||
/src/intellij*/*.ipr | ||
/src/intellij*/*.iws | ||
**/.cache | ||
/.idea | ||
/.settings | ||
|
||
# vscode | ||
/.vscode | ||
|
||
# sbt's target directories | ||
/target/ | ||
/project/target | ||
/project/plugins/project/ | ||
/project/project | ||
/project/**/target/ | ||
/test/macro-annot/target/ | ||
/test/files/target/ | ||
/test/target/ | ||
/build-sbt/ | ||
local.sbt | ||
jitwatch.out | ||
|
||
# metals | ||
.metals | ||
.bloop | ||
project/**/metals.sbt |
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,47 @@ | ||
version = 3.0.3 | ||
|
||
style = defaultWithAlign | ||
|
||
docstrings.style = Asterisk | ||
indentOperator.preset = spray | ||
maxColumn = 120 | ||
rewrite.rules = [RedundantParens, SortImports, AvoidInfix] | ||
unindentTopLevelOperators = true | ||
align.tokens = [{code = "=>", owner = "Case"}] | ||
align.openParenDefnSite = false | ||
align.openParenCallSite = false | ||
optIn.configStyleArguments = false | ||
danglingParentheses.preset = false | ||
spaces.inImportCurlyBraces = true | ||
newlines.afterCurlyLambda = preserve | ||
rewrite.neverInfix.excludeFilters = [ | ||
and | ||
min | ||
max | ||
until | ||
to | ||
by | ||
eq | ||
ne | ||
"should.*" | ||
"contain.*" | ||
"must.*" | ||
in | ||
ignore | ||
be | ||
taggedAs | ||
thrownBy | ||
synchronized | ||
have | ||
when | ||
size | ||
only | ||
noneOf | ||
oneElementOf | ||
noElementsOf | ||
atLeastOneElementOf | ||
atMostOneElementOf | ||
allElementsOf | ||
inOrderElementsOf | ||
theSameElementsAs | ||
] |
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 @@ | ||
## This example show how to create Spans by the users | ||
|
||
## Running Locally | ||
|
||
When running a Kalix service locally, we need to have its companion Kalix Runtime running alongside it. | ||
|
||
To start your service locally, run: | ||
|
||
```shell | ||
sbt runAll | ||
``` | ||
|
||
This command will start your Kalix service and a companion Kalix Runtime as configured in [docker-compose.yml](./docker-compose.yml) file. | ||
This will also start a Jaeger service to which the Kalix service will push the traces. You can find Jaeger at `http://localhost:16686` | ||
|
||
With both the Kalix Runtime and your service running, any defined endpoints should be available at `http://localhost:9000`. In addition to the defined gRPC interface, each method has a corresponding HTTP endpoint. Unless configured otherwise (see [Transcoding HTTP](https://docs.kalix.io/java-protobuf/writing-grpc-descriptors-protobuf.html#_transcoding_http)), this endpoint accepts POST requests at the path `/[package].[entity name]/[method]`. | ||
For example, using [`grpcurl`](https://github.com/fullstorydev/grpcurl): | ||
|
||
```shell | ||
grpcurl -plaintext localhost:9000 com.example.Controller/CallAsyncEndpoint | ||
``` | ||
produces | ||
``` | ||
{ | ||
"message": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit" | ||
} | ||
``` | ||
|
||
## Deploying | ||
|
||
To deploy your service, install the `kalix` CLI as documented in | ||
[Install Kalix](https://docs.kalix.io/kalix/install-kalix.html) | ||
and configure a Docker Registry to upload your docker image to. | ||
|
||
You will need to update the `dockerImage` property in the `pom.xml` and refer to | ||
[Configuring registries](https://docs.kalix.io/projects/container-registries.html) | ||
for more information on how to make your docker image available to Kalix. | ||
|
||
Finally, you use the `kalix` CLI to create a project as described in [Create a new Project](https://docs.kalix.io/projects/create-project.html). Once you have a project you can deploy your service into the project either | ||
by using `mvn deploy kalix:deploy` which will package, publish your docker image, and deploy your service to Kalix, | ||
or by first packaging and publishing the docker image through `mvn deploy` and | ||
then [deploying the image through the `kalix` CLI](https://docs.kalix.io/services/deploy-service.html#_deploy). |
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,38 @@ | ||
organization := "com.example" | ||
|
||
scalaVersion := "2.13.10" | ||
|
||
|
||
enablePlugins(KalixPlugin, JavaAppPackaging, DockerPlugin) | ||
dockerBaseImage := "docker.io/library/adoptopenjdk:11-jre-hotspot" | ||
dockerUsername := sys.props.get("docker.username") | ||
dockerRepository := sys.props.get("docker.registry") | ||
dockerUpdateLatest := true | ||
dockerBuildCommand := { | ||
val arch = sys.props("os.arch") | ||
if (arch != "amd64" && !arch.contains("x86")) { | ||
// use buildx with platform to build supported amd64 images on other CPU architectures | ||
// this may require that you have first run 'docker buildx create' to set docker buildx up | ||
dockerExecCommand.value ++ Seq("buildx", "build", "--platform=linux/amd64", "--load") ++ dockerBuildOptions.value :+ "." | ||
} else dockerBuildCommand.value | ||
} | ||
ThisBuild / dynverSeparator := "-" | ||
run / fork := true | ||
run / envVars += ("HOST", "0.0.0.0") | ||
run / javaOptions ++= Seq("-Dlogback.configurationFile=logback-dev-mode.xml") | ||
|
||
Compile / scalacOptions ++= Seq( | ||
"-release:11", | ||
"-deprecation", | ||
"-feature", | ||
"-unchecked", | ||
"-Xlog-reflective-calls", | ||
"-Xlint") | ||
Compile / javacOptions ++= Seq("-Xlint:unchecked", "-Xlint:deprecation", "-parameters" // for Jackson | ||
) | ||
|
||
libraryDependencies ++= Seq( | ||
"com.softwaremill.sttp.client4" %% "core" % "4.0.0-M11" % Compile, | ||
"org.json4s" %% "json4s-native" % "4.1.0-M5"% Compile, | ||
"org.scalatest" %% "scalatest" % "3.2.7" % Test | ||
) |
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,24 @@ | ||
# If you're looking to use eventing with Google PubSub, to get an emulator running: | ||
# - add property "-Dkalix.proxy.eventing.support=google-pubsub-emulator" to the JAVA_TOOL_OPTIONS environment map under the kalix-runtime service | ||
# - uncomment the env var PUBSUB_EMULATOR_HOST and the section below for gcloud-pubsub-emulator service | ||
version: "3" | ||
services: | ||
kalix-runtime: | ||
image: gcr.io/kalix-public/kalix-runtime:1.1.34 | ||
container_name: tracing | ||
ports: | ||
- "${ADVERTISED_HTTP_PORT}:9000" | ||
extra_hosts: | ||
- "host.docker.internal:host-gateway" | ||
environment: | ||
JAVA_TOOL_OPTIONS: > | ||
-Dkalix.proxy.telemetry.tracing.enabled=true | ||
-Dkalix.proxy.telemetry.tracing.collector-endpoint=http://jaeger:4317 | ||
ADVERTISED_HTTP_PORT: ${ADVERTISED_HTTP_PORT} | ||
USER_SERVICE_HOST: ${USER_SERVICE_HOST} | ||
USER_SERVICE_PORT: ${USER_SERVICE_PORT} | ||
jaeger: | ||
image: jaegertracing/all-in-one:1.54 | ||
ports: | ||
- 4317:4317 | ||
- 16686:16686 |
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 @@ | ||
sbt.version=1.9.9 |
Oops, something went wrong.