Skip to content

Commit

Permalink
fix node vs base packages, telemetry flag fix and package version fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Walker-GM committed Jan 29, 2023
1 parent 6371e25 commit 4a51129
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/create-redwood-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@opentelemetry/api": "1.4.0",
"@opentelemetry/exporter-trace-otlp-http": "0.35.0",
"@opentelemetry/resources": "1.9.0",
"@opentelemetry/sdk-trace-base": "1.9.0",
"@opentelemetry/sdk-trace-node": "1.9.0",
"@opentelemetry/semantic-conventions": "1.9.0",
"chalk": "4.1.2",
"check-node-version": "4.2.1",
Expand Down
8 changes: 3 additions & 5 deletions packages/create-redwood-app/src/create-redwood-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import execa from 'execa'
import fs from 'fs-extra'
import { Listr, figures } from 'listr2'
import terminalLink from 'terminal-link'
import { hideBin } from 'yargs/helpers'
import { hideBin, Parser } from 'yargs/helpers'
import yargs from 'yargs/yargs'

import { name, version } from '../package'
Expand All @@ -37,10 +37,8 @@ import { startTelemetry, shutdownTelemetry } from './telemetry'
//

// Telemetry
if (
!process.argv.includes('--no-telemetry') && // Must include '--no-telemetry' exactly because we want to do this check before any yargs. TODO: Communicate this on cmd help
!process.env.REDWOOD_DISABLE_TELEMETRY // We should use the same condition as in full projects here too
) {
const { telemetry } = Parser(hideBin(process.argv))
if (telemetry !== 'false' && !process.env.REDWOOD_DISABLE_TELEMETRY) {
// Setup and start root span
await startTelemetry()
}
Expand Down
22 changes: 14 additions & 8 deletions packages/create-redwood-app/src/telemetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import { diag, DiagConsoleLogger, DiagLogLevel } from '@opentelemetry/api'
import opentelemetry, { SpanStatusCode } from '@opentelemetry/api'
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
import { Resource } from '@opentelemetry/resources'
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base'
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'
import {
NodeTracerProvider,
BatchSpanProcessor,
} from '@opentelemetry/sdk-trace-node'
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'
import envinfo from 'envinfo'
import system from 'systeminformation'

import { name as packageName, version as packageVersion } from '../package'

/**
* @type NodeTracerProvider
*/
Expand Down Expand Up @@ -58,12 +62,9 @@ export async function startTelemetry() {

const resource = Resource.default().merge(
new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'create-redwood-app',
[SemanticResourceAttributes.SERVICE_NAME]: packageName,
// TODO: Get a better way of recording what version of CRWA is running because this is just null...
[SemanticResourceAttributes.SERVICE_VERSION]:
info.npmPackages != null
? info.npmPackages['@redwoodjs/core']?.installed
: undefined,
[SemanticResourceAttributes.SERVICE_VERSION]: packageVersion,
[SemanticResourceAttributes.OS_TYPE]: info.System?.OS?.split(' ')[0],
[SemanticResourceAttributes.OS_VERSION]: info.System?.OS?.split(' ')[1],
'shell.name': info.System?.Shell?.name,
Expand All @@ -82,14 +83,19 @@ export async function startTelemetry() {
})
traceExporter = new OTLPTraceExporter({
// TODO: Point this to somewhere permanent
// url: 'https://telemetry.redwoodjs.com/v1/traces',
})
traceProcessor = new BatchSpanProcessor(traceExporter)
traceProvider.addSpanProcessor(traceProcessor)
traceProvider.register()

// Start root span
const tracer = opentelemetry.trace.getTracer('crwa-tracer')
rootSpan = tracer.startSpan('root', undefined, opentelemetry.context.active())
rootSpan = tracer.startSpan(
'root',
undefined,
opentelemetry.context.ROOT_CONTEXT
)
}

export async function shutdownTelemetry({ exception } = {}) {
Expand Down
49 changes: 48 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6423,6 +6423,15 @@ __metadata:
languageName: node
linkType: hard

"@opentelemetry/context-async-hooks@npm:1.9.0":
version: 1.9.0
resolution: "@opentelemetry/context-async-hooks@npm:1.9.0"
peerDependencies:
"@opentelemetry/api": ">=1.0.0 <1.5.0"
checksum: 639ff710015f2dd4c399e17fdcebf5fa1023eae533fcf84bd496050476429276a227700d05c3eabc5d54453267bb43ef788be7fff6897e16eadcf40b21c3ce21
languageName: node
linkType: hard

"@opentelemetry/core@npm:1.9.0":
version: 1.9.0
resolution: "@opentelemetry/core@npm:1.9.0"
Expand Down Expand Up @@ -6474,6 +6483,28 @@ __metadata:
languageName: node
linkType: hard

"@opentelemetry/propagator-b3@npm:1.9.0":
version: 1.9.0
resolution: "@opentelemetry/propagator-b3@npm:1.9.0"
dependencies:
"@opentelemetry/core": 1.9.0
peerDependencies:
"@opentelemetry/api": ">=1.0.0 <1.5.0"
checksum: 01aafd3551d52c7d85f28656d846587ee27457a6c7413d14a76a74ed451e90316acbb1f01ef37176a0325f3aed68cea7dff7866565d804ecba14fbb22ae667de
languageName: node
linkType: hard

"@opentelemetry/propagator-jaeger@npm:1.9.0":
version: 1.9.0
resolution: "@opentelemetry/propagator-jaeger@npm:1.9.0"
dependencies:
"@opentelemetry/core": 1.9.0
peerDependencies:
"@opentelemetry/api": ">=1.0.0 <1.5.0"
checksum: ffea89dd14a29df01403219d847a0aefcbccbbf2f21889543e67e4b6d233ad75186a7fbf98916b53333470d717e486797a82a79711dc8530c2f158c5c2986c35
languageName: node
linkType: hard

"@opentelemetry/resources@npm:1.9.0":
version: 1.9.0
resolution: "@opentelemetry/resources@npm:1.9.0"
Expand Down Expand Up @@ -6512,6 +6543,22 @@ __metadata:
languageName: node
linkType: hard

"@opentelemetry/sdk-trace-node@npm:1.9.0":
version: 1.9.0
resolution: "@opentelemetry/sdk-trace-node@npm:1.9.0"
dependencies:
"@opentelemetry/context-async-hooks": 1.9.0
"@opentelemetry/core": 1.9.0
"@opentelemetry/propagator-b3": 1.9.0
"@opentelemetry/propagator-jaeger": 1.9.0
"@opentelemetry/sdk-trace-base": 1.9.0
semver: ^7.3.5
peerDependencies:
"@opentelemetry/api": ">=1.0.0 <1.5.0"
checksum: ee23f10e6f367127fbec149c03af5ff05848abb3e9f6fd8a4d3f1a95d80348c2eb936e24d51b2d5fa0bb5c1c71cdcb65d2407da3313de053f99bf5ca2cb0464c
languageName: node
linkType: hard

"@opentelemetry/semantic-conventions@npm:1.9.0":
version: 1.9.0
resolution: "@opentelemetry/semantic-conventions@npm:1.9.0"
Expand Down Expand Up @@ -15085,7 +15132,7 @@ __metadata:
"@opentelemetry/api": 1.4.0
"@opentelemetry/exporter-trace-otlp-http": 0.35.0
"@opentelemetry/resources": 1.9.0
"@opentelemetry/sdk-trace-base": 1.9.0
"@opentelemetry/sdk-trace-node": 1.9.0
"@opentelemetry/semantic-conventions": 1.9.0
"@types/prompts": 2.4.2
chalk: 4.1.2
Expand Down

0 comments on commit 4a51129

Please sign in to comment.