Skip to content

Commit

Permalink
Release 10/6 (#6)
Browse files Browse the repository at this point in the history
* add metrics to track upload times
  • Loading branch information
mpwsh authored Oct 6, 2023
1 parent 2bc7a7e commit 567db1e
Show file tree
Hide file tree
Showing 5 changed files with 932 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20-alpine AS base
FROM node:19-alpine AS base
WORKDIR /app
ENV HOME=/app
RUN addgroup -g 10000 uploader && adduser -u 10000 -G uploader -s /bin/sh -D uploader
Expand Down
36 changes: 36 additions & 0 deletions metrics.js
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;
Loading

0 comments on commit 567db1e

Please sign in to comment.