Skip to content

Commit

Permalink
Merge branch 'develop' into update-from-template-merged
Browse files Browse the repository at this point in the history
  • Loading branch information
xdev-gh-bot committed Jan 27, 2025
2 parents 6b01863 + a60d7fb commit 8c2b3fc
Show file tree
Hide file tree
Showing 19 changed files with 398 additions and 359 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ body:
attributes:
label: "Checklist"
options:
- label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/template-placeholder/releases/latest)"
- label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/thread-origin-agent/releases/latest)"
required: true
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/thread-origin-agent/issues) or [closed](https://github.com/xdev-software/thread-origin-agent/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
required: true
- label: "I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise."
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/enhancement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ body:
attributes:
label: "Checklist"
options:
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/thread-origin-agent/issues) or [closed](https://github.com/xdev-software/thread-origin-agent/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
required: true
- label: "I have taken the time to fill in all the required details. I understand that the feature request will be dismissed otherwise."
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/question.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ body:
attributes:
label: "Checklist"
options:
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/thread-origin-agent/issues) or [closed](https://github.com/xdev-software/thread-origin-agent/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
required: true
- label: "I have taken the time to fill in all the required details. I understand that the question will be dismissed otherwise."
required: true
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/check-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ on:

env:
PRIMARY_MAVEN_MODULE: ${{ github.event.repository.name }}
DEMO_MAVEN_MODULE: ${{ github.event.repository.name }}-demo

jobs:
build:
Expand Down Expand Up @@ -64,11 +63,11 @@ jobs:
exit 1
fi
- name: Upload demo files
- name: Upload files
uses: actions/upload-artifact@v4
with:
name: demo-files-java-${{ matrix.java }}
path: ${{ env.DEMO_MAVEN_MODULE }}/target/${{ env.DEMO_MAVEN_MODULE }}.jar
name: files-java-${{ matrix.java }}
path: ${{ env.PRIMARY_MAVEN_MODULE }}/target/${{ env.PRIMARY_MAVEN_MODULE }}-*.jar
if-no-files-found: error

checkstyle:
Expand Down
40 changes: 15 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,9 @@ jobs:
See [Changelog#v${{ steps.version.outputs.release }}](https://github.com/${{ github.repository }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }}) for more information.
## Installation
Add the following lines to your pom:
```XML
<dependency>
<groupId>software.xdev</groupId>
<artifactId>${{ env.PRIMARY_MAVEN_MODULE }}</artifactId>
<version>${{ steps.version.outputs.release }}</version>
</dependency>
```
publish-maven:
Download the javaagent from the assets section below and [attach it to your java application](https://github.com/xdev-software/thread-origin-agent#usage).
publish-assets:
runs-on: ubuntu-latest
needs: [prepare-release]
timeout-minutes: 60
Expand All @@ -121,25 +114,22 @@ jobs:
git config --global user.name "GitHub Actions"
git pull
- name: Set up JDK Apache Maven Central
- name: Set up JDK
uses: actions/setup-java@v4
with: # running setup-java again overwrites the settings.xml
with:
java-version: '17'
distribution: 'temurin'
server-id: ossrh
server-username: MAVEN_CENTRAL_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
gpg-passphrase: MAVEN_GPG_PASSPHRASE
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}

- name: Publish to Apache Maven Central
run: ../mvnw -B deploy -Possrh -DskipTests
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.S01_OSS_SONATYPE_MAVEN_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.S01_OSS_SONATYPE_MAVEN_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

- name: Build
run: ../mvnw -B clean package
working-directory: ${{ env.PRIMARY_MAVEN_MODULE }}

- name: Upload Assets
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ needs.prepare_release.outputs.upload_url }}
asset_path: ${{ env.PRIMARY_MAVEN_MODULE }}/target/${{ env.PRIMARY_MAVEN_MODULE }}-*.jar

publish-pages:
runs-on: ubuntu-latest
needs: [prepare-release]
Expand Down Expand Up @@ -173,7 +163,7 @@ jobs:

after-release:
runs-on: ubuntu-latest
needs: [publish-maven]
needs: [publish-assets]
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
Expand Down
79 changes: 0 additions & 79 deletions .github/workflows/sonar.yml

This file was deleted.

33 changes: 0 additions & 33 deletions .github/workflows/test-deploy.yml

This file was deleted.

16 changes: 0 additions & 16 deletions .run/Run Demo.run.xml

This file was deleted.

13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 1.1.0
* Add option to log caller threads #11 (@3nol)
* Updated dependencies

# 1.0.1
* Reword and improve logging
* Can now monitor classes that extend from Thread
* ``Thread#join`` is no longer logged by default. Can be enabled using ``-DTOA_LOG_THREAD_JOINS``
* Method instrumentation failures can be displayed using ``-DTOA_DISPLAY_METHOD_INSTRUMENTATION_FAILURES``

# 1.0.0
<i>Initial release</i>
* Migrated from old repository
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ You should have the following things installed:
* Ensure that the JDK/Java-Version is correct


## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/template-placeholder/release.yml?branch=master)](https://github.com/xdev-software/template-placeholder/actions/workflows/release.yml)
## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/thread-origin-agent/release.yml?branch=master)](https://github.com/xdev-software/thread-origin-agent/actions/workflows/release.yml)

