Skip to content

Commit

Permalink
Merge branch 'main' into decoded-body-size
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarchaud authored Jul 17, 2021
2 parents eb2c20a + 2355717 commit ef19dc3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { ServiceClientType } from './types';
import { CollectorExporterNodeBase } from './CollectorExporterNodeBase';
import { getEnv, baggageUtils } from '@opentelemetry/core';

const DEFAULT_COLLECTOR_URL = 'http://localhost:4317/v1/metrics';
const DEFAULT_COLLECTOR_URL = 'http://localhost:55681/v1/metrics';

/**
* Collector Metric Exporter for Node with protobuf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
import { ServiceClientType } from './types';
import { getEnv, baggageUtils } from '@opentelemetry/core';

const DEFAULT_COLLECTOR_URL = 'http://localhost:4317/v1/traces';
const DEFAULT_COLLECTOR_URL = 'http://localhost:55681/v1/traces';

/**
* Collector Trace Exporter for Node with protobuf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import * as types from '../../types';
import * as path from 'path';
import * as RequireInTheMiddle from 'require-in-the-middle';
import * as semver from 'semver';
import { satisfies } from 'semver';
import { InstrumentationAbstract } from '../../instrumentation';
import { InstrumentationModuleDefinition } from './types';
import { diag } from '@opentelemetry/api';
Expand Down Expand Up @@ -50,7 +50,7 @@ export abstract class InstrumentationBase<T = any>
if (this._modules.length === 0) {
diag.warn(
'No modules instrumentation has been defined,' +
' nothing will be patched'
' nothing will be patched'
);
}

Expand Down Expand Up @@ -80,7 +80,7 @@ export abstract class InstrumentationBase<T = any>
// main module
if (
typeof version === 'string' &&
isSupported(module.supportedVersions, version)
isSupported(module.supportedVersions, version, module.includePrerelease)
) {
if (typeof module.patch === 'function') {
module.moduleExports = exports;
Expand All @@ -93,7 +93,7 @@ export abstract class InstrumentationBase<T = any>
// internal file
const files = module.files ?? [];
const file = files.find(file => file.name === name);
if (file && isSupported(file.supportedVersions, version)) {
if (file && isSupported(file.supportedVersions, version, module.includePrerelease)) {
file.moduleExports = exports;
if (this._enabled) {
return file.patch(exports, module.moduleVersion);
Expand Down Expand Up @@ -167,8 +167,8 @@ export abstract class InstrumentationBase<T = any>
}
}

function isSupported(supportedVersions: string[], version: string): boolean {
function isSupported(supportedVersions: string[], version: string, includePrerelease?: boolean): boolean {
return supportedVersions.some(supportedVersion => {
return semver.satisfies(version, supportedVersion);
return satisfies(version, supportedVersion, { includePrerelease });
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export interface InstrumentationModuleDefinition<T> {
/** Module internal files to be patched */
files: InstrumentationModuleFile<any>[];

/** If set to true, the includePrerelease check will be included when calling semver.satisfies */
includePrerelease?: boolean;

/** Method to patch the instrumentation */
patch?: (moduleExports: T, moduleVersion?: string) => T;

Expand Down
4 changes: 2 additions & 2 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"rangeStrategy": "bump"
},
{
"matchPaths": ["backwards-compatibility/**"],
"ignoreDeps": ["@types/node"],
"matchPaths": ["backwards-compatibility"],
"matchPackageNames": ["@types/node"],
"enabled": false
}
],
Expand Down
12 changes: 6 additions & 6 deletions website_docs/getting_started/browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Copy the following file into an empty directory and call it `index.html`.
<html lang="en">
<head>
<meta charset="utf-8">
<title>Document Load Plugin Example</title>
<title>Document Load Instrumentation Example</title>
<base href="/">
<!--
https://www.w3.org/TR/trace-context/
Expand All @@ -33,14 +33,14 @@ Copy the following file into an empty directory and call it `index.html`.
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
Example of using Web Tracer with document load plugin with console exporter and collector exporter
Example of using Web Tracer with document load instrumentation with console exporter and collector exporter
</body>
</html>
```

## Installation

To create traces in the browser, you will need `@opentelemetry/web`, and the plugin `@opentelemetry/plugin-document-load`:
To create traces in the browser, you will need `@opentelemetry/web`, and the instrumentation `@opentelemetry/instrumentation-document-load`:

```shell
npm init -y
Expand All @@ -59,7 +59,7 @@ We will add some code that will trace the document load timings and output those

## Creating a Tracer Provider

Add the following code to the `document-load.js` to create a tracer provider, which brings the plugin to trace document load:
Add the following code to the `document-load.js` to create a tracer provider, which brings the instrumentaion to trace document load:

```javascript
import { WebTracerProvider } from '@opentelemetry/web';
Expand All @@ -74,7 +74,7 @@ provider.register({
contextManager: new ZoneContextManager(),
});

// Registering instrumentations / plugins
// Registering instrumentations
registerInstrumentations({
instrumentations: [
new DocumentLoadInstrumentation(),
Expand Down Expand Up @@ -113,7 +113,7 @@ provider.register({
contextManager: new ZoneContextManager(),
});

// Registering instrumentations / plugins
// Registering instrumentations
registerInstrumentations({
instrumentations: [
new DocumentLoadInstrumentation(),
Expand Down

0 comments on commit ef19dc3

Please sign in to comment.