forked from open-telemetry/opentelemetry-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(koa): migrate koa example to opentelemetry-instrumentation-koa (o…
…pen-telemetry#1118) * fix(migrate-koa-example): migrate koa example to opentelemetry-instrumentation-koa * chore(koa): fix READMEs, versioning and imports * chore(koa): remove redundant imports * chore(koa): fix server imports * chore(koa): add if to verity span exist
- Loading branch information
1 parent
44f9527
commit b406b1d
Showing
14 changed files
with
105 additions
and
84 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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
build | ||
examples |
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
File renamed without changes.
File renamed without changes
File renamed without changes
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
44 changes: 44 additions & 0 deletions
44
plugins/node/opentelemetry-instrumentation-koa/examples/src/tracer.ts
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,44 @@ | ||
'use strict'; | ||
|
||
import { KoaInstrumentation } from '@opentelemetry/instrumentation-koa'; | ||
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http'; | ||
|
||
import * as api from '@opentelemetry/api'; | ||
import { registerInstrumentations } from '@opentelemetry/instrumentation'; | ||
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'; | ||
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base'; | ||
import { JaegerExporter } from '@opentelemetry/exporter-jaeger'; | ||
import { ZipkinExporter } from '@opentelemetry/exporter-zipkin'; | ||
import { Resource } from '@opentelemetry/resources'; | ||
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions' | ||
|
||
const EXPORTER = process.env.EXPORTER || ''; | ||
|
||
export const setupTracing = (serviceName: string) => { | ||
const provider = new NodeTracerProvider({ | ||
resource: new Resource({ | ||
[SemanticResourceAttributes.SERVICE_NAME]: serviceName | ||
}) | ||
}); | ||
|
||
let exporter; | ||
if (EXPORTER === 'jaeger') { | ||
exporter = new JaegerExporter(); | ||
} else { | ||
exporter = new ZipkinExporter(); | ||
} | ||
provider.addSpanProcessor(new SimpleSpanProcessor(exporter)); | ||
|
||
registerInstrumentations({ | ||
instrumentations: [ | ||
new KoaInstrumentation(), | ||
new HttpInstrumentation(), | ||
], | ||
tracerProvider: provider, | ||
}); | ||
|
||
// Initialize the OpenTelemetry APIs to use the NodeTracerProvider bindings | ||
provider.register(); | ||
|
||
return api.trace.getTracer(serviceName); | ||
}; |
10 changes: 10 additions & 0 deletions
10
plugins/node/opentelemetry-instrumentation-koa/examples/tsconfig.json
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,10 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"noEmit": true, | ||
"rootDir": ".", | ||
}, | ||
"include": [ | ||
"src/**/*.ts", | ||
] | ||
} |
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