Skip to content
Open
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
18 changes: 18 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

# Export all:
# - (should be) .gitignored
# - (potentially) secret environment variables
# - from dotenv-formatted files w/names starting w/`.env`
DOTENV_FILES="$(find . -maxdepth 1 -type f -name '.env*'\
-and -not -name '.envrc'\
-and -not -name '.env.example'\
)"
for file in ${DOTENV_FILES}; do
dotenv "${file}"
done
export DOTENV_FILES

if has nix; then
use flake
fi
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
.claude
.idea/
CLAUDE.md

# nix
.direnv/
result*
115 changes: 115 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 93 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

crane.url = "github:ipetkov/crane";

flake-utils.url = "github:numtide/flake-utils";

advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};

};

outputs =
{ self, ... }@inputs:
inputs.flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import inputs.nixpkgs { localSystem = { inherit system; }; };
inherit (pkgs) lib;

craneLib = inputs.crane.mkLib pkgs;
src = craneLib.cleanCargoSource ./.;

commonArgs = {
inherit src;
strictDeps = true;
buildInputs = [
pkgs.openssl
pkgs.cyrus_sasl
pkgs.curlFull
];
nativeBuildInputs = [
pkgs.cmake
pkgs.pkg-config
]
++ lib.optionals pkgs.stdenv.isDarwin [ pkgs.libiconv ];
};

cargoDetails = pkgs.lib.importTOML ./Cargo.toml;
inherit (cargoDetails.package) name version;
cargoArtifacts = craneLib.buildDepsOnly commonArgs;

rust-prog = craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
meta.mainProgram = name; # This is default in cargo
}
);
dockerTag =
if lib.hasAttr "rev" self then "${lib.toString self.revCount}-${self.shortRev}" else "gitDirty";
tag = "${version}-${dockerTag}";
in
{
devShells.default = pkgs.mkShell {
packages = with pkgs; [
rust-analyzer
cargo-watch
clippy
rustfmt

kubernetes-helm
];
inputsFrom = [ rust-prog ];
};
formatter = inputs.treefmt-nix.lib.mkWrapper pkgs {
programs.nixfmt.enable = true;
programs.rustfmt.enable = true;
};
packages.default = rust-prog;
packages.docker = pkgs.dockerTools.buildImage {
inherit name tag;
config = {
Expose = "8000";
Workdir = "/app";

Entrypoint = [ (lib.getExe rust-prog) ];
Cmd = [
"--config"
"/app/config.toml"
];
};
};
}
);
}
8 changes: 8 additions & 0 deletions helm/klag-exporter/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ data:
granularity = {{ .granularity | quote }}
{{- end }}

[exporter.performance]
{{- with index .Values.config "exporter.performance" }}
kafka_timeout = {{ .kafka_timeout | quote }}
offset_fetch_timeout = {{ .offset_fetch_timeout | quote }}
max_concurrent_groups = {{ .max_concurrent_groups }}
max_concurrent_watermarks = {{ .max_concurrent_watermarks }}
{{- end }}

[exporter.timestamp_sampling]
{{- with index .Values.config "exporter.timestamp_sampling" }}
enabled = {{ .enabled }}
Expand Down
5 changes: 5 additions & 0 deletions helm/klag-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ spec:
{{- end }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.log_level }}
env:
- name: RUST_LOG
value: {{ .Values.log_level }}
{{- end }}
{{- if or .Values.envFromConfigMaps .Values.envFromSecrets }}
envFrom:
{{- range .Values.envFromConfigMaps }}
Expand Down
6 changes: 6 additions & 0 deletions helm/klag-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ readinessProbe:
path: /ready
port: http

log_level: "info"
config:
exporter:
poll_interval: "30s"
Expand All @@ -133,6 +134,11 @@ config:
enabled: false
endpoint: "http://localhost:4317"
export_interval: "60s"
exporter.performance:
kafka_timeout: "30s"
offset_fetch_timeout: "10s"
max_concurrent_groups: 10
max_concurrent_watermarks: 50
clusters:
- name: "cluster-1"
bootstrap_servers: "kafka:9092"
Expand Down