Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/enforce-version-bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Enforce Version Bump

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
check-version:
runs-on: ubuntu-latest

steps:
# Checkout PR branch into default directory
- name: Checkout PR branch
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Extract PR version
id: pr_version
run: |
VERSION_PR=$(mvn -q -DforceStdout help:evaluate -Dexpression=project.version)
echo "version_pr=$VERSION_PR" >> $GITHUB_OUTPUT

# Checkout main into a DIFFERENT directory
- name: Checkout base branch (main)
run: |
git clone --depth 1 --branch ${{ github.base_ref }} \
https://github.com/${{ github.repository }} base_branch

- name: Extract base version
id: base_version
run: |
cd base_branch
VERSION_BASE=$(mvn -q -DforceStdout help:evaluate -Dexpression=project.version)
echo "version_base=$VERSION_BASE" >> $GITHUB_OUTPUT

- name: Compare versions
run: |
echo "Base version: ${{ steps.base_version.outputs.version_base }}"
echo "PR version: ${{ steps.pr_version.outputs.version_pr }}"

if [ "${{ steps.base_version.outputs.version_base }}" = "${{ steps.pr_version.outputs.version_pr }}" ]; then
echo "::error ::Version must be bumped in pom.xml for every PR!"
exit 1
fi
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.n1netails</groupId>
<artifactId>n1netails-kuda</artifactId>
<version>0.3.2</version>
<version>0.3.3</version>
<packaging>jar</packaging>

<name>n1netails-kuda</name>
Expand Down
16 changes: 14 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

![Stars](https://img.shields.io/github/stars/n1netails/n1netails-kuda)
![Issues](https://img.shields.io/github/issues/n1netails/n1netails-kuda)
![Contributors](https://img.shields.io/github/contributors/n1netails/n1netails-kuda)
![Last Commit](https://img.shields.io/github/last-commit/n1netails/n1netails-kuda)

# Kuda
Integration library that acts as a smart link between your application and the n1netails platform quiet, powerful, and built to vanish into your stack like a spirit fox.

Expand Down Expand Up @@ -47,10 +52,15 @@ Install the Kuda by adding the following dependency:
<dependency>
<groupId>com.n1netails</groupId>
<artifactId>n1netails-kuda</artifactId>
<version>0.3.2</version>
<version>0.3.3</version>
</dependency>
```

Gradle (Groovy)
```groovy
implementation 'com.n1netails:n1netails-kuda:0.3.3'
```

## Configure
### Requirements
Set up and have the `n1netails-api` running on your server.
Expand Down Expand Up @@ -256,8 +266,10 @@ public class ExampleService {
// You can configure this anywhere must be set once.
TailConfig.setApiUrl("http://localhost:9901");
TailConfig.setN1neToken("n1_c7PNos3Nru2NLxVA6ANBbbJZsuJ5g8RVzZJhBpQjz5Hz7qrUB5yloRKjouRU9yzzGpbLhuZAS_ga0HQ_a7dLOQ");
// enable kuda to handle Default Uncaught Exception Handler (optional)
// (optional) enable kuda to handle Default Uncaught Exception Handler
TailConfig.enableExceptionHandler();
// (optional) set true if you would like verbose output for the Default Uncaught Exception Handler. Defaults to false
TailConfig.setVerbose(false);
}

public void defaultExceptionHandler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Optional;
import java.util.UUID;

/**
* Tail Config
Expand All @@ -19,6 +18,8 @@ public class TailConfig {
private static String apiUrl;
private static String token;

// Controls the amount of information that is displayed by the ExceptionReporter. defaults to false
private static boolean verbose = false;
// For one-time warning log
private static boolean warningLogged = false;

Expand Down Expand Up @@ -115,6 +116,14 @@ public static void setN1neToken(String token) {
}
}

/**
* Set verbose details for Exception Reporter
* @param verbose is verbose
*/
public static void setVerbose(boolean verbose) {
TailConfig.verbose = verbose;
}

/**
* Get Configured N1netails Api Url
* @return api url
Expand Down Expand Up @@ -144,4 +153,12 @@ private static String getBaseUrl(String fullUrl) {
throw new IllegalArgumentException("Invalid URL: " + fullUrl, e);
}
}

/**
* Is Exception Reporter details verbose?
* @return verbose value if false details are hidden
*/
public static boolean isVerbose() {
return TailConfig.verbose;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.n1netails.n1netails.kuda.service;

import com.n1netails.n1netails.kuda.TailLevel;
import com.n1netails.n1netails.kuda.internal.TailConfig;
import com.n1netails.n1netails.kuda.model.TailModel;

import java.io.PrintWriter;
Expand Down Expand Up @@ -48,21 +49,24 @@ public void reportException(String level, Throwable throwable, String threadName
Map<String, String> kudatags = new HashMap<>();
if (throwable.toString() != null)
kudatags.put("throwable", throwable.toString());
if (throwable.getCause() != null)
kudatags.put("cause", throwable.getCause().toString());
if (throwable.getLocalizedMessage() != null)
kudatags.put("localized-message", throwable.getLocalizedMessage());
kudatags.put("exception-type", throwable.getClass().getName());
kudatags.put("timestamp", Instant.now().toString());
kudatags.put("thread-name", threadName);
kudatags.put("thread-id", String.valueOf(Thread.currentThread().getId()));
kudatags.put("thread-state", Thread.currentThread().getState().toString());
kudatags.put("host", getHostName());
kudatags.put("ip-local", getLocalIp());
kudatags.put("os", System.getProperty("os.name"));
kudatags.put("os-version", System.getProperty("os.version"));
kudatags.put("arch", System.getProperty("os.arch"));
kudatags.put("java-version", System.getProperty("java.version"));
kudatags.put("timestamp", Instant.now().toString());
kudatags.put("exception-type", throwable.getClass().getName());

if (TailConfig.isVerbose()) {
kudatags.put("thread-state", Thread.currentThread().getState().toString());
if (throwable.getCause() != null)
kudatags.put("cause", throwable.getCause().toString());
kudatags.put("java-version", System.getProperty("java.version"));
kudatags.put("host", getHostName());
kudatags.put("ip-local", getLocalIp());
kudatags.put("os", System.getProperty("os.name"));
kudatags.put("os-version", System.getProperty("os.version"));
kudatags.put("arch", System.getProperty("os.arch"));
}

TailModel alert = new TailModel(
level,
Expand Down
Loading