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
26 changes: 26 additions & 0 deletions .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Documentation
on:
push:
branches:
- 'master'
- 'release-'
tags: ['*']
pull_request:
jobs:
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: '1.11'
- uses: julia-actions/cache@v2
- name: Install dependencies
run: julia --project=docs -e 'using Pkg; Pkg.instantiate()'
- name: Build and deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
run: julia --project=docs --color=yes docs/make.jl
28 changes: 4 additions & 24 deletions .github/workflows/CI.yml → .github/workflows/Test.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
name: CI

---
name: Test
on:
push:
branches:
- 'master'
- 'release-'
tags: '*'
tags: ['*']
pull_request:

jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
version:
- '1.6'
- '1.7'
- '1.8'
- '1.9'
- '1.10'
- '1'
- 'nightly'
os:
Expand All @@ -41,19 +37,3 @@ jobs:
file: lcov.info
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: '1.11'
- uses: julia-actions/cache@v2
- name: Install dependencies
run: julia --project=docs -e 'using Pkg; Pkg.instantiate()'
- name: Build and deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
run: julia --project=docs --color=yes docs/make.jl
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SimpleBufferStream = "777ac1f9-54b0-4bf8-805c-2214025038e7"
CodecZlib = "0.7"
HTTP = "1"
SimpleBufferStream = "1"
julia = "1.6"
julia = "1.10"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
54 changes: 10 additions & 44 deletions src/Prometheus.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,40 +64,6 @@ function verify_metric_name(metric_name::String)
return metric_name
end

###########################################
# Compat for const fields, @lock, @atomic #
###########################################
@eval macro $(Symbol("const"))(field)
if VERSION >= v"1.8.0-DEV.1148"
Expr(:const, esc(field))
else
return esc(field)
end
end
if VERSION < v"1.7.0"
# Defined but not exported
using Base: @lock
end
if !isdefined(Base, Symbol("@atomic")) # v1.7.0
const ATOMIC_COMPAT_LOCK = ReentrantLock()
macro atomic(expr)
if Meta.isexpr(expr, :(::))
return esc(expr)
else
return quote
lock(ATOMIC_COMPAT_LOCK)
tmp = $(esc(expr))
unlock(ATOMIC_COMPAT_LOCK)
tmp
end
end
end
end
if !isdefined(Base, :eachsplit) # v1.8.0
const eachsplit = split
end


#####################
# CollectorRegistry #
#####################
Expand Down Expand Up @@ -151,8 +117,8 @@ end
# certain types of exceptions. This is count_exceptions in Python.

mutable struct Counter <: Collector
@const metric_name::String
@const help::String
const metric_name::String
const help::String
@atomic value::Float64

function Counter(
Expand Down Expand Up @@ -222,8 +188,8 @@ end
# https://prometheus.io/docs/instrumenting/writing_clientlibs/#gauge

mutable struct Gauge <: Collector
@const metric_name::String
@const help::String
const metric_name::String
const help::String
@atomic value::Float64

function Gauge(
Expand Down Expand Up @@ -335,12 +301,12 @@ const DEFAULT_BUCKETS = [
]

mutable struct Histogram <: Collector
@const metric_name::String
@const help::String
@const buckets::Vector{Float64}
const metric_name::String
const help::String
const buckets::Vector{Float64}
@atomic _count::Int
@atomic _sum::Float64
@const bucket_counters::Vector{Threads.Atomic{Int}}
const bucket_counters::Vector{Threads.Atomic{Int}}

function Histogram(
metric_name::String, help::String; buckets::Vector{Float64} = DEFAULT_BUCKETS,
Expand Down Expand Up @@ -439,8 +405,8 @@ end
# https://prometheus.io/docs/instrumenting/writing_clientlibs/#summary

mutable struct Summary <: Collector
@const metric_name::String
@const help::String
const metric_name::String
const help::String
@atomic _count::Int
@atomic _sum::Float64

Expand Down
2 changes: 1 addition & 1 deletion src/process_collector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#################################

mutable struct ProcessCollector <: Collector
@const pid::Function
const pid::Function
@atomic initialized::Ptr{Nothing}
@atomic system_boot_time::Int
@atomic clock_ticks_per_second::Int
Expand Down