Skip to content

Commit

Permalink
Merge pull request #89 from solarwindscloud/NH-29703
Browse files Browse the repository at this point in the history
Rework config handling
  • Loading branch information
raphael-theriault-swi authored Sep 1, 2023
2 parents 2a0e391 + 30171a1 commit 7792574
Show file tree
Hide file tree
Showing 18 changed files with 386 additions and 638 deletions.
2 changes: 2 additions & 0 deletions .yarn/versions/4dea33b4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
releases:
solarwinds-apm: major
2 changes: 1 addition & 1 deletion examples/next-prisma/solarwinds.apm.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { PrismaInstrumentation } = require("@prisma/instrumentation")

/** @type {import("solarwinds-apm").ConfigFile} */
/** @type {import("solarwinds-apm").Config} */
module.exports = {
instrumentations: {
configs: {
Expand Down
1 change: 0 additions & 1 deletion packages/merged-config/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion packages/merged-config/.prettierignore

This file was deleted.

3 changes: 0 additions & 3 deletions packages/merged-config/README.md

This file was deleted.

43 changes: 0 additions & 43 deletions packages/merged-config/package.json

This file was deleted.

114 changes: 0 additions & 114 deletions packages/merged-config/src/index.ts

This file was deleted.

110 changes: 0 additions & 110 deletions packages/merged-config/test/index.test.ts

This file was deleted.

8 changes: 0 additions & 8 deletions packages/merged-config/tsconfig.json

This file was deleted.

63 changes: 25 additions & 38 deletions packages/solarwinds-apm/CONFIGURATION.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
# Configuration

Configuration options are read from both then environment and an optional configuration file, with environment variables taking precedence over config file values.
Configuration options are read from both the environment and an optional configuration file, with environment variables taking precedence over config file values.

All configuration options are optional except for the service key which is always required.

## Environment Variables

| Name | Default | Description |
| ------------------------------ | ----------------- | ------------------------------------------------- |
| **`SW_APM_SERVICE_KEY`** | | **Service key** |
| `SW_APM_ENABLED` | `true` | Whether instrumentation should be enabled |
| `SW_APM_COLLECTOR` | Default collector | Collector URL |
| `SW_APM_TRUSTED_PATH` | None | Path to the collector's SSL certificate |
| `SW_APM_PROXY` | None | URL of a proxy to use to connect to the collector |
| `SW_APM_LOG_LEVEL` | `info` | Logging level for the instrumentation libraries |
| `SW_APM_TRIGGER_TRACE_ENABLED` | `true` | Whether trigger tracing should be enabled |
| `SW_APM_RUNTIME_METRICS` | `true` | Whether runtime metrics should be enabled |

## Configuration File

When required, the package will look for the file in the current working directory under three possible formats, in the following order:
Expand All @@ -32,41 +19,41 @@ It's also possible to use a custom name for the configuration file using the `SW
The package exports a type for the config file which can be used to type check it when using TypeScript or add a JSDoc type annotation when using JavaScript.

```ts
import type { ConfigFile } from "solarwinds-apm"
import type { Config } from "solarwinds-apm"

const config: ConfigFile = {
const config: Config = {
// ...
}
export default config
```

```js
/** @type {import('solarwinds-apm').ConfigFile} */
/** @type {import('solarwinds-apm').Config} */
module.exports = {
// ...
}
```

### Specification

| Key | Default | Description |
| ------------------------------- | ----------------- | ------------------------------------------------------------ |
| **`serviceKey`** | | **Service key** |
| `enabled` | `true` | Whether instrumentation should be enabled |
| `collector` | Default collector | Collector URL |
| `trustedPath` | None | Path to the collector's SSL certificate |
| `proxy` | None | URL of a proxy to use to connect to the collector |
| `logLevel` | `info` | Logging level for the instrumentation libraries |
| `triggerTraceEnabled` | `true` | Whether trigger tracing should be enabled |
| `runtimeMetrics` | `true` | Whether runtime metrics should be enabled |
| `tracingMode` | None | Custom tracing mode |
| `insertTraceContextIntoLogs` | `false` | Whether to insert trace context information into logs |
| `insertTraceContextIntoQueries` | `false` | Whether to insert trace context information into SQL queries |
| `transactionSettings` | None | See [Transaction Settings](#transaction-settings) |
| `instrumentations` | None | See [Instrumentations](#instrumentations) |
| `metricViews` | None | Custom metric views |

#### Transaction Settings
## Specification

| Key | Environment | Default | Description |
| ------------------------------- | ------------------------------ | ----------------- | ------------------------------------------------------------ |
| **`serviceKey`** | **`SW_APM_SERVICE_KEY`** | | **Service key** |
| `enabled` | `SW_APM_ENABLED` | `true` | Whether instrumentation should be enabled |
| `collector` | `SW_APM_COLLECTOR` | Default collector | Collector URL |
| `trustedPath` | `SW_APM_TRUSTED_PATH` | None | Path to the collector's SSL certificate |
| `proxy` | `SW_APM_PROXY` | None | URL of a proxy to use to connect to the collector |
| `logLevel` | `SW_APM_LOG_LEVEL` | `info` | Logging level for the instrumentation libraries |
| `triggerTraceEnabled` | `SW_APM_TRIGGER_TRACE_ENABLED` | `true` | Whether trigger tracing should be enabled |
| `runtimeMetrics` | `SW_APM_RUNTIME_METRICS` | `true` | Whether runtime metrics should be collected |
| `tracingMode` | `SW_APM_TRACING_MODE` | None | Custom tracing mode |
| `insertTraceContextIntoLogs` | | `false` | Whether to insert trace context information into logs |
| `insertTraceContextIntoQueries` | | `false` | Whether to insert trace context information into SQL queries |
| `transactionSettings` | | None | See [Transaction Settings](#transaction-settings) |
| `instrumentations` | | None | See [Instrumentations](#instrumentations) |
| `metricViews` | | None | Custom metric views |

### Transaction Settings

Transaction settings allow filtering out certain transactions, based on URL for web requests, and the type and name concatenated with a colon for everything else. This option should be set to an array of objects.

Expand All @@ -92,7 +79,7 @@ module.exports = {
}
```

#### Instrumentations
### Instrumentations

A default set of instrumentations are provided and configured by the library. However in many cases it may be desirable to manually configure the instrumentations or provide additional ones. The `instrumentations` configuration field accepts an object which in turn can contain two fields.

Expand Down
Loading

0 comments on commit 7792574

Please sign in to comment.