From 1458b2f137edfbb4f474e3096aaa10c39ded582e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Th=C3=A9riault?= Date: Fri, 17 Nov 2023 14:26:44 -0800 Subject: [PATCH 1/3] fix testing packages workflow & update major deps --- .github/workflows/testing.yml | 1 + examples/next-prisma/next.config.js | 4 +- examples/next-prisma/package.json | 4 +- packages/sdk/src/sampler.ts | 1 - packages/test/package.json | 2 +- yarn.lock | 122 ++++++++++++++-------------- 6 files changed, 68 insertions(+), 66 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 46dffb2f..b41002e3 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -40,6 +40,7 @@ jobs: rm yarn.lock git grep -lz '@solarwinds-apm/' | xargs -0 sed -ie 's:@solarwinds-apm/:@${{ github.repository_owner }}/solarwinds-apm-:g' git grep -lz -G 'solarwinds-apm[^-]' | xargs -0 sed -rie 's:solarwinds-apm([^-]):@${{ github.repository_owner }}/solarwinds-apm\1:g' + yarn install yarn version:testing yarn install yarn lint:fix diff --git a/examples/next-prisma/next.config.js b/examples/next-prisma/next.config.js index bfed1cae..a934eb9e 100644 --- a/examples/next-prisma/next.config.js +++ b/examples/next-prisma/next.config.js @@ -2,8 +2,10 @@ module.exports = { experimental: { instrumentationHook: true, - serverActions: true, + serverComponentsExternalPackages: ["solarwinds-apm"], }, + // the following is only necessary due to a bug in how next.js handles monorepos + // it is not necessary to include in your own config webpack: (config) => { config.externals.push({ "solarwinds-apm": "commonjs solarwinds-apm", diff --git a/examples/next-prisma/package.json b/examples/next-prisma/package.json index fc4138c4..4dd70bcb 100644 --- a/examples/next-prisma/package.json +++ b/examples/next-prisma/package.json @@ -10,7 +10,7 @@ "@opentelemetry/api": "^1.3.0", "@prisma/client": "^5.4.1", "@prisma/instrumentation": "^5.4.1", - "next": "^13.5.4", + "next": "^14.0.3", "react": "^18.2.0", "react-dom": "^18.2.0", "solarwinds-apm": "workspace:^" @@ -19,7 +19,7 @@ "@types/node": "^16.13.0", "@types/react": "^18.2.25", "eslint": "^8.50.0", - "eslint-config-next": "^13.5.4", + "eslint-config-next": "^14.0.3", "prisma": "^5.4.1", "typescript": "^5.2.2" } diff --git a/packages/sdk/src/sampler.ts b/packages/sdk/src/sampler.ts index eeb09272..65350fff 100644 --- a/packages/sdk/src/sampler.ts +++ b/packages/sdk/src/sampler.ts @@ -164,7 +164,6 @@ export class SwSampler implements Sampler { return this.oboeDecisionFunction({ in_xtrace: traceparent, - custom_sample_rate: oboe.SETTINGS_UNSET, custom_tracing_mode: tracingMode, custom_trigger_mode: this.config.triggerTraceEnabled ? oboe.TRIGGER_ENABLED diff --git a/packages/test/package.json b/packages/test/package.json index 078318c0..94510987 100644 --- a/packages/test/package.json +++ b/packages/test/package.json @@ -47,7 +47,7 @@ "chai-as-promised": "^7.1.1", "globby": "^11.1.0", "semver": "^7.5.4", - "tsx": "^3.13.0" + "tsx": "^4.1.3" }, "devDependencies": { "@solarwinds-apm/eslint-config": "workspace:^", diff --git a/yarn.lock b/yarn.lock index 927d8d4d..2266cfcc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -498,81 +498,81 @@ __metadata: languageName: node linkType: hard -"@next/env@npm:13.5.6": - version: 13.5.6 - resolution: "@next/env@npm:13.5.6" - checksum: b1fefa21b698397a2f922ee53a5ecb91ff858f042b2a198652b9de49c031fc5e00d79da92ba7d84ef205e95368d5afbb0f104abaf00e9dde7985d9eae63bb4fb +"@next/env@npm:14.0.3": + version: 14.0.3 + resolution: "@next/env@npm:14.0.3" + checksum: 8688367c22461a075b5406463d16c284cf58e6861418e974fbd5901721da73402988340f8dd72d8e2e41e32ae0b7f24f91bd49029ee6e63424361587165febc5 languageName: node linkType: hard -"@next/eslint-plugin-next@npm:13.5.6": - version: 13.5.6 - resolution: "@next/eslint-plugin-next@npm:13.5.6" +"@next/eslint-plugin-next@npm:14.0.3": + version: 14.0.3 + resolution: "@next/eslint-plugin-next@npm:14.0.3" dependencies: glob: "npm:7.1.7" - checksum: c357c4b8b7b67c22e552e4979e7d2c71a21423ccf18ed3928402aa5a84a8d683e0bbcde4acc092a493f933033fffbb882a00ae075e190c2488ed3fb774d3a2be + checksum: 7ab9cb7a4dcaf97b66fc79aefa848ce0e46a43d48145484ffa0ce8629f3355e684ca4a52d1b2c1093a527a4f7ac31b57a2e429377c93770747046f41a1a73e1e languageName: node linkType: hard -"@next/swc-darwin-arm64@npm:13.5.6": - version: 13.5.6 - resolution: "@next/swc-darwin-arm64@npm:13.5.6" +"@next/swc-darwin-arm64@npm:14.0.3": + version: 14.0.3 + resolution: "@next/swc-darwin-arm64@npm:14.0.3" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@next/swc-darwin-x64@npm:13.5.6": - version: 13.5.6 - resolution: "@next/swc-darwin-x64@npm:13.5.6" +"@next/swc-darwin-x64@npm:14.0.3": + version: 14.0.3 + resolution: "@next/swc-darwin-x64@npm:14.0.3" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@next/swc-linux-arm64-gnu@npm:13.5.6": - version: 13.5.6 - resolution: "@next/swc-linux-arm64-gnu@npm:13.5.6" +"@next/swc-linux-arm64-gnu@npm:14.0.3": + version: 14.0.3 + resolution: "@next/swc-linux-arm64-gnu@npm:14.0.3" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@next/swc-linux-arm64-musl@npm:13.5.6": - version: 13.5.6 - resolution: "@next/swc-linux-arm64-musl@npm:13.5.6" +"@next/swc-linux-arm64-musl@npm:14.0.3": + version: 14.0.3 + resolution: "@next/swc-linux-arm64-musl@npm:14.0.3" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@next/swc-linux-x64-gnu@npm:13.5.6": - version: 13.5.6 - resolution: "@next/swc-linux-x64-gnu@npm:13.5.6" +"@next/swc-linux-x64-gnu@npm:14.0.3": + version: 14.0.3 + resolution: "@next/swc-linux-x64-gnu@npm:14.0.3" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@next/swc-linux-x64-musl@npm:13.5.6": - version: 13.5.6 - resolution: "@next/swc-linux-x64-musl@npm:13.5.6" +"@next/swc-linux-x64-musl@npm:14.0.3": + version: 14.0.3 + resolution: "@next/swc-linux-x64-musl@npm:14.0.3" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@next/swc-win32-arm64-msvc@npm:13.5.6": - version: 13.5.6 - resolution: "@next/swc-win32-arm64-msvc@npm:13.5.6" +"@next/swc-win32-arm64-msvc@npm:14.0.3": + version: 14.0.3 + resolution: "@next/swc-win32-arm64-msvc@npm:14.0.3" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@next/swc-win32-ia32-msvc@npm:13.5.6": - version: 13.5.6 - resolution: "@next/swc-win32-ia32-msvc@npm:13.5.6" +"@next/swc-win32-ia32-msvc@npm:14.0.3": + version: 14.0.3 + resolution: "@next/swc-win32-ia32-msvc@npm:14.0.3" conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@next/swc-win32-x64-msvc@npm:13.5.6": - version: 13.5.6 - resolution: "@next/swc-win32-x64-msvc@npm:13.5.6" +"@next/swc-win32-x64-msvc@npm:14.0.3": + version: 14.0.3 + resolution: "@next/swc-win32-x64-msvc@npm:14.0.3" conditions: os=win32 & cpu=x64 languageName: node linkType: hard @@ -1950,8 +1950,8 @@ __metadata: "@types/node": "npm:^16.13.0" "@types/react": "npm:^18.2.25" eslint: "npm:^8.50.0" - eslint-config-next: "npm:^13.5.4" - next: "npm:^13.5.4" + eslint-config-next: "npm:^14.0.3" + next: "npm:^14.0.3" prisma: "npm:^5.4.1" react: "npm:^18.2.0" react-dom: "npm:^18.2.0" @@ -2173,7 +2173,7 @@ __metadata: prettier: "npm:^3.0.3" rollup: "npm:^4.3.0" semver: "npm:^7.5.4" - tsx: "npm:^3.13.0" + tsx: "npm:^4.1.3" typescript: "npm:^5.2.2" bin: swtest: ./dist/es/bin.js @@ -3944,11 +3944,11 @@ __metadata: languageName: node linkType: hard -"eslint-config-next@npm:^13.5.4": - version: 13.5.6 - resolution: "eslint-config-next@npm:13.5.6" +"eslint-config-next@npm:^14.0.3": + version: 14.0.3 + resolution: "eslint-config-next@npm:14.0.3" dependencies: - "@next/eslint-plugin-next": "npm:13.5.6" + "@next/eslint-plugin-next": "npm:14.0.3" "@rushstack/eslint-patch": "npm:^1.3.3" "@typescript-eslint/parser": "npm:^5.4.2 || ^6.0.0" eslint-import-resolver-node: "npm:^0.3.6" @@ -3963,7 +3963,7 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 819d3be8007ae062217857669c1ef616f7e30ce358ec044483f235f4246c02b38de740010cfd8e0deacf7cc323f5de9a7ccb1e3271c851d205841eff894c4729 + checksum: 398da0334b803da885de2d3fa53dd37c18aae0e5f62a38ad88bed5f2cc21cfa97ef75dfdfdc0009dc57e59d412554430d54052d2d555973c16df247f9be118d9 languageName: node linkType: hard @@ -5910,20 +5910,20 @@ __metadata: languageName: node linkType: hard -"next@npm:^13.5.4": - version: 13.5.6 - resolution: "next@npm:13.5.6" +"next@npm:^14.0.3": + version: 14.0.3 + resolution: "next@npm:14.0.3" dependencies: - "@next/env": "npm:13.5.6" - "@next/swc-darwin-arm64": "npm:13.5.6" - "@next/swc-darwin-x64": "npm:13.5.6" - "@next/swc-linux-arm64-gnu": "npm:13.5.6" - "@next/swc-linux-arm64-musl": "npm:13.5.6" - "@next/swc-linux-x64-gnu": "npm:13.5.6" - "@next/swc-linux-x64-musl": "npm:13.5.6" - "@next/swc-win32-arm64-msvc": "npm:13.5.6" - "@next/swc-win32-ia32-msvc": "npm:13.5.6" - "@next/swc-win32-x64-msvc": "npm:13.5.6" + "@next/env": "npm:14.0.3" + "@next/swc-darwin-arm64": "npm:14.0.3" + "@next/swc-darwin-x64": "npm:14.0.3" + "@next/swc-linux-arm64-gnu": "npm:14.0.3" + "@next/swc-linux-arm64-musl": "npm:14.0.3" + "@next/swc-linux-x64-gnu": "npm:14.0.3" + "@next/swc-linux-x64-musl": "npm:14.0.3" + "@next/swc-win32-arm64-msvc": "npm:14.0.3" + "@next/swc-win32-ia32-msvc": "npm:14.0.3" + "@next/swc-win32-x64-msvc": "npm:14.0.3" "@swc/helpers": "npm:0.5.2" busboy: "npm:1.6.0" caniuse-lite: "npm:^1.0.30001406" @@ -5961,7 +5961,7 @@ __metadata: optional: true bin: next: dist/bin/next - checksum: ef141d7708a432aff8bf080d285c466a83b0c1d008d1c66bbd49652a598f9ac15ef2e69a045f21ba44a5543b595cb945468b5f33e25deae2cc48b4d32be5bcec + checksum: 73aa3d5dd7b65b53ef68fa7723a7a98536482a69ae2d56e7b335194168f00b2851397bbdfe490b53dba2c70dfb8ad0150035fab4c762d6bc331e884487c4ff07 languageName: node linkType: hard @@ -7627,9 +7627,9 @@ __metadata: languageName: node linkType: hard -"tsx@npm:^3.13.0": - version: 3.14.0 - resolution: "tsx@npm:3.14.0" +"tsx@npm:^4.1.3": + version: 4.1.3 + resolution: "tsx@npm:4.1.3" dependencies: esbuild: "npm:~0.18.20" fsevents: "npm:~2.3.3" @@ -7640,7 +7640,7 @@ __metadata: optional: true bin: tsx: dist/cli.mjs - checksum: b6c938bdae9c656aef2aa0130ee6aa8f3487b5d411d5f7934b705c28ff44ab268db3dde123cf5237b4e5e2ab4441a0bad4b1a39e3ff2170d138538e44082f05d + checksum: 0c8fb5fa242735b0f10f2ff6f21eed79f61d026c19edbdb7d71935a66b6411a1447e43f705045545bd090e53f7735bcc7ba72249b4a03d15db1406b733490a72 languageName: node linkType: hard From a5d3289c30a154b241e7eb27be29bd4cc9310c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Th=C3=A9riault?= Date: Fri, 17 Nov 2023 16:27:36 -0800 Subject: [PATCH 2/3] fix various serverless issues --- docker/otel-collector/config.yml | 4 ++ examples/express-mysql/package.json | 2 +- examples/fastify-postgres/package.json | 2 +- examples/hello-distributed/package.json | 2 +- examples/hello-manual/package.json | 2 +- examples/hello/package.json | 2 +- packages/bindings/build.js | 6 ++- packages/sdk/package.json | 9 +++- packages/sdk/src/metrics/serverless.ts | 34 +++++++++++---- packages/sdk/src/otlp-metrics-exporter.ts | 50 +++++++++++++++++++++++ packages/sdk/src/sampler.ts | 8 +++- packages/solarwinds-apm/package.json | 12 +----- packages/solarwinds-apm/src/init.ts | 7 ++-- scripts/example.js | 7 +++- yarn.lock | 13 +++--- 15 files changed, 120 insertions(+), 40 deletions(-) create mode 100644 packages/sdk/src/otlp-metrics-exporter.ts diff --git a/docker/otel-collector/config.yml b/docker/otel-collector/config.yml index f24bc559..0dd8eff2 100644 --- a/docker/otel-collector/config.yml +++ b/docker/otel-collector/config.yml @@ -13,6 +13,10 @@ exporters: service: pipelines: + traces: + receivers: [otlp] + processors: [batch] + exporters: [logging] metrics: receivers: [otlp] processors: [batch] diff --git a/examples/express-mysql/package.json b/examples/express-mysql/package.json index 9c063efa..d7c5b97e 100644 --- a/examples/express-mysql/package.json +++ b/examples/express-mysql/package.json @@ -2,7 +2,7 @@ "name": "@solarwinds-apm/example-express-mysql", "private": true, "scripts": { - "start": "node --loader solarwinds-apm/loader index.js" + "start": "node --import solarwinds-apm index.js" }, "dependencies": { "@opentelemetry/api": "^1.3.0", diff --git a/examples/fastify-postgres/package.json b/examples/fastify-postgres/package.json index a7307203..01f5f89d 100644 --- a/examples/fastify-postgres/package.json +++ b/examples/fastify-postgres/package.json @@ -3,7 +3,7 @@ "private": true, "type": "module", "scripts": { - "start": "node --loader solarwinds-apm/loader index.js" + "start": "node --import solarwinds-apm index.js" }, "dependencies": { "@fastify/postgres": "^5.2.0", diff --git a/examples/hello-distributed/package.json b/examples/hello-distributed/package.json index 5bbd58a8..27757e95 100644 --- a/examples/hello-distributed/package.json +++ b/examples/hello-distributed/package.json @@ -3,7 +3,7 @@ "private": true, "type": "module", "scripts": { - "start": "concurrently \"node --loader solarwinds-apm/loader external.js\" \"node --loader solarwinds-apm/loader internal.js\"" + "start": "concurrently \"node --import solarwinds-apm external.js\" \"node --import solarwinds-apm internal.js\"" }, "dependencies": { "@opentelemetry/api": "^1.3.0", diff --git a/examples/hello-manual/package.json b/examples/hello-manual/package.json index c0dffb55..046f2ca6 100644 --- a/examples/hello-manual/package.json +++ b/examples/hello-manual/package.json @@ -3,7 +3,7 @@ "private": true, "type": "module", "scripts": { - "start": "node --loader solarwinds-apm/loader index.js" + "start": "node --import solarwinds-apm index.js" }, "dependencies": { "@opentelemetry/api": "^1.3.0", diff --git a/examples/hello/package.json b/examples/hello/package.json index 134f87ee..fa9d5d39 100644 --- a/examples/hello/package.json +++ b/examples/hello/package.json @@ -3,7 +3,7 @@ "private": true, "type": "module", "scripts": { - "start": "node --loader solarwinds-apm/loader index.js" + "start": "node --import solarwinds-apm index.js" }, "dependencies": { "@opentelemetry/api": "^1.3.0", diff --git a/packages/bindings/build.js b/packages/bindings/build.js index 78336614..0e166044 100644 --- a/packages/bindings/build.js +++ b/packages/bindings/build.js @@ -64,7 +64,11 @@ const configs = targets.flatMap(({ name, oboe, target, cpu, glibc }) => { // only build serverless api for serverless const oboeSources = name.includes("serverless") - ? ["src/oboe/oboe.serverless.cc", "src/oboe/oboe_api.cc"] + ? [ + "src/oboe/oboe.serverless.cc", + "src/oboe/oboe_api.cc", + "oboe/include/oboe_api.cpp", + ] : [ "src/oboe/oboe.cc", "src/oboe/config.cc", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 9a38abba..ad18a5f9 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -16,7 +16,8 @@ "type": "commonjs", "exports": { ".": "./dist/index.js", - "./otlp-exporter": "./dist/otlp-exporter.js" + "./otlp-exporter": "./dist/otlp-exporter.js", + "./otlp-metrics-exporter": "./dist/otlp-metrics-exporter.js" }, "main": "./dist/index.js", "files": [ @@ -47,18 +48,24 @@ }, "peerDependencies": { "@opentelemetry/api": "^1.3.0", + "@opentelemetry/exporter-metrics-otlp-grpc": ">=0.34.0", "@opentelemetry/exporter-trace-otlp-grpc": ">=0.34.0" }, "peerDependenciesMeta": { "@opentelemetry/api": { "optional": false }, + "@opentelemetry/exporter-metrics-otlp-grpc": { + "optional": true + }, "@opentelemetry/exporter-trace-otlp-grpc": { "optional": true } }, "devDependencies": { "@opentelemetry/api": "^1.3.0", + "@opentelemetry/exporter-metrics-otlp-grpc": "~0.45.1", + "@opentelemetry/exporter-trace-otlp-grpc": "~0.45.1", "@opentelemetry/instrumentation": "~0.45.1", "@opentelemetry/resources": "~1.18.1", "@opentelemetry/sdk-trace-node": "~1.18.1", diff --git a/packages/sdk/src/metrics/serverless.ts b/packages/sdk/src/metrics/serverless.ts index 465dd712..0afc7f73 100644 --- a/packages/sdk/src/metrics/serverless.ts +++ b/packages/sdk/src/metrics/serverless.ts @@ -14,24 +14,42 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { metrics } from "@opentelemetry/api" +import { metrics, ValueType } from "@opentelemetry/api" import { type oboe } from "@solarwinds-apm/bindings" import { lazy } from "@solarwinds-apm/lazy" -const meter = metrics.getMeter("sw.apm.sampling.metrics") +const meter = lazy(() => metrics.getMeter("sw.apm.sampling.metrics")) const counters = { - RequestCount: lazy(() => meter.createCounter("trace.service.request_count")), + RequestCount: lazy(() => + meter.createCounter("trace.service.request_count", { + valueType: ValueType.INT, + }), + ), TokenBucketExhaustionCount: lazy(() => - meter.createCounter("trace.service.tokenbucket_exhaustion_count"), + meter.createCounter("trace.service.tokenbucket_exhaustion_count", { + valueType: ValueType.INT, + }), + ), + TraceCount: lazy(() => + meter.createCounter("trace.service.tracecount", { + valueType: ValueType.INT, + }), + ), + SampleCount: lazy(() => + meter.createCounter("trace.service.samplecount", { + valueType: ValueType.INT, + }), ), - TraceCount: lazy(() => meter.createCounter("trace.service.tracecount")), - SampleCount: lazy(() => meter.createCounter("trace.service.samplecount")), ThroughTraceCount: lazy(() => - meter.createCounter("trace.service.through_trace_count"), + meter.createCounter("trace.service.through_trace_count", { + valueType: ValueType.INT, + }), ), TriggeredTraceCount: lazy(() => - meter.createCounter("trace.service.triggered_trace_count"), + meter.createCounter("trace.service.triggered_trace_count", { + valueType: ValueType.INT, + }), ), } diff --git a/packages/sdk/src/otlp-metrics-exporter.ts b/packages/sdk/src/otlp-metrics-exporter.ts new file mode 100644 index 00000000..0d3f9a32 --- /dev/null +++ b/packages/sdk/src/otlp-metrics-exporter.ts @@ -0,0 +1,50 @@ +/* +Copyright 2023 SolarWinds Worldwide, LLC. + +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 + + http://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. +*/ + +import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-grpc" +import { + Aggregation, + AggregationTemporality, + ExponentialHistogramAggregation, + InstrumentType, + type PushMetricExporter, +} from "@opentelemetry/sdk-metrics" + +export class SwOtlpMetricsExporter + extends OTLPMetricExporter + implements PushMetricExporter +{ + override selectAggregationTemporality( + instrumentType: InstrumentType, + ): AggregationTemporality { + switch (instrumentType) { + case InstrumentType.COUNTER: + case InstrumentType.OBSERVABLE_COUNTER: + return AggregationTemporality.DELTA + default: + return super.selectAggregationTemporality(instrumentType) + } + } + + selectAggregation(instrumentType: InstrumentType): Aggregation { + switch (instrumentType) { + case InstrumentType.HISTOGRAM: + return new ExponentialHistogramAggregation(undefined, true) + default: + return Aggregation.Default() + } + } +} diff --git a/packages/sdk/src/sampler.ts b/packages/sdk/src/sampler.ts index 65350fff..8b451eb1 100644 --- a/packages/sdk/src/sampler.ts +++ b/packages/sdk/src/sampler.ts @@ -162,7 +162,7 @@ export class SwSampler implements Sampler { traceparent = traceParent(parentSpanContext) } - return this.oboeDecisionFunction({ + const input: oboe.DecisionOptions = { in_xtrace: traceparent, custom_tracing_mode: tracingMode, custom_trigger_mode: this.config.triggerTraceEnabled @@ -175,7 +175,11 @@ export class SwSampler implements Sampler { header_signature: traceOptions?.signature, header_timestamp: traceOptions?.timestamp, tracestate: parentSpanContext?.traceState?.get(TRACESTATE_SW_KEY), - }) + } + this.logger.debug("tracing decision input", input) + const output = this.oboeDecisionFunction(input) + this.logger.debug("tracing decision output", output) + return output } private tracingMode( diff --git a/packages/solarwinds-apm/package.json b/packages/solarwinds-apm/package.json index d4f66587..7fbf31a0 100644 --- a/packages/solarwinds-apm/package.json +++ b/packages/solarwinds-apm/package.json @@ -71,25 +71,15 @@ "zod": "^3.22.4" }, "peerDependencies": { - "@opentelemetry/api": "^1.3.0", - "@opentelemetry/exporter-metrics-otlp-grpc": ">=0.34.0", - "@opentelemetry/exporter-trace-otlp-grpc": ">=0.34.0" + "@opentelemetry/api": "^1.3.0" }, "peerDependenciesMeta": { "@opentelemetry/api": { "optional": false - }, - "@opentelemetry/exporter-metrics-otlp-grpc": { - "optional": true - }, - "@opentelemetry/exporter-trace-otlp-grpc": { - "optional": true } }, "devDependencies": { "@opentelemetry/api": "^1.3.0", - "@opentelemetry/exporter-metrics-otlp-grpc": "~0.45.1", - "@opentelemetry/exporter-trace-otlp-grpc": "~0.45.1", "@solarwinds-apm/eslint-config": "workspace:^", "@solarwinds-apm/rollup-config": "workspace:^", "@solarwinds-apm/test": "workspace:^", diff --git a/packages/solarwinds-apm/src/init.ts b/packages/solarwinds-apm/src/init.ts index ed5d5f7f..9f202475 100644 --- a/packages/solarwinds-apm/src/init.ts +++ b/packages/solarwinds-apm/src/init.ts @@ -92,6 +92,7 @@ export async function init() { .merge( new Resource({ [SemanticResourceAttributes.SERVICE_NAME]: config.serviceName, + "sw.data.module": "apm", }), ) @@ -289,10 +290,10 @@ async function metricReaders( } if (config.dev.otlpMetrics) { - const { OTLPMetricExporter } = await import( - "@opentelemetry/exporter-metrics-otlp-grpc" + const { SwOtlpMetricsExporter } = await import( + "@solarwinds-apm/sdk/otlp-metrics-exporter" ) - const exporter = new OTLPMetricExporter() + const exporter = new SwOtlpMetricsExporter() readers.push( new PeriodicExportingMetricReader({ exporter, diff --git a/scripts/example.js b/scripts/example.js index 66ddaee7..eb834858 100644 --- a/scripts/example.js +++ b/scripts/example.js @@ -32,13 +32,18 @@ exec(`turbo run build --filter=./examples/${example}...`) // get env vars that will be passed to the container const env = Object.fromEntries( Object.entries(process.env).filter( - ([key]) => key.startsWith("SW_APM_") || key.startsWith("OTEL_"), + ([key]) => + key.startsWith("SW_APM_") || + key.startsWith("OTEL_") || + key.startsWith("AWS_LAMBDA_"), ), ) if (collector) { env.SW_APM_COLLECTOR = "apm-collector:12224" env.SW_APM_TRUSTED_PATH = "/solarwinds-apm/docker/apm-collector/server-grpc.crt" + env.OTEL_EXPORTER_OTLP_PROTOCOL = "grpc" + env.OTEL_EXPORTER_OTLP_ENDPOINT = "http://otel-collector:4317" } // run example inside container diff --git a/yarn.lock b/yarn.lock index 2266cfcc..cc9f2118 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2114,6 +2114,8 @@ __metadata: dependencies: "@opentelemetry/api": "npm:^1.3.0" "@opentelemetry/core": "npm:~1.18.1" + "@opentelemetry/exporter-metrics-otlp-grpc": "npm:~0.45.1" + "@opentelemetry/exporter-trace-otlp-grpc": "npm:~0.45.1" "@opentelemetry/instrumentation": "npm:~0.45.1" "@opentelemetry/resources": "npm:~1.18.1" "@opentelemetry/sdk-metrics": "npm:~1.18.1" @@ -2135,10 +2137,13 @@ __metadata: typescript: "npm:^5.2.2" peerDependencies: "@opentelemetry/api": ^1.3.0 + "@opentelemetry/exporter-metrics-otlp-grpc": ">=0.34.0" "@opentelemetry/exporter-trace-otlp-grpc": ">=0.34.0" peerDependenciesMeta: "@opentelemetry/api": optional: false + "@opentelemetry/exporter-metrics-otlp-grpc": + optional: true "@opentelemetry/exporter-trace-otlp-grpc": optional: true languageName: unknown @@ -7230,8 +7235,6 @@ __metadata: dependencies: "@opentelemetry/api": "npm:^1.3.0" "@opentelemetry/core": "npm:~1.18.1" - "@opentelemetry/exporter-metrics-otlp-grpc": "npm:~0.45.1" - "@opentelemetry/exporter-trace-otlp-grpc": "npm:~0.45.1" "@opentelemetry/instrumentation": "npm:~0.45.1" "@opentelemetry/resources": "npm:~1.18.1" "@opentelemetry/sdk-metrics": "npm:~1.18.1" @@ -7255,15 +7258,9 @@ __metadata: zod: "npm:^3.22.4" peerDependencies: "@opentelemetry/api": ^1.3.0 - "@opentelemetry/exporter-metrics-otlp-grpc": ">=0.34.0" - "@opentelemetry/exporter-trace-otlp-grpc": ">=0.34.0" peerDependenciesMeta: "@opentelemetry/api": optional: false - "@opentelemetry/exporter-metrics-otlp-grpc": - optional: true - "@opentelemetry/exporter-trace-otlp-grpc": - optional: true languageName: unknown linkType: soft From 6dbe287ae3b66df927a92453edcfa71159e050f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Th=C3=A9riault?= Date: Fri, 17 Nov 2023 16:28:30 -0800 Subject: [PATCH 3/3] mark version bumps --- .yarn/versions/0d3fa678.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .yarn/versions/0d3fa678.yml diff --git a/.yarn/versions/0d3fa678.yml b/.yarn/versions/0d3fa678.yml new file mode 100644 index 00000000..17a49210 --- /dev/null +++ b/.yarn/versions/0d3fa678.yml @@ -0,0 +1,9 @@ +releases: + "@solarwinds-apm/bindings": patch + "@solarwinds-apm/sdk": minor + "@solarwinds-apm/test": minor + solarwinds-apm: patch + +declined: + - "@solarwinds-apm/compat" + - "@solarwinds-apm/dependencies"