Skip to content

Instantly share code, notes, and snippets.

View jkschneider's full-sized avatar

Jonathan Schnéider jkschneider

View GitHub Profile
package org.openrewrite.java;
import lombok.SneakyThrows;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Recipe;
import org.openrewrite.SourceFile;
import org.openrewrite.TreeVisitor;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.java.search.FindAnnotations;
import org.openrewrite.java.search.UsesType;
package org.openrewrite.java;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Recipe;
import org.openrewrite.SourceFile;
import org.openrewrite.Tree;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.java.tree.J;
import org.openrewrite.marker.Markers;
import org.openrewrite.text.PlainText;
@jkschneider
jkschneider / Micrometer.java
Last active July 18, 2020 21:22
Is `Metrics.gauge(Number)` declarative looking enough to avoid the downsides of annotations that come with `@Gauge`?
public class PrimeNumberChecker {
// could use Gauge.builder(..) instead if you want description text and base units
private final AtomicLong highestPrimeNumberSoFar = Metrics.gauge("highestPrimeNumberSoFar", new AtomicLong(2));
public String checkIfPrime(long number) {
...
return highestPrimeNumberSoFar.compareAndExchange(Math.min(highestPrimeNumberSoFar.get(), number), number) +
" is prime.";
}
}
WebClient client = WebClient.builder()
.baseUrl("http://" + args[0])
.build();
Flux
.generate(AtomicLong::new, (state, sink) -> {
long i = state.getAndIncrement();
sink.next(i);
return state;
})
@jkschneider
jkschneider / SpinnakerMetricsConfiguration.java
Last active October 10, 2019 17:53
Spring Boot configuration to wire Spinnaker K8S v2 Provider annotations to Micrometer for use in Kayenta
@Configuration
public class PaneraMetricsAutoConfiguration {
private final Logger logger = LoggerFactory.getLogger(PaneraMetricsAutoConfiguration.class);
@Value("${spring.application.name:unknown}")
private String appName;
@Value("${HOSTNAME:unknown}")
private String host;
@jkschneider
jkschneider / dependency-problems.md
Created September 19, 2019 21:06
Classes of dependency problems

API utilization

Guava famously deprecates in one minor release and removes deprecations in the next, but it isn't uncommon to see Guava version divergences greater than two minor releases in a large dependency graph in application code. Latest or nearest version conflict resolution both lead to breaking consequences because different parts of the dependency graph make different assumptions.

Semantic incompatibility leads to a similar problem as the Guava problem.

Developers on core libraries or organization-wide curators of third-party dependencies may wish to peek at API utilization to determine the impact of an impending change.

Security teams may wish to peek at API utilization to determine where known vulnerable methods are in use.

@jkschneider
jkschneider / spinnaker-local.yml
Created June 7, 2019 15:19
Spinnaker config with CloudFoundry, Jenkins, Artifactory
# This file is intended to serve as a master configuration for a Spinnaker
# deployment. Customizations to the deployment should be made in another file
# named "spinnaker-local.yml". The distribution has a prototype called
# "default-spinnaker-local.yml" which calls out the subset of attributes of
# general interest. It can be copied into a "spinnaker-local.yml" to start
# with. The prototype does not change any of the default values here, it just
# surfaces the more critical attributes.
global:
{
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false
}
@jkschneider
jkschneider / metricsdemo-atherton.yml
Last active April 3, 2019 03:30
A series of manifests for testing Spinnaker CF integration.
---
applications:
- name: metricsdemo
routes:
- route: metricsdemo.apps.atherton.cf-app.com
@jkschneider
jkschneider / build.gradle
Created March 7, 2019 14:46
Gradle publishing to artifactory
plugins {
id 'java'
id 'com.jfrog.artifactory' version '4.9.0'
id 'org.springframework.boot' version '2.1.3.RELEASE'
id 'io.spring.dependency-management' version '1.0.7.RELEASE'
id 'nebula.maven-publish' version '9.5.0'
id 'nebula.release' version '9.2.0'
id 'nebula.info' version '5.0.0'
}