Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defaultRecorderBuckets not respected with swift-metrics #74

Open
Sherlouk opened this issue Jul 31, 2022 · 0 comments · May be fixed by #75
Open

defaultRecorderBuckets not respected with swift-metrics #74

Sherlouk opened this issue Jul 31, 2022 · 0 comments · May be fixed by #75

Comments

@Sherlouk
Copy link

Steps to reproduce

Setup Prometheus and Swift Metrics:

        let client = PrometheusClient()
        
        // Setup Factory
        let factory = PrometheusMetricsFactory(client: client, configuration: .init(defaultRecorderBuckets: [
            0.05, 0.1, 0.5, 1, 5, 10, 25, 50, 75, 100
        ]))
        
        MetricsSystem.bootstrap(factory)
        
        // Collect Metrics
        app.get("metrics") { _ async throws -> String in
            return await client.collect()
        }

Create a Recorder and record a value:

Recorder(label: "x").record(100)

View output and see that bucket sizes are the default bucket sizes rather than the ones I've provided in the setup.

Expected behavior

Bucket sizes should be those which I provided to the factory

Actual behavior

Bucket sizes are instead the defaulted bucket sizes hard coded into the library

Environment

  • OS version: 12.4
  • Swift version: 5.6
  • Serverside Swift Framework: Vapor
  • Framework version: 4

Solution

The root cause appears to be that the makeHistogram function calls createHistogram which has a variable called buckets: Buckets = .defaultBuckets. This defaults to defaultBuckets which is incorrect, it should instead be set to configuration.defaultRecorderBuckets (which itself defaults to defaultBuckets but can be overridden by the user, me, as above).

Sherlouk added a commit to Sherlouk/SwiftPrometheus that referenced this issue Jul 31, 2022
@Sherlouk Sherlouk linked a pull request Jul 31, 2022 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant