You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[Set callbacks for logging](#set-callbacks-for-logging)
@@ -45,43 +46,44 @@ This is the official Node.js implementation of the [Dynatrace OneAgent SDK](http
45
46
* When loading the OneAgent via [OneAgent NPM module](https://www.npmjs.com/package/@dynatrace/oneagent) or a similar tool, make sure to require the SDK after the OneAgent
46
47
* Dynatrace OneAgent (required versions see below)
47
48
* The OneAgent SDK is not supported on serverless code modules, including those for AWS Lambda.
48
-
Consider using [OpenTelemetry](https://www.dynatrace.com/support/help/shortlink/opentel-lambda) instead in these scenarios.
49
+
In these scenarios consider using [OpenTelemetry](https://www.dynatrace.com/support/help/shortlink/opentel-lambda) instead.
49
50
50
-
|OneAgent SDK for Node.js|Required OneAgent version|Support status|
|1.3.x |>=1.165 |Deprecated with support ending 2023-08-01|
56
+
|1.2.x |>=1.145 |Deprecated with support ending 2023-08-01|
57
+
|1.1.x |>=1.143 |Deprecated with support ending 2023-08-01|
58
+
|1.0.x |>=1.137 |Deprecated with support ending 2023-08-01|
57
59
58
60
## Integration
59
61
60
62
Using this module should not cause any errors if no OneAgent is present (e.g. in testing).
61
63
62
-
Make sure that this module is required after Dynatrace OneAgent.
64
+
Make sure that this module is loaded after Dynatrace OneAgent.
63
65
64
66
### Installation
65
67
66
68
`npm install --save @dynatrace/oneagent-sdk`
67
69
68
70
### Troubleshooting
69
71
70
-
If the SDK can't connect to the OneAgent ([Current SDK state](#current-sdk-state) is not `ACTIVE`) verify that a matching version of OneAgent is used *and required before* the SDK module.
72
+
If the SDK cannot connect to the OneAgent ([Current SDK state](#current-sdk-state) is not `ACTIVE`) verify that a matching version of OneAgent is used *and loaded before* the SDK module.
71
73
72
74
Verify that OneAgent is working as intended (see [Dynatrace OneAgent](https://www.dynatrace.com/technologies/nodejs-monitoring/)).
73
75
74
76
You should ensure that you have set [LoggingCallbacks](#set-callbacks-for-logging).
75
77
76
-
OneAgent transparently wrap*supported* libraries to add context information. For every yet*unsupported* module [Pass Context](#pass-context) can be used to provide transactional context to callbacks.
78
+
OneAgent transparently wraps*supported* libraries to add context information. For every currently*unsupported* module [Pass Context](#pass-context) can be used to provide transactional context to callbacks.
77
79
78
80
## API Concepts
79
81
80
-
Common concepts of the Dynatrace OneAgent SDK are explained the [Dynatrace OneAgent SDK repository](https://github.com/Dynatrace/OneAgent-SDK).
82
+
Common concepts of the Dynatrace OneAgent SDK are explained in the [Dynatrace OneAgent SDK repository](https://github.com/Dynatrace/OneAgent-SDK).
81
83
82
84
### OneAgentSDK object
83
85
84
-
The first step is to acquire an OneAgent SDK API object by calling `createInstance()`. The resulting object holds methods to create tracers, administrative methods (e.g. check SDK state, install logging callbacks) and `passContext()`. Every call to `createInstance()` will return a new API object allowing the user to install separate logging callbacks for separate use cases.
86
+
The first step is to acquire a OneAgent SDK API object by calling `createInstance()`. The resulting object holds methods to create tracers, administrative methods (e.g. check SDK state, install logging callbacks) and `passContext()`. Every call to `createInstance()` will return a new API object allowing the user to install separate logging callbacks for separate use cases.
85
87
86
88
```js
87
89
constSdk=require('@dynatrace/oneagent-sdk');
@@ -94,8 +96,8 @@ The life-cycle of a tracer is as follows:
94
96
95
97
1. Create a trace using the `traceXXX` method matching to your use case. For incoming taggable traces pass the received Dynatrace tag (if present) to the `traceXXX` method.
96
98
1. Start the trace which in turn invokes and times the given handler function.
97
-
1. For outgoing taggable traces fetch a Dynatrace tag and include it to the message sent out.
98
-
1.Optional mark the traced operation as failed via a call to `error()`
99
+
1. For outgoing taggable traces fetch a Dynatrace tag and include it to the message being sent.
100
+
1.Optionally mark the traced operation as failed via a call to `error()`
99
101
1. End the trace once the operation is done. For outgoing traces you may pass a callback to be included in this trace.
100
102
101
103
Each tracer offers following methods:
@@ -115,8 +117,8 @@ Tracers for outgoing taggable requests additionally offer following methods to g
115
117
*`getDynatraceStringTag()` returns a Dynatrace tag encoded as `string`
116
118
*`getDynatraceByteTag()` returns a Dynatrace tag binary encoded as `Buffer`
117
119
118
-
This Dynatrace tag needs to be embedded into the message sent to remote service. Depending on the concrete protocol used the `string` or binary representation may fit better and it's up to the user to decide which variant to use.
119
-
On incoming service this tag needs to be extracted by the user and passed to the corresponding `traceXXX` method using the `dynatraceTag` property of the arguments to allow linking of outgoing and the corresponding incoming trace.
120
+
This Dynatrace tag needs to be embedded into the message sent to remote service. The `string` or binary representation may fit better depending on the concrete protocol used. It is up to the user to decide which variant to use.
121
+
On an incoming service this tag needs to be extracted by the user and passed to the corresponding `traceXXX` method using the `dynatraceTag` property of the arguments to allow linking of outgoing and the corresponding incoming trace.
120
122
121
123
The tracer objects returned by above methods are always valid even if there is no OneAgent present or no trace is created for whatever reason. In this case the methods are still present to avoid the need of extra checking in client code.
122
124
@@ -136,6 +138,7 @@ A more detailed specification of the features can be found in [Dynatrace OneAgen
136
138
|Set custom request attributes |>=1.2.0 |
137
139
|Trace Messaging |>=1.3.0 |
138
140
|Metrics (deprecated) |>=1.4.0 |
141
+
|Trace context |>=1.5.0 |
139
142
140
143
### Trace incoming and outgoing remote calls
141
144
@@ -356,7 +359,7 @@ It receives an object with following properties:
356
359
*`rowsReturned` Optional - Number of rows returned by this traced database request. Only positive values are allowed
357
360
*`roundTripCount` Optional - Count of round-trips that took place. Only positive values are allowed
358
361
359
-
Please note that SQL database traces are only created if they occur within some other SDK trace (e.g. incoming remote call) or an OneAgent built-in trace (e.g. incoming web request).
362
+
Please note that SQL database traces are only created if they occur within some other SDK trace (e.g. incoming remote call) or a OneAgent built-in trace (e.g. incoming web request).
360
363
361
364
**Example (see [DatabaseRequestSample.js](samples/Database/DatabaseRequestSample.js) for more details):**
362
365
@@ -450,6 +453,10 @@ Otherwise, using the same metric name multiple times is an error. All metrics wi
450
453
*`dimensionName` Optional - a `string` specifying the name of the dimension added to the metric.
451
454
If a name is given here it's required to set a dimension value during booking samples on the metric. A dimension is like an additional label attached to values, for example a "disk.written.bytes" metric could have a dimension name of "disk-id" and when adding values to it a dimension value would be "/dev/sda1".
452
455
456
+
### Trace context
457
+
The implementation follows the specification from [Dynatrace OneAgent SDK - Trace Context](https://github.com/Dynatrace/OneAgent-SDK#tracecontext).
458
+
For an usage example refer to [W3CTraceContextApiSample.js](samples/TraceContext/W3CTraceContextApiSample.js).
After `collection.findOne()` is executed asynchronously `callback()` will be called. `callback()` again contains an asynchronous call `http.get()` which performs an outbound HTTP request. If there is a current transactional context with an ongoing trace, Dynatrace OneAgent will transparently add a HTTP header containing a Dynatrace tag to this outbound request. The next tier - if instrumented with OneAgent - will continue this trace then. Without further intervention any transactional context would get lost between asynchronous invocation and a callback. Currently the only reliable way to pass over context information to a callback is called 'wrapping'.
589
+
After `collection.findOne()` is executed asynchronously `callback()` will be called. `callback()` again contains an asynchronous call `http.get()` which performs an outbound HTTP request. If there is a current transactional context with an ongoing trace, Dynatrace OneAgent will transparently add a HTTP header containing a Dynatrace tag to this outbound request. The next tier - if instrumented with OneAgent - will continue this trace then. Without further intervention any transactional context would be lost between asynchronous invocation and a callback. Currently the only reliable way to pass over context information to a callback is called 'wrapping'.
583
590
584
591
**Example: Regular callbacks**
585
592
Assume `some.asyncFunction()` in below sample causes loss of transactional context in OneAgent. To ensure that OneAgent correctly shows activities triggered inside the callback of this function `passContext()` can be used to create a closure preserving the transactional context active at call time of `some.asyncFunction()`.
@@ -650,14 +657,15 @@ SLAs apply according to the customer's support level.
650
657
651
658
see also [Releases](https://github.com/Dynatrace/OneAgent-SDK-for-NodeJs/releases)
0 commit comments