-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start instrumenting sql connections and queries
- Loading branch information
Showing
19 changed files
with
806 additions
and
2,786 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
docker run -d --name jaeger \ | ||
-e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \ | ||
-e COLLECTOR_OTLP_ENABLED=true \ | ||
-p 6831:6831/udp \ | ||
-p 6832:6832/udp \ | ||
-p 5778:5778 \ | ||
-p 16686:16686 \ | ||
-p 4317:4317 \ | ||
-p 4318:4318 \ | ||
-p 14250:14250 \ | ||
-p 14268:14268 \ | ||
-p 14269:14269 \ | ||
-p 9411:9411 \ | ||
jaegertracing/all-in-one:1.37 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { tracer } from '@aphro/instrument'; | ||
|
||
tracer.configure('@aphro/absurd-sql-connector', '0.2.1'); | ||
|
||
export default tracer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# instrument | ||
|
||
Helper functions to trace and measure program execution. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "@aphro/instrument", | ||
"version": "0.0.1", | ||
"main": "lib/index.js", | ||
"type": "module", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/tantaman/aphrodite.git", | ||
"directory": "packages/instrument" | ||
}, | ||
"dependencies": { | ||
"@opentelemetry/api": "^1.1.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.17.12", | ||
"@babel/preset-env": "^7.17.12", | ||
"@types/jest": "^27.4.1", | ||
"jest": "^28.1.0", | ||
"ts-jest": "^28.0.1", | ||
"typescript": "^4.6.4" | ||
}, | ||
"scripts": { | ||
"clean": "tsc --build --clean", | ||
"build": "tsc --build", | ||
"watch": "tsc --build -w", | ||
"test": "node ./node_modules/jest/bin/jest.js", | ||
"deep-clean": "rm -rf ./lib || true && rm tsconfig.tsbuildinfo || true" | ||
}, | ||
"jest": { | ||
"testMatch": [ | ||
"**/__tests__/**/*.test.js" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as tracer } from './tracer.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { SpanStatusCode, trace, Tracer } from '@opentelemetry/api'; | ||
|
||
let tracer: Tracer; | ||
|
||
export default { | ||
configure(pkg: string, version: string) { | ||
tracer = trace.getTracer(pkg, version); | ||
}, | ||
|
||
get tracer() { | ||
return tracer; | ||
}, | ||
|
||
startSpan(name: string) { | ||
return tracer.startSpan(name); | ||
}, | ||
|
||
startActiveSpan<T>(name: string, cb: () => T): T { | ||
return tracer.startActiveSpan(name, span => { | ||
try { | ||
return cb(); | ||
} catch (e) { | ||
span.recordException(e); | ||
throw e; | ||
} finally { | ||
span.end(); | ||
} | ||
}); | ||
}, | ||
|
||
genStartActiveSpan<T>(name: string, cb: () => Promise<T>): Promise<T> { | ||
return tracer.startActiveSpan(name, async span => { | ||
try { | ||
return await cb(); | ||
} catch (e) { | ||
span.recordException(e); | ||
throw e; | ||
} finally { | ||
span.end(); | ||
} | ||
}); | ||
}, | ||
|
||
async genSpan<T>(name: string, cb: () => Promise<T>): Promise<T> { | ||
const span = tracer.startSpan(name); | ||
try { | ||
return await cb(); | ||
} catch (e) { | ||
span.recordException(e); | ||
throw e; | ||
} finally { | ||
span.end(); | ||
} | ||
}, | ||
|
||
span<T>(name: string, cb: () => T): T { | ||
const span = tracer.startSpan(name); | ||
try { | ||
return cb(); | ||
} catch (e) { | ||
span.recordException(e); | ||
throw e; | ||
} finally { | ||
span.end(); | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "../../tsconfig-templates/lib.json", | ||
"compilerOptions": { | ||
"outDir": "./lib/", | ||
"rootDir": "./src" | ||
}, | ||
"include": ["./src/"], | ||
"references": [] | ||
} |
Oops, something went wrong.