Skip to content

Commit

Permalink
feat: Add prometheus exporter (#483)
Browse files Browse the repository at this point in the history
* fix(http-plugin): move node-sdk to dev deps

* feat: update dependencies

* feat: server implementation and tests

* fix: remove console logger

* fix: add types

* feat(prometheus-exporter): counter and gauge

* feat(prometheus-exporter): implement counter and gauge

* feat(prometheus-exporter): export configuration interface

* fix: linting

* fix: typo

Co-Authored-By: Mayur Kale <mayurkale@google.com>

* chore: document ExporterConfig

* fix: dependencies

* fix: typo

Co-Authored-By: Mayur Kale <mayurkale@google.com>

* chore: document sanitize method and make behavior more strict

* chore: do not use global prom-client registry

* chore: add defaults to description and metric endpoint

* test: export couter, gauge, multiple, and none

* test: sanitize prom metric names

* fix: typo

Co-Authored-By: Mayur Kale <mayurkale@google.com>

* chore: make _server read only

* test: add tests for prom export configuration

* style: make comments descriptive

* test: update tests for label sets

* fix: lint
  • Loading branch information
dyladan authored and mayurkale22 committed Nov 11, 2019
1 parent 39732fa commit 460d986
Show file tree
Hide file tree
Showing 6 changed files with 838 additions and 4 deletions.
9 changes: 6 additions & 3 deletions packages/opentelemetry-exporter-prometheus/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "@opentelemetry/exporter-prometheus",
"version": "0.2.0",
"private": true,
"description": "OpenTelemetry Exporter Prometheus provides a metrics endpoint for Prometheus",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
Expand Down Expand Up @@ -43,16 +42,20 @@
"@types/node": "^12.6.9",
"codecov": "^3.5.0",
"gts": "^1.1.0",
"mocha": "^6.2.0",
"mocha": "^6.2.2",
"nyc": "^14.1.1",
"rimraf": "^3.0.0",
"ts-mocha": "^6.0.0",
"ts-node": "^8.3.0",
"tslint-consistent-codestyle": "^1.16.0",
"tslint-microsoft-contrib": "^6.2.0",
"typescript": "3.7.2"
},
"dependencies": {
"@opentelemetry/base": "^0.2.0",
"@opentelemetry/core": "^0.2.0",
"@opentelemetry/types": "^0.2.0"
"@opentelemetry/metrics": "^0.2.0",
"@opentelemetry/types": "^0.2.0",
"prom-client": "^11.5.3"
}
}
53 changes: 53 additions & 0 deletions packages/opentelemetry-exporter-prometheus/src/export/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*!
* Copyright 2019, OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import * as types from '@opentelemetry/types';

/**
* Configuration interface for prometheus exporter
*/
export interface ExporterConfig {
/**
* App prefix for metrics, if needed
*
* @default ''
* */
prefix?: string;

/**
* Endpoint the metrics should be exposed at with preceeding slash
* @default '/metrics'
*/
endpoint?: string;

/**
* Port number for Prometheus exporter server
*
* Default registered port is 9464:
* https://github.com/prometheus/prometheus/wiki/Default-port-allocations
* @default 9464
*/
port?: number;

/**
* Define if the Prometheus exporter server will be started
* @default false
*/
startServer?: boolean;

/** Standard logging interface */
logger?: types.Logger;
}
3 changes: 2 additions & 1 deletion packages/opentelemetry-exporter-prometheus/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
* limitations under the License.
*/

//
export * from './prometheus';
export * from './export/types';
Loading

0 comments on commit 460d986

Please sign in to comment.