Before releasing:
* Consider doing a [test-deployment](https://github.com/xdev-software/template-placeholder/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
* Check the [changelog](CHANGELOG.md)

If the ``develop`` is ready for release, create a pull request to the ``master``-Branch and merge the changes
Expand Down
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2024 XDEV Software
Copyright 2019 XDEV Software
Copyright 2011 kreyssel

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
59 changes: 53 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,57 @@
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/template-placeholder?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/template-placeholder)
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/template-placeholder/check-build.yml?branch=develop)](https://github.com/xdev-software/template-placeholder/actions/workflows/check-build.yml?query=branch%3Adevelop)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_template-placeholder&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_template-placeholder)
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/thread-origin-agent/check-build.yml?branch=develop)](https://github.com/xdev-software/thread-origin-agent/actions/workflows/check-build.yml?query=branch%3Adevelop)

# template-placeholder
# Thread Origin Agent

In many situations is it helpful to find out who created a [Thread](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Thread.html).

To find the origin of a thread, this project provides a [javaagent](https://docs.oracle.com/en/java/javase/21/docs/api/java.instrument/java/lang/instrument/package-summary.html) which logs the stacktrace at Thread creation.

## Installation
[Installation guide for the latest release](https://github.com/xdev-software/template-placeholder/releases/latest#Installation)
[Installation guide for the latest release](https://github.com/xdev-software/thread-origin-agent/releases/latest#Installation)

## Usage
Insert ``-javaagent:<pathToThread-origin-agent.jar>=<packagesToIgnore>`` into the JVM-arguments (at the beginning!)<br/>
Examples:
```bash
java -javaagent:thread-origin-agent-1.0.0.jar -jar <appToInspect>.jar
java -javaagent:"C:\temp\thread-origin-agent-1.0.0.jar"=sun/awt,sun/java2d -jar <appToInspect>.jar
```

> [!NOTE]
> Please note that it's not possible to monitor all ``Thread`` starts as the ``Thread`` class is loaded and used extremely early.<br/>
> Some static instantiations that use Threads e.g. ``ForkJoinPool#common`` are therefore not affected by changing the underlying bytecode.
<details><summary>Example output for a Spring Boot application</summary>

```
[TOA] Arg: null
[TOA] Ignoring excluded:
[TOA] Trying to retransform loaded classes
[TOA] Ignoring javassist.CtField
...
[TOA] Retransformed loaded classes; 820x successful, 150x unmodifiable
[TOA] Detected java.lang.Thread.start() id: 46 name: background-preinit
[TOA] org.springframework.boot.autoconfigure.BackgroundPreinitializer.performPreinitialization(BackgroundPreinitializer.java:129)
[TOA] org.springframework.boot.autoconfigure.BackgroundPreinitializer.onApplicationEvent(BackgroundPreinitializer.java:85)
[TOA] org.springframework.boot.autoconfigure.BackgroundPreinitializer.onApplicationEvent(BackgroundPreinitializer.java:55)
...
[TOA] Detected java.lang.Thread.start() id: 47 name: Thread-0
[TOA] org.springframework.boot.autoconfigure.condition.OnClassCondition$ThreadedOutcomesResolver.<init>(OnClassCondition.java:147)
...
```

</details>

### Additional configuration options

These options can be configured as system properties. Example:<br/>
``-DTOA_LOG_CALLER_THREADS``

| Option | Description |
| --- | --- |
| ``TOA_LOG_THREAD_JOINS`` | Also logs ``Thread#join`` calls |
| ``TOA_LOG_CALLER_THREADS`` | Displays additional information about the thread that started the new thread |
| ``TOA_DISPLAY_METHOD_INSTRUMENTATION_FAILURES`` | Displays method instrumentation failures.<br/>This happens when a method is not present or can't be instrumented due to other reasons (e.g. JDK internal method).<br/>Produces a lot of log output so it's recommended to only enable it for debugging |

## Support
If you need support as soon as possible and you can't wait for any pull request, feel free to use [our support](https://xdev.software/en/services/support).
Expand All @@ -15,4 +60,6 @@ If you need support as soon as possible and you can't wait for any pull request,
See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project.

## Dependencies and Licenses
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/template-placeholder/dependencies)
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/thread-origin-agent/dependencies)

<sub>This project was inspired by [kreyssel/maven-examples](https://github.com/kreyssel/maven-examples)</sub>
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

## Reporting a Vulnerability

Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/template-placeholder/security/advisories/new).
Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/thread-origin-agent/security/advisories/new).
7 changes: 3 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<modelVersion>4.0.0</modelVersion>

<groupId>software.xdev</groupId>
<artifactId>template-placeholder-root</artifactId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>thread-origin-agent-root</artifactId>
<version>1.1.1-SNAPSHOT</version>
<packaging>pom</packaging>

<organization>
Expand All @@ -15,8 +15,7 @@
</organization>

<modules>
<module>template-placeholder</module>
<module>template-placeholder-demo</module>
<module>thread-origin-agent</module>
</modules>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"packageRules": [
{
"description": "Ignore project internal dependencies",
"packagePattern": "^software.xdev:template-placeholder",
"packagePattern": "^software.xdev:thread-origin-agent",
"datasources": [
"maven"
],
Expand Down
Loading

0 comments on commit 8c2b3fc

Please sign in to comment.