Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add snippet injection readme #934

Merged
merged 3 commits into from
Mar 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ appInsights.setup("<YOUR_CONNECTION_STRING>")
.setAutoCollectHeartbeat(false)
.setInternalLogging(false, true)
.setDistributedTracingMode(appInsights.DistributedTracingModes.AI_AND_W3C)
.enableAutoWebSnippetInjection(false)
.start();
```

Expand Down Expand Up @@ -263,8 +264,9 @@ separately from clients created with `new appInsights.TelemetryClient()`.
| noPatchModules | Disable individual monkey-patches. Set `noPatchModules` to a comma separated list of packages to disable. e.g. `"noPatchModules": "console,redis"` to avoid patching the console and redis packages. The following modules are available: `azuresdk, bunyan, console, mongodb, mongodb-core, mysql, redis, winston, pg`, and `pg-pool`. Visit the [diagnostic-channel-publishers' README](https://github.com/microsoft/node-diagnostic-channel/blob/master/src/diagnostic-channel-publishers/README.md) for information about exactly which versions of these packages are patched. |
| noHttpAgentKeepAlive | HTTPS without a passed in agent |
| httpAgent | An http.Agent to use for SDK HTTP traffic (Optional, Default undefined) |
| httpsAgent | An https.Agent to use for SDK HTTPS traffic (Optional, Default undefined)
| aadTokenCredential| Azure Credential instance to be used to authenticate the App. [AAD Identity Credential Classes](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/identity/identity#credential-classes) | |
| httpsAgent | An https.Agent to use for SDK HTTPS traffic (Optional, Default undefined)
| aadTokenCredential| Azure Credential instance to be used to authenticate the App. [AAD Identity Credential Classes](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/identity/identity#credential-classes)
| enableAutoWebSnippetInjection(Preview)| Sets the state of automatic web snippet injection (disabled by default). If true, web snippet will be injected into valid node server http response automatically | |
Karlie-777 marked this conversation as resolved.
Show resolved Hide resolved

[Config.ts]: https://github.com/microsoft/ApplicationInsights-node.js/blob/develop/Library/Config.ts

Expand Down Expand Up @@ -327,6 +329,18 @@ appInsights.defaultClient.setAutoPopulateAzureProperties(true);
appInsights.start();
```

### Automatic web snippet injection[Preview]

Automatic web snippet injection is currently in **Preview**. For node server with configuration `enableAutoWebSnippetInjection` set to `true` or environment variable `APPLICATIONINSIGHTS_WEB_SNIPPET_ENABLED = true`, web snippet will be injected into node server response when all of the following requirements are met:

- Response has status code `200`.
- Response method is `GET`.
- Sever response has `Content-Type` html.
- Server response must have both `<head>` and `</head>` Tags.
- If response is compressed, it must have only one `Content-Encoding` type, and encoding type must be one of `gzip`, `br` or `deflate`.
- Response does not contain current /backup snippet CDN endpoints. (current and backup snippet CDN endpoints [here](https://github.com/microsoft/ApplicationInsights-JS#active-public-cdn-endpoints))

**Note:** Snippet auto injection may slow down server response time, especially when response size is large or response is compressed. For the case in which some middle layers are applied, it may result in auto injection not working and original response will be returned.

### Automatic third-party instrumentation

Expand Down