Skip to content

Commit

Permalink
Add prometheus mode to obsagent-client test module (Azure#5147)
Browse files Browse the repository at this point in the history
The main change in this PR is the addition of a new Prometheus mode in the obsagent-client module. In this mode, the client hosts a prometheus endpoint from which 3 example metrics (a counter, guage, and histogram) can be pulled periodically.  The endpoint is configurable via the PROMETHEUS_ENDPOINT env variable.

Other changes:
1. Move OTel mode code into otel_client module
2. Move config code into a config module
3. Create new prometheus_server module
4. Add Cargo feature flags for the two modes (prom and otel)
5. Upgrade from opentelemetry-0.13 and optentelemetry-otlp-0.6 to opentelemetry-0.15 and opentelemetry-otlp-0.8
  • Loading branch information
nlcamp authored Jun 30, 2021
1 parent 323bdc9 commit e4945b4
Show file tree
Hide file tree
Showing 10 changed files with 593 additions and 206 deletions.
18 changes: 14 additions & 4 deletions builds/checkin/rust-test-modules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,19 @@ jobs:
- bash: scripts/linux/generic-rust/clippy.sh --project-root "test/modules/generic-mqtt-tester"
displayName: Clippy (Generic MQTT Tester)

- bash: scripts/linux/generic-rust/build.sh --project-root "test/modules/obsagent-client" --packages "Cargo.toml" --manifest-path
displayName: Build Observability-Agent Client Module
- bash: >
scripts/linux/generic-rust/build.sh --project-root "test/modules/obsagent-client"
--packages "Cargo.toml" --manifest-path --no-default-features --features prom
displayName: Build ObsAgent Client Module (Prometheus mode)
- bash: >
scripts/linux/generic-rust/build.sh --project-root "test/modules/obsagent-client"
--packages "Cargo.toml" --manifest-path --no-default-features --features otel
displayName: Build ObsAgent Client Module (OpenTelemetry mode)
- bash: >
scripts/linux/generic-rust/build.sh --project-root "test/modules/obsagent-client"
--packages "Cargo.toml" --manifest-path --no-default-features --features "prom otel"
displayName: Build ObsAgent Client Module (Prom & OTel)
- bash: scripts/linux/generic-rust/format.sh --project-root "test/modules/obsagent-client"
displayName: Format Code (Observability-Agent Client)
displayName: Format Code (ObsAgent Client)
- bash: scripts/linux/generic-rust/clippy.sh --project-root "test/modules/obsagent-client"
displayName: Clippy (Observability-Agent Client)
displayName: Clippy (ObsAgent Client)
2 changes: 1 addition & 1 deletion builds/misc/images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ jobs:
- template: templates/rust-test-module-images.yaml
parameters:
module.path: 'test/modules/obsagent-client'
module.name: 'obsagent-client'
module.name: 'obsagent-client'

################################################################################
- job: manifest
Expand Down
12 changes: 9 additions & 3 deletions builds/misc/templates/rust-test-module-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ steps:
displayName: Build observability-agent client - amd64
inputs:
filePath: scripts/linux/cross-platform-rust-build.sh
arguments: --os alpine --arch amd64 --build-path test/modules/obsagent-client
arguments: >
--os alpine --arch amd64 --build-path test/modules/obsagent-client
--cargo-flags "--no-default-features --features otel,prom"
- task: Bash@3
displayName: Build observability-agent client - arm32
inputs:
filePath: scripts/linux/cross-platform-rust-build.sh
arguments: --os ubuntu18.04 --arch arm32v7 --build-path test/modules/obsagent-client
arguments: >
--os ubuntu18.04 --arch arm32v7 --build-path test/modules/obsagent-client
--cargo-flags "--no-default-features --features otel,prom"
- task: Bash@3
displayName: Build observability-agent client - arm64
inputs:
filePath: scripts/linux/cross-platform-rust-build.sh
arguments: --os ubuntu18.04 --arch aarch64 --build-path test/modules/obsagent-client
arguments: >
--os ubuntu18.04 --arch aarch64 --build-path test/modules/obsagent-client
--cargo-flags "--no-default-features --features otel,prom"
57 changes: 52 additions & 5 deletions test/modules/obsagent-client/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions test/modules/obsagent-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,24 @@ edition = "2018"
description = "Test module that connects to the IoT Edge Observability Agent for benchmarking and testing purposes."

[dependencies]
anyhow = "1.0"
cfg-if = "1.0"
clap = "2"
futures = "0.3"
lazy_static = "1.4"
opentelemetry = { version = "0.13", features = ["rt-tokio", "metrics", "serialize"] }
opentelemetry-otlp = { version = "0.6", features = ["tonic", "metrics"] }
hyper = { version = "0.14", features = ["http1", "runtime", "server"], optional = true }
opentelemetry = { version = "0.15", features = ["rt-tokio", "metrics", "serialize"], optional = true }
opentelemetry-otlp = { version = "0.8", features = ["tonic", "metrics"], optional = true }
prometheus = { version = "0.12", optional = true }
rand = "0.8"
serde_json = "1.0"
signal-hook = "0.3"
thiserror = "1.0"
tokio = { version = "1.0", features = ["rt-multi-thread", "macros"] }
tracing = "0.1"
tracing-futures = "0.2"
tracing-subscriber = "0.2"
tracing-subscriber = "0.2"

[features]
default = ["prom"]
otel = ["opentelemetry", "opentelemetry-otlp"]
prom = ["hyper", "prometheus"]
Loading

0 comments on commit e4945b4

Please sign in to comment.