Skip to content

Commit

Permalink
Merge pull request #71 from gian1200/feature/add-windows-support
Browse files Browse the repository at this point in the history
Add Windows support for main scripts (run and build)
  • Loading branch information
zeitlinger authored Jul 9, 2024
2 parents 24c2758 + 65b4265 commit 1716214
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 5 deletions.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@ The `grafana/otel-lgtm` Docker image is an open source backend for OpenTelemetry

## Get the Docker image

The Docker image is available on Docker hub: https://hub.docker.com/r/grafana/otel-lgtm
The Docker image is available on Docker hub: <https://hub.docker.com/r/grafana/otel-lgtm>

## Run the Docker image

```sh
# Unix/Linux
./run-lgtm.sh

# Windows (PowerShell)
./run-lgtm
```

## Run lgtm in kubernetes

```sh
# create k8s resources
kubectl apply -f k8s/lgtm.yaml
Expand Down Expand Up @@ -55,19 +60,27 @@ docker build . -t grafana/otel-lgtm
Run the example REST service:

```sh
# Unix/Linux
./run-example.sh

# Windows (PowerShell)
./run-example
```

Generate traffic:

```sh
# Unix/Linux
./generate-traffic.sh

# Windows (PowerShell)
./generate-traffic
```

## Run example apps in different languages

The example apps are in the `examples/` directory.
Each example has a `run.sh` script to start the app.
Each example has a `run.sh` or `run.cmd` script to start the app.

Every example implements a rolldice service, which returns a random number between 1 and 6.

Expand All @@ -82,4 +95,4 @@ Each example uses a different application port (to be able to run all applicatio

## Related Work

* Metrics, Logs, Traces and Profiles in Grafana: https://github.com/grafana/intro-to-mltp
* Metrics, Logs, Traces and Profiles in Grafana: <https://github.com/grafana/intro-to-mltp>
28 changes: 28 additions & 0 deletions build-lgtm.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@echo off

SET release_tag=latest
if not "%~1"=="" (
SET release_tag=%1
)

WHERE /Q podman
if not ERRORLEVEL 1 (
goto use_podman
)

WHERE /Q docker
if not ERRORLEVEL 1 (
goto use_docker
)

:no_executable_found
echo Please install Podman or docker
goto:EOF

:use_podman
podman buildx build -f docker/Dockerfile docker --tag grafana/otel-lgtm:%release_tag%
goto:EOF

:use_docker
docker buildx build -f docker/Dockerfile docker --tag grafana/otel-lgtm:%release_tag%
goto:EOF
2 changes: 1 addition & 1 deletion build-lgtm.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

RELEASE=${1:-dev}
RELEASE=${1:-latest}

docker buildx build -f docker/Dockerfile docker --tag grafana/otel-lgtm:${RELEASE}
16 changes: 16 additions & 0 deletions examples/java/run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@REM @echo off

if not exist ./target/rolldice.jar (
mvnw clean package
)

set version=v2.1.0
set jar=opentelemetry-javaagent-%version%.jar
if not exist ./%jar% (
curl -sL https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/%version%/opentelemetry-javaagent.jar -o %jar%
)

set OTEL_RESOURCE_ATTRIBUTES=service.name=rolldice,service.instance.id=localhost:8080
@REM uncomment the next line to switch to Prometheus native histograms.
@REM set OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION=base2_exponential_bucket_histogram
java -Dotel.metric.export.interval=500 -Dotel.bsp.schedule.delay=500 -javaagent:%jar% -jar ./target/rolldice.jar
9 changes: 9 additions & 0 deletions generate-traffic.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@ECHO OFF
:loop
cls
curl -s http://localhost:8080/rolldice
curl -s http://localhost:8081/rolldice
curl -s http://localhost:8082/rolldice
curl -s http://localhost:8083/rolldice
timeout /t 2
goto loop
4 changes: 4 additions & 0 deletions run-example.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off

cd examples/java
run
54 changes: 54 additions & 0 deletions run-lgtm.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
@echo off

SET release_tag=latest
if not "%~1"=="" (
SET release_tag=%1
)

mkdir "container/grafana"
mkdir "container/prometheus"
mkdir "container/loki"

WHERE /Q podman
if not ERRORLEVEL 1 (
goto use_podman
)

WHERE /Q docker
if not ERRORLEVEL 1 (
goto use_docker
)

:no_executable_found
echo Please install Podman or docker
goto:EOF

:use_podman
podman run ^
--name lgtm ^
-p 3000:3000 ^
-p 4317:4317 ^
-p 4318:4318 ^
--rm ^
-ti ^
-v ./container/grafana:/data/grafana ^
-v ./container/prometheus:/data/prometheus ^
-v ./container/loki:/loki ^
-e GF_PATHS_DATA=/data/grafana ^
docker.io/grafana/otel-lgtm:%release_tag%
goto:EOF

:use_docker
docker run ^
--name lgtm ^
-p 3000:3000 ^
-p 4317:4317 ^
-p 4318:4318 ^
--rm ^
-ti ^
-v ./container/grafana:/data/grafana ^
-v ./container/prometheus:/data/prometheus ^
-v ./container/loki:/loki ^
-e GF_PATHS_DATA=/data/grafana ^
docker.io/grafana/otel-lgtm:%release_tag%
goto:EOF
2 changes: 1 addition & 1 deletion run-lgtm.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

RELEASE=${1:-dev}
RELEASE=${1:-latest}

docker run \
--name lgtm \
Expand Down

0 comments on commit 1716214

Please sign in to comment.