File tree Expand file tree Collapse file tree 4 files changed +22
-1
lines changed
packages/opentelemetry-exporter-zipkin Expand file tree Collapse file tree 4 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,12 @@ Install the exporter on your application and pass the options. `serviceName` is
24
24
const { ZipkinExporter } = require (' @opentelemetry/exporter-zipkin' );
25
25
26
26
// Add your zipkin url (`http://localhost:9411/api/v2/spans` is used as
27
- // default) and application name to the Zipkin options
27
+ // default) and application name to the Zipkin options.
28
+ // You can also define your custom headers which will be added automatically.
28
29
const options = {
30
+ headers: {
31
+ ' my-header' : ' header-value' ,
32
+ },
29
33
url: ' your-zipkin-url' ,
30
34
serviceName: ' your-application-name'
31
35
}
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import * as api from '@opentelemetry/api';
20
20
* Exporter config
21
21
*/
22
22
export interface ExporterConfig {
23
+ headers ?: { [ key : string ] : string } ;
23
24
logger ?: api . Logger ;
24
25
serviceName ?: string ;
25
26
url ?: string ;
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ export class ZipkinExporter implements SpanExporter {
52
52
headers : {
53
53
'Content-Type' : 'application/json' ,
54
54
[ OT_REQUEST_HEADER ] : 1 ,
55
+ ...config . headers ,
55
56
} ,
56
57
} ,
57
58
urlOpts
Original file line number Diff line number Diff line change @@ -97,6 +97,21 @@ describe('ZipkinExporter', () => {
97
97
assert . ok ( typeof exporter . export === 'function' ) ;
98
98
assert . ok ( typeof exporter . shutdown === 'function' ) ;
99
99
} ) ;
100
+ it ( 'should construct an exporter with headers' , ( ) => {
101
+ const exporter = new ZipkinExporter ( {
102
+ headers : {
103
+ foo : 'bar' ,
104
+ } ,
105
+ } ) ;
106
+ interface ExporterWithHeaders {
107
+ _reqOpts : {
108
+ headers : { [ key : string ] : string } ;
109
+ } ;
110
+ }
111
+ const exporterWithHeaders = ( exporter as unknown ) as ExporterWithHeaders ;
112
+
113
+ assert . ok ( exporterWithHeaders . _reqOpts . headers [ 'foo' ] === 'bar' ) ;
114
+ } ) ;
100
115
} ) ;
101
116
102
117
describe ( 'export' , ( ) => {
You can’t perform that action at this time.
0 commit comments