Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
moray95 committed Jul 16, 2024
0 parents commit ed81a53
Show file tree
Hide file tree
Showing 20 changed files with 884 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[*.{kt,kts}]
ij_kotlin_allow_trailing_comma = false
ij_kotlin_allow_trailing_comma_on_call_site = false
41 changes: 41 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Publish
on:
push:
tags:
- '*'

jobs:
verify:
uses: ./.github/workflows/verify.yaml
publish:
runs-on: ubuntu-latest
needs: [ verify ]
steps:
- uses: actions/checkout@v4
- name: setup java
uses: graalvm/setup-graalvm@v1
with:
java-version: "21"
architecture: x64
distribution: graalvm
cache: 'gradle'
- name: Validate version
run: |
VERSION=${GITHUB_REF#refs/tags/}
if grep -Eq "version\s+=\s+\"${VERSION}\"" ./build.gradle.kts
then
echo "Publishing version '${VERSION}'"
./gradlew publish
else
echo "Detected tag version '${VERSION}' and version from build.gradle.kts does not match."
exit 1
fi
- name: Publish
run: ./gradlew publishToCentralPortal
env:
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
SIGNING_SECRETKEY: ${{ secrets.SIGNING_SECRETKEY }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
LIBRARY_GROUP: ${{ vars.LIBRARY_GROUP }}
SIGNING_KEYID: ${{ vars.SIGNING_KEYID }}
36 changes: 36 additions & 0 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Verify
on:
pull_request:
workflow_call:
push:
branches: ['**']
# Don't run on tags, publish will call this workflow
tags-ignore: ['**']

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: setup java
uses: graalvm/setup-graalvm@v1
with:
java-version: "21"
architecture: x64
distribution: graalvm
cache: 'gradle'
- name: Lint
run: ./gradlew lintKotlin
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: setup java
uses: graalvm/setup-graalvm@v1
with:
java-version: "21"
architecture: x64
distribution: graalvm
cache: 'gradle'
- name: Test
run: ./gradlew test
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.gradle
/build/
/modules/**/build/
!gradle/wrapper/gradle-wrapper.jar

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

*/lib
out/
build

*/report
__pycache__/
trace.db/
kubernetes-configuration/istio-release-0.8
*/logs
*.log
.DS_Store
secret

build-gradle.properties

docker-compose.yml
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2024 Valensas

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Valensas Observability

A simple library to manage observability needs for Spring Boot.

## Usage

### Installation

Include in your `build.gradle.kts`:

```kotlin

dependencies {
implementation("com.valensas:observability:$observabilityVersion")
}

// Needed for dependency version metrics only
plugins {
id("com.valensas.observability-artifacts") version "$observabilityVersion"
}

tasks.withType<KotlinCompile> {
dependsOn(tasks.getByName("observabilityArtifacts"))
}
```

### WebClient metrics

This feature allows to expose [Micrometer](http://micrometer.io) metrics for [Spring's WebClient](https://docs.spring.io/spring-framework/reference/web/webflux-webclient.html).

```kotlin
val webClient = WebClient.builder().observationConvention(IntegrationRequestObservationConvention("metric.name"))
```

### Feign Micrometer Capability auto configuration

This feature is automatically enabled when [Feign](https://github.com/OpenFeign/feign) and [Micrometer](http://micrometer.io)
are configured. It enables Micrometer metrics for Feign requests.

### B3 Header propagation

Allows for customization of [B3 header propagation](https://github.com/openzipkin/b3-propagation). This configuration
is enabled when `management.tracing.propagation.type=B3` and the header format can be configured using
`management.tracing.propagation.format=SINGLE/MULTI/SINGLE_NO_PARENT`. The default value is `SINGLE`.

### Version metrics

This feature allows to expose you application's dependencies' versions to Micrometer. This feature
is enabled when Micrometer is configured and `valensas.observability.version-metrics.enabled=true` (default is true).
The metric name can be configured using the `valensas.observability.version-metric.name` property (default is `valensas_application`).

For this feature to work properly, you will need the use the `com.valensas.observability-artifacts` plugin as described
in the installation section.
114 changes: 114 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

repositories {
mavenCentral()
}

plugins {
`java-gradle-plugin`
id("com.github.ben-manes.versions") version "0.51.0"
id("org.springframework.boot") version "3.3.1" apply false
id("io.spring.dependency-management") version "1.1.6"
id("org.jmailen.kotlinter") version "4.4.0"
id("maven-publish")
id("java-library")
kotlin("jvm") version "1.9.21"
id("net.thebugmc.gradle.sonatype-central-portal-publisher") version "1.2.3"
}

group = "com.valensas"
version = "3.0.0"
java.sourceCompatibility = JavaVersion.VERSION_17

dependencyManagement {
imports {
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
}
}

gradlePlugin {
val observabilityArtifactsPlugin by plugins.creating {
id = "com.valensas.observability-artifacts"
implementationClass = "com.valensas.observability.plugin.ObservabilityArtifactsPlugin"
}
}

dependencies {
implementation("org.graalvm.polyglot:polyglot:24.0.1")
compileOnly("io.micrometer:micrometer-tracing-bridge-brave")
compileOnly("org.springframework.boot:spring-boot-starter-actuator")
compileOnly("io.github.openfeign:feign-micrometer:13.3")
compileOnly("org.springframework.boot:spring-boot-starter")
compileOnly("org.springframework.boot:spring-boot-starter-webflux")

testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
}
}

tasks.withType<Test> {
useJUnitPlatform()
}

publishing {
publications {
create<MavenPublication>("plugin") {
groupId = "com.valensas.observability-artifacts"
artifactId = "com.valensas.observability-artifacts"
from(components["java"])
}
create<MavenPublication>("artifact") {
groupId = "com.valensas"
artifactId = "observability"
from(components["java"])
}
}
}

tasks.getByName<Jar>("jar") {
archiveClassifier = ""
}


signing {
val keyId = System.getenv("SIGNING_KEYID")
val secretKey = System.getenv("SIGNING_SECRETKEY")
val passphrase = System.getenv("SIGNING_PASSPHRASE")

useInMemoryPgpKeys(keyId, secretKey, passphrase)
}

centralPortal {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")

pom {
name = "Observability"
description = "A simple library to manage observability needs for Spring Boot."
url = "https://valensas.com/"
scm {
url = "https://github.com/Valensas/observability"
}

licenses {
license {
name.set("MIT License")
url.set("https://mit-license.org")
}
}

developers {
developer {
id.set("0")
name.set("Valensas")
email.set("[email protected]")
}
}
}
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit ed81a53

Please sign in to comment.