Skip to content

Commit

Permalink
Merge pull request #52 from permutive-engineering/update/all
Browse files Browse the repository at this point in the history
Dependency Updates
  • Loading branch information
github-actions[bot] authored Aug 30, 2024
2 parents a1eb342 + 50718d6 commit 3df79d9
Show file tree
Hide file tree
Showing 38 changed files with 1,376 additions and 1,139 deletions.
1 change: 0 additions & 1 deletion .envrc

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE → .github/docs/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright (C) @YEAR_RANGE@ @COPYRIGHT_OWNER@

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
92 changes: 92 additions & 0 deletions .github/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Prometheus4Cats Contrib

This repository contains a series of integrations for [Prometheus4Cats] that instrument other libraries or metric
sources. Each integration is documented below:

## Bigtable

Google Bigtable [Java client instrumentation](https://cloud.google.com/bigtable/docs/client-side-metrics).
Uses a [Prometheus4Cats] callback registry to inspect the client metrics registered with OpenCensus.

Use the [`BigtableOpenCensusMetrics`](/modules/prometheus4cats-contrib-google-cloud-bigtable/src/main/scala/prometheus4cats/bigtable/BigtableOpenCensusMetrics.scala)
smart constructor to enable metric collection on the Java client and registering them with a
[`MetricFactory.WithCallbacks`].

```sbt
"com.permutive" %% "prometheus4cats-contrib-google-cloud-bigtable" % "@VERSION@"
```

## Cats-Effect

[Cats-Effect] metrics taken from JMX MBeans. This includes a
[CPU starvation](https://typelevel.org/cats-effect/docs/core/starvation-and-tuning) counter.

Use the [`CatsEffectMBeans`](/modules/prometheus4cats-contrib-cats-effect/src/main/scala/prometheus4cats/catseffect/CatsEffectMBeans.scala)
smart constructor register callbacks for [Cats-Effect] MBeans with [`MetricFactory.WithCallbacks`].

```sbt
"com.permutive" %% "prometheus4cats-contrib-cats-effect" % "@VERSION@"
```

## FS2-Kafka

[FS2-Kafka] integration that instruments consumers and producers. Uses a [Prometheus4Cats] callback registry to inspect
built-in [Kafka client metrics](https://docs.confluent.io/platform/current/kafka/monitoring.html#).

Use the smart constructors in [`KafkaMetrics`](/modules/prometheus4cats-contrib-fs2-kafka/src/main/scala/prometheus4cats/fs2kafka/KafkaMetrics.scala)
to register callbacks for producers and consumers with a [`MetricFactory.WithCallbacks`].

```sbt
"com.permutive" %% "prometheus4cats-contrib-fs2-kafka" % "@VERSION@"
```

## Refreshable

Instrumented implementation of [Refreshable]. Provides the following metrics:

| Metric Name | Labels | Metric Type | Description |
|--------------------------------------|-----------------------------------|-------------|-------------------------------------------------------------------------------------------------------------|
| `refreshable_read_total` | `refreshable_name`, `value_state` | Counter | Number of times this Refreshable has been read, with a label denoting the state of the value |
| `refreshable_is_running` | `refreshable_name` | Gauge | Whether this Refreshable is running - `1` if true, `0` if false |
| `refreshable_retries_exhausted` | `refreshable_name` | Gauge | Whether retries have been exhausted for this Refreshable - `1` if true, `0` if false |
| `refreshable_refresh_failing` | `refreshable_name` | Gauge | Whether refresh is currently failing - `1` if true, `0` if false |
| `refreeshable_refresh_success_total` | `refreshable_name` | Counter | Number of times the refresh operation has succeeded |
| `refreshable_refresh_failure_total` | `refreshable_name` | Counter | Number of times refresh failed |
| `refreshable_status` | `refreshable_name`, `value_state` | Gauge | The current status of this Refreshable - a value of `1` against the label value indicates the current state |

Use the [`InstrumentedRefreshable`](/modules/prometheus4cats-contrib-refreshable/src/main/scala/prometheus4cats/refreshable/InstrumentedRefreshable.scala)
smart constructor to instrument a given `Refreshable` when used with an instance of [`MetricFactory.WithCallbacks`].

```sbt
"com.permutive" %% "prometheus4cats-contrib-refreshable" % "@VERSION@"
```

## Trace4Cats

Instrumented implementations of [Trace4Cats] interfaces. Provides the following metrics:

| Interface | Metric Name | Labels | Metric Type | Description |
|-----------------|--------------------------------------|-------------------------------------------|-------------|----------------------------------------------------|
| `EntryPoint` | `trace4cats_entry_point_spans_total` | `span_kind`, `is_root`, `sample_decision` | Counter | Total number of spans created |
| `SpanCompleter` | `trace4cats_completer_spans_total` | `completer_name` | Counter | Total number of spans completed |
| `SpanCompleter` | `trace4cats_completer_complete_time` | `completer_name` | Histogram | Time it takes to complete a span in seconds |
| `SpanExporter` | `trace4cats_exporter_batches_total` | `exporter_name` | Counter | Total number of batches sent via this exporter |
| `SpanExporter` | `trace4cats_exporter_export_time` | `exporter_name` | Histogram | Time it takes to export a span batch in seconds |
| `SpanExporter` | `trace4cats_exporter_batch_size` | `exporter_name` | Histogram | Size distribution of batches sent by this exporter |

Use the [`InstrumentedEntrypoint`](/modules/prometheus4cats-contrib-trace4cats/src/main/scala/prometheus4cats/trace4cats/InstrumentedEntrypoint.scala),
[`InstrumentedSpanCompleter`](/modules/prometheus4cats-contrib-trace4cats/src/main/scala/prometheus4cats/trace4cats/InstrumentedSpanCompleter.scala) and
[`InstrumentedSpanExporter`](/modules/prometheus4cats-contrib-trace4cats/src/main/scala/prometheus4cats/trace4cats/InstrumentedSpanExporter.scala) with
a [`MetricFactory`] to return instrumented wrappers of the underlying implementations.

```sbt
"com.permutive" %% "prometheus4cats-contrib-trace4cats" % "@VERSION@"
```

[Cats-Effect]: https://typelevel.org/cats-effect
[FS2-Kafka]: https://fd4s.github.io/fs2-kafka/
[Refreshable]: https://github.com/permutive-engineering/refreshable
[Trace4Cats]: https://github.com/trace4cats/trace4cats
[Prometheus4Cats]: https://github.com/permutive-engineering/prometheus4cats
[`MetricFactory`]: https://permutive-engineering.github.io/prometheus4cats/docs/interface/metric-factory/
[`MetricFactory.WithCallbacks`]: https://permutive-engineering.github.io/prometheus4cats/docs/interface/metric-factory/#metricfactory-or-metricfactorywithcallbacks
28 changes: 28 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Don't edit this file!
# It is automatically updated after every release of https://github.com/alejandrohdezma/sbt-ci
# If you want to suggest a change, please open a PR or issue in that repository

# This file contains the template for the "auto-generated release notes"

changelog:
exclude:
labels:
- ":chart_with_upwards_trend: dependency-update"
authors:
- dependabot
categories:
- title: "⚠️ Breaking changes"
labels:
- ":warning: breaking"
- title: "🚀 New features"
labels:
- ":rocket: feature"
- title: "📘 Documentation updates"
labels:
- ":blue_book: documentation"
- title: "🐛 Bug fixes"
labels:
- ":beetle: bug"
- title: Other Changes
labels:
- "*"
237 changes: 59 additions & 178 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,193 +1,74 @@
# This file was automatically generated by sbt-github-actions using the
# githubWorkflowGenerate task. You should add and commit this file to
# your git repository. It goes without saying that you shouldn't edit
# this file by hand! Instead, if you wish to make changes, you should
# change your sbt build configuration to revise the workflow description
# to meet your needs, then regenerate this file.

name: Continuous Integration
# Don't edit this file!
# It is automatically updated after every release of https://github.com/alejandrohdezma/sbt-ci
# If you want to suggest a change, please open a PR or issue in that repository

# Runs `sbt ci-test` on the project on differnt JDKs (this task should be added to the project as a command alias
# containing the necessary steps to compile, check formatters, launch tests...).
#
# Examples of this `ci-test` alias can be found [here](https://github.com/search?q=org%3Aalejandrohdezma+%22ci-test%22+path%3Abuild.sbt++NOT+is%3Aarchived&type=code).
#
# It will also do the following:
#
# - It will automatically label PRs based on head branch.
# - It will automatically enable auto-merge on `Scala Steward` PRs. You'll need to add a `STEWARD_BOT` repository or
# organization variable with the name of your scala-steward bot. See https://docs.github.com/en/actions/learn-github-actions/variables.

name: CI

on:
pull_request:
branches: ['**', '!update/**', '!pr/**']
push:
branches: ['**', '!update/**', '!pr/**']
tags: [v*]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


concurrency:
group: ${{ github.workflow }} @ ${{ github.ref }}
cancel-in-progress: true
types: [opened, reopened, labeled, unlabeled, synchronize]

jobs:
build:
name: Build and Test
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12, 2.13, 3]
java: [temurin@8]
project: [rootJVM]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
labeler:
if: github.event.pull_request.state == 'OPEN' && github.actor != 'dependabot[bot]'
name: Labeler
runs-on: ubuntu-latest
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
run: sbt +update

- name: Check that workflows are up to date
run: sbt githubWorkflowCheck

- name: Check headers and formatting
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck

- name: Test
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' test

- name: Check binary compatibility
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' mimaReportBinaryIssues

- name: Generate API documentation
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' doc

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: mkdir -p fs2-kafka/target opencensus/target cats-effect/target refreshable/target bigtable/target trace4cats/target project/target

- name: Compress target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: tar cf targets.tar fs2-kafka/target opencensus/target cats-effect/target refreshable/target bigtable/target trace4cats/target project/target

- name: Upload target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
uses: actions/upload-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}-${{ matrix.project }}
path: targets.tar

publish:
name: Publish Artifacts
needs: [build]
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
strategy:
matrix:
os: [ubuntu-latest]
java: [temurin@8]
runs-on: ${{ matrix.os }}
- name: Update PR labels
uses: alejandrohdezma/actions/labeler@v1
if: github.event.pull_request.head.repo.full_name == github.repository

- name: Check PR labels
uses: alejandrohdezma/actions/label-check@v1

ci-steward:
if: |
github.event.pull_request.state == 'OPEN' && github.event.pull_request.head.repo.full_name == github.repository &&
github.event.pull_request.user.login == vars.STEWARD_BOT
name: (Scala Steward) Enable auto-merge
runs-on: ubuntu-latest
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
run: sbt +update

- name: Download target directories (2.12, rootJVM)
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12-rootJVM

- name: Inflate target directories (2.12, rootJVM)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.13, rootJVM)
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13-rootJVM

