Skip to content

Open Tracing Implementation #1918

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

Merged
merged 11 commits into from
Mar 6, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ since we removed some methods from the public API and removed some classes from
- **breaking** [all] build: Use `es6` target instead of esnext for ESM builds
- [all] feat: Prefix all private methods with `_`
- [all] build: Use terser instead of uglify
- [opentracing] feat: Introduce `@sentry/opentracing` providing functions to attach opentracing data to Sentry Events

## 4.6.4

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build:watch": "lerna run build:watch --stream --no-sort --concurrency 9999",
"clean": "lerna run --stream clean",
"fix": "lerna run --stream --concurrency 1 fix",
"link:yarn": "lerna run --stream --concurrency 1 link:yarn",
"lint": "lerna run --stream --concurrency 1 lint",
"lint:json": "lerna run --stream --concurrency 1 lint:tslint:json",
"test": "lerna run --stream --concurrency 1 --sort test",
Expand All @@ -19,6 +20,7 @@
"packages/integrations",
"packages/minimal",
"packages/node",
"packages/opentracing",
"packages/types",
"packages/typescript",
"packages/utils"
Expand Down
1 change: 1 addition & 0 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"build:esm": "tsc -p tsconfig.esm.json",
"build:watch": "rollup --config --watch",
"clean": "rimraf dist coverage .rpt2_cache build esm",
"link:yarn": "yarn link",
"lint": "run-s lint:prettier lint:tslint",
"lint:prettier": "prettier-check \"{src,test}/**/*.ts\"",
"lint:tslint": "tslint -t stylish -p .",
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"build:esm": "tsc -p tsconfig.esm.json",
"build:watch": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
"clean": "rimraf dist coverage",
"link:yarn": "yarn link",
"lint": "run-s lint:prettier lint:tslint",
"lint:prettier": "prettier-check \"{src,test}/**/*.ts\"",
"lint:tslint": "tslint -t stylish -p .",
Expand Down
1 change: 1 addition & 0 deletions packages/hub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"build:esm": "tsc -p tsconfig.esm.json",
"build:watch": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
"clean": "rimraf dist coverage",
"link:yarn": "yarn link",
"lint": "run-s lint:prettier lint:tslint",
"lint:prettier": "prettier-check \"{src,test}/**/*.ts\"",
"lint:tslint": "tslint -t stylish -p .",
Expand Down
1 change: 1 addition & 0 deletions packages/minimal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"build:esm": "tsc -p tsconfig.esm.json",
"build:watch": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
"clean": "rimraf dist coverage",
"link:yarn": "yarn link",
"lint": "run-s lint:prettier lint:tslint",
"lint:prettier": "prettier-check \"{src,test}/**/*.ts\"",
"lint:tslint": "tslint -t stylish -p .",
Expand Down
1 change: 1 addition & 0 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"build": "tsc -p tsconfig.build.json",
"build:watch": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
"clean": "rimraf dist coverage",
"link:yarn": "yarn link",
"lint": "run-s lint:prettier lint:tslint",
"lint:prettier": "prettier-check \"{src,test}/**/*.ts\"",
"lint:tslint": "tslint -t stylish -p .",
Expand Down
3 changes: 3 additions & 0 deletions packages/opentracing/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!/dist/**/*
!/esm/**/*
29 changes: 29 additions & 0 deletions packages/opentracing/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2019, Sentry
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 changes: 22 additions & 0 deletions packages/opentracing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<p align="center">
<a href="https://sentry.io" target="_blank" align="center">
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
</a>
<br />
</p>

# Sentry JavaScript OpenTracing API

[![npm version](https://img.shields.io/npm/v/@sentry/opentracing.svg)](https://www.npmjs.com/package/@sentry/opentracing)
[![npm dm](https://img.shields.io/npm/dm/@sentry/opentracing.svg)](https://www.npmjs.com/package/@sentry/opentracing)
[![npm dt](https://img.shields.io/npm/dt/@sentry/opentracing.svg)](https://www.npmjs.com/package/@sentry/opentracing)
[![typedoc](https://img.shields.io/badge/docs-typedoc-blue.svg)](http://getsentry.github.io/sentry-javascript/)

## Links

- [Official SDK Docs](https://docs.sentry.io/quickstart/)
- [TypeDoc](http://getsentry.github.io/sentry-javascript/)

## General

TBD
71 changes: 71 additions & 0 deletions packages/opentracing/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"name": "@sentry/opentracing",
"version": "5.0.0-beta0",
"description": "Sentry OpenTracing SDK",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/minimal",
"author": "Sentry",
"license": "BSD-3-Clause",
"engines": {
"node": ">=6"
},
"main": "dist/index.js",
"module": "esm/index.js",
"types": "dist/index.d.ts",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@sentry/hub": "5.0.0-beta0",
"@sentry/utils": "5.0.0-beta0",
"@sentry/types": "5.0.0-beta0",
"opentracing": "0.14.3"
},
"devDependencies": {
"jest": "^24.1.0",
"npm-run-all": "^4.1.2",
"prettier": "^1.16.4",
"prettier-check": "^2.0.0",
"rimraf": "^2.6.3",
"tslint": "^5.12.1",
"typescript": "^3.3.3"
},
"scripts": {
"build": "run-p build:es5 build:esm",
"build:es5": "tsc -p tsconfig.build.json",
"build:esm": "tsc -p tsconfig.esm.json",
"build:watch": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
"clean": "rimraf dist coverage",
"link:yarn": "yarn link",
"lint": "run-s lint:prettier lint:tslint",
"lint:prettier": "prettier-check \"{src,test}/**/*.ts\"",
"lint:tslint": "tslint -t stylish -p .",
"lint:tslint:json": "tslint --format json -p . | tee lint-results.json",
"fix": "run-s fix:tslint fix:prettier",
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
"fix:tslint": "tslint --fix -t stylish -p .",
"test": "jest --passWithNoTests",
"test:watch": "jest --watch --passWithNoTests"
},
"jest": {
"collectCoverage": true,
"transform": {
"^.+\\.ts$": "ts-jest"
},
"moduleFileExtensions": [
"js",
"ts"
],
"testEnvironment": "node",
"testMatch": [
"**/*.test.ts"
],
"globals": {
"ts-jest": {
"tsConfig": "./tsconfig.json",
"diagnostics": false
}
}
},
"sideEffects": false
}
3 changes: 3 additions & 0 deletions packages/opentracing/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { Span } from './span';
export { Tracer } from './tracer';
export { OpenTracingIntegration as Integration } from './opentracingintegration';
45 changes: 45 additions & 0 deletions packages/opentracing/src/opentracingintegration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Integration } from '@sentry/types';
import { Tracer } from './tracer';

/**
* Session Tracking Integration
*/
export class OpenTracingIntegration implements Integration {
/**
* @inheritDoc
*/
public name: string = OpenTracingIntegration.id;

/**
* @inheritDoc
*/
public static id: string = 'OpenTracingIntegration';

/**
* Constructor for OpenTracingIntegration
*
* @param traceId Optional TraceId that should be set into the integration.
* @param _tracer Optional custom tracer that should be used.
*/
public constructor(traceId?: string, private readonly _tracer: Tracer = new Tracer()) {
_tracer.setTraceId(traceId);
}

/**
* @inheritDoc
*/
public setupOnce(): void {
const span = this._tracer.startSpan('sdk.init');
span.finish();
setTimeout(() => {
this._tracer.flush();
});
}

/**
* Returns the Tracer which can be used as the parent.
*/
public getTracer(): Tracer {
return this._tracer;
}
}
Loading