Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds possibility to set headers to zipkin exporter #1202

Merged
merged 7 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/opentelemetry-exporter-zipkin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ Install the exporter on your application and pass the options. `serviceName` is
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');

// Add your zipkin url (`http://localhost:9411/api/v2/spans` is used as
// default) and application name to the Zipkin options
// default) and application name to the Zipkin options.
// You can also define your custom headers which will be added automatically.
const options = {
headers: {
'my-header': 'header-value',
},
url: 'your-zipkin-url',
serviceName: 'your-application-name'
}
Expand Down
1 change: 1 addition & 0 deletions packages/opentelemetry-exporter-zipkin/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import * as api from '@opentelemetry/api';
* Exporter config
*/
export interface ExporterConfig {
headers?: { [key: string]: string };
logger?: api.Logger;
serviceName?: string;
url?: string;
Expand Down
1 change: 1 addition & 0 deletions packages/opentelemetry-exporter-zipkin/src/zipkin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class ZipkinExporter implements SpanExporter {
headers: {
'Content-Type': 'application/json',
[OT_REQUEST_HEADER]: 1,
...config.headers,
},
},
urlOpts
Expand Down
15 changes: 15 additions & 0 deletions packages/opentelemetry-exporter-zipkin/test/zipkin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,21 @@ describe('ZipkinExporter', () => {
assert.ok(typeof exporter.export === 'function');
assert.ok(typeof exporter.shutdown === 'function');
});
it('should construct an exporter with headers', () => {
const exporter = new ZipkinExporter({
headers: {
foo: 'bar',
},
});
interface ExporterWithHeaders {
_reqOpts: {
headers: { [key: string]: string };
};
}
const exporterWithHeaders = (exporter as unknown) as ExporterWithHeaders;

assert.ok(exporterWithHeaders._reqOpts.headers['foo'] === 'bar');
});
});

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