diff --git a/.github/renovate-tracked-deps.json b/.github/renovate-tracked-deps.json index 4f3f8c203..2f3a757cc 100644 --- a/.github/renovate-tracked-deps.json +++ b/.github/renovate-tracked-deps.json @@ -158,6 +158,7 @@ "mise": [ "actionlint", "aqua:grafana/flint", + "aqua:grafana/gcx", "aqua:jonwiggins/xmloxide", "aqua:owenlamont/ryl", "biome", diff --git a/examples/example-exporter-opentelemetry/oats-tests/agent/oats-case.yaml b/examples/example-exporter-opentelemetry/oats-tests/agent/oats-case.yaml new file mode 100644 index 000000000..a8a05d0f2 --- /dev/null +++ b/examples/example-exporter-opentelemetry/oats-tests/agent/oats-case.yaml @@ -0,0 +1,20 @@ +name: java agent exporter preserves target_info identity +fixture: + compose: + template: lgtm + file: docker-compose.yml +seed: + type: app +expected: + metrics: + - promql: "uptime_seconds_total{}" + value: ">= 0" + - promql: 'count(target_info{service_name!="otelcol-contrib"})' + value: "== 2" + - promql: 'count(count by (instance) (target_info{service_name!="otelcol-contrib"}))' + value: "== 1" + custom-checks: + - script: | + #!/usr/bin/env bash + set -euo pipefail + curl -fsS "${OATS_GRAFANA_URL:?}/api/health" >/dev/null diff --git a/examples/example-exporter-opentelemetry/oats-tests/agent/oats.yaml b/examples/example-exporter-opentelemetry/oats-tests/agent/oats.yaml deleted file mode 100644 index 899d1cd5d..000000000 --- a/examples/example-exporter-opentelemetry/oats-tests/agent/oats.yaml +++ /dev/null @@ -1,12 +0,0 @@ -# OATS is an acceptance testing framework for OpenTelemetry - -# https://github.com/grafana/oats/tree/main/yaml -oats-schema-version: 2 -docker-compose: - files: - - ./docker-compose.yml -expected: - custom-checks: - - script: ./service_instance_id_check.py - metrics: - - promql: "uptime_seconds_total{}" - value: ">= 0" diff --git a/examples/example-exporter-opentelemetry/oats-tests/agent/service_instance_id_check.py b/examples/example-exporter-opentelemetry/oats-tests/agent/service_instance_id_check.py deleted file mode 100755 index 35ff88b8d..000000000 --- a/examples/example-exporter-opentelemetry/oats-tests/agent/service_instance_id_check.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python3 -""" -Check if the service instance id is present in the exported data. -Returns 0 if the service instance id is present in the exported data. -""" - -import json -import urllib.parse -from urllib.request import urlopen - - -def get_json(url): - with urlopen(url) as response: - return json.loads(response.read().decode("utf-8")) - - -def main(): - # Query Prometheus for target_info - res = get_json("http://localhost:9090/api/v1/query?query=target_info") - - # Uncomment for local debugging - # with open('example_target_info.json') as f: - # res = json.load(f) - - instance_ids = { - r["metric"]["instance"] - for r in res["data"]["result"] - if r["metric"].get("service_name") != "otelcol-contrib" - } - instance_ids = list(instance_ids) - - print(f"Instance ids found:{instance_ids}") - if len(instance_ids) > 1: - print("More than one instance id found") - print(res) - - # Both the agent and the exporter should report the same instance id - assert len(instance_ids) == 1, "Expected exactly one instance id" - - query = f'target_info{{instance="{instance_ids[0]}"}}' - encoded_query = urllib.parse.quote_plus(query) - res = get_json(f"http://localhost:9090/api/v1/query?query={encoded_query}") - - infos = res["data"]["result"] - print(infos) - - # They should not have the same target info (e.g. only the agent has telemetry_distro_name) - assert len(infos) == 2, "Expected two target info results" - - -if __name__ == "__main__": - main() diff --git a/examples/example-exporter-opentelemetry/oats-tests/http/oats-case.yaml b/examples/example-exporter-opentelemetry/oats-tests/http/oats-case.yaml new file mode 100644 index 000000000..fab99dfe3 --- /dev/null +++ b/examples/example-exporter-opentelemetry/oats-tests/http/oats-case.yaml @@ -0,0 +1,11 @@ +name: http protobuf exporter emits uptime metric +fixture: + compose: + template: lgtm + file: docker-compose.yml +seed: + type: app +expected: + metrics: + - promql: "uptime_seconds_total{}" + value: ">= 0" diff --git a/examples/example-exporter-opentelemetry/oats-tests/http/oats.yaml b/examples/example-exporter-opentelemetry/oats-tests/http/oats.yaml deleted file mode 100644 index dbcfcf84f..000000000 --- a/examples/example-exporter-opentelemetry/oats-tests/http/oats.yaml +++ /dev/null @@ -1,10 +0,0 @@ -# OATS is an acceptance testing framework for OpenTelemetry - -# https://github.com/grafana/oats/tree/main/yaml -oats-schema-version: 2 -docker-compose: - files: - - ./docker-compose.yml -expected: - metrics: - - promql: "uptime_seconds_total{}" - value: ">= 0" diff --git a/mise.lock b/mise.lock index 89d88d894..785003cb9 100644 --- a/mise.lock +++ b/mise.lock @@ -86,6 +86,45 @@ url = "https://github.com/grafana/flint/releases/download/v0.22.7/flint-x86_64-p url_api = "https://api.github.com/repos/grafana/flint/releases/assets/469229804" provenance = "github-attestations" +[[tools."aqua:grafana/gcx"]] +version = "v0.5.0" +backend = "aqua:grafana/gcx" + +[tools."aqua:grafana/gcx"."platforms.linux-arm64"] +checksum = "sha256:07811e994101abf3fe51b7d9d5bbcc045830382ece80f37af29d32234cbe4731" +url = "https://github.com/grafana/gcx/releases/download/v0.5.0/gcx_0.5.0_linux_arm64.tar.gz" +url_api = "https://api.github.com/repos/grafana/gcx/releases/assets/484583603" + +[tools."aqua:grafana/gcx"."platforms.linux-arm64-musl"] +checksum = "sha256:07811e994101abf3fe51b7d9d5bbcc045830382ece80f37af29d32234cbe4731" +url = "https://github.com/grafana/gcx/releases/download/v0.5.0/gcx_0.5.0_linux_arm64.tar.gz" +url_api = "https://api.github.com/repos/grafana/gcx/releases/assets/484583603" + +[tools."aqua:grafana/gcx"."platforms.linux-x64"] +checksum = "sha256:5c0ce026b0625da09ee976115799cba28e6c84375f802c64f7995c0ba87a83b6" +url = "https://github.com/grafana/gcx/releases/download/v0.5.0/gcx_0.5.0_linux_amd64.tar.gz" +url_api = "https://api.github.com/repos/grafana/gcx/releases/assets/484583622" + +[tools."aqua:grafana/gcx"."platforms.linux-x64-musl"] +checksum = "sha256:5c0ce026b0625da09ee976115799cba28e6c84375f802c64f7995c0ba87a83b6" +url = "https://github.com/grafana/gcx/releases/download/v0.5.0/gcx_0.5.0_linux_amd64.tar.gz" +url_api = "https://api.github.com/repos/grafana/gcx/releases/assets/484583622" + +[tools."aqua:grafana/gcx"."platforms.macos-arm64"] +checksum = "sha256:3835b426490dddbf0cd3cd4a96566ebb2b2a45121c3d61c518e8c3ae54d1ac0c" +url = "https://github.com/grafana/gcx/releases/download/v0.5.0/gcx_0.5.0_darwin_arm64.tar.gz" +url_api = "https://api.github.com/repos/grafana/gcx/releases/assets/484583602" + +[tools."aqua:grafana/gcx"."platforms.macos-x64"] +checksum = "sha256:40db287702572bc9e7c5decdd25cd054e8b076008b8f3d543eafa721441da4db" +url = "https://github.com/grafana/gcx/releases/download/v0.5.0/gcx_0.5.0_darwin_amd64.tar.gz" +url_api = "https://api.github.com/repos/grafana/gcx/releases/assets/484583604" + +[tools."aqua:grafana/gcx"."platforms.windows-x64"] +checksum = "sha256:e71bdc867b6d13399d4aad15a667c7bc5c6fbf37a187cb87dafeb61113c48921" +url = "https://github.com/grafana/gcx/releases/download/v0.5.0/gcx_0.5.0_windows_amd64.zip" +url_api = "https://api.github.com/repos/grafana/gcx/releases/assets/484583601" + [[tools."aqua:jonwiggins/xmloxide"]] version = "v0.4.3" backend = "aqua:jonwiggins/xmloxide" @@ -251,7 +290,7 @@ url = "https://github.com/editorconfig-checker/editorconfig-checker/releases/dow url_api = "https://api.github.com/repos/editorconfig-checker/editorconfig-checker/releases/assets/460248513" [[tools."go:github.com/grafana/oats"]] -version = "0.7.0" +version = "0.7.1-0.20260722144929-3d12ca623d63" backend = "go:github.com/grafana/oats" [[tools.google-java-format]] diff --git a/mise.toml b/mise.toml index 93e9a3634..824a4ec3f 100644 --- a/mise.toml +++ b/mise.toml @@ -1,5 +1,6 @@ [tools] -"go:github.com/grafana/oats" = "0.7.0" +"aqua:grafana/gcx" = "v0.5.0" +"go:github.com/grafana/oats" = { version = "v0.7.1-0.20260722144929-3d12ca623d63", install_env = { GOPROXY = "direct", GONOSUMDB = "github.com/grafana/oats" } } hugo = "0.164.0" java = "temurin-25.0.3+9.0.LTS" node = "24.18.0" @@ -93,7 +94,12 @@ run = "flint run --fix" [tasks.acceptance-test] description = "Run OATs acceptance tests" depends = "build" -run = "oats -lgtm-version $LGTM_VERSION -timeout 5m examples/" +run = """ +oats \ + --config oats-config.yaml \ + --no-cache \ + --timeout=5m +""" [tasks.javadoc] description = "Generate Javadoc" diff --git a/oats-config.yaml b/oats-config.yaml new file mode 100644 index 000000000..d23490ffb --- /dev/null +++ b/oats-config.yaml @@ -0,0 +1,6 @@ +meta: + version: 3 + +cases: + - examples/example-exporter-opentelemetry/oats-tests/http/oats-case.yaml + - examples/example-exporter-opentelemetry/oats-tests/agent/oats-case.yaml