Skip to content

Commit

Permalink
Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
myrotvorets-team committed Oct 6, 2023
1 parent c408089 commit 6f7fa51
Show file tree
Hide file tree
Showing 11 changed files with 2,150 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
/.vscode
/coverage
/dist
/node_modules
node_modules
/test-report.xml
33 changes: 9 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,16 @@ OpenTelemetry knex automatic instrumentation package
## Usage

```typescript
import opentelemetry from '@opentelemetry/api';
import { NodeTracerProvider } from '@opentelemetry/node';
import { SimpleSpanProcessor } from '@opentelemetry/tracing';
import { ZipkinExporter } from '@opentelemetry/exporter-zipkin';
import { NodeSDK } from '@opentelemetry/sdk-node';
import { KnexInstrumentation } from '@myrotvorets/opentelemetry-plugin-knex';
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';

const provider = new NodeTracerProvider({
plugins: {
knex: {
path: '@myrotvorets/opentelemetry-plugin-knex',
},
// Add other plugins as needed
http: {},
https: {},
},
const sdk = new NodeSDK({
serviceName: 'example',
instrumentations: [new HttpInstrumentation(), new KnexInstrumentation()],
});

// Add exporters as needed
const zipkinExporter = new ZipkinExporter({
url: process.env.ZIPKIN_ENDPOINT,
serviceName: 'my-service',
});

const zipkinProcessor = new SimpleSpanProcessor(zipkinExporter);
provider.addSpanProcessor(zipkinProcessor);

// Go!
provider.register();
sdk.start();
```

See the `example` directory for a working example.
6 changes: 6 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# opentelemetry-plugin-knex Usage Example

```sh
docker run -it --rm -d -p 9411:9411 openzipkin/zipkin
OTEL_BSP_SCHEDULE_DELAY=0 OTEL_TRACES_EXPORTER=zipkin npx ts-node src/index.ts
```
Loading

0 comments on commit 6f7fa51

Please sign in to comment.