Skip to content

Commit

Permalink
Merge branch 'main' into rm-norecordingspan
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan authored Feb 8, 2021
2 parents c7e0681 + 2f0d612 commit 42c0fbe
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/canary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
npm run compile
- name: Publish
run: npx lerna publish --canary --yes
run: npx lerna publish --canary --yes --no-verify-access
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,6 @@ registerInstrumentations({

- `registerInstrumentations` supports loading old plugins and instrumentations together. It also supports setting tracer provider and meter provider on instrumentations

## Upgrade guidelines

### 0.15.0 to 0.16.0

[PR-1874](https://github.com/open-telemetry/opentelemetry-js/pull/1874) More specific API type names

Some types exported from `"@opentelemetry/api"` have been changed to be more specific.
Expand All @@ -305,6 +301,8 @@ Some types exported from `"@opentelemetry/api"` have been changed to be more spe
- `Status` renamed to `SpanStatus`
- `StatusCode` renamed to `SpanStatusCode`

### 0.15.0 to 0.16.0

[PR-1863](https://github.com/open-telemetry/opentelemetry-js/pull/1863) removed public attributes `keepAlive` and `httpAgentOptions` from nodejs `CollectorTraceExporter` and `CollectorMetricExporter`

### 0.14.0 to 0.15.0
Expand Down
2 changes: 2 additions & 0 deletions packages/opentelemetry-exporter-prometheus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@
"devDependencies": {
"@types/mocha": "8.2.0",
"@types/node": "14.14.20",
"@types/sinon": "9.0.10",
"codecov": "3.8.1",
"gts": "3.1.0",
"mocha": "7.2.0",
"nyc": "15.1.0",
"rimraf": "3.0.2",
"sinon": "9.2.3",
"ts-mocha": "8.0.0",
"ts-node": "9.1.1",
"typescript": "4.1.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ export class PrometheusExporter implements MetricExporter {
});
}

/**
* Request handler that responds with the current state of metrics
* @param request Incoming HTTP request of server instance
* @param response HTTP response objet used to response to request
*/
public getMetricsRequestHandler(
_request: IncomingMessage,
response: ServerResponse
) {
this._exportMetrics(response);
}

/**
* Request handler used by http library to respond to incoming requests
* for the current state of metrics by the Prometheus backend.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ import {
HistogramAggregator,
} from '@opentelemetry/metrics';
import * as assert from 'assert';
import * as sinon from 'sinon';
import * as http from 'http';
import { PrometheusExporter } from '../src';
import { mockAggregator, mockedHrTimeMs } from './util';
import { SinonStubbedInstance } from 'sinon';

describe('PrometheusExporter', () => {
mockAggregator(SumAggregator);
Expand Down Expand Up @@ -171,6 +173,23 @@ describe('PrometheusExporter', () => {
return done();
});
});

it('should able to call getMetricsRequestHandler function to generate response with metrics', () => {
const exporter = new PrometheusExporter({ preventServerStart: true });
const mockRequest: SinonStubbedInstance<http.IncomingMessage> = sinon.createStubInstance(
http.IncomingMessage
);
const mockResponse: SinonStubbedInstance<http.ServerResponse> = sinon.createStubInstance(
http.ServerResponse
);
exporter.getMetricsRequestHandler(
(mockRequest as unknown) as http.IncomingMessage,
(mockResponse as unknown) as http.ServerResponse
);
sinon.assert.calledOnce(mockResponse.setHeader);
sinon.assert.calledOnce(mockResponse.end);
assert.strictEqual(mockResponse.statusCode, 200);
});
});

describe('export', () => {
Expand Down

0 comments on commit 42c0fbe

Please sign in to comment.