- name: Inflate target directories (2.13, rootJVM)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (3, rootJVM)
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3-rootJVM

- name: Inflate target directories (3, rootJVM)
run: |
tar xf targets.tar
rm targets.tar
- name: Import signing key
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == ''
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
run: echo $PGP_SECRET | base64 -d -i - | gpg --import

- name: Import signing key and strip passphrase
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != ''
- name: Enable auto-merge for this PR
run: gh pr merge --auto --merge ${{github.event.pull_request.number}} -R "$GITHUB_REPOSITORY"
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
run: |
echo "$PGP_SECRET" | base64 -d -i - > /tmp/signing-key.gpg
echo "$PGP_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --import /tmp/signing-key.gpg
(echo "$PGP_PASSPHRASE"; echo; echo) | gpg --command-fd 0 --pinentry-mode loopback --change-passphrase $(gpg --list-secret-keys --with-colons 2> /dev/null | grep '^sec:' | cut --delimiter ':' --fields 5 | tail -n 1)
- name: Publish
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_CREDENTIAL_HOST: ${{ secrets.SONATYPE_CREDENTIAL_HOST }}
run: sbt tlCiRelease

validate-steward:
name: Validate Steward Config
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

test:
needs: [ci-steward]
if: |
always() && !contains(needs.*.result, 'failure') && github.event.pull_request.state == 'OPEN' &&
github.actor != 'dependabot[bot]'
name: Run "sbt ci-test" on JDK ${{ matrix.jdk }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
java: [temurin@11]
runs-on: ${{ matrix.os }}
jdk:
- 11
- 17
steps:
- name: Checkout current branch (fast)
uses: actions/checkout@v4

- name: Setup Java (temurin@11)
id: setup-java-temurin-11
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v4
- name: Checkout project
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
distribution: temurin
java-version: 11
ref: ${{ github.head_ref }}
fetch-depth: 0

- uses: coursier/setup-action@v1
- uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
apps: scala-steward
distribution: "liberica"
java-version: ${{ matrix.jdk }}
cache: "sbt"

- run: scala-steward validate-repo-config .scala-steward.conf
- name: Run `sbt ci-test`
run: sbt ci-test
Loading

0 comments on commit 3df79d9

Please sign in to comment.