Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit cfa6e4c

Browse files
OrGeva10gitbook-bot
authored andcommitted
GitBook: [#155] package to service, auto instrument and otlp endpoint option
1 parent 0b2d48e commit cfa6e4c

File tree

5 files changed

+56
-27
lines changed

5 files changed

+56
-27
lines changed

send-tracing-data-to-aspecto/aspecto-sdk/nodejs/README.md

+28
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,34 @@ Install our Node.js library using `npm`:
1212
$ npm install @aspecto/opentelemetry
1313
```
1414

15+
#### Auto Instrument
16+
17+
1. Use node `-r` (or `--require`) [cli option](https://nodejs.org/api/cli.html#-r---require-module) to preload Aspecto SDK before application start:
18+
19+
```
20+
-r @aspecto/opentelemetry/auto-instrument
21+
```
22+
23+
e.g. your `node` invocation should look like this:
24+
25+
```
26+
// before
27+
node ./app
28+
29+
// after
30+
node -r @aspecto/opentelemetry/auto-instrument ./app
31+
```
32+
33+
2\. Set `aspectoAuth` and other optional SDK options via [environment variables or `aspecto.json` file](customize-defaults/advanced.md).
34+
35+
For example:
36+
37+
```
38+
ASPECTO_AUTH="*your-token-goes-here*" node -r @aspecto/opentelemetry/auto-instrument ./app
39+
```
40+
41+
#### Initialise in Code
42+
1543
After obtaining your token [here](https://app.aspecto.io/app/integration/api-key), **before any other import,** add the following call at the top of your app entry point:
1644

1745
{% tabs %}

send-tracing-data-to-aspecto/aspecto-sdk/nodejs/customize-defaults/advanced.md

+24-23
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ You can pass a configuration **options object** when initializing Aspecto in cod
1010

1111
```javascript
1212
require('@aspecto/opentelemetry')({
13-
packageName: 'my-package',
13+
serviceName: 'my-service',
1414
env: 'production',
1515
samplingRatio: 0.1
1616
});
@@ -20,7 +20,7 @@ Or add configuration **file** named `aspecto.json` near your `package.json` with
2020

2121
```
2222
{
23-
packageName: 'my-package',
23+
serviceName: 'my-service',
2424
env: 'production',
2525
samplingRatio: 0.1
2626
}
@@ -29,7 +29,7 @@ Or add configuration **file** named `aspecto.json` near your `package.json` with
2929
Or use various environment variables, for example:
3030

3131
```
32-
export ASPECTO_PACKAGE_NAME=my-package
32+
export OTEL_SERVICE_NAME=my-service
3333
```
3434

3535
Values are evaluated in the following priority:
@@ -44,26 +44,27 @@ Values are evaluated in the following priority:
4444
\
4545
Available install configurations (all are optional):
4646

47-
| Option | Environment Variable | Type | Default | Description |
48-
| ----------------------------------------- | ------------------------------------------------------ | ---------------- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
49-
| `disableAspecto` | `DISABLE_ASPECTO` | boolean | `false` (aspecto enabled) | Disable aspecto |
50-
| `env` | `NODE_ENV` | string | `process.env.NODE_ENV` | Set environment name manually |
51-
| `aspectoAuth` | `ASPECTO_AUTH` | UUID | | Set Aspecto token from code instead of using `aspecto.json` |
52-
| `packageName` | `ASPECTO_PACKAGE_NAME` | string | "name" in `package.json` | Set packageName manually instead of reading it from `package.json`. For example: a service that runs in multiple "modes" |
53-
| `packageVersion` | `ASPECTO_PACKAGE_VERSION` | string | "version" in `package.json` | Set packageVersion manually instead of reading it from `package.json` |
54-
| `samplingRatio` | `ASPECTO_SAMPLING_RATIO` | number | `1.0` | How many of the traces starting in this service should be sampled. Set to number in range \[0.0, 1.0] where `0.0` is no sampling, and `1.0` is sample all. Specific rules set via aspecto app takes precedence |
55-
| `requireConfigForTraces` | `ASPECTO_REQUIRE_CONFIG_FOR_TRACES` | boolean | `false` | When `true`, the SDK will not trace anything until remote sampling configuration arrives (few hundreds ms). Can be used to enforce sampling configuration is always applied, with the cost of losing traces generated during service startup. |
56-
| `logger` | - | logger interface | | Logger to be used in this tracing library. Common use for debugging `logger: console` |
57-
| `collectPayloads` | `ASPECTO_COLLECT_PAYLOADS` | boolean | `true` | Should Aspecto SDK collect payloads of operations |
58-
| `local` | - | boolean | `false` | When set to true, enable [live traces](https://www.npmjs.com/package/@aspecto/opentelemetry#live-traces) |
59-
| `exportBatchSize` | `ASPECTO_EXPORT_BATCH_SIZE` | number | `100` | How many spans to batch in a single export to the collector |
60-
| `exportBatchTimeoutMs` | `ASPECTO_EXPORT_BATCH_TIMEOUT_MS` | number | `1000` (1s) | Maximum time in ms for batching spans before sending to collector |
61-
| `writeSystemLogs` | - | boolean | `false` | If `true`, emit all log messages from Opentelemetry SDK to supplied logger if present, or to console if missing |
62-
| `customZipkinEndpoint` | - | URL | | Send all traces to additional Zipkin server for debug |
63-
| `sqsExtractContextPropagationFromPayload` | `ASPECTO_SQS_EXTRACT_CONTEXT_PROPAGATION_FROM_PAYLOAD` | boolean | `true` | For aws-sdk instrumentation. Should be true when the service receiveMessages from SQS which is subscribed to SNS and subscription configured with "Raw message delivery": Disabled. Setting to `false` is a bit more performant as it turns off JSON parse on message payload |
64-
| `extractB3Context` | `ASPECTO_EXTRACT_B3_CONTEXT` | boolean | `false` | Set to `true` when the service receives requests from another instrumented component that propagate context via B3 protocol multi or single header. For example: Envoy Proxy, Ambassador and Istio |
65-
| `injectB3ContextSingleHeader` | `ASPECTO_INJECT_B3_CONTEXT_SINGLE_HEADER` | boolean | `false` | Set to `true` when the service send traffic to another instrumented component that propagate context via B3 **single header** protocol |
66-
| `injectB3ContextMultiHeader` | `ASPECTO_INJECT_B3_CONTEXT_MULTI_HEADER` | boolean | `false` | Set to `true` when the service send traffic to another instrumented component that propagate context via B3 **multi header** protocol. For example: Envoy Proxy, Istio |
47+
| Option | Environment Variable | Type | Default | Description |
48+
| ----------------------------------------- | ------------------------------------------------------ | ---------------- | ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
49+
| `disableAspecto` | `DISABLE_ASPECTO` | boolean | `false` (aspecto enabled) | Disable aspecto |
50+
| `env` | `NODE_ENV` | string | `process.env.NODE_ENV` | Set environment name manually |
51+
| `aspectoAuth` | `ASPECTO_AUTH` | UUID | | Set Aspecto token from code instead of using `aspecto.json` |
52+
| `serviceName` | `OTEL_SERVICE_NAME` | string | "name" in `package.json` | Set serviceName manually instead of reading it from `package.json`. For example: a service that runs in multiple "modes" |
53+
| `serviceVersion` | `OTEL_SERVICE_VERSION` | string | "version" in `package.json` | Set serviceVersion manually instead of reading it from `package.json` |
54+
| `samplingRatio` | `ASPECTO_SAMPLING_RATIO` | number | `1.0` | How many of the traces starting in this service should be sampled. Set to number in range \[0.0, 1.0] where `0.0` is no sampling, and `1.0` is sample all. Specific rules set via aspecto app takes precedence |
55+
| `requireConfigForTraces` | `ASPECTO_REQUIRE_CONFIG_FOR_TRACES` | boolean | `false` | When `true`, the SDK will not trace anything until remote sampling configuration arrives (few hundreds ms). Can be used to enforce sampling configuration is always applied, with the cost of losing traces generated during service startup. |
56+
| `logger` | - | logger interface | | Logger to be used in this tracing library. Common use for debugging `logger: console` |
57+
| `collectPayloads` | `ASPECTO_COLLECT_PAYLOADS` | boolean | `true` | Should Aspecto SDK collect payloads of operations |
58+
| `local` | - | boolean | `false` | When set to true, enable [live traces](https://www.npmjs.com/package/@aspecto/opentelemetry#live-traces) |
59+
| `otlpCollectorEndpoint` | `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` | string | `https://otelcol-fast.aspecto.io/v1/trace` | Target URL to which the OTLP http exporter is going to send spans |
60+
| `exportBatchSize` | `ASPECTO_EXPORT_BATCH_SIZE` | number | `100` | How many spans to batch in a single export to the collector |
61+
| `exportBatchTimeoutMs` | `ASPECTO_EXPORT_BATCH_TIMEOUT_MS` | number | `1000` (1s) | Maximum time in ms for batching spans before sending to collector |
62+
| `writeSystemLogs` | - | boolean | `false` | If `true`, emit all log messages from Opentelemetry SDK to supplied logger if present, or to console if missing |
63+
| `customZipkinEndpoint` | - | URL | | Send all traces to additional Zipkin server for debug |
64+
| `sqsExtractContextPropagationFromPayload` | `ASPECTO_SQS_EXTRACT_CONTEXT_PROPAGATION_FROM_PAYLOAD` | boolean | `true` | For aws-sdk instrumentation. Should be true when the service receiveMessages from SQS which is subscribed to SNS and subscription configured with "Raw message delivery": Disabled. Setting to `false` is a bit more performant as it turns off JSON parse on message payload |
65+
| `extractB3Context` | `ASPECTO_EXTRACT_B3_CONTEXT` | boolean | `false` | Set to `true` when the service receives requests from another instrumented component that propagate context via B3 protocol multi or single header. For example: Envoy Proxy, Ambassador and Istio |
66+
| `injectB3ContextSingleHeader` | `ASPECTO_INJECT_B3_CONTEXT_SINGLE_HEADER` | boolean | `false` | Set to `true` when the service send traffic to another instrumented component that propagate context via B3 **single header** protocol |
67+
| `injectB3ContextMultiHeader` | `ASPECTO_INJECT_B3_CONTEXT_MULTI_HEADER` | boolean | `false` | Set to `true` when the service send traffic to another instrumented component that propagate context via B3 **multi header** protocol. For example: Envoy Proxy, Istio |
6768

6869
## Advanced Settings
6970

send-tracing-data-to-aspecto/aspecto-sdk/nodejs/customize-defaults/manual-spans.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: '- Allows you to send data that doesnt normally get sent (done manually)'
2+
description: '- Allows you to send data that doesn''t normally get sent (done manually)'
33
---
44

55
# Send Spans Manually

send-tracing-data-to-aspecto/aspecto-sdk/nodejs/gcf.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ exports.users = gcf(app);
3737
```
3838

3939
\
40-
**Note**: if your GCF is not deployed with a `package.json` file, make sure to provide the `packageName` option when initializing Aspecto.
40+
**Note**: if your GCF is not deployed with a `package.json` file, make sure to provide the `serviceName` option when initializing Aspecto.

0 commit comments

Comments
 (0)