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-10.4.0 spec/prometheus_metrics_spec.rb
gitlab-exporter-10.3.0 spec/prometheus_metrics_spec.rb
gitlab-exporter-10.2.0 spec/prometheus_metrics_spec.rb
gitlab-exporter-10.1.0 spec/prometheus_metrics_spec.rb
gitlab-exporter-10.0.0 spec/prometheus_metrics_spec.rb
gitlab-exporter-9.1.0 spec/prometheus_metrics_spec.rb
gitlab-exporter-9.0.0 spec/prometheus_metrics_spec.rb
gitlab-exporter-8.0.0 spec/prometheus_metrics_spec.rb
gitlab-exporter-7.2.0 spec/prometheus_metrics_spec.rb
gitlab-exporter-7.1.2 spec/prometheus_metrics_spec.rb
gitlab-exporter-7.1.1 spec/prometheus_metrics_spec.rb
gitlab-exporter-7.1.0 spec/prometheus_metrics_spec.rb
gitlab-exporter-7.0.6 spec/prometheus_metrics_spec.rb
gitlab-exporter-7.0.5 spec/prometheus_metrics_spec.rb
gitlab-exporter-7.0.4 spec/prometheus_metrics_spec.rb
gitlab-exporter-7.0.3 spec/prometheus_metrics_spec.rb
gitlab-exporter-7.0.2 spec/prometheus_metrics_spec.rb
gitlab-exporter-7.0.1 spec/prometheus_metrics_spec.rb
gitlab-exporter-7.0.0 spec/prometheus_metrics_spec.rb
gitlab-exporter-6.1.0 spec/prometheus_metrics_spec.rb