Skip to content

Commit

Permalink
fix: add mayurkale22 recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierAlbertini committed Sep 25, 2019
1 parent d48afa9 commit b82a20a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
17 changes: 17 additions & 0 deletions packages/opentelemetry-exporter-zipkin/src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*!
* 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.
*/

export const OT_HEADER_NAME = 'x-opentelemetry-outgoing-request';
5 changes: 2 additions & 3 deletions packages/opentelemetry-exporter-zipkin/src/zipkin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ import {
statusCodeTagName,
statusDescriptionTagName,
} from './transform';

import { OT_HEADER_NAME } from './utils';
/**
* Zipkin Exporter
*/
export class ZipkinExporter implements SpanExporter {
static readonly DEFAULT_URL = 'http://localhost:9411/api/v2/spans';
static readonly OT_HEADER_NAME = 'x-opentelemetry-outgoing-request';
private readonly _forceFlush: boolean;
private readonly _logger: types.Logger;
private readonly _serviceName: string;
Expand All @@ -56,7 +55,7 @@ export class ZipkinExporter implements SpanExporter {
method: 'POST',
headers: {
'Content-Type': 'application/json',
[ZipkinExporter.OT_HEADER_NAME]: 1,
[OT_HEADER_NAME]: 1,
},
},
urlOpts
Expand Down
5 changes: 3 additions & 2 deletions packages/opentelemetry-exporter-zipkin/test/zipkin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { NoopLogger, hrTimeToMilliseconds } from '@opentelemetry/core';
import * as types from '@opentelemetry/types';
import { ZipkinExporter } from '../src';
import * as zipkinTypes from '../src/types';
import { OT_HEADER_NAME } from '../src/utils';

const MICROS_PER_MILLI = 1000;

Expand Down Expand Up @@ -242,11 +243,11 @@ describe('ZipkinExporter', () => {
});
});

it(`should send '${ZipkinExporter.OT_HEADER_NAME}' header`, () => {
it(`should send '${OT_HEADER_NAME}' header`, () => {
const scope = nock('https://localhost:9411')
.post('/api/v2/spans')
.reply(function(uri, requestBody, cb) {
assert.ok(this.req.headers[ZipkinExporter.OT_HEADER_NAME]);
assert.ok(this.req.headers[OT_HEADER_NAME]);
cb(null, [200, 'Ok']);
});

Expand Down

0 comments on commit b82a20a

Please sign in to comment.