Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add grafana example #290

Merged
merged 3 commits into from
Sep 11, 2023
Merged

Add grafana example #290

merged 3 commits into from
Sep 11, 2023

Conversation

keuhdall
Copy link
Contributor

@keuhdall keuhdall commented Aug 6, 2023

Added Grafana example as described in #270

I was planning to also add Loki for a full Grafana-stack example with log correlations, but I think it is currently blocked by #202
Let me know if I should change anything the example ! 🙂


Add settings to the `build.sbt`:
```scala
libraryDependencies ++= Seq(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example uses Scala 3. Should we reference the Scala version in the settings too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also thinking about whether we should provide multiple examples:

  1. sbt. Scala 2
  2. sbt. Scala 3
  3. scala-cli. Scala 2
  4. scala-cli. Scala 3

The code will be nearly identical, so the benefit is questionable.

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding showing the differences between Scala 2 and 3 the only thing coming to my mind for sbt is ThisBuild / scalaVersion, maybe I'm missing something though. Assuming there's only this attribute changing I don't know if it's worth adding a dedicated scala 3 example just for that.
I never got to try scala-cli yet, so I can't really tell how different things should be there, so maybe it could be worth having a scala 3 example here, tell me what you think

@:choice(sbt)

```shell
$ sbt run
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see an entry point in the example above, so will sbt run work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tried it on my example project, works fine 👌
On a second thought though I wonder if the scala-cli snippet makes a lot of sense here, it could maybe even be somewhat misleading as I chose grafana.scala kind of as a placeholder name.
Should I change/remove it ?

@iRevive
Copy link
Contributor

iRevive commented Aug 9, 2023

Great example, thanks! I like dashboards being attached too. A few minor questions to discuss and we can move forward.

Comment on lines 41 to 52
@:choice(scala-cli Scala 2)

Add directives to the `grafana.scala`:
```scala
//> using lib "org.typelevel::otel4s-java:@VERSION@" // <1>
//> using lib "io.opentelemetry:opentelemetry-exporter-otlp:@OPEN_TELEMETRY_VERSION@" // <2>
//> using lib "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:@OPEN_TELEMETRY_VERSION@" // <3>
//> using `java-opt` "-Dotel.java.global-autoconfigure.enabled=true" // <4>
//> using `java-opt` "-Dotel.service.name=grafana-example" // <5>
```

@:choice(scala-cli Scala 3)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@:choice(scala-cli Scala 2)
Add directives to the `grafana.scala`:
```scala
//> using lib "org.typelevel::otel4s-java:@VERSION@" // <1>
//> using lib "io.opentelemetry:opentelemetry-exporter-otlp:@OPEN_TELEMETRY_VERSION@" // <2>
//> using lib "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:@OPEN_TELEMETRY_VERSION@" // <3>
//> using `java-opt` "-Dotel.java.global-autoconfigure.enabled=true" // <4>
//> using `java-opt` "-Dotel.service.name=grafana-example" // <5>
```
@:choice(scala-cli Scala 3)
@:choice(scala-cli)

Let's keep only one scala-cli example.


Add directives to the `grafana.scala`:
```scala
//> using lib "org.typelevel::otel4s-java:@VERSION@" // <1>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//> using lib "org.typelevel::otel4s-java:@VERSION@" // <1>
//> using scala 3.3.0
//> using lib "org.typelevel::otel4s-java:@VERSION@" // <1>

That way we can ensure users will have a correct Scala version and the example will compile

Comment on lines 26 to 25

@:choice(sbt Scala 3)

Add settings to the `build.sbt`:
```scala
libraryDependencies ++= Seq(
"org.typelevel" %% "otel4s-java" % "@VERSION@", // <1>
"io.opentelemetry" % "opentelemetry-exporter-otlp" % "@OPEN_TELEMETRY_VERSION@" % Runtime, // <2>
"io.opentelemetry" % "opentelemetry-sdk-extension-autoconfigure" % "@OPEN_TELEMETRY_VERSION@" % Runtime // <3>
)
run / fork := true
javaOptions += "-Dotel.java.global-autoconfigure.enabled=true" // <4>
javaOptions += "-Dotel.service.name=grafana-example" // <5>
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@:choice(sbt Scala 3)
Add settings to the `build.sbt`:
```scala
libraryDependencies ++= Seq(
"org.typelevel" %% "otel4s-java" % "@VERSION@", // <1>
"io.opentelemetry" % "opentelemetry-exporter-otlp" % "@OPEN_TELEMETRY_VERSION@" % Runtime, // <2>
"io.opentelemetry" % "opentelemetry-sdk-extension-autoconfigure" % "@OPEN_TELEMETRY_VERSION@" % Runtime // <3>
)
run / fork := true
javaOptions += "-Dotel.java.global-autoconfigure.enabled=true" // <4>
javaOptions += "-Dotel.service.name=grafana-example" // <5>
```

Let's keep only one sbt example


@:select(build-tool)

@:choice(sbt Scala 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@:choice(sbt Scala 2)
@:choice(sbt)

@iRevive
Copy link
Contributor

iRevive commented Aug 30, 2023

I'm sorry for the delay. As you mentioned, I guess it's not worth making a separate example per Scala version since they are nearly identical.

@keuhdall
Copy link
Contributor Author

keuhdall commented Sep 4, 2023

Should be good now 👍

@iRevive
Copy link
Contributor

iRevive commented Sep 9, 2023

I made a few changes to the PR keuhdall#1. We will have a minimal working example right on the documentation page, while we also reference your complete project too

Grafana All-in-one, add more details: configuration notes, service configs
Copy link
Contributor

@iRevive iRevive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@iRevive iRevive merged commit 2c59bc1 into typelevel:main Sep 11, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants