-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add metrics to track upload times
- Loading branch information
Showing
5 changed files
with
932 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { MeterProvider } from "@opentelemetry/sdk-metrics"; | ||
import { PrometheusExporter } from "@opentelemetry/exporter-prometheus"; | ||
|
||
// Define a configuration object to organize configuration values | ||
const config = { | ||
port: 9464, | ||
meterName: "hub-uploads", | ||
histogramConfig: { | ||
name: "hub_uploads_upload_time_milliseconds", | ||
description: "Time in milliseconds for a file upload", | ||
unit: "ms", | ||
boundaries: [100, 200, 400, 800, 1600], | ||
labelKeys: ["status"], | ||
}, | ||
}; | ||
|
||
// Export a Metrics object to encapsulate initialization and the exporter | ||
const Metrics = { | ||
exporter: new PrometheusExporter({ port: config.port }), | ||
|
||
initialize() { | ||
const meterProvider = new MeterProvider(); | ||
meterProvider.addMetricReader(this.exporter); | ||
const meter = meterProvider.getMeter(config.meterName); | ||
|
||
const FileUploadTime = meter.createHistogram(config.histogramConfig.name, { | ||
description: config.histogramConfig.description, | ||
unit: config.histogramConfig.unit, | ||
boundaries: config.histogramConfig.boundaries, | ||
}); | ||
|
||
return { meter, FileUploadTime }; | ||
}, | ||
}; | ||
|
||
export default Metrics; |
Oops, something went wrong.