@opentelemetry/exporter-zipkin
Advanced tools
Comparing version 0.8.3 to 0.9.0
@@ -1,17 +0,2 @@ | ||
/*! | ||
* 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 * from './zipkin'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
/*! | ||
* Copyright 2019, OpenTelemetry Authors | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
@@ -17,7 +17,14 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
*/ | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./zipkin")); | ||
__exportStar(require("./zipkin"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -1,16 +0,1 @@ | ||
/*! | ||
* 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 api from '@opentelemetry/api'; | ||
@@ -17,0 +2,0 @@ import { ReadableSpan } from '@opentelemetry/tracing'; |
"use strict"; | ||
/*! | ||
* Copyright 2019, OpenTelemetry Authors | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
@@ -18,2 +18,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports._toZipkinAnnotations = exports._toZipkinTags = exports.toZipkinSpan = exports.statusDescriptionTagName = exports.statusCodeTagName = void 0; | ||
const api = require("@opentelemetry/api"); | ||
@@ -20,0 +21,0 @@ const core_1 = require("@opentelemetry/core"); |
@@ -1,16 +0,1 @@ | ||
/*! | ||
* 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 api from '@opentelemetry/api'; | ||
@@ -21,4 +6,7 @@ /** | ||
export interface ExporterConfig { | ||
headers?: { | ||
[key: string]: string; | ||
}; | ||
logger?: api.Logger; | ||
serviceName: string; | ||
serviceName?: string; | ||
url?: string; | ||
@@ -25,0 +13,0 @@ statusCodeTagName?: string; |
"use strict"; | ||
/*! | ||
* Copyright 2019, OpenTelemetry Authors | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
@@ -18,2 +18,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SpanKind = void 0; | ||
/** | ||
@@ -20,0 +21,0 @@ * When present, kind clarifies timestamp, duration and remoteEndpoint. When |
@@ -1,17 +0,2 @@ | ||
/*! | ||
* 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 declare const OT_REQUEST_HEADER = "x-opentelemetry-outgoing-request"; | ||
//# sourceMappingURL=utils.d.ts.map |
"use strict"; | ||
/*! | ||
* Copyright 2019, OpenTelemetry Authors | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
@@ -18,3 +18,4 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OT_REQUEST_HEADER = void 0; | ||
exports.OT_REQUEST_HEADER = 'x-opentelemetry-outgoing-request'; | ||
//# sourceMappingURL=utils.js.map |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.8.3"; | ||
export declare const VERSION = "0.9.0"; | ||
//# sourceMappingURL=version.d.ts.map |
"use strict"; | ||
/* | ||
* Copyright 2020, OpenTelemetry Authors | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
@@ -18,4 +18,5 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VERSION = void 0; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.8.3'; | ||
exports.VERSION = '0.9.0'; | ||
//# sourceMappingURL=version.js.map |
@@ -1,16 +0,1 @@ | ||
/*! | ||
* 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 { ExportResult } from '@opentelemetry/core'; | ||
@@ -24,9 +9,10 @@ import { SpanExporter, ReadableSpan } from '@opentelemetry/tracing'; | ||
static readonly DEFAULT_URL = "http://localhost:9411/api/v2/spans"; | ||
private readonly DEFAULT_SERVICE_NAME; | ||
private readonly _logger; | ||
private readonly _serviceName; | ||
private readonly _statusCodeTagName; | ||
private readonly _statusDescriptionTagName; | ||
private readonly _reqOpts; | ||
private _serviceName?; | ||
private _isShutdown; | ||
constructor(config: zipkinTypes.ExporterConfig); | ||
constructor(config?: zipkinTypes.ExporterConfig); | ||
/** | ||
@@ -41,6 +27,2 @@ * Export spans. | ||
/** | ||
* Transforms an OpenTelemetry span to a Zipkin span. | ||
*/ | ||
private _toZipkinSpan; | ||
/** | ||
* Transform spans and sends to Zipkin service. | ||
@@ -47,0 +29,0 @@ */ |
"use strict"; | ||
/*! | ||
* Copyright 2019, OpenTelemetry Authors | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
@@ -18,2 +18,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ZipkinExporter = void 0; | ||
const http = require("http"); | ||
@@ -25,2 +26,3 @@ const https = require("https"); | ||
const utils_1 = require("./utils"); | ||
const resources_1 = require("@opentelemetry/resources"); | ||
/** | ||
@@ -30,3 +32,4 @@ * Zipkin Exporter | ||
class ZipkinExporter { | ||
constructor(config) { | ||
constructor(config = {}) { | ||
this.DEFAULT_SERVICE_NAME = 'OpenTelemetry Service'; | ||
const urlStr = config.url || ZipkinExporter.DEFAULT_URL; | ||
@@ -37,6 +40,3 @@ const urlOpts = url.parse(urlStr); | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
[utils_1.OT_REQUEST_HEADER]: 1, | ||
}, | ||
headers: Object.assign({ 'Content-Type': 'application/json', [utils_1.OT_REQUEST_HEADER]: 1 }, config.headers), | ||
}, urlOpts); | ||
@@ -53,2 +53,6 @@ this._serviceName = config.serviceName; | ||
export(spans, resultCallback) { | ||
if (typeof this._serviceName !== 'string') { | ||
this._serviceName = String(spans[0].resource.labels[resources_1.SERVICE_RESOURCE.NAME] || | ||
this.DEFAULT_SERVICE_NAME); | ||
} | ||
this._logger.debug('Zipkin exporter export'); | ||
@@ -59,3 +63,3 @@ if (this._isShutdown) { | ||
} | ||
return this._sendSpans(spans, resultCallback); | ||
return this._sendSpans(spans, this._serviceName, resultCallback); | ||
} | ||
@@ -73,12 +77,6 @@ /** | ||
/** | ||
* Transforms an OpenTelemetry span to a Zipkin span. | ||
*/ | ||
_toZipkinSpan(span) { | ||
return transform_1.toZipkinSpan(span, this._serviceName, this._statusCodeTagName, this._statusDescriptionTagName); | ||
} | ||
/** | ||
* Transform spans and sends to Zipkin service. | ||
*/ | ||
_sendSpans(spans, done) { | ||
const zipkinSpans = spans.map(span => this._toZipkinSpan(span)); | ||
_sendSpans(spans, serviceName, done) { | ||
const zipkinSpans = spans.map(span => transform_1.toZipkinSpan(span, serviceName, this._statusCodeTagName, this._statusDescriptionTagName)); | ||
return this._send(zipkinSpans, (result) => { | ||
@@ -85,0 +83,0 @@ if (done) { |
{ | ||
"name": "@opentelemetry/exporter-zipkin", | ||
"version": "0.8.3", | ||
"version": "0.9.0", | ||
"description": "OpenTelemetry Zipkin Exporter allows the user to send collected traces to Zipkin.", | ||
@@ -42,20 +42,20 @@ "main": "build/src/index.js", | ||
"devDependencies": { | ||
"@types/mocha": "^7.0.0", | ||
"@types/node": "^14.0.5", | ||
"codecov": "^3.6.1", | ||
"gts": "^2.0.0", | ||
"mocha": "^7.1.2", | ||
"nock": "^11.0.0", | ||
"nyc": "^15.0.0", | ||
"rimraf": "^3.0.0", | ||
"ts-mocha": "^7.0.0", | ||
"ts-node": "^8.6.2", | ||
"typescript": "3.7.2" | ||
"@types/mocha": "7.0.2", | ||
"@types/node": "14.0.13", | ||
"codecov": "3.7.0", | ||
"gts": "2.0.2", | ||
"mocha": "7.2.0", | ||
"nock": "12.0.3", | ||
"nyc": "15.1.0", | ||
"rimraf": "3.0.2", | ||
"ts-mocha": "7.0.0", | ||
"ts-node": "8.10.2", | ||
"typescript": "3.9.5" | ||
}, | ||
"dependencies": { | ||
"@opentelemetry/api": "^0.8.3", | ||
"@opentelemetry/core": "^0.8.3", | ||
"@opentelemetry/resources": "^0.8.3", | ||
"@opentelemetry/tracing": "^0.8.3" | ||
"@opentelemetry/api": "^0.9.0", | ||
"@opentelemetry/core": "^0.9.0", | ||
"@opentelemetry/resources": "^0.9.0", | ||
"@opentelemetry/tracing": "^0.9.0" | ||
} | ||
} |
# OpenTelemetry Zipkin Trace Exporter | ||
[![Gitter chat][gitter-image]][gitter-url] | ||
@@ -20,3 +21,3 @@ [![NPM Published Version][npm-img]][npm-url] | ||
Install the exporter on your application and pass the options, it must contain a service name. | ||
Install the exporter on your application and pass the options. `serviceName` is an optional string. If omitted, the exporter will first try to get the service name from the Resource. If no service name can be detected on the Resource, a fallback name of "OpenTelemetry Service" will be used. | ||
@@ -27,4 +28,8 @@ ```js | ||
// 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', | ||
@@ -49,8 +54,9 @@ serviceName: 'your-application-name' | ||
Please visit the Zipkin UI endpoint http://localhost:9411 | ||
Please visit the Zipkin UI endpoint <http://localhost:9411> | ||
## Useful links | ||
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/> | ||
- For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js> | ||
- For Zipkin project at https://zipkin.io/ | ||
- For Zipkin project at <https://zipkin.io/> | ||
- For help or feedback on this project, join us on [gitter][gitter-url] | ||
@@ -57,0 +63,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
75
37123
521
+ Added@opentelemetry/api@0.9.0(transitive)
+ Added@opentelemetry/context-base@0.9.0(transitive)
+ Added@opentelemetry/core@0.9.0(transitive)
+ Added@opentelemetry/resources@0.9.0(transitive)
+ Added@opentelemetry/tracing@0.9.0(transitive)
- Removed@opentelemetry/api@0.8.3(transitive)
- Removed@opentelemetry/context-base@0.8.3(transitive)
- Removed@opentelemetry/core@0.8.3(transitive)
- Removed@opentelemetry/resources@0.8.3(transitive)
- Removed@opentelemetry/tracing@0.8.3(transitive)
Updated@opentelemetry/api@^0.9.0
Updated@opentelemetry/core@^0.9.0