-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@artusx/otl): split to olt/tracer/meter, and update usages
- Loading branch information
Showing
22 changed files
with
1,260 additions
and
254 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import path from 'path'; | ||
import { setupTracing } from '@artusx/otl'; | ||
import { initOtl, initMeter, initTracer } from '@artusx/otl'; | ||
import { bootstrap } from '@artusx/utils'; | ||
|
||
const ROOT_DIR = path.resolve(__dirname); | ||
|
||
setupTracing('artusx-koa'); | ||
initOtl('artusx-koa', '1.0.0'); | ||
initMeter(); | ||
initTracer(); | ||
|
||
bootstrap({ root: ROOT_DIR }); |
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 |
---|---|---|
@@ -1,9 +1,15 @@ | ||
.nav { | ||
nav { | ||
padding: 2em 4em; | ||
display: flex; | ||
gap: 1em; | ||
} | ||
|
||
header, | ||
main, | ||
footer { | ||
padding: 2em 4em; | ||
} | ||
|
||
.container { | ||
margin: 2em 4em; | ||
} |
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 @@ | ||
<nav> | ||
<a href="/ejs">ejs</a> | ||
<a href="/ejs/user-list">user-list</a> | ||
<a href="/ejs/user-detail">user-detail</a> | ||
</nav> |
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...pps/artusx-koa/src/view-ejs/user/show.ejs → ...s/artusx-koa/src/view-ejs/user/detail.ejs
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<div> | ||
<div class="container"> | ||
<h2>show</h2> | ||
<%= name %> | ||
</div> | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<div> | ||
<div class="info"> | ||
<h2>info</h2> | ||
<%= name %> | ||
</div> |
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,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title><%= title %></title> | ||
<link rel="stylesheet" href="/public/style.css" /> | ||
</head> | ||
<body> | ||
<%= people.join(", "); %> | ||
|
||
<%- include('user/detail') %> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<div class="nav"> | ||
<a href="/">Home</a> | ||
<a href="/html">HTML</a> | ||
</div> | ||
<nav> | ||
<a href="/">home</a> | ||
<a href="/html">html</a> | ||
<a href="/ejs">ejs</a> | ||
</nav> |
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 |
---|---|---|
@@ -1 +1,76 @@ | ||
# @artusx/plugin-opentelemetry | ||
# @artusx/otl | ||
|
||
Opentelemetry for ArtusX. | ||
|
||
## Usage | ||
|
||
### Automatic Instrumentation setup | ||
|
||
init opentelemetry with default config. | ||
|
||
- KoaInstrumentation | ||
- HttpInstrumentation | ||
|
||
```ts | ||
import path from 'path'; | ||
import { initOtl } from '@artusx/otl'; | ||
import { bootstrap } from '@artusx/utils'; | ||
|
||
const ROOT_DIR = path.resolve(__dirname); | ||
|
||
initOtl('artusx-koa', '1.0.0'); | ||
bootstrap({ root: ROOT_DIR }); | ||
``` | ||
|
||
### Manual instrumentation setup | ||
|
||
custom tracer and meter. | ||
|
||
```ts | ||
import path from 'path'; | ||
import { | ||
initOtl, | ||
initMeter, | ||
initTracer, | ||
} from '@artusx/otl'; | ||
import { bootstrap } from '@artusx/utils'; | ||
|
||
const ROOT_DIR = path.resolve(__dirname); | ||
|
||
// initOtl('artusx-koa', '1.0.0'); | ||
initMeter(); | ||
initTracer(); | ||
|
||
bootstrap({ root: ROOT_DIR }); | ||
``` | ||
|
||
#### addEvent and counter | ||
|
||
```ts | ||
import { ArtusXInjectEnum, Inject, Controller, GET } from '@artusx/core'; | ||
import { getMeter, getTracer, Span } from '@artusx/otl'; | ||
|
||
const meter = getMeter('artusx-koa', '1.0.0'); | ||
const tracer = getTracer('artusx-koa', '1.0.0'); | ||
const homeCounter = meter.createCounter('home.counter'); | ||
|
||
@Controller() | ||
export default class HomeController { | ||
@Inject(ArtusXInjectEnum.Nunjucks) | ||
nunjucks: NunjucksClient; | ||
|
||
@GET('/') | ||
async home(ctx: ArtusXContext) { | ||
// meter | ||
homeCounter.add(1); | ||
|
||
// tracer | ||
tracer.startActiveSpan('home', (span: Span) => { | ||
span.addEvent('home', { key: 'home', value: Math.random() }); | ||
|
||
ctx.body = this.nunjucks.render('index.html', { title: 'ArtusX', message: 'Hello ArtusX!' }); | ||
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
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,12 @@ | ||
import { SEMRESATTRS_SERVICE_NAME, SEMRESATTRS_SERVICE_VERSION } from '@opentelemetry/semantic-conventions'; | ||
|
||
import { Resource } from '@opentelemetry/resources'; | ||
|
||
export const initResource = (name?: string, version?: string) => { | ||
const resource = new Resource({ | ||
[SEMRESATTRS_SERVICE_NAME]: name || 'artusx', | ||
[SEMRESATTRS_SERVICE_VERSION]: version || '1.0', | ||
}); | ||
|
||
return Resource.default().merge(resource); | ||
}; |
Oops, something went wrong.