Skip to content

Instantly share code, notes, and snippets.

View nathanleclaire's full-sized avatar
👨‍🍳
Cooking up great code

Nathan LeClaire nathanleclaire

👨‍🍳
Cooking up great code
View GitHub Profile
@nathanleclaire
nathanleclaire / DebugResponseObserver.java
Created March 10, 2020 21:42
Generic filter with context injection - Honeycomb Java Beeline implementation
package com.mycompany.config.filters;
import io.honeycomb.libhoney.ResponseObserver;
import io.honeycomb.libhoney.responses.ClientRejected;
import io.honeycomb.libhoney.responses.ServerAccepted;
import io.honeycomb.libhoney.responses.ServerRejected;
import io.honeycomb.libhoney.responses.Unknown;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
@nathanleclaire
nathanleclaire / HoneycombFilterRegistration.java
Created March 9, 2020 16:28
filters with Honeycomb Java Beeline - Spring Boot Filter version
package org.springframework.samples.petclinic.system;
import io.honeycomb.beeline.DefaultBeeline;
import io.honeycomb.beeline.spring.beans.SpringServletFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.swing.*;
import java.util.Arrays;

prom metrics -

class YourClass {
    static final Counter requests = Counter.build()
     .name("http_requests_total")
     .help("Total requests.")
     .labelNames(
         Arrays.asList(
 "http_status",
import java.io.Serializable;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.ml.evaluation.RegressionEvaluator;
import org.apache.spark.ml.recommendation.ALS;
import org.apache.spark.ml.recommendation.ALSModel;
public static class Rating implements Serializable {
private int userId;
private int productId;
package com.mycompany.servlet.filterlistener;
import io.honeycomb.beeline.DefaultBeeline;
import io.honeycomb.beeline.tracing.Span;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
INFO[0000] accepted connection                           authority=10.0.0.3:63349 port=80
INFO[0000] basic authentication accepted                 user=foo
INFO[0000] processing request                            path=/super/slow/server
INFO[0000] sent response code                            status=200
INFO[0000] closed connection                             authority=10.0.0.3:63349
$('body').on("click mousedown mouseup focus blur keydown change dblclick mousemove mouseover mouseout mousewheel keydown keyup keypress textInput touchstart touchmove touchend touchcancel resize scroll zoom select change submit reset",function(e){
libhoney.sendNow(e);
});
public static class DatabaseService {
public void queryDb(String id) {
try (Span childSpan = beeline.startChildSpan("customer-db-query")) {
String data = getCustomerDataById(id);
childSpan.addField("customer-data", data);
}
}
public String getCustomerDataById(String id) {

create a new network

$ docker network create test

create a container to listen

$ docker run -d --net test --network-alias listener alpine nc -l 8080
@nathanleclaire
nathanleclaire / index.js
Created February 20, 2019 21:19
honeycombio nodejs beeline tracing without any frameworks
const beeline = require("honeycomb-beeline")({
writeKey: "KEY",
dataset: "examples.puppeteer",
serviceName: "examples.puppeteer",
});
const puppeteer = require("puppeteer");
let trace = beeline.startTrace();
(async () => {