This is an automated email from the ASF dual-hosted git repository. poorejc pushed a commit to branch test in repository https://gitbox.apache.org/repos/asf/incubator-flagon-useralejs.git
commit ae1758dfa8b9615e2d82a9208bcbdc23a7a01c62 Author: Joshua Poore <[email protected]> AuthorDate: Sun Jan 30 14:32:32 2022 -0500 updated example text --- example/custom-non-user-events-example/README.md | 13 ++++++++++--- example/custom-non-user-events-example/index.js | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/example/custom-non-user-events-example/README.md b/example/custom-non-user-events-example/README.md index 090afe0..f4de34c 100644 --- a/example/custom-non-user-events-example/README.md +++ b/example/custom-non-user-events-example/README.md @@ -1,6 +1,9 @@ -## Logging Non-User Events Examples +## Logging Custom, Non-User Events Examples +UserALE.js' API provides significant customization options; you can use it extend UserALE.js' out-of-the-box capabilities and log non-user events. + +### XMLHttpRequests +For user-workflow segmentation or more comprehensive instrumentation, it may be desirable to capture when the client sends requests to other services. -First, OpenTelemetry can be installed as follows: ```JavaScript req.onreadystatechange = function () { @@ -18,8 +21,12 @@ First, OpenTelemetry can be installed as follows: } } ``` +The example above uses the `userale.log` API, allowing users to script their own log. However, the same effect is achieve with the `userale.packageCustomLog` API, which adds custom user field to the canonical UserALE.js schema. + +The method above will similarly work with other types of requests (e.g., fetch, websocket, etc..) -Then, OpenTelemetry can be automatically instrumented using the following code from the <a href="https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-instrumentation-user-interaction">Open Telemetry GitHub Repository</a>: +### Custom Integrations +In the example below, custom UserALE.js logs can be used for integration with other instrumentation packages such as [OpenTelemetry](https://github.com/open-telemetry/opentelemetry-js). We can grab traceId's created by OpenTelemetry for tracing client requests throughout distributed systems and associate them with UserALE.js Logs. See the `index.js` for complete example modified from the [OpenTelemetry UserInteraction Plugin](https://github.com/open-telemetry/opentelemetry-js-contrib/tre [...] ```JavaScript req.onreadystatechange = function () { if (req.readyState == XMLHttpRequest.DONE) { diff --git a/example/custom-non-user-events-example/index.js b/example/custom-non-user-events-example/index.js index a46d0a3..2d7f415 100644 --- a/example/custom-non-user-events-example/index.js +++ b/example/custom-non-user-events-example/index.js @@ -6,6 +6,8 @@ import { registerInstrumentations } from '@opentelemetry/instrumentation'; // or if you already have zone.js // import { ZoneContextManager } from '@opentelemetry/context-zone-peer-dep'; +const userale = require('flagon-userale'); + const provider = new WebTracerProvider({ contextManager: new ZoneContextManager() });
