Skip to content

Commit 4f6bd12

Browse files
committed
collect tags
1 parent 90b7c96 commit 4f6bd12

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict'
2+
3+
const path = require('node:path')
4+
const pkg = require('../pkg')
5+
6+
const CURRENT_WORKING_DIRECTORY = process.cwd()
7+
const ENTRYPOINT_PATH = require.main?.filename || ''
8+
9+
module.exports = function processTags () {
10+
return {
11+
// last segment of the current working directory, e.g. /foo/bar/baz/ -> baz
12+
'entrypoint.workdir': path.basename(CURRENT_WORKING_DIRECTORY),
13+
14+
// the entrypoint script filename without the extension, e.g. /foo/bar/baz/banana.js -> banana
15+
'entrypoint.name': path.basename(ENTRYPOINT_PATH, path.extname(ENTRYPOINT_PATH)),
16+
17+
// always script for JavaScript applications
18+
'entrypoint.type': 'script',
19+
20+
// the immediate parent directory name of the entrypoint script, e.g. /foo/bar/baz/banana.js -> baz
21+
'entrypoint.basedir': path.basename(path.dirname(ENTRYPOINT_PATH)),
22+
23+
// the .name field from the application's package.json
24+
'package.json.name': pkg.name
25+
}
26+
}

packages/dd-trace/src/proxy.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const {
1818
removeBaggageItem,
1919
removeAllBaggageItems
2020
} = require('./baggage')
21+
const getProcessTags = require('./process-tags')
2122

2223
class LazyModule {
2324
constructor (provider) {
@@ -78,6 +79,7 @@ class Tracer extends NoopProxy {
7879
this.getAllBaggageItems = getAllBaggageItems
7980
this.removeBaggageItem = removeBaggageItem
8081
this.removeAllBaggageItems = removeAllBaggageItems
82+
this.processTags = getProcessTags()
8183

8284
// these requires must work with esm bundler
8385
this._modules = {

0 commit comments

Comments
 (0)