diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 4c6f1afb..aac6478f 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -67,6 +67,8 @@ jobs: aws s3 cp custom/shared/src/main/resources/solarwinds-apm-config.json \ s3://$STAGE_BUCKET/apm/java/$AGENT_VERSION/solarwinds-apm-config.json \ --acl public-read + env: + AGENT_VERSION: ${{ steps.set_version.outputs.version }} - name: Copy to S3(latest) run: | @@ -172,12 +174,34 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Free Disk Space before Build + run: | + echo "Disk space before pre-build cleanup:" + df -h + sudo rm -rf /usr/local/.ghcup + sudo rm -rf /opt/hostedtoolcache/CodeQL + sudo rm -rf /usr/local/lib/android/sdk/ndk + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf /usr/local/share/boost + echo "Disk space after pre-build cleanup:" + df -h + - name: Set up JDK 17 uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' + - name: Set agent version + id: set_version + uses: ./.github/actions/version + + - name: Set snapshot version + run: | + GIT_HASH=$(git rev-parse --short "$GITHUB_SHA") + echo "AGENT_VERSION=${{ steps.set_version.outputs.version }}.$GIT_HASH" >> $GITHUB_ENV + - name: Build smoke-test run: | cd smoke-tests @@ -186,12 +210,6 @@ jobs: - name: Docker login run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_USERNAME --password-stdin - - name: Set agent version env - run: | - ./gradlew build -x test - GIT_HASH=$(git rev-parse --short "$GITHUB_SHA") - echo "AGENT_VERSION=$(cd agent/build/libs && unzip -p solarwinds-apm-agent.jar META-INF/MANIFEST.MF | grep Implementation-Version | awk '{ print $2 }' | sed 's/[^a-z0-9.-]//g').$GIT_HASH" >> $GITHUB_ENV - - name: Execute smoke tests run: | cd smoke-tests @@ -203,6 +221,20 @@ jobs: path: smoke-tests/build/reports/tests/test name: lambda-release-test + - name: Free Disk Space After Build + run: | + echo "Disk space before post-build cleanup:" + df -h + sudo rm -rf /usr/local/.ghcup + sudo rm -rf /opt/hostedtoolcache/CodeQL + sudo rm -rf /usr/local/lib/android/sdk/ndk + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf /usr/local/share/boost + sudo rm -rf smoke-tests/build/ + echo "Disk space after post-build cleanup:" + df -h + - name: Docker logout if: always() run: docker logout @@ -381,6 +413,16 @@ jobs: java-version: '17' distribution: 'temurin' + - name: Set agent version + id: set_version + uses: ./.github/actions/version + + - name: Set snapshot version + shell: bash + run: | + GIT_HASH=$(git rev-parse --short "$GITHUB_SHA") + echo "AGENT_VERSION=${{ steps.set_version.outputs.version }}.$GIT_HASH" >> $GITHUB_ENV + - name: Run application working-directory: smoke-tests run: | @@ -397,6 +439,19 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Free Disk Space before Build + run: | + echo "Disk space before pre-build cleanup:" + df -h + sudo rm -rf /usr/local/.ghcup + sudo rm -rf /opt/hostedtoolcache/CodeQL + sudo rm -rf /usr/local/lib/android/sdk/ndk + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf /usr/local/share/boost + echo "Disk space after pre-build cleanup:" + df -h + - name: Set up JDK 17 uses: actions/setup-java@v4 with: @@ -441,6 +496,20 @@ jobs: path: smoke-tests/build/reports/tests/test name: release-test + - name: Free Disk Space After Build + run: | + echo "Disk space before post-build cleanup:" + df -h + sudo rm -rf /usr/local/.ghcup + sudo rm -rf /opt/hostedtoolcache/CodeQL + sudo rm -rf /usr/local/lib/android/sdk/ndk + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf /usr/local/share/boost + sudo rm -rf smoke-tests/build/ + echo "Disk space after post-build cleanup:" + df -h + - name: Docker logout if: always() run: docker logout diff --git a/build.gradle b/build.gradle index 31f788b1..fd3c9b1d 100644 --- a/build.gradle +++ b/build.gradle @@ -48,7 +48,7 @@ subprojects { opentelemetryJavaagent: "2.8.0", bytebuddy : "1.12.10", guava : "30.1-jre", - joboe : "10.0.11", + joboe : "10.0.12", agent : "2.8.0", // the custom distro agent version autoservice : "1.0.1", caffeine : "2.9.3", diff --git a/custom/src/main/java/com/solarwinds/opentelemetry/extensions/initialize/ConfigurationLoader.java b/custom/src/main/java/com/solarwinds/opentelemetry/extensions/initialize/ConfigurationLoader.java index a3a6e9a5..3c51b7bc 100644 --- a/custom/src/main/java/com/solarwinds/opentelemetry/extensions/initialize/ConfigurationLoader.java +++ b/custom/src/main/java/com/solarwinds/opentelemetry/extensions/initialize/ConfigurationLoader.java @@ -194,7 +194,7 @@ private static void maybeFollowOtelConfigProperties(ConfigContainer configs) { } } - static void configOtelLogExport(ConfigContainer container) { + static void configureOtelLogExport(ConfigContainer container) { Boolean exportLog = (Boolean) container.get(ConfigProperty.AGENT_EXPORT_LOGS_ENABLED); if (exportLog != null && exportLog) { String serviceKey = (String) container.get(ConfigProperty.AGENT_SERVICE_KEY); @@ -221,7 +221,7 @@ static void configOtelLogExport(ConfigContainer container) { } } - System.setProperty("otel.exporter.otlp.protocol", "grpc"); + System.setProperty("otel.exporter.otlp.logs.protocol", "grpc"); System.setProperty("otel.logs.exporter", "otlp"); System.setProperty( "otel.exporter.otlp.logs.headers", String.format("authorization=Bearer %s", apiKey)); @@ -232,6 +232,44 @@ static void configOtelLogExport(ConfigContainer container) { } } + static void configureOtelMetricExport(ConfigContainer container) { + Boolean exportMetrics = (Boolean) container.get(ConfigProperty.AGENT_EXPORT_METRICS_ENABLED); + if (exportMetrics != null && exportMetrics) { + String serviceKey = (String) container.get(ConfigProperty.AGENT_SERVICE_KEY); + String apiKey = ServiceKeyUtils.getApiKey(serviceKey); + + String dataCell = "na-01"; + String env = "cloud"; + String collectorEndpoint = (String) container.get(ConfigProperty.AGENT_COLLECTOR); + + if (collectorEndpoint != null) { + if (collectorEndpoint.contains("appoptics.com")) { + return; + } + collectorEndpoint = collectorEndpoint.split(":")[0]; + String[] fragments = collectorEndpoint.split("\\."); + if (fragments.length > 2) { + // This is based on knowledge of the SWO url format where the third name from the left in + // the domain is the data-cell name and assumes this format will stay stable. + dataCell = fragments[2]; + } + + if (fragments.length > 3) { + env = fragments[3]; + } + } + + System.setProperty("otel.exporter.otlp.metrics.protocol", "grpc"); + System.setProperty("otel.metrics.exporter", "otlp"); + System.setProperty( + "otel.exporter.otlp.metrics.headers", String.format("authorization=Bearer %s", apiKey)); + + System.setProperty( + "otel.exporter.otlp.metrics.endpoint", + String.format("https://otel.collector.%s.%s.solarwinds.com", dataCell, env)); + } + } + static Map mergeEnvWithSysProperties(Map env, Properties props) { Map res = new HashMap<>(env); @@ -283,7 +321,8 @@ private static void loadConfigurations() throws InvalidConfigException { config)); // initialize the logger factory as soon as the config is available try { processConfigs(configs); - configOtelLogExport(configs); + configureOtelLogExport(configs); + configureOtelMetricExport(configs); } catch (InvalidConfigException e) { // if there was a config read exception then processConfigs might throw exception due to // incomplete config container. diff --git a/custom/src/test/java/com/solarwinds/opentelemetry/extensions/initialize/ConfigurationLoaderTest.java b/custom/src/test/java/com/solarwinds/opentelemetry/extensions/initialize/ConfigurationLoaderTest.java index c6bd723f..723fba15 100644 --- a/custom/src/test/java/com/solarwinds/opentelemetry/extensions/initialize/ConfigurationLoaderTest.java +++ b/custom/src/test/java/com/solarwinds/opentelemetry/extensions/initialize/ConfigurationLoaderTest.java @@ -164,10 +164,10 @@ void verifySettingOtelLogExportSystemVariablesWhenEnabled() throws InvalidConfig ConfigProperty.AGENT_COLLECTOR, "apm.collector.na-02.cloud.solarwinds.com"); configContainer.putByStringValue(ConfigProperty.AGENT_EXPORT_LOGS_ENABLED, "true"); - ConfigurationLoader.configOtelLogExport(configContainer); + ConfigurationLoader.configureOtelLogExport(configContainer); assertEquals("otlp", System.getProperty("otel.logs.exporter")); - assertEquals("grpc", System.getProperty("otel.exporter.otlp.protocol")); + assertEquals("grpc", System.getProperty("otel.exporter.otlp.logs.protocol")); assertEquals( "https://otel.collector.na-02.cloud.solarwinds.com", @@ -178,7 +178,7 @@ void verifySettingOtelLogExportSystemVariablesWhenEnabled() throws InvalidConfig @Test @ClearSystemProperty(key = "otel.logs.exporter") - @ClearSystemProperty(key = "otel.exporter.otlp.protocol") + @ClearSystemProperty(key = "otel.exporter.otlp.logs.protocol") @ClearSystemProperty(key = "otel.exporter.otlp.logs.headers") @ClearSystemProperty(key = "otel.exporter.otlp.logs.endpoint") void verifyOtelLogExportSystemVariablesAreNotSetWhenNotEnabled() throws InvalidConfigException { @@ -187,10 +187,10 @@ void verifyOtelLogExportSystemVariablesAreNotSetWhenNotEnabled() throws InvalidC configContainer.putByStringValue( ConfigProperty.AGENT_COLLECTOR, "apm.collector.na-02.cloud.solarwinds.com"); - ConfigurationLoader.configOtelLogExport(configContainer); + ConfigurationLoader.configureOtelLogExport(configContainer); assertNull(System.getProperty("otel.logs.exporter")); - assertNull(System.getProperty("otel.exporter.otlp.protocol")); + assertNull(System.getProperty("otel.exporter.otlp.logs.protocol")); assertNull(System.getProperty("otel.exporter.otlp.logs.endpoint")); assertNull(System.getProperty("otel.exporter.otlp.logs.headers")); @@ -198,7 +198,7 @@ void verifyOtelLogExportSystemVariablesAreNotSetWhenNotEnabled() throws InvalidC @Test @ClearSystemProperty(key = "otel.logs.exporter") - @ClearSystemProperty(key = "otel.exporter.otlp.protocol") + @ClearSystemProperty(key = "otel.exporter.otlp.logs.protocol") @ClearSystemProperty(key = "otel.exporter.otlp.logs.headers") @ClearSystemProperty(key = "otel.exporter.otlp.logs.endpoint") void verifyOtelLogExportEndpointIsProperlyFormed() throws InvalidConfigException { @@ -208,7 +208,7 @@ void verifyOtelLogExportEndpointIsProperlyFormed() throws InvalidConfigException ConfigProperty.AGENT_COLLECTOR, "apm.collector.na-02.staging.solarwinds.com"); configContainer.putByStringValue(ConfigProperty.AGENT_EXPORT_LOGS_ENABLED, "true"); - ConfigurationLoader.configOtelLogExport(configContainer); + ConfigurationLoader.configureOtelLogExport(configContainer); assertEquals( "https://otel.collector.na-02.staging.solarwinds.com", @@ -217,7 +217,7 @@ void verifyOtelLogExportEndpointIsProperlyFormed() throws InvalidConfigException @Test @ClearSystemProperty(key = "otel.logs.exporter") - @ClearSystemProperty(key = "otel.exporter.otlp.protocol") + @ClearSystemProperty(key = "otel.exporter.otlp.logs.protocol") @ClearSystemProperty(key = "otel.exporter.otlp.logs.headers") @ClearSystemProperty(key = "otel.exporter.otlp.logs.endpoint") void verifyOtelLogExportEndpointIsProperlyFormedWithPort() throws InvalidConfigException { @@ -227,7 +227,7 @@ void verifyOtelLogExportEndpointIsProperlyFormedWithPort() throws InvalidConfigE ConfigProperty.AGENT_COLLECTOR, "otel.collector.na-01.cloud.solarwinds.com:443"); configContainer.putByStringValue(ConfigProperty.AGENT_EXPORT_LOGS_ENABLED, "true"); - ConfigurationLoader.configOtelLogExport(configContainer); + ConfigurationLoader.configureOtelLogExport(configContainer); assertEquals( "https://otel.collector.na-01.cloud.solarwinds.com", @@ -236,7 +236,7 @@ void verifyOtelLogExportEndpointIsProperlyFormedWithPort() throws InvalidConfigE @Test @ClearSystemProperty(key = "otel.logs.exporter") - @ClearSystemProperty(key = "otel.exporter.otlp.protocol") + @ClearSystemProperty(key = "otel.exporter.otlp.logs.protocol") @ClearSystemProperty(key = "otel.exporter.otlp.logs.headers") @ClearSystemProperty(key = "otel.exporter.otlp.logs.endpoint") void verifyOtelLogExportEndpointIsNullForAO() throws InvalidConfigException { @@ -245,14 +245,14 @@ void verifyOtelLogExportEndpointIsNullForAO() throws InvalidConfigException { configContainer.putByStringValue(ConfigProperty.AGENT_COLLECTOR, "collector.appoptics.com:443"); configContainer.putByStringValue(ConfigProperty.AGENT_EXPORT_LOGS_ENABLED, "true"); - ConfigurationLoader.configOtelLogExport(configContainer); + ConfigurationLoader.configureOtelLogExport(configContainer); assertNull(System.getProperty("otel.exporter.otlp.logs.endpoint")); } @Test @ClearSystemProperty(key = "otel.logs.exporter") - @ClearSystemProperty(key = "otel.exporter.otlp.protocol") + @ClearSystemProperty(key = "otel.exporter.otlp.logs.protocol") @ClearSystemProperty(key = "otel.exporter.otlp.logs.headers") @ClearSystemProperty(key = "otel.exporter.otlp.logs.endpoint") void verifyDefaultEndpointIsUsed() throws InvalidConfigException { @@ -260,10 +260,126 @@ void verifyDefaultEndpointIsUsed() throws InvalidConfigException { configContainer.putByStringValue(ConfigProperty.AGENT_SERVICE_KEY, "token:service"); configContainer.putByStringValue(ConfigProperty.AGENT_EXPORT_LOGS_ENABLED, "true"); - ConfigurationLoader.configOtelLogExport(configContainer); + ConfigurationLoader.configureOtelLogExport(configContainer); assertEquals( "https://otel.collector.na-01.cloud.solarwinds.com", System.getProperty("otel.exporter.otlp.logs.endpoint")); } + + @Test + @ClearSystemProperty(key = "otel.metrics.exporter") + @ClearSystemProperty(key = "otel.exporter.otlp.metrics.protocol") + @ClearSystemProperty(key = "otel.exporter.otlp.metrics.headers") + @ClearSystemProperty(key = "otel.exporter.otlp.metrics.endpoint") + void verifySettingOtelMetricExportSystemVariablesWhenEnabled() throws InvalidConfigException { + ConfigContainer configContainer = new ConfigContainer(); + configContainer.putByStringValue(ConfigProperty.AGENT_SERVICE_KEY, "token:service"); + configContainer.putByStringValue( + ConfigProperty.AGENT_COLLECTOR, "apm.collector.na-02.cloud.solarwinds.com"); + + configContainer.putByStringValue(ConfigProperty.AGENT_EXPORT_METRICS_ENABLED, "true"); + ConfigurationLoader.configureOtelMetricExport(configContainer); + + assertEquals("otlp", System.getProperty("otel.metrics.exporter")); + assertEquals("grpc", System.getProperty("otel.exporter.otlp.metrics.protocol")); + + assertEquals( + "https://otel.collector.na-02.cloud.solarwinds.com", + System.getProperty("otel.exporter.otlp.metrics.endpoint")); + assertEquals( + "authorization=Bearer token", System.getProperty("otel.exporter.otlp.metrics.headers")); + } + + @Test + @ClearSystemProperty(key = "otel.metrics.exporter") + @ClearSystemProperty(key = "otel.exporter.otlp.metrics.protocol") + @ClearSystemProperty(key = "otel.exporter.otlp.metrics.headers") + @ClearSystemProperty(key = "otel.exporter.otlp.metrics.endpoint") + void verifyOtelMetricExportSystemVariablesAreNotSetWhenNotEnabled() + throws InvalidConfigException { + ConfigContainer configContainer = new ConfigContainer(); + configContainer.putByStringValue(ConfigProperty.AGENT_SERVICE_KEY, "token:service"); + configContainer.putByStringValue( + ConfigProperty.AGENT_COLLECTOR, "apm.collector.na-02.cloud.solarwinds.com"); + + ConfigurationLoader.configureOtelMetricExport(configContainer); + + assertNull(System.getProperty("otel.metrics.exporter")); + assertNull(System.getProperty("otel.exporter.otlp.metrics.protocol")); + + assertNull(System.getProperty("otel.exporter.otlp.metrics.endpoint")); + assertNull(System.getProperty("otel.exporter.otlp.metrics.headers")); + } + + @Test + @ClearSystemProperty(key = "otel.metrics.exporter") + @ClearSystemProperty(key = "otel.exporter.otlp.metrics.protocol") + @ClearSystemProperty(key = "otel.exporter.otlp.metrics.headers") + @ClearSystemProperty(key = "otel.exporter.otlp.metrics.endpoint") + void verifyOtelMetricExportEndpointIsProperlyFormed() throws InvalidConfigException { + ConfigContainer configContainer = new ConfigContainer(); + configContainer.putByStringValue(ConfigProperty.AGENT_SERVICE_KEY, "token:service"); + configContainer.putByStringValue( + ConfigProperty.AGENT_COLLECTOR, "apm.collector.na-02.staging.solarwinds.com"); + + configContainer.putByStringValue(ConfigProperty.AGENT_EXPORT_METRICS_ENABLED, "true"); + ConfigurationLoader.configureOtelMetricExport(configContainer); + + assertEquals( + "https://otel.collector.na-02.staging.solarwinds.com", + System.getProperty("otel.exporter.otlp.metrics.endpoint")); + } + + @Test + @ClearSystemProperty(key = "otel.metrics.exporter") + @ClearSystemProperty(key = "otel.exporter.otlp.metrics.protocol") + @ClearSystemProperty(key = "otel.exporter.otlp.metrics.headers") + @ClearSystemProperty(key = "otel.exporter.otlp.metrics.endpoint") + void verifyOtelMetricExportEndpointIsProperlyFormedWithPort() throws InvalidConfigException { + ConfigContainer configContainer = new ConfigContainer(); + configContainer.putByStringValue(ConfigProperty.AGENT_SERVICE_KEY, "token:service"); + configContainer.putByStringValue( + ConfigProperty.AGENT_COLLECTOR, "otel.collector.na-01.cloud.solarwinds.com:443"); + + configContainer.putByStringValue(ConfigProperty.AGENT_EXPORT_METRICS_ENABLED, "true"); + ConfigurationLoader.configureOtelMetricExport(configContainer); + + assertEquals( + "https://otel.collector.na-01.cloud.solarwinds.com", + System.getProperty("otel.exporter.otlp.metrics.endpoint")); + } + + @Test + @ClearSystemProperty(key = "otel.metrics.exporter") + @ClearSystemProperty(key = "otel.exporter.otlp.metrics.protocol") + @ClearSystemProperty(key = "otel.exporter.otlp.metrics.headers") + @ClearSystemProperty(key = "otel.exporter.otlp.metrics.endpoint") + void verifyOtelMetricExportEndpointIsNullForAO() throws InvalidConfigException { + ConfigContainer configContainer = new ConfigContainer(); + configContainer.putByStringValue(ConfigProperty.AGENT_SERVICE_KEY, "token:service"); + configContainer.putByStringValue(ConfigProperty.AGENT_COLLECTOR, "collector.appoptics.com:443"); + + configContainer.putByStringValue(ConfigProperty.AGENT_EXPORT_METRICS_ENABLED, "true"); + ConfigurationLoader.configureOtelMetricExport(configContainer); + + assertNull(System.getProperty("otel.exporter.otlp.metrics.endpoint")); + } + + @Test + @ClearSystemProperty(key = "otel.metrics.exporter") + @ClearSystemProperty(key = "otel.exporter.otlp.metrics.protocol") + @ClearSystemProperty(key = "otel.exporter.otlp.metrics.headers") + @ClearSystemProperty(key = "otel.exporter.otlp.metrics.endpoint") + void verifyDefaultEndpointIsUsedForMetric() throws InvalidConfigException { + ConfigContainer configContainer = new ConfigContainer(); + configContainer.putByStringValue(ConfigProperty.AGENT_SERVICE_KEY, "token:service"); + + configContainer.putByStringValue(ConfigProperty.AGENT_EXPORT_METRICS_ENABLED, "true"); + ConfigurationLoader.configureOtelMetricExport(configContainer); + + assertEquals( + "https://otel.collector.na-01.cloud.solarwinds.com", + System.getProperty("otel.exporter.otlp.metrics.endpoint")); + } } diff --git a/libs/config-10.0.11.jar b/libs/config-10.0.12.jar similarity index 62% rename from libs/config-10.0.11.jar rename to libs/config-10.0.12.jar index 8175c7bf..6cfa327c 100644 Binary files a/libs/config-10.0.11.jar and b/libs/config-10.0.12.jar differ diff --git a/libs/core-10.0.11.jar b/libs/core-10.0.12.jar similarity index 95% rename from libs/core-10.0.11.jar rename to libs/core-10.0.12.jar index 9fad2321..55c99910 100644 Binary files a/libs/core-10.0.11.jar and b/libs/core-10.0.12.jar differ diff --git a/libs/logging-10.0.11.jar b/libs/logging-10.0.12.jar similarity index 83% rename from libs/logging-10.0.11.jar rename to libs/logging-10.0.12.jar index 9c55b0b2..89e9084e 100644 Binary files a/libs/logging-10.0.11.jar and b/libs/logging-10.0.12.jar differ diff --git a/libs/metrics-10.0.11.jar b/libs/metrics-10.0.12.jar similarity index 88% rename from libs/metrics-10.0.11.jar rename to libs/metrics-10.0.12.jar index 449eeb6d..0a7531e8 100644 Binary files a/libs/metrics-10.0.11.jar and b/libs/metrics-10.0.12.jar differ diff --git a/libs/sampling-10.0.11.jar b/libs/sampling-10.0.12.jar similarity index 87% rename from libs/sampling-10.0.11.jar rename to libs/sampling-10.0.12.jar index 84c28bc8..58cd7968 100644 Binary files a/libs/sampling-10.0.11.jar and b/libs/sampling-10.0.12.jar differ diff --git a/smoke-tests/k6/basic.js b/smoke-tests/k6/basic.js index 2e63c758..cdbb34dc 100644 --- a/smoke-tests/k6/basic.js +++ b/smoke-tests/k6/basic.js @@ -289,7 +289,7 @@ function verify_that_specialty_path_is_not_sampled() { check(flag, {"verify that transaction is filtered": f => f === "00"}) } -function verify_that_metrics_are_reported(metric, checkFn) { +function verify_that_metrics_are_reported(metric, checkFn, service="lambda-e2e") { let retryCount = Number.parseInt(`${__ENV.SWO_RETRY_COUNT}`) || 1000; for (let i = 0; i < retryCount; i++) { const newOwner = names.randomOwner(); @@ -317,7 +317,7 @@ function verify_that_metrics_are_reported(metric, checkFn) { "fillIfResultEmpty": false }, "filter": null, - "query": "service.name:\"lambda-e2e\"", + "query": `service.name:\"${service}\"`, "groupBy": [ "service.name" ], @@ -334,7 +334,7 @@ function verify_that_metrics_are_reported(metric, checkFn) { "fillIfResultEmpty": false }, "filter": null, - "query": "service.name:\"lambda-e2e\"", + "query": `service.name:\"${service}\"`, "groupBy": [ "service.name" ], @@ -577,6 +577,12 @@ export default function () { silence(verify_transaction_name) } else { + silence(function () { + verify_that_metrics_are_reported("jvm.memory.used", + (measurement) => check(measurement, {"otel-metrics": mrs => mrs.value > 0}), + "java-apm-smoke-test" + ) + }) silence(verify_logs_export) silence(verify_that_specialty_path_is_not_sampled) silence(verify_that_span_data_is_persisted_0) diff --git a/smoke-tests/src/test/java/com/solarwinds/SmokeTest.java b/smoke-tests/src/test/java/com/solarwinds/SmokeTest.java index 4b95f39b..0137ebbe 100644 --- a/smoke-tests/src/test/java/com/solarwinds/SmokeTest.java +++ b/smoke-tests/src/test/java/com/solarwinds/SmokeTest.java @@ -183,7 +183,6 @@ void assertTransactionNaming() throws IOException { assertTrue(passes > 1, "transaction naming is broken"); } - @Test void assertAgentClassesAreNotInstrumented() { Boolean actual = logStreamAnalyzer.getAnswer().get("Transformed (com.solarwinds.ext.*|com.solarwinds.joboe.*)"); @@ -208,7 +207,6 @@ void assertInitMessageIsSent() { assertTrue(actual, "init message wasn't sent"); } - @Test @EnabledIfSystemProperty(named = "test.cloud", matches = "AWS") void assertAgentAwsMetadata() { @@ -241,7 +239,6 @@ void assertThatJDBCInstrumentationIsApplied() { assertTrue(actual, "sw-jdbc instrumentation is not applied"); } - @Test void assertThatLogsAreExported() throws IOException { String resultJson = new String( @@ -251,6 +248,15 @@ void assertThatLogsAreExported() throws IOException { assertTrue(passes > 0, "log export is broken"); } + @Test + void assertThatMetricsAreExported() throws IOException { + String resultJson = new String( + Files.readAllBytes(namingConventions.local.k6Results(Configs.E2E.config.agents().get(0)))); + double passes = ResultsCollector.read(resultJson, + "$.root_group.checks.['otel-metrics'].passes"); + assertTrue(passes > 0, "otel metric export is broken"); + } + @Test void assertThatSdkTracingIsWorking() throws IOException { String resultJson = new String( diff --git a/smoke-tests/src/test/java/com/solarwinds/containers/PetClinicRestContainer.java b/smoke-tests/src/test/java/com/solarwinds/containers/PetClinicRestContainer.java index 09ea97a0..54cb9660 100644 --- a/smoke-tests/src/test/java/com/solarwinds/containers/PetClinicRestContainer.java +++ b/smoke-tests/src/test/java/com/solarwinds/containers/PetClinicRestContainer.java @@ -85,7 +85,6 @@ public GenericContainer build() { String.format("authorization=Bearer %s", System.getenv("SW_APM_SERVICE_KEY"))) .withEnv("OTEL_SERVICE_NAME", "lambda-e2e") .withEnv("SW_APM_TRANSACTION_NAME", "lambda-test-txn") - .withEnv("SW_APM_EXPORT_LOGS_ENABLED", "true") .withStartupTimeout(Duration.ofMinutes(5)) .withCopyFileToContainer( MountableFile.forHostPath(agentPath), @@ -117,6 +116,7 @@ public GenericContainer build() { .withEnv("SW_APM_SQL_TAG_DATABASES", "postgresql") .withEnv("SW_APM_SQL_TAG_PREPARED", "true") .withEnv("SW_APM_EXPORT_LOGS_ENABLED", "true") + .withEnv("SW_APM_EXPORT_METRICS_ENABLED", "true") .withEnv("SW_APM_COLLECTOR", System.getenv("SW_APM_COLLECTOR")) .withEnv("SW_APM_SERVICE_KEY", String.format("%s:java-apm-smoke-test", System.getenv("SW_APM_SERVICE_KEY"))) .withStartupTimeout(Duration.ofMinutes(5))