Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove sampling decision from runtime #541

Merged
merged 5 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [6.45.20] - 2023-08-30
### Changed
- Remove sampling decision from runtime
- Only create tracing spans when they come from router

## [6.45.20-beta] - 2023-08-30

## [6.45.19] - 2023-07-12
### Changed
- Bump `graphql-upload` version
Expand Down Expand Up @@ -1769,7 +1776,10 @@ instead
- `HttpClient` now adds `'Accept-Encoding': 'gzip'` header by default.


[Unreleased]: https://github.com/vtex/node-vtex-api/compare/v6.45.15...HEAD
[Unreleased]: https://github.com/vtex/node-vtex-api/compare/v6.45.20...HEAD
[6.45.15]: https://github.com/vtex/node-vtex-api/compare/v6.45.14...v6.45.15
[6.45.14]: https://github.com/vtex/node-vtex-api/compare/v6.45.13...v6.45.14
[6.45.13]: https://github.com/vtex/node-vtex-api/compare/v6.45.12...v6.45.13

[6.45.20]: https://github.com/vtex/node-vtex-api/compare/v6.45.20-beta...v6.45.20
[6.45.20-beta]: https://github.com/vtex/node-vtex-api/compare/v6.45.19...v6.45.20-beta
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vtex/api",
"version": "6.45.19",
"version": "6.45.20",
"description": "VTEX I/O API client",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
6 changes: 0 additions & 6 deletions src/service/tracing/TracerSingleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ export class TracerSingleton {
reporter: {
agentHost: process.env.VTEX_OWN_NODE_IP,
},
sampler: {
host: process.env.VTEX_OWN_NODE_IP,
param: 0.05,
refreshIntervalMs: 60 * 1000,
type: 'remote',
},
serviceName,
}

Expand Down
9 changes: 7 additions & 2 deletions src/service/tracing/tracingMiddlewares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ export const addTracingMiddleware = (tracer: Tracer) => {
return async function addTracing(ctx: ServiceContext, next: () => Promise<void>) {
const start = process.hrtime()
concurrentRequests.inc(1)
const rootSpan = tracer.extract(FORMAT_HTTP_HEADERS, ctx.request.headers) as undefined | SpanContext

if (PATHS_BLACKLISTED_FOR_TRACING.includes(ctx.request.path)) {
if (!shouldTrace(ctx, rootSpan)) {
await next()
concurrentRequests.dec(1)
return
}

const rootSpan = tracer.extract(FORMAT_HTTP_HEADERS, ctx.request.headers) as undefined | SpanContext
const currentSpan = tracer.startSpan('unknown-operation', {
childOf: rootSpan,
tags: { [OpentracingTags.SPAN_KIND]: OpentracingTags.SPAN_KIND_RPC_SERVER },
Expand Down Expand Up @@ -150,3 +150,8 @@ export const traceUserLandRemainingPipelineMiddleware = () => {
}
}
}
function shouldTrace(ctx: ServiceContext, rootSpan: SpanContext | undefined) {
// Should trace if path isnt blacklisted and tracing decision came from the edge
return !PATHS_BLACKLISTED_FOR_TRACING.includes(ctx.request.path) && rootSpan != null
}

Loading