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

remove examples, because the upstream spring starter has great spring coverage now #822

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
37 changes: 0 additions & 37 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,6 @@
matchPackageNames: [ "nodejs"],
enabled: false
},
{
// keep spring 2 examples
"matchFileNames": [
"examples/**/build.gradle",
],
"matchPackagePrefixes": [
"org.springframework.boot:",
"io.spring.dependency-management",
"redis.clients:"
// spring 2 examples can't use the next major version
],
"matchUpdateTypes": [
"major"
],
"enabled": false
},
{
"matchFileNames": [
"examples/**/build.gradle",
],
"labels": [
"oats"
],
"groupName": "examples"
}
],
"vulnerabilityAlerts": {
"enabled": true,
Expand Down Expand Up @@ -105,17 +80,5 @@
"# renovate: datasource=(?<datasource>[a-z-]+?)(?: depName=(?<depName>.+?))? packageName=(?<packageName>.+?)(?: versioning=(?<versioning>[a-z-]+?))?\\s(?:ENV|ARG) .+?_VERSION=(?<currentValue>.+?)\\s"
]
},
{
"customType": "regex",
"description": "Update release in run-example.sh",
"depNameTemplate": "grafana/grafana-opentelemetry-java",
"datasourceTemplate": "github-releases",
"fileMatch": [
"^examples/run-example.sh$",
],
"matchStrings": [
"RELEASE=(?<currentValue>[^\\s]+)"
]
}
]
}
15 changes: 0 additions & 15 deletions .github/workflows/acceptance-tests.yml

This file was deleted.

43 changes: 0 additions & 43 deletions .github/workflows/reusable-acceptance-tests.yml

This file was deleted.

50 changes: 1 addition & 49 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ javaagent.jar as well as our custom extension.
- Markdown link checker: `find . -name '*.md' -print0 | xargs -0 -n1 markdown-link-check -c .markdown-link-check.json`
(requires [markdown-link-check](https://github.com/tcort/markdown-link-check))

## Debugging

If one of the test applications in the "examples" directory fails to produce the right telemetry
(usually detected by the oats test), you can run the application with the javaagent attached to it
by adding the following command line arguments:

```sh
./run.sh --attachDebugger --debugLogging --debugInstrumentations --includeAllInstrumentations
```

## Smoke Tests

Smoke tests test the entire javaagent distribution, including the custom extension. To run the smoke tests,
Expand All @@ -42,39 +32,14 @@ run the following command:
SMOKE_TEST_JAVA_VERSION=8 ./gradlew :smoke-tests:test
```

## Acceptance Tests

Unlike smoke tests, acceptance tests are only run if the pull request has the "oats" label.

Acceptance test cases are defined in `oats.yaml` files in the examples directory. The test cases are run by [oats].
The declarative yaml tests are described in <https://github.com/grafana/oats/blob/main/yaml>.

If a test case fails (lets say "examples/jdbc/spring-boot-reactive-2"), follows these steps:

1. Check out the [oats] repo
2. Go to the oats folder
3. `cd yaml`
4. Install ginkgo: `go install github.com/onsi/ginkgo/v2/ginkgo`
5. `TESTCASE_TIMEOUT=2h TESTCASE_BASE_PATH=/path/to/this/repo/examples ginkgo -v -r -focus 'jdbc-spring-boot-reactive-2'`
6. go to <http://localhost:3000> and login with admin/admin

Use `-focus 'yaml'` to run all acceptance tests.

Also see [Java specific options](https://github.com/grafana/oats/blob/main/yaml/README.md#java-specific-options)
for additional options.

### Common problems

First, check the [java specific oats options](https://github.com/grafana/oats/tree/main/yaml#java-specific-options),
which can be used for debugging.

#### Instrumentation not included

Check if the test passes with `TESTCASE_INCLUDE_ALL_INSTRUMENTATIONS=true`.

If yes, check what the instrumentation scope is, and include this instrumentation in the list of
[tested instrumentations](./README.md#tested-instrumentations). You should also include a test case
for this instrumentation, similar to the other tests in the examples directory.
[tested instrumentations](https://github.com/grafana/grafana-opentelemetry-java/blob/main/custom/src/main/java/com/grafana/extensions/instrumentations/Instrumentations.java).

Where you can find the instrumentation scope:

Expand All @@ -85,20 +50,7 @@ Where you can find the instrumentation scope:

See [RELEASING](RELEASING.md).

## Debugging GitHub Actions

GitHub Actions for Acceptance test store the output log files - which can be found in the artifacts section of the
GitHub Actions run.

- If you need more files, you can change the `path` for `actions/upload-artifact@v3` in acceptance-tests.yml.
- If you want to run a single test only, you can change the ginkgo command in run-acceptance-tests.sh to
e.g. `ginkgo -v -r -focus 'redis-spring-boot-reactive-2'`.

![oats acceptance tests](./docs/oats-logs.png)

## Known Issues

The tests occasionally fail due to TestContainers not starting in time. Please rerun the build for now, until a new
wait strategy can be determined.

[oats]: https://github.com/grafana/oats
68 changes: 0 additions & 68 deletions custom/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,73 +56,5 @@ public class DistributionVersion {
}
}

//private String[] readmeLines() {
// // scrape the table from https://grafana.com/docs/grafana-cloud/monitor-applications/application-observability/setup/instrument/java/ once published
//// return new File("${projectDir}/../README.md").text.split("\n")
//}
//
//task manageTestedInstrumentationsClass() {
// doLast {
// def instrumentations = readmeLines()
// .dropWhile { !it.startsWith("| ID") }
// .takeWhile { it.startsWith("|") }
// .drop(2)
// .collect { " \"${it.split("\\|")[1].trim()}\"" }
// .join(",\n")
//
// updateGeneratedFile(new File("${projectDir}/src/main/java/com/grafana/extensions/instrumentations", "Instrumentations.java"), """/*
// * Copyright Grafana Labs
// * SPDX-License-Identifier: Apache-2.0
// */
//
//package com.grafana.extensions.instrumentations;
//
//// This class is generated from README.md in custom/build.gradle. Do not edit.
//
//import java.util.Arrays;
//import java.util.List;
//
//public class Instrumentations {
//
// public static final List<String> TESTED_INSTRUMENTATIONS =
// Arrays.asList(
//$instrumentations);
//}
//""")
// }
//}
//
//task manageDefaultMetricsClass() {
// doLast {
// def metrics = readmeLines()
// .dropWhile { !it.startsWith("| Metric") }
// .takeWhile { it.startsWith("|") }
// .drop(2)
// .collect { " \"${it.split("\\|")[1].trim()}\"" }
// .join(",\n")
//
// updateGeneratedFile(new File("${projectDir}/src/main/java/com/grafana/extensions/filter", "DefaultMetrics.java"), """/*
// * Copyright Grafana Labs
// * SPDX-License-Identifier: Apache-2.0
// */
//
//package com.grafana.extensions.filter;
//
//// This class is generated from README.md in custom/build.gradle. Do not edit.
//
//import java.util.Arrays;
//import java.util.List;
//
//public class DefaultMetrics {
//
// public static final List<String> DEFAULT_METRICS =
// Arrays.asList(
//$metrics);
//}
//""")
// }
//}

//compileJava.dependsOn(manageVersionClass, manageTestedInstrumentationsClass, manageDefaultMetricsClass)
compileJava.dependsOn(manageVersionClass)

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

package com.grafana.extensions.instrumentations;

// This class is generated from README.md in custom/build.gradle. Do not edit.

import java.util.Arrays;
import java.util.List;

Expand Down
Loading