Sha256: b49cc65ef61173813003b881436be7eb4405beafd1f93e9ef4e26616e0587553

Contents?: true

Size: 852 Bytes

Versions: 25

Compression:

Stored size: 852 Bytes

Contents

require "spec_helper"

describe GitLab::Exporter::PrometheusMetrics do
  it "supports simple metrics" do
    expect(subject.add("mymetric", 1.1).to_s).to match(/mymetric 1.1 \d*$/)
  end

  it "supports metrics with one label" do
    expect(subject.add("mymetric", 1.2, mylabel: "x").to_s).to match(/mymetric{mylabel="x"} 1.2 \d*$/)
  end

  it "supports metrics with many labels" do
    expect(subject.add("mymetric", 1.3, mylabel: "x", myotherlabel: "y").to_s).to match(
      /mymetric{mylabel="x",myotherlabel="y"} 1.3 \d*$/
    )
  end

  it "fails to add a non-numeric metric value" do
    expect {
      subject.add("mymetric", "1.4", mylabel: "x", myotherlabel: "y").to_s
    }.to raise_error(RuntimeError)
    expect {
      subject.add("mymetric", "invalid", mylabel: "x", myotherlabel: "y").to_s
    }.to raise_error(RuntimeError)
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
gitlab-exporter-6.0.0 spec/prometheus_metrics_spec.rb
gitlab-exporter-5.2.2 spec/prometheus_metrics_spec.rb
gitlab-exporter-5.2.1 spec/prometheus_metrics_spec.rb
gitlab-exporter-5.2.0 spec/prometheus_metrics_spec.rb
gitlab-exporter-5.1.0 spec/prometheus_metrics_spec.rb