Skip to content

Commit

Permalink
Merge branch 'main' into alibaba-cloud-detector
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan authored Aug 9, 2021
2 parents 0a81661 + a295efe commit 20c47a0
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .github/component_owners.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Test configuration

components:
packages/opentelemetry-id-generator-aws-xray:
- NathanielRN
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/component-owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ jobs:
name: Auto Assign Owners
steps:
- uses: dyladan/component-owners@main
with:
config-file: .github/component_owners.yml
repo-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions packages/opentelemetry-id-generator-aws-xray/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
[![devDependencies][devDependencies-image]][devDependencies-url]
[![Apache License][license-image]][license-image]

[component owners](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/.github/component_owners.yml): @willarmiros @NathanielRN

The OpenTelemetry IdGenerator for AWS X-Ray generates trace IDs with its first four bytes set to the start time of the
trace followed by a unique identifier consisting of 12 bytes of randomly generated numbers. OpenTelemetry offers an
extension point which allows the usage of this custom IdGenerator as opposed to the out-of-the-box random IdGenerator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
[![devDependencies][devDependencies-image]][devDependencies-url]
[![Apache License][license-image]][license-image]

[component owners](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/.github/component_owners.yml): @willarmiros @NathanielRN

This module provides automatic instrumentation for [`AWS Lambda`](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html).

This module is currently under active development and not ready for general use.
Expand Down
2 changes: 2 additions & 0 deletions propagators/opentelemetry-propagator-aws-xray/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
[![devDependencies][devDependencies-image]][devDependencies-url]
[![Apache License][license-image]][license-image]

[component owners](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/.github/component_owners.yml): @willarmiros @NathanielRN

The OpenTelemetry Propagator for AWS X-Ray provides HTTP header propagation for systems that are using AWS `X-Amzn-Trace-Id` format.
This propagator translates the OpenTelemetry SpanContext into the equivalent AWS header format, for use with the OpenTelemetry JS SDK.
`TraceState` is currently not propagated.
Expand Down
145 changes: 145 additions & 0 deletions scripts/update-core-deps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/*!
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Update all dependencies from the core repo to the @next tag versions
*
* To use the script, run it from the root of the contrib repository like this:
* `node scripts/update-core-deps.js`
*
* If your core repository is checked out in the same directory as your contrib
* repository with the default name, it will be found automatically. If not,
* you can point to the core repository with the environment variable
* CORE_REPOSITORY like this:
* `CORE_REPOSITORY=../../otel-core node scripts/update-core-deps.js
*
* Note that this only updates the versions in the package.json for each package
* and you will still need to run `lerna bootstrap` and make any necessary
* code changes.
*/

"use strict";

const path = require('path');
const fs = require('fs');
const child_process = require('child_process')

// Use process.env.CORE_REPOSITORY to point to core repository directory
// Defaults to ../opentelemetry-js
let coreDir = path.join(process.cwd(), '..', 'opentelemetry-js');
if (process.env.CORE_REPOSITORY) {
coreDir = path.resolve(process.env.CORE_REPOSITORY);
}

if (!fs.existsSync(path.join(coreDir, "lerna.json"))) {
console.error(`Missing lerna.json in ${coreDir}`);
console.error("Be sure you are setting $CORE_REPOSITORY to a valid lerna monorepo");
process.exit(1);
}

async function main() {
const corePackageList = await getCorePackages();
const contribPackageLocations = await getContribPackageLocations();

for (const packageLocation of contribPackageLocations) {
let changed = false;
const package = require(packageLocation);
console.log('Processing', package.name);

for (const type of ["dependencies", "devDependencies", "peerDependencies"]) {
changed = changed || updateDeps(package, type, corePackageList);
}

if (changed) {
console.log('Package changed. Writing new version.');
fs.writeFileSync(packageLocation, JSON.stringify(package, null, 2) + '\n');
} else {
console.log('No change detected');
}

console.log();
}
}

function updateDeps(package, type, corePackageList) {
if (!package[type]) {
return false;
}

console.log("\t", type)
let changed = false;
for (const corePackage of corePackageList) {
const oldCoreVersion = package[type][corePackage.name];
if (oldCoreVersion) {
const newVersion = `${getVersionLeader(oldCoreVersion)}${corePackage.nextVersion}`;
console.log('\t\t', corePackage.name);
console.log('\t\t\t', oldCoreVersion, '=>', newVersion)
package[type][corePackage.name] = newVersion;
changed = true;
}
}
return changed;
}

async function getContribPackageLocations() {
const gitContribPackageLocations = await exec('git ls-files');
return gitContribPackageLocations
.split(/\r?\n/)
.filter(f => f.match(/package\.json$/))
.map(f => path.resolve(f));
}

async function getCorePackages() {
const coreLernaList = await exec('lerna list --no-private --json', coreDir);
return Promise.all(
JSON.parse(coreLernaList)
.map(async p => {
const nextVersion = await exec(`npm view ${p.name}@next version`);
return {
...p,
nextVersion: nextVersion.trim(),
};
})
);
}

function getVersionLeader(version) {
if (version.match(/^\d/)) {
return '';
}

return version[0];
}

async function exec(cmd, dir) {
return new Promise((resolve, reject) => {
child_process.exec(cmd, {
cwd: dir
}, function (err, stdout) {
if (err) {
reject(err);
} else {
resolve(stdout);
}
});
})
}

main()
.catch((err) => {
console.error(err);
process.exit(1);
});

0 comments on commit 20c47a0

Please sign in to comment.